Provide ObsoleteAttribute message
Provide ObsoleteAttribute message
Microsoft docsDescription
System.ObsoleteAttribute is used to mark deprecated library types and members. Library consumers should avoid the use of any type or member that is marked obsolete. This is because it might not be supported and will eventually be removed from later versions of the library. When a type or member marked by using System.ObsoleteAttribute is compiled, the System.ObsoleteAttribute.Message property of the attribute is displayed. This gives the user information about the obsolete type or member. This information generally includes how long the obsolete type or member will be supported by the library designers and the preferred replacement to use.
Cause
A type or member is marked by using a System.ObsoleteAttribute attribute that does not have its System.ObsoleteAttribute.Message property specified.
By default, this rule only looks at externally visible types and members, but this is configurable.
How to fix violations
To fix a violation of this rule, add the message parameter to the System.ObsoleteAttribute constructor.
Example
[ObsoleteAttribute("This property is obsolete and will be removed in a " +
"future version. Use the FullName property instead.", false)]
public string Name
{
get => "Name";
}When to suppress
Do not suppress a warning from this rule because the System.ObsoleteAttribute.Message property provides critical information about the obsolete type or member.