nDependency查询直接间接方法以查找程序集中的所有方法 [英] nDepend querying direct indirect methods for all methods in an assembly
问题描述
我正在尝试使用nDepend提供的CQL检索程序集中所有方法的所有直接间接方法调用. 问题是我无法遍历程序集内的所有方法来获取此信息.
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.
DepthOfIsUsedBy仅允许使用字符串类型,而不能使用字符串的集合.
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?
推荐答案
使用方法 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).
记下Prasad的评论,然后尝试查询列出所有直接&的查询该怎么办? A的间接调用者,针对B的每种方法:
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 }
这篇关于nDependency查询直接间接方法以查找程序集中的所有方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!