What is the quickest way to determine which members of an enum are not being used?
Using find references on each member of the enum is the fastest way I can think of.
Commenting / uncommenting members. If the compiler does not throw an error the enum member is not used.
Update: As mentioned in the comments this of course only works for projects contained in the solution / the active build configuration. The same holds for the Find References and Ctrl+F methods.
Otherwise there is also the option to do a file search, e.g. using grep. However, this option only allows to do a string-based search and does not resolve any types.
Comment the enum members out one by one and see if your code compiles. If compilation breaks, the member is used. Although this method only catches compile-time use of your enums. They could be used at runtime.
If you are using VS2005/8 Ctrl-Shift-F so search in the files. This will give you a list of files that you can double-click to goto the lines.
If you don't use VS then you can use WinGrep which will do the same thing (without the double-click feature)
If you're using ReSharper, click on the enum to check, hit Alt+F7 (Shift+F12 if you're using VS shortcuts), and it'll give you a list of every place it's used in your entire solution.
Being on the safe side you can mark your members with ObsoleteAttribute
. Adding [Obsolete(true)]
will fail the build if given member is used.
This can obviously be used not only for enums but for nearly anything in .NET.
Resharper is your tool of choice if you need to delete the members from a solution and you're not worried about another uses in different solutions.