rspec/rules/S2214/csharp/rule.adoc

41 lines
740 B
Plaintext
Raw Normal View History

2020-06-30 12:48:07 +02:00
Obsoleted method should be avoided, rather than overridden. Obsolescence is a warning that the method has been superseded, and will eventually be removed. The obsolescence period allows you to make a smooth transition away from the aging, soon-to-be-retired technology.
== Noncompliant Code Example
----
public class Car
{
[Obsolete("Replaced by the automatic starter")]
public void CrankEngine(int turnsOfCrank)
{ ... }
}
public class R2 : Car
{
public void CrankEngine(int turnsOfCrank) // Noncompliant
{ ... }
...
}
----
== Compliant Solution
----
public class Car
{
[Obsolete("Replaced by the automatic starter")]
public void CrankEngine(int turnsOfCrank)
{ ... }
}
public class R2 : Car
{
...
}
----