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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 16:17:52  来源:igfitidea点击:

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

c#.netrefactoringcode-analysis

提问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 中显示为灰色......例如未调用的方法或类或未使用的属性和变量

回答by OregonGhost

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.

我再次推荐AQTime。静态代码分析已经做了你想要的(以及更多),但其他分析器更有用。物有所值,如果你能负担得起。