CA2130: Security critical constants should be transparent
Visual Studio 2012
|
TypeName |
ConstantsShouldBeTransparent |
|
CheckId |
CA2130 |
|
Category |
Microsoft.Security |
|
Breaking Change |
Breaking |
A constant field or an enumeration member is marked with the SecurityCriticalAttribute.
In the following examples, the enum value EnumWithCriticalValues.CriticalEnumValue and the constant CriticalConstant raise this warning. To fix the issues, remove the [SecurityCritical] attribute to make them security transparent.
using System; using System.Security; //[assembly: SecurityRules(SecurityRuleSet.Level2)] //[assembly: AllowPartiallyTrustedCallers] namespace TransparencyWarningsDemo { public enum EnumWithCriticalValues { TransparentEnumValue, // CA2130 violation [SecurityCritical] CriticalEnumValue } public class ClassWithCriticalConstant { // CA2130 violation [SecurityCritical] public const int CriticalConstant = 21; } }