Skip to content

[Version 9.0] Feature support for init accessors#1452

Draft
BillWagner wants to merge 5 commits into
draft-v9from
v9-init-accessors
Draft

[Version 9.0] Feature support for init accessors#1452
BillWagner wants to merge 5 commits into
draft-v9from
v9-init-accessors

Conversation

@BillWagner

@BillWagner BillWagner commented Nov 6, 2025

Copy link
Copy Markdown
Member

This PR contains the work for init accessors in C# 9.

The commits from #978 were squashed to one commit in this branch.

There are a number of comments that haven't been addressed on #978:

Notes:

  • The ANTLR grammar validation fails for one test where the validation is designed to fail – it is testing that right shift is not erroneously recognised – and the checker passes the test if the error message is what it expected. Antlr writes a long informative error message listing all the tokens it might have expected to find at the failing point of the code and that list now has init in it.
  • The renumbering action fails because this feature depends on the grammar in "records".

Comment thread standard/basic-concepts.md Outdated
Comment thread standard/attributes.md Outdated
Comment thread standard/attributes.md Outdated
Comment thread standard/expressions.md
> <td rowspan="6">Property access</td>
> <td><code>P</code></td>
> <td>The get accessor of the property <code>P</code> in the containing class or struct is invoked. A compile-time error occurs if <code>P</code> is write-only. If <code>P</code> is not <code>static</code>, the instance expression is <code>this</code>.</td>
> <td>The get accessor of the property <code>P</code> in the containing class or struct is invoked. A compile-time error occurs if <code>P</code> is write-only or init-only. If <code>P</code> is not <code>static</code>, the instance expression is <code>this</code>.</td>

@RexJaeschke RexJaeschke Nov 7, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should "containing class or struct" be extended to include interface? Here and a few other table rows below?

Comment thread standard/classes.md Outdated
Comment thread standard/classes.md Outdated
@RexJaeschke RexJaeschke added the Review: pending Proposal is available for review label Nov 7, 2025
@RexJaeschke RexJaeschke added this to the C# 9.0 milestone Nov 7, 2025
@BillWagner BillWagner changed the title Feature support for init accessors [Version 9.0] Feature support for init accessors Nov 7, 2025
@RexJaeschke RexJaeschke added the type: feature This issue describes a new feature label Nov 11, 2025
@jskeet jskeet self-assigned this Nov 27, 2025
@BillWagner BillWagner force-pushed the v9-init-accessors branch from 1dd0bbe to 0a30078 Compare May 12, 2026 19:27
RexJaeschke and others added 5 commits June 24, 2026 14:14
Add support for init accessors

Add support for init accessors

Add support for init accessors

Add support for init accessors

Add support for init accessors

Add support for init accessors

Add support for init accessors

fix md formatting

fix formatting, add xref links

add xref links
Use different reasonable placeholders.
I made these tweaks after comparing the edits I researched 2+ years ago and what I found in this new feature branch.
@BillWagner

Copy link
Copy Markdown
Member Author

An earlier version of this feature is already present on alpha-v9 from a prior meeting. Edits made to this PR since then are not yet on alpha-v9; they will land at the next propagation. If you need them on alpha-v9 sooner, please open a separate PR targeting alpha-v9.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review: pending Proposal is available for review type: feature This issue describes a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants