右键单击UI中任意位置的方法,然后选择菜单:选择方法...> ...正在使用我(直接或间接)导致代码查询,如:
from m in Methods
let depth0 = m.DepthOfIsUsing("NUnit.Core.NUnitFramework+Assert.GetAssertCount()")
where depth0 >= 0 orderby depth0
select new { m, depth0 }
Run Code Online (Sandbox Code Playgroud)
问题是这样的查询提供了间接使用,但不查找通过接口(或在基类中声明的重写方法)发生的调用.
希望您可以通过此查询获得所要求的内容:
// Retrieve the target method by name
let methodTarget = Methods.WithFullName("NUnit.Core.NUnitFramework+Assert.GetAssertCount()").Single()
// Build a ICodeMetric<IMethod,ushort> representing the depth of indirect
// call of the target method.
let indirectCallDepth =
methodTarget.ToEnumerable()
.FillIterative(
methods => methods.SelectMany(
m => m.MethodsCallingMe.Union(m.OverriddensBase)))
from m in indirectCallDepth.DefinitionDomain
select new { m, callDepth = indirectCallDepth[m] }
Run Code Online (Sandbox Code Playgroud)
此查询的两个角落是: