This is one of those wonderful tools out of Microsoft which does not get too much time out there in the sun, which it surely and richly deserves. I am talking about a tool called FxCop. According to the site FxCop is
"FxCop is a code analysis tool that checks your .NET assemblies for conformance to the .NET Framework Design Guidelines . It uses reflection, MSIL parsing, and callgraph analysis to inspect your assemblies for more than 175 defects in the following areas: naming conventions, library design, localization, security, and performance "
I find this one of the most useful tool when coding in .NET. It is so easy to do some idiotic thing when you are coding under pressure. I make it a rule to run FxCop on my code, before I put my code into the SCC system. I also insist that my team does the same and I find that we catch most of those maintenance nightmare problems at this stage.
Another thing I like about this is that it also ships with a SDK which allows you to write your own rules. This is still in Beta, but I have started playing around with it. It is very easy to write a simple rule, but if you are looking at going deeper, then you need to have an understanding of IL etc. Of course, the people who have written FxCop have written a set of libraries that parse IL and allows you to access IL easily, but then these are marked as obsolete. Michael from the MS team which has created FxCop said in reply to one of my posts, that they plan to completely replace these classes with a newer set in the future release. I am eagerly awaiting that release, but as with all good things, they do not have any fixed date when they plan to have that release...:-)