C# 您使用哪些工具和技术来查找死代码?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/162641/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What tools and techniques do you use to find dead code?
提问by Scott Lawrence
What tools and techniques do you use to find dead code in .NET?
您使用哪些工具和技术来查找 .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).
过去,我使用 Obsolete 属性装饰方法(传递 true 以便编译器会发出错误,如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.
我很想看到其他人的建议(除了像 FxCop 或 ReSharper 这样的工具)。我想确保我不会错过其他有用的工具。
采纳答案by Chris Canal
TDD + NCover
TDD+NC覆盖
回答by Quibblesome
Why do you need other answers? FxCop and Resharper do the trick, especially seeing as FxCop is now integrated into VS through "Code Analysis".
为什么你需要其他答案?FxCop 和 Resharper 可以解决问题,尤其是看到 FxCop 现在通过“代码分析”集成到 VS 中。
回答by cruizer
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
如果它是死代码(至少仅在解决方案中),它在 ReSharper 中显示为灰色......例如未调用的方法或类或未使用的属性和变量