25

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.

durron597
  • 31,968
  • 17
  • 99
  • 158
Scott Lawrence
  • 6,993
  • 12
  • 46
  • 64
  • 2
    possible duplicate of [Is there a tool for finding unreferenced functions (dead, obsolete code) in a C# app?](http://stackoverflow.com/questions/65585/is-there-a-tool-for-finding-unreferenced-functions-dead-obsolete-code-in-a-c) – Alex Angas Jul 08 '10 at 23:49
  • possible duplicate of http://stackoverflow.com/questions/1413548/visual-studio-find-unused-code/1413573#1413573 – Michael La Voie Oct 08 '13 at 17:54
  • 9
    A question asked 5 years ago can't be a duplicate of a question asked 4 years ago. – Scott Lawrence Oct 08 '13 at 20:46
  • The tools part of the question would be on-topic at http://softwarerecs.stackexchange.com – Nicolas Raoul Aug 06 '15 at 08:48

4 Answers4

16

Why do you need other answers? FxCop and Resharper do the trick, especially seeing as FxCop is now integrated into VS through "Code Analysis".

Quibblesome
  • 25,225
  • 10
  • 61
  • 100
4

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

cruizer
  • 6,103
  • 2
  • 27
  • 34
3

TDD + NCover

Chris Canal
  • 4,824
  • 9
  • 35
  • 45
2

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.

OregonGhost
  • 23,359
  • 7
  • 71
  • 108