-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
CSHARP-3315: Implement Equals for serializers. #1281
base: master
Are you sure you want to change the base?
Conversation
Not ready for review yet. The new commits are just to back up work in progress in case something happens to my laptop. |
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.
Partial review. About ~50% of the tests remain to be reviewed.
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Shared\" /> |
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.
I think this folder include is not needed.
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.
Not sure how it got here. Don't think I edited this file manually.
object.Equals(_memberInfo, other._memberInfo) && | ||
_order.Equals(other._order) && | ||
object.Equals(_serializer, other._serializer) && | ||
object.Equals(_shouldSerializeMethod, other._shouldSerializeMethod); |
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.
Do we need to compare _idGenerator
?
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.
I think so. Looks like I missed it.
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Include="..\..\THIRD-PARTY-NOTICES" Pack="true" PackagePath="\" /> | ||
<Folder Include="Shared\" /> |
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.
Same question as in Bson project.
|
||
var result = x.Equals(y); | ||
|
||
result.Should().Be(notEqualFieldName == null ? true : false); |
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.
notEqualFieldName
can't be null?
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.
I will remove the null check. It's left over from some intermediate experiments.
|
||
private BsonClassMap Clone(BsonClassMap classMap) | ||
{ | ||
var clone = (BsonClassMap)FormatterServices.GetUninitializedObject(classMap.GetType()); |
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.
Do we have to use the Reflector here?
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.
I think we do because there is no easy way to change just ONE field at a time to test Equals
, but we can do it easily using reflection.
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.
I have avoided using reflection wherever possible.
[Fact] | ||
public void Equals_with_equal_fields_should_return_true() | ||
{ | ||
var x = (StandardDiscriminatorConvention)new ConcreteStandardDiscriminatorConvention("_t"); |
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.
minor: is this cast needed?
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.
Depends how you define "needed".
I wanted the compile time type of x
to be the abstract
base class, not the concrete
type.
No description provided.