-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Implement auto-generated Equals for records #41401
Conversation
df3e969
to
43dd43c
Compare
Generates a strongly-typed Equals method and an override of the object.Equals method.
src/Compilers/CSharp/Portable/Compiler/EqualityMethodBodySynthesizer.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Compiler/EqualityMethodBodySynthesizer.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordEquals.cs
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordEquals.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordObjEquals.cs
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordObjEquals.cs
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordEquals.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordGetHashCode.cs
Outdated
Show resolved
Hide resolved
Wrong license. #Resolved Refers to: src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedRecordPropertySymbol.cs:1 in 32b4b4e. [](commit_id = 32b4b4e, deletion_comment = False) |
Wrong license. #Resolved Refers to: src/Compilers/CSharp/Test/Semantic/Semantics/RecordTests.cs:1 in 32b4b4e. [](commit_id = 32b4b4e, deletion_comment = False) |
Done reviewing Iteration 1. |
@gafter I think I've addressed your comments. |
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.
@333fred Can you take a look when you get a chance? |
@dotnet/roslyn-compiler Please review |
src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Source/SourceOrRecordPropertySymbol.cs
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordGetHashCode.cs
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordEquals.cs
Show resolved
Hide resolved
{ | ||
var F = new SyntheticBoundNodeFactory(this, ContainingType.GetNonNullSyntaxNode(), compilationState, diagnostics); | ||
|
||
// return this.Equals(param as ContainingType); |
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.
Should we add a quick reference equality check to avoid the possibly-unnecessary cast?
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.
Right now I'm not concerned with the performance of the implementation. That's something I'll look at later.
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.
Can we add a prototype comment to track then?
src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordEquals.cs
Show resolved
Hide resolved
Done review pass (commit 4) |
@333fred Anything else? |
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.
Would like to see a PROTOTYPE around the equality perf part, but otherwise LGTM (commit 6)
@333fred It's no worse than what we're doing for anonymous types, so it's not exactly bad. |
Generates a strongly-typed Equals method and an override of the
object.Equals method.
Relates to #40726 (test plan for records)