-
Notifications
You must be signed in to change notification settings - Fork 6k
Improve C# value equality documentation with enhanced content and structured code examples #48073
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
Conversation
… and records with collections Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot this is a good start, but there's a lot to fix and clarify.
...rogramming-guide/statements-expressions-operators/how-to-define-value-equality-for-a-type.md
Outdated
Show resolved
Hide resolved
...rogramming-guide/statements-expressions-operators/how-to-define-value-equality-for-a-type.md
Outdated
Show resolved
Hide resolved
...rogramming-guide/statements-expressions-operators/how-to-define-value-equality-for-a-type.md
Outdated
Show resolved
Hide resolved
...rogramming-guide/statements-expressions-operators/how-to-define-value-equality-for-a-type.md
Outdated
Show resolved
Hide resolved
...how-to-define-value-equality-for-a-type/RecordCollectionsIssue/RecordCollectionsIssue.csproj
Show resolved
Hide resolved
...to-define-value-equality-for-a-type/ValueEqualityPolymorphic/ValueEqualityPolymorphic.csproj
Show resolved
Hide resolved
…arify polymorphic equality Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closer, but still a lot to do.
...how-to-define-value-equality-for-a-type/RecordCollectionsIssue/RecordCollectionsIssue.csproj
Show resolved
Hide resolved
...to-define-value-equality-for-a-type/ValueEqualityPolymorphic/ValueEqualityPolymorphic.csproj
Show resolved
Hide resolved
...rogramming-guide/statements-expressions-operators/how-to-define-value-equality-for-a-type.md
Outdated
Show resolved
Hide resolved
...rogramming-guide/statements-expressions-operators/how-to-define-value-equality-for-a-type.md
Outdated
Show resolved
Hide resolved
...rogramming-guide/statements-expressions-operators/how-to-define-value-equality-for-a-type.md
Outdated
Show resolved
Hide resolved
...operators/snippets/how-to-define-value-equality-for-a-type/RecordCollectionsIssue/Program.cs
Outdated
Show resolved
Hide resolved
...operators/snippets/how-to-define-value-equality-for-a-type/RecordCollectionsIssue/Program.cs
Outdated
Show resolved
Hide resolved
...operators/snippets/how-to-define-value-equality-for-a-type/RecordCollectionsIssue/Program.cs
Outdated
Show resolved
Hide resolved
...to-define-value-equality-for-a-type/ValueEqualityPolymorphic/ValueEqualityPolymorphic.csproj
Show resolved
Hide resolved
...how-to-define-value-equality-for-a-type/RecordCollectionsIssue/RecordCollectionsIssue.csproj
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot I have two more major comments to address.
...rogramming-guide/statements-expressions-operators/how-to-define-value-equality-for-a-type.md
Outdated
Show resolved
Hide resolved
...rogramming-guide/statements-expressions-operators/how-to-define-value-equality-for-a-type.md
Outdated
Show resolved
Hide resolved
… samples with snippet tags Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ready for final review.
(I think this article still needs some work, but let's leave that for another day)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved to unblock with some minor issues to fix.
...rogramming-guide/statements-expressions-operators/how-to-define-value-equality-for-a-type.md
Show resolved
Hide resolved
...rogramming-guide/statements-expressions-operators/how-to-define-value-equality-for-a-type.md
Outdated
Show resolved
Hide resolved
...rogramming-guide/statements-expressions-operators/how-to-define-value-equality-for-a-type.md
Outdated
Show resolved
Hide resolved
…readability Co-authored-by: adegeo <67293991+adegeo@users.noreply.github.com>
This PR significantly enhances the C# value equality documentation to address critical gaps and technical inaccuracies identified during review, while restructuring code examples for better readability.
Key Improvements
Enhanced Records Documentation
IEquatable<T>
using virtual methods that check runtime typesstring
Corrected Polymorphic Equality Explanation
Equals(object?)
override with runtime type checkingobject.Equals
is implemented, not the interface implementation patternRestructured Code Examples
id=
syntax to include specific sections: problem demonstration, solution examples, edge casesContent and Style Improvements
The documentation now correctly explains the nuances of value equality in inheritance scenarios and provides clear, digestible examples that demonstrate both problematic patterns and their solutions.
Fixes #45164.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Internal previews