What tools and techniques do you use to find dead code?
Solution 1
TDD + NCover
Solution 2
Why do you need other answers? FxCop and Resharper do the trick, especially seeing as FxCop is now integrated into VS through "Code Analysis".
Solution 3
it appears gray in ReSharper if it's dead code (at least within the solution only)...like uncalled methods or classes or unused properties and variables
Solution 4
Once again, I recommend AQTime. The static code analysis already does what you want (and a lot more), but the other profilers are even more useful. Worth the money, if you can afford it.
Related videos on Youtube
Scott Lawrence
I lead a small team within Capital One implementing fraud defenses within the agent servicing platform, among other enhancements. I occasionally blog here: http://scottlaw.knot.org/blog/ on technology and my other interests. My technology career to-date has spanned many roles beyond hands-on software engineer, including systems analyst, project manager, scrum master, database administrator, and team lead for previous employers. I earned degrees in computer science (BSc) and business (MBA) at the University of Maryland-College Park.
Updated on April 19, 2022Comments
-
Scott Lawrence almost 2 years
What tools and techniques do you use to find dead code in .NET?
In the past, I've decorated methods with the Obsolete attribute (passing true so the compiler will issue an error, as described in MSDN).
I'd be interested in seeing the suggestions of others (beyond tools like FxCop or ReSharper). I want to make sure I'm not missing out on other tools that would be helpful.
-
Alex Angas almost 14 yearspossible duplicate of Is there a tool for finding unreferenced functions (dead, obsolete code) in a C# app?
-
Scott Lawrence over 10 yearsA question asked 5 years ago can't be a duplicate of a question asked 4 years ago.
-
-
Scott Lawrence over 15 yearsI hadn't heard of this tool before. Thanks for the tip.
-
Lemon about 15 yearsCode Analysis in visual studio is just the same as running FxCop manually?
-
AMissico almost 12 years@Svish; Yes, they are the same.
-
Dan Atkinson about 11 yearsThe link now redirect to smartbear.com. The actual link should now be smartbear.com/products/qa-tools/….
-
OregonGhost almost 11 years@DanAtkinson: Updated the link, thanks.
-
Olivier Jacot-Descombes over 6 yearsBut what if you have a unit test for an otherwise unused method?