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

The blogged wandering of Robert W. Anderson

CA2204 is broken

CA2204: Literals should be spelled correctly (docs here).

I agree, but it doesn’t work.

At least not with compound words.  If you are authoring a reusable class library, you are bound to have compound words in literal strings.  Do yourself a favor and turn off the warning.

I had to search around to get this acknowledged, and finally found it on Microsoft Connect here

Tags: , , ,

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: , , , ,