NDepend-查找无效方法 [英] NDepend -Finding dead methods

查看:94
本文介绍了NDepend-查找无效方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两种公共方法A和B.我修改了CQL,向我展示了公开的和无效的方法.

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

如果B仅由A调用,而A作为死方法(在应用程序中的任何地方都未调用或引用)来使用,NDepend是否可以通过进行某些设置或CQL将这两种方法显示为死方法?

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?

在当前情况下,我仅获得A作为无效方法,而没有获得B.

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

推荐答案

NDepend是否可以通过进行某些设置或通过CQL将这两种方法显示为无效?

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

是的,由于围绕建议使用200条默认代码规则,其中3条专门用于未使用/无效的代码检测:

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

如果单击上面指向这些规则源代码的这3个链接,您会发现与类型和方法有关的链接有点复杂.这是因为这些规则不仅检测未使用的类型和方法,而且还检测未使用的无效类型和方法(递归,您要提供的内容) 仅使用的类型和方法.

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).

这篇关于NDepend-查找无效方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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