1

我可以使用 CQLinq / NDepend 找到间接依赖项,并使用神奇的“FillIterative”方法过滤找到的依赖项。之后访问“DefinitionDomain”可以给我依赖路径的深度(多少跳)。

我现在的问题是:我可以以某种方式将依赖路径添加到查询结果中的每个条目吗?因此,对于列出成员“目标”的所有间接使用以及使用深度的查询,而不是表单的结果

method          depth
------------------------------------------------------------------------
Foo             2
Bar             1
Baz             0

我会得到表格的结果

method          depth          path
------------------------------------------------------------------------
Foo             2              Foo, Something1, Something2, Target
Bar             1              Bar, Something3, Target
Baz             0              Baz, Target

...这可能吗?

编辑:到目前为止,这是我的查询:

// <Name>Async methods must not use non-async variants of EnsureInThisCtx methods, even indirectly</Name>
warnif count > 0
let mse = Methods.WithFullNameLike("DbContext\\.EnsureIsInThisCtx[^A]")
let m1 = mse.First()       // there are two overloads
let m2 = mse.ElementAt(1)  // of the method I want to catch.
let icd1 = m1.ToEnumerable().FillIterative(methods => methods.SelectMany(m => m.MethodsCallingMe.Union(m.OverriddensBase)))
let icd2 = m2.ToEnumerable().FillIterative(methods => methods.SelectMany(m => m.MethodsCallingMe.Union(m.OverriddensBase)))
let hits1 = (from m in icd1.DefinitionDomain where m.IsAsync select m)
let hits2 = (from m in icd2.DefinitionDomain where m.IsAsync select m)
from m in hits1.Union(hits2).Distinct()
let dist1=icd1[m]
let dist2=icd2[m]
select new { m, DepthOfUsageVariant1=dist1, DepthOfUsageVariant2=dist2 }

示例输出如下所示:

methods         DepthOfUsageVariant1  DepthOfUsageVariant2
------------------------------------------------------------------------
Foo             2                     0
Bar             0                     1
...
4

0 回答 0