Getting dependencies between assemblies programatically by NDepend APIs

I want to create an analyzer tool for extracting a dependency matrix like the matrix in Visual NDepend.

How do I list the dependencies that exist between two assemblies in a solution?


Read first the NDepend.API Getting Started page. Then, you can exercise by looking at CQLinq queries generated by right-click a non-empty dependency matrix cell > Generate a query that matches these X code elements ... For example, if the matrix option Weight on cells is set to Direct: # methods, you get:

N依赖依赖矩阵

... this generates the following CQLinq query. You can then reuse this query as a classic LINQ query in a program consuming NDepend.API. These generated queries should constitute a good starting point to develop more sophisticated dependency queries and programs.

from m in Assemblies.WithNameIn( "mscorlib").ChildMethods()
where m.IsUsedBy ("pnunit-launcher")
select new { m, m.NbLinesOfCode }
//--------------------------------------------------------------------
// 52 methods of the assembly
// mscorlib
// v4.0.0.0
// 
// are used by
// 24 methods of the assembly
// pnunit-launcher
// v1.0.4661.29691
// 

Btw, here is the query edited view:

在这里输入图像描述

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

上一篇: 你如何忽略NDepend中的.NET程序集?

下一篇: 通过NDepend API以编程方式获得程序集之间的依赖关系