找到“死代码” [英] Find "Dead code"

查看:82
本文介绍了找到“死代码”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试查找未从任何其他代码(CA1811)调用的私有方法



作为建议,最好使用我们的自定义规则集,以更好地控制规则违例,例如,您可以将任何违规定义为错误,以便将其作为编译并修复错误。


I am trying to find private methods that are not called from any other code (CA1811) https://msdn.microsoft.com/en-us/library/ms182264(v=vs.110).aspx, with Visual Studio 2012 Code Analysis buy it doesn't detect it, despite putting the project code analysis rule set in "all rules". This is possible? In this case, how can I configure my project solution? In case of installing any extension, I will prefer that it was free. Thanks!

解决方案

The rule CA1811: Avoid uncalled private code perfectly works fine to detect the uncalled private methods.

To enable the code analysis warnings, you also need to set this value in project properties like this -

As a suggestion it is good idea to have our custom ruleset, to have more control over rule violations for example you can define any violation as error, so that you can get it as compile error and fix it.

这篇关于找到“死代码”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆