How-to: write custom code analysis/FxCop rules

Jason Kresowaty has posted a great tutorial on writing Code Analysis/FxCop rules. It’s excellent for advanced users who want to write their own custom rules, but doesn’t leave new users out. There’s wonderful introductory information explaining what the tool can be used for and how to get the most out of it. He also explains parts of the Introspection API, including the different nodes and their relationship to each other. The article is written for the FxCop 1.36 Beta, which I hear is really stable. The v1.36 beta is the first version that supports some of the new features of .NET Framework 3.5.

FxCop v 1.35 ships in the Windows SDK for Windows Server 2008 and .NET Framework 3.5. It’s possible to select only the .NET Framework tools during SDK setup if you wish. That way you can avoiding downloading content you don’t need (although the SDK is packed with goodness).