Domanda

Let's say I have method A.M1. It is called in B.M2 2 times and in B.M3 3 times. I need to find all number of usages (like Resharper does through find usages interface). So the sum for method calls would be 5.

Following Query:

from m in Methods where m.HasAttribute("specific attribute") orderby m.MethodsCallingMe.Count() descending select new { m, m.MethodsCallingMe }

gives me only 2 usages for method A.M1.

Could you please help me to find the usages number?

È stato utile?

Soluzione

It's difficult or impossible to do with NDepend. NDepends shows which methods are calling specified method and not count in this situation them and even not count them recursively or through call graph.

So try to use other techniques. By first of all, why you need such metric? Some kind of method rank?

Anyway a pretty simple way to achieve it, is using RegEx experssion. You can use also NDepend API or regex and ndepend api together. For example, get all method names from source code base using nDepend API and then using regex for each method name count matches except method definition itself.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top