문제

NDepend seems to be a great tool for code analysis, especially for dependency graph visualization, so we bought a copy.

However, the one thing I really need most seems not to be possible: I need a namespace dependency graph over the whole solution. The only thing I can get is an assembly graph.

And this is why I need it:

We have the architectural rule that dependencies accross layer boundaries must always point to interface components. Interface components carry the suffix "Interface" in both assemby name and namespace.

We have namespaces in the form of

Company.Product.Layer.Component

Since the layer information is not visible from the assembly names, but from the namespaces, the namespace dependency graph would be the only useful graph for this kind of analysis.

So my question is: How can I verify that the architectural rule described above? Do you know how to actually get the dependency graph? Do you know another possibility to verify the rules?

도움이 되었습니까?

해결책

To get a graph of application namespaces in the VS solutions, just use the menu shown below...

Reset Graph to application namespaces only

...et voila!

Graph of application namespaces assemblies

Thanks to Code Rule over LINQ Query (CQLinq) capabilities, the CQLinq rule below could be a good start to polish it to get the exact rule you need:

warnif count > 0 

// Namespaces with suffix Interface
let interfacesNamespaces = 
   Application.Namespaces.WithNameLike("Interface$").ToHashSet()

// Match namespaces that are using something else than interfacesNamespaces 
from n in Application.Namespaces
let nonInterfacesNamespacesUsed = n.NamespacesUsed.Except(interfacesNamespaces)
where nonInterfacesNamespacesUsed.Count() > 0
select new { n, nonInterfacesNamespacesUsed }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top