I can find indirect dependencies using CQLinq / NDepend, and using the magic "FillIterative"-Method I can filter the found dependencies. Accessing the "DefinitionDomain" afterwards can give me the depth of the dependency path (how many hops).
My question now is: Can I somehow add the dependency path to each entry in my query results? So for a query that lists all indirect usages of the Member "Target" together with the depth-of-usage, instead of results of the form
method depth
------------------------------------------------------------------------
Foo 2
Bar 1
Baz 0
I'd get results of the form
method depth path
------------------------------------------------------------------------
Foo 2 Foo, Something1, Something2, Target
Bar 1 Bar, Something3, Target
Baz 0 Baz, Target
...is this possible?
Edit: Here's my query so far:
// <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 }
And example output looks like this:
methods DepthOfUsageVariant1 DepthOfUsageVariant2
------------------------------------------------------------------------
Foo 2 0
Bar 0 1
...