[Version 10.0] Feature support for record with sealed ToString#1550
Draft
RexJaeschke wants to merge 2 commits into
Draft
[Version 10.0] Feature support for record with sealed ToString#1550RexJaeschke wants to merge 2 commits into
RexJaeschke wants to merge 2 commits into
Conversation
RexJaeschke
marked this pull request as draft
January 24, 2026 16:14
Contributor
|
The proposal exists as dotnet/csharplang#4174. I would be happy to review this, as the original author. |
jnm2
approved these changes
Jan 26, 2026
| ``` | ||
|
|
||
| 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). |
Contributor
There was a problem hiding this comment.
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). |
| 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`. |
BillWagner
force-pushed
the
v10-record-with-sealed-ToString
branch
from
March 24, 2026 19:32
6d786ac to
8befc03
Compare
BillWagner
force-pushed
the
v10-record-with-sealed-ToString
branch
from
April 14, 2026 21:28
8befc03 to
9ffa65f
Compare
BillWagner
force-pushed
the
v10-record-with-sealed-ToString
branch
from
May 13, 2026 14:45
9ffa65f to
df28094
Compare
Remove unnecessary blank lines from classes.md
BillWagner
force-pushed
the
v10-record-with-sealed-ToString
branch
from
June 24, 2026 18:58
df28094 to
e8f79d1
Compare
Member
|
An earlier version of this feature is already present on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.