csharplang icon indicating copy to clipboard operation
csharplang copied to clipboard

[Proposal]: Show obsolete errors from overrides

Open 333fred opened this issue 11 months ago • 0 comments

Show obsolete errors from overrides

  • Specification: None yet.
  • Discussion: https://github.com/dotnet/csharplang/discussions/8937

Summary

Today, when an override of a virtual member adds Obsolete, we do not warn that the method is obsoleted when the derived type is statically known as the receiver. For example:

abstract class Base
{
    public abstract void M();
}

class Derived : Base
{
    [Obsolete]
    public override void M() => throw null;

    public void M2()
    {
        M(); // No warning
    }
}

This is something that we can detect at warn about.

Design meetings

333fred avatar Dec 26 '24 23:12 333fred