Get Dependency List from Depend

I'm using NDepend to help manage a project and I was just asked to get an ordered list of dependencies (for build ordering of different solutions) based on what was using, both directly and indirectly, a given assembly.

NDepend provides a fine way of finding those modules that are dependent on that assembly, but no way of ordering it in the way I want. For instance I can run

from a in Assemblies 
let depth0 = a.DepthOfIsUsing("Assembly1".MatchAssembly())
where depth0  >= 0 orderby depth0
select new { a, depth0 }

and that will get me a list like this

Assembly1 0
Assembly2 1
Assembly3 1
Assembly4 2

Which essentially means that Assembly2 and Assembly3 have direct dependencies on Assembly1, and Assembly4 has a dependency on either Assembly2 or Assembly3.

My problem exists because Assembly3 has a dependency on Assembly1 AND Assembly2. And if Assembly4 only had a dependency on Assembly 2, I'd like to see a list like this:

Assembly1 0
Assembly2 1
Assembly3 2
Assembly4 2

If Assembly4 also had a dependency on Assembly3, then the list should look like this:

Assembly1 0
Assembly2 1
Assembly3 2
Assembly4 3

Now I can export the original list to a dependency graph, and view it horizontally, and manually fill out that dependency list myself, but I've actually got 123 assemblies in my hierarchy and that's a hell of a job, especially when I have other processing to do after that (something I know can't be achieved with NDepend), so I'd rather find a way of do this in CQL.

Anyone with ninja NDepend skills know how I can achieve this?

Thanks.

链接地址: http://www.djcxy.com/p/6438.html

上一篇: 如何重新定义NDepend查询的应用程序域?

下一篇: 从Depend获取依赖列表