Andy Philpotts

I'm trying to suppress a report of CA2211. This is the error message:

[microsoft.visualstudio.qualitytools.unittestframework.dll] Microsoft.VisualStudio.TestTools.UnitTesting.BaseShadow.AttachShadowName
=========================================================================
Rule: Non-constant fields should not be visible
Documentation: http://fxcop/docs/rules.aspx version=v1.35&url=/Usage/NonConstantFieldsShouldNotBeVisible.html
Category: Microsoft.Usage
Check Id: CA2211
Suppression: [SuppressMessage("Microsoft.Usage", "CA2211:NonConstantFieldsShouldNotBeVisible")]
Module Suppression: [module: SuppressMessage("Microsoft.Usage", "CA2211:NonConstantFieldsShouldNotBeVisible", Scope="member", Target="Microsoft.VisualStudio.TestTools.UnitTesting.BaseShadow.AttachShadowName")]
Message Level: Warning
Certainty: 90%
Resolution: Consider making 'AttachShadowName' non-public or a constant.

This is the code with suppression:

[SuppressMessage("Microsoft.Usage", "CA2211:NonConstantFieldsShouldNotBeVisible")] // Should have been const
public static string AttachShadowName = "AttachShadow";

If this looks right, what other things may be going wrong. I don't know if it is a factor but the assembly in question is Gacced, however, some of the fixes worked, others did not.




Re: Visual Studio Code Analysis and Code Metrics Cannot suppress CA2211 (amongst others)

David M. Kean - MSFT

See the following FAQ: Why does FxCop ignore my in-code (SuppressMessageAttribute) suppressions

Regards

David