Welcome to Team System Rocks Sign in | Join | Help

Mickey Gousset

My Journey Into Team System
(Add me to your Live Messenger at mickey_gousset@hotmail.com)

<January 2007>
SuMoTuWeThFrSa
31123456
78910111213
14151617181920
21222324252627
28293031123
45678910

Post Categories

News

ProTFS Book Cover

Navigation

Awards

Links-O-Interest

Syndication

Static Code Analysis - Part 3 - Suppress Messages
[NOTE: Please log into Team System Rocks! to be able to see the images. ]

For background, please see Part 1 and Part 2 in this series of posts.

It could be that you want a particular static code analysis rule to continue to be used and run, but that it doesn't apply to a particular piece of code for some reason. In my example, I'm going to say that the 6th warning, CA1822, just doesn't apply in this case. I want to continue to use rule CA1822, but I don't want the Subtract method to continue to trip this warning.

To solve this problem, I want to suppress this warning message for this particular piece of code. To do that, I right-click on the warning, and select Suppress Message(s). This will take you to the offending code, and adds an attribute above the method:

This attribute makes sure that for the Microsoft.Performance category, and the CS1822:MarkMembersAsStatic rule, that this method, Subtract, will not trigger this warning when static code analysis is run. You can have multiple SuppressMessage attributes if need be.

If I save my code, and rebuild my solution again, this time, when static code analysis is run, the Subtract method no longer throws a warning, as shown:

Published Wednesday, January 24, 2007 8:24 AM by mickey_gousset

Comments

New Comments to this post are disabled
Powered by Community Server, by Telligent Systems