Attribute string literals should parse correctly
Attribute string literals should parse correctly
Microsoft docsDescription
Since attributes are derived from System.Attribute, and attributes are used at compile time, only constant values can be passed to their constructors. Attribute parameters that must represent URLs, GUIDs, and Versions cannot be typed as System.Uri, System.Guid, and System.Version, because these types cannot be represented as constants. Instead, they must be represented by strings.
Because the parameter is typed as a string, it is possible that an incorrectly formatted parameter could be passed at compile time.
This rule uses a naming heuristic to find parameters that represent a uniform resource identifier (URI), a Globally Unique Identifier (GUID), or a Version, and verifies that the passed value is correct.
Cause
An attribute's string literal parameter does not parse correctly for a URL, GUID, or Version.
How to fix violations
Change the parameter string to a correctly formed URL, GUID, or Version.
Example
#pragma warning disable CA2243
// The code that's violating the rule is on this line.
#pragma warning restore CA2243When to suppress
It is safe to suppress a warning from this rule if the parameter does not represent a URL, GUID, or Version.