Ok, so I recently made the analogy that in the code metrics world, vil is a knife (good for slicing and dicing) while NDepend is the utilitarian fork. I was going to try to fit SourceMonitor into the world of eating utensils as well, but I think that analogy is just about played out.
So how about this instead…
If you were going on blind dates with these tools, I’d tell you that SourceMonitor is a “looker”, while NDepend has a “nice personality”. In the end, both of them are gonna show you a good time, and NDepend may arguably provide more stimulating conversation, but SourceMonitor is the one you are telling your buddies about in the locker room. Not a knockout per se, but pretty enough to brag about.
Put simply, SourceMonitor provides most of the information you need in a very refined and attractive package.
For instance, here’s a screenshot to whet your appetite:

Like what you see? Ok, so let’s add it to CruiseControl.NET…
1. Create the NAnt target.
This target will:
a. Write out an input file with the commands that SourceMonitor will call. The first command generates the project summary; the second spits out the details. Also, note that the commands specify a SoureMonitor project file (.smp) – if this file doesn’t exist it will generate one, but if you wanted to, you could reference a permanent one and it will track your code metrics data over time using the checkpoint name (or date) that you provide.
b. Call the executable that will read in the input commands file.
2. Copy the xsl transforms to the ccnet\webdashboard\xsl directory.
I’ve created several modified transforms based on some that come as part of an Ant example with the SourceMonitor distribution:
sourcemonitor-group-by-file.xsl
sourcemonitor-group-by-metric.xsl
sourcemonitor-summary.xsl (for use on your summary build report if desired)
Note that these should play nice within the ccnet dashboard without jacking with existing dashboard styling unlike some of the other xsl files I posted previously (which I’ve since gone back and fixed).
3. Add the xsl report plugin entries to the dashboard.config.
4. Add the output files to merge into your project’s entry in ccnet.config.
Summary:
It turned out that this tool was pretty easy to integrate into my builds - not nearly as messy as I’d imagined, and the results are crisp and applicable. Another upside – SourceMonitor analyzes your source rather than the IL, so the results tend to be a more accurate reflection of your code.
Ok, so here’s the downside – no kiviat diagrams. This is the main thing that attracted me to SourceMonitor in the first place, but currently there doesn’t seem to be any support for generating these from the command line, so if you want’em, you’ll have to run the SourceMonitor client. Bummer, but I still really like the what SourceMonitor is giving me. Concise and attractive - you can’t go wrong with that. Here’s some screenshots of the finished product…
Final Result:



Alright, so good luck, and enjoy your “hot date” with SourceMonitor. (Ok, I need to get out more.)