Domanda

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?

È stato utile?

Soluzione

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:

NDepend Dependency Matrixk

... 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:

enter image description here

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top