URI properties should not be strings
URI properties should not be strings
Microsoft docsDescription
This rule splits the property name into tokens based on the Pascal casing convention and checks whether each token equals "uri", "Uri", "urn", "Urn", "url", or "Url". If there's a match, the rule assumes that the property represents a uniform resource identifier (URI). A string representation of a URI is prone to parsing and encoding errors, and can lead to security vulnerabilities. The System.Uri class provides these services in a safe and secure manner.
Cause
A type declares a string property whose name contains "uri", "Uri", "urn", "Urn", "url", or "Url".
By default, this rule only looks at externally visible types, but this is configurable.
How to fix violations
To fix a violation of this rule, change the property to a System.Uri type.
Example
#pragma warning disable CA1056
// The code that's violating the rule is on this line.
#pragma warning restore CA1056When to suppress
It's safe to suppress a warning from this rule if the property doesn't represent a URI.