I recently gave Microsoft Source Analysis a try. It was released sometime ago, and act's as an add-in in Visual Studio to check the source code with some coding rules. This is different from FxCop which checks assemblies. This checks your source code before it is compiled right in Visual Studio editor.I did like the tool. Quite handy, but will need a little bit getting used to.
Some companies may need to change some rules to match their coding standards. For people who don't have a particularly though out coding standard in place, and are using something from the ASP / VB / C days, it may be worth changing over the standard based on the Source Analysis rules, as it has been in use for quite a while at some parts of Microsoft, and from an overall look, it does look quite a decent one.
There are a few irritations, but you can turn rules on and off. The most irritating part is that it throws up tons of errors in the Visual Studio generated code. Also, another irritation is that the default rules need a header on every page. However, it is not a bad thing. Either you can toggle the rule off, or write a header. Doh... Most of you like me will go, how do I write a header which Source Analysis will understand? Well, worry not, help is at hand.You can use the following header for your code files:
//-----------------------------------------------------------------------
// <copyright file="Program.cs" company="Your Company Name">
// Copyright (c) Your Company Name. All rights reserved.
// </copyright>
// <author>Your Name</author>
//-----------------------------------------------------------------------
What about the Visual Studio auto-generated files? You don't need to worry about Source formatting and coding practices in those files. So how do we exclude them from being checked? Well, there is a simple enough way.Just add the following header in all files you don't want checked by Source Analysis.
// <auto-generated />
For more details about headers, you can check out the rules documentation on the Source Analysis Blog.
Lastly, now, you are sort of morally forced to document every method. I know it's a bit of an effort for all lazy developers like me. So GhostDoc come here to rescue us from our plight. For those of you, who don't know about Ghost Doc, shame on you. Just kidding ;) It is a cool VS Add-In by Roland Weigelt, which auto generates method descriptions by guessing it from the description. It is not perfect, but definitely a big leap from the Visual Studio way. Download it and I can assure you that you will seriously get addicted to it. Combine together Ghost Doc and Source Analysis, make coding much clearer, better documented and developer friendly.