I was fortunate enough to get the opportunity to test drive NDepend (thanks to Patrick Smacchia). NDepend is a source code management tool that among other things, allows you to write ad-hoc queries against your code base. The queries allow you to easily find answers to almost any question you can possibly dream up about your code.
The product implements a SQL-Like language called CQL (Code Query Language) to query your source code. If you are familiar with T-SQL then the learning curve for using CQL is practically zero. Instead of boring you with the technical details, lets get to some examples.
Naming Conventions - How many of my static fields violate company naming standards?
SELECT FIELDS WHERE !NameLike '_%' AND IsStatic
The query above checks for all fields where the name does not start with an underscore.
Documentation - Which complex methods need more comments? (In my case, this was especially useful for checking up on the source code developed by our contractors).
SELECT METHODS WHERE NbLinesOfCode > 40 AND IsPublic AND NBLinesOfComment < 1
The query above returns all methods where there are more than 40 lines of code, are public and have less than 1 line of comments.
Refactoring - Which methods are referencing the namespace?
SELECT TOP 10 METHODS OUT OF NAMESPACES "Codecapers.Utils"
This query is useful if you are deprecating a library or if you are trying to rid your source code of a 3rd party dependency.
I know that there are a lot of tools on the market that let you do "static analysis" of your code. For example, I have been using FxCop for years to find naming violations and other potential problems with my source code. However, when it comes to code analysis, NDepend is in a league of its own. Being able to write ad-hoc queries against your source code is really an eye-opening experience. Other third party tools tend to give you some very standardized metrics that are generally applicable to all projects. However, since every project is different, the metrics produced by a "static" view are really not that useful. Having the ability to generate unique queries for each project is something that sets NDepend apart from the competition. For these reasons alone, NDepend could be referred to as the first "dynamic analysis" tool for your source code.
In conclusion, I would highly recommend NDepend. The short learning curve and overall flexibility of the product make it a must have in any programmer's arsenal. If you want to learn more about the product then please visit NDepend's website.