问题
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