Skip to content

Conversation

@BillWagner
Copy link
Member

@BillWagner BillWagner commented Nov 6, 2025

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".

RexJaeschke and others added 2 commits November 6, 2025 13:40
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.
> <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>
Copy link
Contributor

@RexJaeschke RexJaeschke Nov 7, 2025

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?

I made these tweaks after comparing the edits I researched 2+ years ago and what I found in this new feature branch.
@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
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