Larkware banner
border

Review: NDepend

NDepend 2.0, Free
Patrick Smacchia
http://www.ndepend.com/

We all know that the compiled IL for our .NET applications contains a wealth of information, but very few of us do anything with it. NDepend is a power developer's tool that can perform a very deep analysis of your compiled code to help you understand and control your development efforts. Created by Patrick Smacchia, the author of Practical .NET 2 and C#2, this tool can provide more metrics than most developers will ever need. If you're working on a large project, though, you'll likely find its assistance in spotting potential trouble and enforcing standards quite valuable.

NDepend is quite simple to use. For interactive analysis, you'll be using two applications in tandem. The first, NDepend.Project, allows you to select a set of assemblies to analyze. It then churns through the IL and produces a detailed report on metrics (you can see a number of samples at the NDepend site - for example, here's one on the entire .NET 2.0 Framework). After the initial analysis, you can load the results into Visual NDepend for interactive exploration. Here you have a treeview and a treemap to drill in to the details of your assembly, right down to the member level. You can see things like the number of IL instructions for each class, the number of methods it contains, its cyclomatic complexity, numeric measures of its coupling, and more.

Visual NDepend also lets you write and evaluate queries written in Code Query Language (CQL). This is a SQL-like language that lets you interrogate NDepend's internal view of your code's structure to find out nearly anything you might like to know. As one tiny example, want to see a part of the call tree of your application? Try this CQL:

SELECT METHODS WHERE IsCalledBy "MyType.MyMethod()" ORDER BY DepthOfIsCalledBy DESC

CQL covers a wide range of things: methods, types, fields, assemblies, namespaces, metrics, IsConstructor, IsPropertySetter, IsOverloaded, IsSealed, and on and on. NDepend comes stocked with a number of pre-built CQL queries to warn you about things that are generally bad; you can think of this as a sort of easily customizable system for watching for violations of your corporate coding standards.

Finally, NDepend is not just an interactive tool; it's also designed to fit into a build process. There's a console version and it's designed to be integrated into MSBuild or NAnt build scripts, with results in XML files. So if you find yourself wanting to watch over some particular chunks of integration, this free tool gives you a way to do so. Roll up your sleeves, spend a bit of time learning CQL and integrating it into your process, and you'll find yourself with a deeper understanding of what's going on in your shop than ever before.

NDepend screenshot  Click for larger screenshot

Mike GunderloyLarkware is the editor of Larkware, the daily .NET newspaper of record.

Published June 8, 2006