Skip to content

Champion: "Allow Obsolete attribute on getters and setters" (16.3, Core 3) #2152

Open
@gafter

Description

@gafter
  • Proposal added
    Discussed in LDM 2019-02-27
    Decision in LDM
    Finalized (done, rejected, inactive)
    Spec'ed

See dotnet/roslyn#32472
See dotnet/roslyn#32571

LDM history:

Activity

self-assigned this
on Jan 17, 2019
YairHalberstadt

YairHalberstadt commented on Jan 17, 2019

@YairHalberstadt
Contributor

It would have to be decided whether it would be an error to obsolete all the accessors in a property, as the property should be obsoleted instead.

I would suggest for consistency the design should follow that of VB which already allows the obsolete attribute on getters and setters.

VB allows all accessors ina property to be declared obsolete. It also allows usages of nameof on a property where all accessors have been declared obsolete.

This also avoids needing to special case the obsolete attribute, as any other attribute which is valid on both methods and properties can be applied to all accessors of a property at once.

scalablecory

scalablecory commented on Jan 26, 2019

@scalablecory

I found myself wishing for this just a few weeks ago, when trying to clean up some code that used a bunch of get/set properties to one that was a more read-only ctor-initialized record.

YairHalberstadt

YairHalberstadt commented on Mar 11, 2019

@YairHalberstadt
Contributor

https://github.com/dotnet/csharplang/blob/master/meetings/2019/LDM-2019-02-27.md

It looks like the LDC has supported this proposal.

A prototype exists at dotnet/roslyn#32571

YairHalberstadt

YairHalberstadt commented on Mar 13, 2019

@YairHalberstadt
Contributor

I think that obsolete should be disallowed on event accessors since it is meaningless to make add but not remove (or the other way round) obsolete.

added this to the 8.0 candidate milestone on Mar 13, 2019
jcouv

jcouv commented on Apr 2, 2019

@jcouv
Member

Merged the feature for dev16.1 preview2 (dotnet/roslyn#32571). Thanks @YairHalberstadt!

changed the title [-]Champion: "Allow Obsolete attribute on getters and setters"[/-] [+]Champion: "Allow Obsolete attribute on getters and setters" (16.3, Core 3)[/+] on Jul 18, 2019
added
Implemented Needs ECMA SpecThis feature has been implemented in C#, but still needs to be merged into the ECMA specification
on Oct 16, 2020
assigned and unassigned on Aug 30, 2021
locked and limited conversation to collaborators on Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Implemented Needs ECMA SpecThis feature has been implemented in C#, but still needs to be merged into the ECMA specificationProposal champion

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @333fred@gafter@scalablecory@jcouv@YairHalberstadt

      Issue actions

        Champion: "Allow Obsolete attribute on getters and setters" (16.3, Core 3) · Issue #2152 · dotnet/csharplang