Skip to content

[Version 10.0] Feature support for record with sealed ToString - #1550

Draft
RexJaeschke wants to merge 2 commits into
draft-v10from
v10-record-with-sealed-ToString
Draft

[Version 10.0] Feature support for record with sealed ToString#1550
RexJaeschke wants to merge 2 commits into
draft-v10from
v10-record-with-sealed-ToString

Conversation

@RexJaeschke

Copy link
Copy Markdown
Contributor

There is no corresponding MS proposal.

This PR builds on V9's PR #1458, which as of this time has not been reviewed, and changes during its adoption may impact this PR.

@RexJaeschke RexJaeschke added this to the C# 10 milestone Jan 24, 2026
@RexJaeschke RexJaeschke added type: feature This issue describes a new feature Review: pending Proposal is available for review labels Jan 24, 2026
@RexJaeschke
RexJaeschke marked this pull request as draft January 24, 2026 16:14
@jnm2

jnm2 commented Jan 26, 2026

Copy link
Copy Markdown
Contributor

The proposal exists as dotnet/csharplang#4174. I would be happy to review this, as the original author.

@RexJaeschke
RexJaeschke requested a review from jnm2 January 26, 2026 17:40
Comment thread standard/classes.md
```

The method may be declared explicitly. It is an error if the explicit declaration does not match the expected signature or accessibility, or if the explicit declaration doesn't allow overriding it in a derived type and the record class type is not sealed. It is an error if either synthesized, or explicitly declared, method doesn't override `object.ToString()` (for example, due to shadowing in intermediate base types).
The method may be declared explicitly. It is an error if the explicit declaration does not match the expected signature or accessibility. It is an error if either synthesized, or explicitly declared, method doesn't override `object.ToString()` (for example, due to shadowing in intermediate base types).

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.

The removed statement is a consequence of the requirement that the member overrides object.ToString().

Suggested change
The method may be declared explicitly. It is an error if the explicit declaration does not match the expected signature or accessibility. It is an error if either synthesized, or explicitly declared, method doesn't override `object.ToString()` (for example, due to shadowing in intermediate base types).
The method may be declared explicitly. It is an error if either synthesized, or explicitly declared, method doesn't override `object.ToString()` (for example, due to shadowing in intermediate base types).

Comment thread standard/classes.md
The method may be declared explicitly. It is an error if the explicit declaration does not match the expected signature or accessibility, or if the explicit declaration doesn't allow overriding it in a derived type and the record class type is not sealed. It is an error if either synthesized, or explicitly declared, method doesn't override `object.ToString()` (for example, due to shadowing in intermediate base types).
The method may be declared explicitly. It is an error if the explicit declaration does not match the expected signature or accessibility. It is an error if either synthesized, or explicitly declared, method doesn't override `object.ToString()` (for example, due to shadowing in intermediate base types).

Sealing an explicitly declared `ToString` method prevents the compiler from synthesizing a `ToString` method for any derived record types. However, this does not prevent the compiler from synthesizing `PrintMembers`.

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 this be a note?

@BillWagner
BillWagner force-pushed the v10-record-with-sealed-ToString branch from 6d786ac to 8befc03 Compare March 24, 2026 19:32
@BillWagner
BillWagner force-pushed the v10-record-with-sealed-ToString branch from 8befc03 to 9ffa65f Compare April 14, 2026 21:28
@BillWagner
BillWagner force-pushed the v10-record-with-sealed-ToString branch from 9ffa65f to df28094 Compare May 13, 2026 14:45
RexJaeschke and others added 2 commits June 24, 2026 14:58
@BillWagner
BillWagner force-pushed the v10-record-with-sealed-ToString branch from df28094 to e8f79d1 Compare June 24, 2026 18:58
@BillWagner

Copy link
Copy Markdown
Member

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

BillWagner added a commit that referenced this pull request Jul 24, 2026
…monize to 'provided' per refreshed #1458, keep Sealing paragraph
BillWagner added a commit that referenced this pull request Jul 24, 2026
Surgical wording-only propagation of the committee-approved #1458 records
refresh onto draft-v11's existing section structure (no heading/section
moves). Harmonizes #1550 to 'provided' while keeping the Sealing paragraph.
classes.md 'synthesized' prose reduced 40→~6 (kept: async entry-point,
positional/copy-constructor concepts, and the #1550 Sealing paragraph).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
BillWagner added a commit that referenced this pull request Jul 24, 2026
Surgical wording-only propagation onto v11-alpha's existing structure
(no heading/section moves). Harmonizes #1550 to 'provided', keeps the
Sealing paragraph. Matches refreshed draft-v11 records content.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
BillWagner added a commit that referenced this pull request Jul 24, 2026
Surgical wording-only propagation onto draft-v12's existing structure
(no heading/section moves). Harmonizes #1550 to 'provided', keeps the
Sealing paragraph. Completes the v9→v12 records refresh cascade.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@BillWagner

Copy link
Copy Markdown
Member

I attempted to rebase this PR onto the updated draft-v10 after the latest TC49-TG2 committee meeting but encountered conflicts that need author resolution. Please rebase locally onto draft-v10 and resolve them. 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