dotnet / dotnet/csharpstandard

Address "invisible" use of obsolete fields for auto-properties and field-like events

Open
#693 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
815
Forks
99
Avg merge
1d 14h
Merged PRs (30d)
16

Description

From [attributes.md](https://github.com/dotnet/csharpstandard/blob/draft-v7/standard/attributes.md#2154-the-obsolete-attribute):

> If a program uses a type or member that is decorated with the Obsolete attribute, the compiler shall issue a warning or an error.

Now an automatically-implemented property or field-like event can use `[field:Obsolete]` to make the compiler-generated backing field obsolete. That field would then be used by:

- A property setter call for a read-only property in a constructor
- Any use of the event within the declaring class

(The latter of these is actually only specified in a *note* in [14.8.2](https://github.com/dotnet/csharpstandard/blob/draft-v7/standard/classes.md#1482-field-like-events)) which should potentially be made normative at the same time.)

This issue was raised based on comments on #262.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.