Expert Texture Home Contact me About Subscribe Digipede Connect on LinkedIn rwandering on Twitter rwandering on FriendFeed

The blogged wandering of Robert W. Anderson

SuppressMessageAttribute for .NET1.1

I started using the new Code Analysis feature of VSTS today, moving from external FxCop usage. A cool thing about this new feature is that is adds supression information directly to the source code in the form of attributes.

I like this since it keeps the supressions with the code. There is one drawback for us at Digipede: we cross compile back to .NET 1.1. These new attributes don’t exist in the old framework, so I added my own for compilation with our .NET 1.1 code:

namespace System.Diagnostics.CodeAnalysis { 
    [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
    internal class SuppressMessageAttribute : Attribute {  
        public SuppressMessageAttribute(string category, string checkId) {} 
        public string Category { get { return null;} set {} } 
        public string CheckId { get { return null;} set {} } 
        public string Justification { get { return null;} set {} } 
        public string MessageId { get { return null;} set {} } 
        public string Scope { get { return null;} set {} } 
        public string Target { get { return null;} set {} } 

Thanks to The Moth for part of the implementation. He blogs about the attribute not being included in the Compact Framework here: SuppressMessage not in CF.

Tags: , , , ,


No comments yet »

Your comment

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>