Skip to content

Obsolete constructor doesn't produce warning when used to satisfy a constructor constraint #19430

@alrz

Description

@alrz

Version Used: current

Steps to Reproduce:

public class C {
    [Obsolete]
    public C() {}
    public void M<T>() where T : new() => M<C>();
}

Expected Behavior: warning: C() is obsolete

Actual Behavior: no warnings

EDIT: As @sharwell pointed out, warnings for obsolete members are not reported when the use is itself enclosed in a construct which is marked obsolete. so the following should be compiled without any warnings.

class C<T> where T : new() {
  [Obsolete]
  public C() => new C<C<T>>();
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions