NDepend -Finding dead methods

自作多情 提交于 2020-01-03 17:42:08

问题


I have two public methods A & B. I modified CQL to show me methods which are public and dead.

If B is only called by A and A is coming as dead method(not called or referenced anywhere in the application) can NDepend show both the methods as dead by doing some settings or by CQL?

In current scenario I am getting only A as dead method not B.


回答1:


can NDepend show both the methods as dead by doing some settings or by CQL?

Yes, NDepend can do that thanks to Code Rule over LINQ Query (CQLinq) capabilities.

Around 200 default code rules are proposed, 3 of them being dedicated to unused/dead code detection:

  • Potentially dead Types (hence detect unused class, struct, interface, delegate...)
  • Potentially dead Methods (hence detect unused method, ctor, property getter/setter...)
  • Potentially dead Fields

If you click these 3 links above toward the source code of these rules, you'll see that the ones concerning types and methods are a bit complex. This is because these rules detect not only unused types and methods, but also types and methods used only by unused dead types and methods (recursive, what you are asking for).



来源:https://stackoverflow.com/questions/6505263/ndepend-finding-dead-methods

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!