Send mail to the author(s)

June 7, 2007

Smart Device Framework Code Metrics

One of the new features of Visual Studio 2008 (you may know this as Visual Studio Orcas) is Code Metrics. Code Metrics gives you a way of measuring the complexity and maintainability of your code. The point of gathering code metrics is to aid in the writing quality code.

The way in which Visual Studio 2008 performs these measurements is to compile your code and then examine the IL output by the compiler. A side effect of measuring metrics at the IL level is that the lines of code metric is based on the number of IL instructions, rather than the source code in which the code was written. For example, in the Code Metrics results below, Visual Studio says the SDF is in the order of 21,000 lines of (IL) code, whereas SourceMonitor reports something in the order of 94,000 lines of (source) code.

Anyway, for those of you who might be interested here is the results of running the Code Metrics tool over the Smart Device Framework:

SDF Code Metrics

I'm not surprised by the high cyclomatic complexity of OpenNETCF.dll, OpenNETCF.Web.Services2.dll and OpenNETCF.Windows.Forms.dll as these are quite large assemblies with a large number of classes.

As a final word, I cannot encourage you enough to take a look at the Code Metrics feature. This, in conjunction with the Code Analysis and Unit Testing features are a powerful set of tools every developer should use before they even think about debugging.