Reputation: 479
Is there an attribute like Obsolete
or Deprecated
to indicate that a method has become obsolete or deprecated in the next version of a C# API? Otherwise, is there a standard for indicating that, like adding it in the remarks of a method's documentation?
Upvotes: 1
Views: 2149
Reputation: 166
You should mark the method as obsolete using the Obsolete annotation. Refer to ObsoleteAttribute for details.
[Obsolete("Your warning message")]
public void MyMethod()
{
// Method body
}
If you want to throw an error instead of a warning, you could set the second argument error which is a boolean to true.
[Obsolete("Your error message", true)]
public void MyMethod()
{
// Method body
}
Upvotes: 5