Posts
208
Comments
1144
Trackbacks
51
SuppressMessage with FxCop and NON-Team System Visual Studio

If you're using Visual Studio 2005 Team System then FxCop is completely integrated and when you exclude messages it automatically applies the new SuppressMessage attributes to the appropriate location in code. But if you're using Visual Studio Professional edition then you have to use the external FxCop 1.35 UI. If this is the case, you can STILL utilize the SuppressMessage attribute but have to do a couple of things first. I had to do a little digging but the steps are pretty simple.

It turns out you have to enable your project to recognize the SuppressMessage attribute by FIRST adding a condition compilation symbol.

To include this symbol do the following:
C#
1. In Solution Explorer, right-click your project and choose Properties
2. In the Properties window, choose the Build tab
3. In the Conditional compilation symbols text box enter CODE_ANALYSIS

VB
1. In Solution Explorer, right-click your project and choose Properties
2. In the Properties window, choose the Compile tab and click Advanced Compile Options
3. In the Custom constants text box enter CODE_ANALYSIS
Found these steps here:

Now for the cool part. In Team System, you can just right-click on the rule and say “Suppress” and it will automatically add the SuppressMessage attribute in the right spot. In Professional edition, we don’t have this integrated into the IDE so we have to use the normal FxCop 1.35 UI (which of course has no knowledge of Visual Studio) – and correctly specifying these attributes is not easy to do by hand. It turns out all you have to do, is to right-click the error message in FxCop UI and select “Copy As” – “SuppressMessage” (or “Module-level SupressMessage”). Then you can simply paste the attribute into your code at the appropriate location. Very slick!

posted on Wednesday, January 11, 2006 1:40 PM Print
Comments
Gravatar
# re: SuppressMessage with FxCop and NON-Team System Visual Studio
David M. Kean
6/14/2006 7:04 AM
Just to let you know that, the post has been moved and made into a blog entry: http://blogs.msdn.com/fxcop/archive/2006/03/23/559149.aspx
Gravatar
# re: SuppressMessage with FxCop and NON-Team System Visual Studio
mr s
12/18/2006 10:51 AM
so that's how to make it work.
Gravatar
# re: SuppressMessage with FxCop and NON-Team System Visual Studio
Steve
5/27/2008 1:14 PM
Is there a way to suppress the messages by not adding the attribute to the code?
Gravatar
# re: SuppressMessage with FxCop and NON-Team System Visual Studio
Steve
5/30/2008 9:09 AM
Sure, the easiest way is to simply right-click the rule in the FxCop GUI and suppress it there.

Post Comment

Title *
Name *
Email
Comment *  
Verification

View Steve Michelotti's profile on LinkedIn

profile for Steve Michelotti at Stack Overflow, Q&A for professional and enthusiast programmers




Google My Blog

Tag Cloud