Some time ago, I wrote an article for CodeProject on performing dependency analysis. I gradually extended the Python code and examples and placed them on GitHub. Subsequently, I agreed to talk about architecture for a local .NET meetup so, for greater relevance, I wrote a tool to decompile .NET assemblies with Mono.Cecil. I've since recorded most of the Python into C# to create the Visual Studio extension DeepEnds that is available via the Visual Studio Gallery. One advantage is that it uses Roslyn to parse the individual C# and VB files.
Visual Studio Enterprise 2015 includes a number of architecture tools whose results can be visualized within the Community and Professional editions. Of particular interest is the DGML file format for describing directed graphs (used to visualize dependencies) as these files can be viewed in Community. I believe the DGML viewer uses the Microsoft Automatic Graph Layout library to do the actual drawing, thus it should be possible to create a standalone viewer.
The source code for the plug-in is available on GitHub for those wishing to see example code for parsing C# and Visual Basic source in Roslyn, decompiling assemblies with Mono.Cecil or using the Visual Studio API to create DGML files.
DeepEnds allows you to dive into your architecture without having to dive deeply into your pocket... i.e. It has been developed for Visual Studio Community 2015 and is distributed gratis. It uses the same concepts for visualizing dependencies and calculating associated metrics as described in "As-Is Software Architecture" and "Why Favour the Cyclomatic Number?", so they won't be repeated here.
To launch the tool from the menu bar choose View → Other Windows → DeepEnds; the tool window is very simple. The first text box is multi-line and takes a set of input files, one-per-line, that can be appended to by using the associated browse button. Once the required files are determined the read button needs to be pressed. The second text box is single line and specifies the creation of either a DGML file or the associated HTML report once the write button is pressed.
There are some limitations on the input: Cannot mix C++ and .NET. The decompilation of assemblies will not produce as good a result as parsing the C# or VB source code.
As mentioned, the main form of output is a DGML file which happens to be a collapsible hierarchical graph format which supports hyperlinks to code as can be seen by the underlining of the text of the leaf node (
FEA.cpp) in the following diagram. The hierarchy is defined by the namespace for .NET and by the filter for Visual C++. Note that it is possible for the user to edit this diagram interactively.
This can be compared with the Doxygen output (generated as a png file using the dot tool) from my previous article.
The second form of output is an HTML report that starts with a table of complexities ordered so that the worst is first. The sum columns refer to the formula to their left that is evaluated for the current and all child nodes, recursively. Thus it is possible to get one value for the project and to track that over the course of development.
The externals column refers to the number of unique dependencies that aren't contained by the current node. Thus the Top Level node will always have a value of zero. The maximum on the node and all its children is tracked for completeness. This measure is equivalent to Class Coupling in Microsoft Code Metrics.
For instances other than decompiled code, the number of lines of code in a leaf node are counted. Thus comments (but not C style comments) are ignored along with braces in C++ and C#. The sum and maximum calculated over the current and child nodes are reported along with the arithmetic mean.
Finally, whether a cycle exists within the graph is reported.
This table hyperlinks to sections that detail the underlying dependencies that cause the links to be displayed in the graph. For example,
FEA\Core should not be dependent on anything so it is useful to see what is creating the circular dependency (so that it can be broken) by looking at the appropriate section.
There are further tables of the external dependencies, the individual SLOC and the structure matrix.
Additionally, there is a console application called DeepEnds.Console.exe. Run it with no arguments to get usage instructions. Note that extensions (*.vsix) are just an archive if you cannot find where Visual Studio has installed the extension.
So, if interested, please download and install. It should work for Visual Studio Professional 2015 as well as for Community.
- 2016/07/29: First release
- 2016/08/11: Update due to new version of software - can now mix C# code and .NET assemblies
- 2016/08/15: Update due to new version of software - added support for VB.NET source code
- 2016/08/24: Push source to GitHub
- 2016/09/14: Update with new statistics