Last post Oct 06, 2013 09:35 PM by Rion Williams
Oct 06, 2013 06:44 PM|Moises Durovni|LINK
I am a amateur code writer drinking from this knowledge fountain to improve myself.
A new learned technique improve the part of code I am using and turn 'obsolete' the older one, hence I current have many methods that are not in use anymore, with no reference to it in the whole solution. This problem turn the code dificult to mantain.
Is there a way VS can tell which methods are not been used so I can choose to delete or keep it.
Oct 06, 2013 09:35 PM|Rion Williams|LINK
Sadly, you'll likely need to use a third-party or extension to Visual Studio to handle this, but don't worry it certainly can be done.
Resharper is an incredible development tool that offers a free 30-day trial that you could use and it does a heck of alot more than just detect dead code. It provides its own Intellisense, offers improvements over existing code and helps you write cleaner
and more maintainable code.
Within Resharper, there is an option called "Analyze Errors in Solution" option within Resharper, which can be enabled through the Resharper status bar (right-click on the Resharper icon).
After that is enabled, right-click on your project or solution and select "Find Code Issues". You should see a "Unused Symbols" tab within the results that will contain unused classes, methods and members. (It should say "Type or Member is never used")
You can also use Microsoft's FxCop tool to perform code analysis and find "dead code" within your applications. You can find a post here that
details installing it if you aren't using at least Visual Studio 2010 Premium or Ultimate (It is integrated in newer versions of Visual Studio under the Code Analysis option.)
NDepend is another tool that can help suggest and find unused methods as well as optimize some of your existing code that you might want to consider trying as well.
Related Suggestions and Discussions