Skip to content

Record types can seal ToString in C# 10. #24957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 6, 2021

Conversation

BillWagner
Copy link
Member

Fixes #24077

Beginning in C# 10.0, records may declare a ToString method as sealed. This prevents derived records from creating an override. Effectively, that means the ToString output will not include the runtime type information. (All members and values are displayed, because derived records will still have a PrintMembers method generated.)

Fixes dotnet#24077

Beginning in C# 10.0, records may declare a `ToString` method as `sealed`. This prevents derived records from creating an override. Effectively, that means the `ToString` output will not include the runtime type information. (All members and values are displayed, because derived records will still have a PrintMembers method generated.)
This was introduced in an earlier PR
Copy link
Contributor

@tdykstra tdykstra left a comment

Choose a reason for hiding this comment

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

LGTM, a couple of minor suggestions.

@BillWagner BillWagner merged commit c889d4b into dotnet:main Jul 6, 2021
@BillWagner BillWagner deleted the record-sealed-tostring branch July 6, 2021 18:21
@BillWagner BillWagner added the okr-freshness OKR: Freshness of content label Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Record types can seal ToString
4 participants