JohnB
JohnB

Reputation: 18982

Tool for Visual Studio to automatically remove methods that aren't being referenced

I'm looking for a feature, script, or tool in Visual Studio to remove methods that aren't referenced by any code in a solution.

All my projects are in one solution (i.e. no external class libraries).

Usually I right-click on methods and choose "Find All References," and if the method declaration is the only reference, I delete he method, to help clean up the code.

For me this helps in the code analysis/reverse engineering process.

Upvotes: 3

Views: 3878

Answers (3)

Sabitha
Sabitha

Reputation: 243

I think this is not the right thing to do, from the product perspective. If your class is being referenced by external applications, and if your public methods are being used in that external application, then by Find all References, you will not see those references in your solution.If you remove those methods, then the applications referencing your classes will be broken.(It may be the case that in your current situation this may not be the problem, but in general it would be). So i doubt if this will be a useful feature to have.

Upvotes: 3

Jackson Pope
Jackson Pope

Reputation: 14640

Try ReSharper: http://www.jetbrains.com/resharper/features/code_refactoring.html?gclid=CN66956kqagCFQoZ4Qodexn_HA

It's not free, but it is awesome :)

Upvotes: 3

reggie
reggie

Reputation: 13721

Use Resharper. Refreactor your code with ease. Its just awesome

Upvotes: 2

Related Questions