title | description | ms.date | ms.topic | f1_keywords | author | ms.author | manager | ms.subservice | monikerRange | |
---|---|---|---|---|---|---|---|---|---|---|
CA2145: Transparent methods should not be decorated with the SuppressUnmanagedCodeSecurityAttribute |
A transparent method, a method that is marked with the SecuritySafeCritical attribute, or a type that contains a method is marked with the SuppressUnmanagedCodeSecurity attribute. |
11/04/2016 |
reference |
|
mikejo5000 |
mikejo |
mijacobs |
code-analysis |
vs-2019 |
Item | Value |
---|---|
RuleId | CA2145 |
Category | Microsoft.Security |
Breaking change | Breaking |
A transparent method, a method that is marked with the xref:System.Security.SecuritySafeCriticalAttribute attribute, or a type that contains a method is marked with the xref:System.Security.SuppressUnmanagedCodeSecurityAttribute attribute.
Note
This rule has been deprecated. For more information, see Deprecated rules.
Methods decorated with the xref:System.Security.SuppressUnmanagedCodeSecurityAttribute attribute have an implicit LinkDemand placed upon any method that calls it. This LinkDemand requires that the calling code be security critical. Marking the method that uses SuppressUnmanagedCodeSecurity with the xref:System.Security.SecurityCriticalAttribute attribute makes this requirement more obvious for callers of the method.
To fix a violation of this rule, mark the method or type with the xref:System.Security.SecurityCriticalAttribute attribute.
Do not suppress a warning from this rule.
:::code language="csharp" source="../snippets/csharp/VS_Snippets_CodeAnalysis/fxcop.security.ca2145.transparentmethodsshouldnotusesuppressunmanagedcodesecurity/cs/ca2145.cs" id="Snippet1":::