What tools and techniques do you use to find dead code?

16,434

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.

Share:
16,434

Related videos on Youtube

Scott Lawrence
Author by

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, 2022

Comments

  • Scott Lawrence
    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.

  • Scott Lawrence
    Scott Lawrence over 15 years
    I hadn't heard of this tool before. Thanks for the tip.
  • Lemon
    Lemon about 15 years
    Code Analysis in visual studio is just the same as running FxCop manually?
  • AMissico
    AMissico almost 12 years
    @Svish; Yes, they are the same.
  • Dan Atkinson
    Dan Atkinson about 11 years
    The link now redirect to smartbear.com. The actual link should now be smartbear.com/products/qa-tools/….
  • OregonGhost
    OregonGhost almost 11 years
    @DanAtkinson: Updated the link, thanks.
  • Olivier Jacot-Descombes
    Olivier Jacot-Descombes over 6 years
    But what if you have a unit test for an otherwise unused method?