Search code examples
c#.netvisualizationdependenciescsproj

How do I get a diagram of the dependencies between my C# projects


I have a fairly complex application which has been broken up into multiple components. Each component has a solution file which contains a bunch of projects. So I like to think of this as a component has multiple projects/dlls in it. There is also a "common" component. All the other components depend on "common". So a compile goes like this: "nant component1.compile" will compile "common" and then compile component1 since component1 depends on "common". Over time "common" has become quite big. I'm pretty sure it can be split into a few smaller components. Then components need to depend only on some of these smaller, broken up "common". This would hopefully cut down on compile time for the different components.

So question: I'd like to visualise the dependency between all the different projects in the application while also tagging which component the project belongs to. How would you do this?


Solution

  • The tool NDepend proposes a dependency graph coupled with a dependency matrix. By default you'll get a dependency graph of .NET assemblies and it is not restricted to assemblies of only one VS solution. NDepend is integrated in VS 2017, 2015, 2013, 2012, 2010 and it can show any kind of graph on your code including:

    • dependencies between assemblies
    • method call graph,
    • dependencies of namespaces inside a VS project,
    • dependencies of types inside a namespace,
    • classes inheritance graph,
    • graph representing classes coupling between 2 components

    etc...

    This is all explained here.

    NDepend code graph dependency diagram

    NDepend also proposes a dependency structure matrix (DSM) and a way to query dependencies with C# LINQ queries.