TIP: Automatically generate Managed Code Analysis/FxCop suppressions

I see a lot of users attempting to hand code a SuppressMessageAttribute themselves. This can be error prone and is not needed when both Visual Studio and the standalone FxCop can automatically generate these for you. In Visual Studio 2005 Right-click a Code Analysis warning in the Error List and choose Suppress Message(s). In Visual Studio Orcas Right-click a…

1

FAQ: What is the GlobalSuppressions.cs/GlobalSuppressions.vb file and why is it needed? Is it possible to change the name of this file? [David Kean]

I’ve noticed that Code Analysis sometimes places suppressions in a file called GlobalSuppression.cs (GlobalSuppressions.vb in Visual Basic). Why this is file needed and it is possible to change its name? What is this file? When you right-click on a warning and choose Suppress Message(s), Code Analysis checks to see if the warning was raised against an…

1

A couple of new Orcas features for Managed Code Analysis [David Kean]

Yesterday our team, Code Analysis, checked-in the last of our scheduled feature work for the next version of Visual Studio; Orcas. Now that I have a little time up my sleeve, I thought I would cover a couple of new features that you may have already seen in the Orcas October CTP. First, before I detail what…

8

FAQ: Why does FxCop ignore my in-code (SuppressMessageAttribute) suppressions? [David Kean]

FxCop 1.35 brings with it the ability to suppress messages in code via the use of the SuppressMessage attribute. This allows you to do the following:     public class PublicKey    {        private byte[] _Token;        […]        [SuppressMessage(“Microsoft.Performance”, “CA1819:PropertiesShouldNotReturnArrays”)]        public byte[] Token        {            get { return (byte[])_Token.Clone(); }        }    } In the above example, we’ve suppressed the Properties Should Not Return Arrays violation for the Token property…

2