Static Code Analysis made easier in VS 2005

The built in Static Code analysis in Visual Studio 2005 is pretty cool, and quit intuitive to use.

There are a couple of nice features worth mentioning that are accessible right from the Error List.

If you come across warnings in your error list put there by the Static Code Analyzer. There are a couple of quick ways to deal with them.

Create a Work Item:
This is a nice way to remind yourself to deal with the issue later. You could even assign the Work Item to someone else so they can deal with it later. :)

I wish you could add a Todo: to the code from here. Sometimes I don't want a Work Item I just want a reminder in my code to fix it up. Maybe next version.

Suppress Message:
If this is not an issue for this particular project or class you can suppress the warning by selecting Suppress Message.

For example if you create an Enum and its members have values 1 - 4 you will get the warning CA1008 Enums should have zero value. For this instance you are knowingly breaking the rule, although you would like to continue to be warned when this happens. When you select Suppress Message from the context menu it will add an attribute to the enum telling the Static Code Analyzer to ignore the rule. If it's a project level rule a new file is created in the project called ModuleSuppressions.cs and attributes will be added to it.