Microsoft recently released a new tool in the vein of FxCop for analysing source code (instead of compiled assemblies) named, not so imaginatively, Microsoft Source Analysis for C#.  There's a blog entry with an overview from the team about it at http://blogs.msdn.com/sourceanalysis/archive/2008/05/23/announcing-the-release-of-microsoft-source-analysis.aspx 

In summary the tool will check the consistency and layout of your code to help ensure that all team members are working to the same standards.  The intent being to ensure code is easily readable by anyone else on the team, helping to reduce code debt and improve team productivity (as it takes less time to read/grok code you haven't seen before).

When you install StyleCop you will see a new option in the Visual Studio tools menu and also when you right click a file in Solution Explorer.

image

image

Running it will then open an output window looking something like the following:

image

Quite nice, but how do you configure the rules?  Simple - right click the project file and you'll see a separate option for the configuring which rules will be applied:

image

Selecting this brings up a dialog where you can then enable/disable the rules - here I've turned off the "no tabs" rule.

image 

One other good thing is that the team has already posted a guide on how to perform these rule checks as part of your MSBuild projects (ie inside a TFS Team Build or CC.NET build).  See http://blogs.msdn.com/sourceanalysis/pages/source-analysis-msbuild-integration.aspx for more details.

 

So what are you waiting for? Go get it from https://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=sourceanalysis and start making your code more maintainable today :-)