Software metrics help you understand portions of your system which may need some additional attention to cut complexity and ease maintainability. Having access to such data from within Visual Studio gives you real-time feedback as you’re working on your code.
Software metrics help you understand portions of your system which may need some additional attention to cut complexity and ease maintainability. Having access to such data from within Visual Studio gives you real-time feedback as you’re working on your code. The Metrics tool portion of the CR Plugin add-in for DX Core gives you just that.
Developer Express’s DXCore is an integration framework enabling rapid plug-in development for Visual Studio. Developer Express has made DXCore available as a free download in order for other developers to create useful plugins.
CR Plugin, an open source add-in built for DXCore, includes a handy metrics tool as part of its package. The other tools in CR Plugin work only under CodeRush, itself a productivity add-in for Visual Studio’s IDE. The metrics package, however, works well under the freely-available DXCore.
Download both DXCore and CR Plugin, then unzip the plugin to a working directory. Exit all instances of Visual Studio and install DXCore. After that’s finished you’ll need to build the CR Plugin components and copy the output DLLs to DXCore’s Plugin folder. (Normally C:\Program Files\Developer Express Inc\DXCore for Visual Studio .NET\1.1\Bin\Plugins.)
Restart Visual Studio and you’ll find the “Metrics” option added under the DevExpres -> Tool Window option. Select it and you’ll get a dockable window open in your IDE.
The following graphic shows the metrics window displaying cyclomatic complexity stats for NAnt’s Core assembly. Note that the Metric tool only works on open files. Select all files in an assembly, then right-click and select “Open” to quickly pop everything into separate editor windows.

The Metrics tool also displays Lines of Code and a Maintenance Complexity (MC) statistic. The MC stat is derived from a large number of elements in the code, including use of comments, array declarations, conditionals and other expressions. Mark Miller details the breakdown of how MC scores are derived on his blog. He also gives a useful chart showing levels where you should start thinking about refactoring and simplifying things.
Clicking on namespaces or classes in the left pane of the Metrics window will limit metrics computation to that selected element. You can continue to drill down to individual methods by double-clicking on a method/statistic in the right pane. The corresponding class will open into focus in the code editor. The code will be highlighted in the editor unless it’s in a collapsed region, in which case only the class is displayed.
The Metrics add-in works on C# and Visual Basic .NET source. DXCore supports Visual Studio .NET 2000, 2003 and has experimental support for 2005.
You can find other plug-ins for DXCore at Jay Kimble’s blog.
