nDepend querying direct indirect methods for all methods in an assembly

旧城冷巷雨未停 提交于 2020-01-02 17:33:46

问题


I am trying to retrieve all direct indirect method calls for all methods in an assembly using the CQL provided by nDepend. Issue is I am not able to iterate through all methods inside a assembly to get this info.

The DepthOfIsUsedBy only allows a string type and not a collection of strings.

Is there a way t get this info for all methods inside an assembly?


回答1:


What about using the method DepthOfIsUsing() instead of DepthOfIsUsedBy() :o)

from m in Assemblies.WithNameNotIn("nunit.uikit").ChildMethods() 
let depth0 = m.DepthOfIsUsing("nunit.uikit")
where depth0  >= 0 orderby depth0
select new { m, depth0 }

This query has been generated through the menu below. (Btw a more sophisticated solution could be elaborated with the magic method FillIterative(), but it is not necessary here).


Taking account the comment of Prasad, what about trying this query that list all direct & indirect callers from A, for each method of B:

from m in Assemblies.WithNameIn("AsmB").ChildMethods()
where m.IsPubliclyVisible // Optimization
let indirectcallers = m.MethodsCallingMe
                      .FillIterative(
                          callers => callers.SelectMany(m1 => m1.MethodsCallingMe))
                      .DefinitionDomain
                      .Where(m1 => m1.ParentAssembly.Name == "AsmA")
                      .ToArray()  // Avoid double enumeration
where indirectcallers.Length > 0
orderby indirectcallers.Length descending
select new { m, indirectcallers }


来源:https://stackoverflow.com/questions/13386682/ndepend-querying-direct-indirect-methods-for-all-methods-in-an-assembly

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