Skip to content

Conversation

@Turnerj
Copy link
Collaborator

@Turnerj Turnerj commented Dec 18, 2019

There was a subtle bug in the equality checking of the Values structs that didn't properly handle mixed types. While Values2 did properly handle mixed types, it didn't properly handle only one of the types having data.

After a bit of studying the code, it really can be simplified down to comparing the internal OneOrMany. I do add one additional check prior to that as a shortcut for empty data.

Values2 passes, Values3 and Values4 fail all but the first generic argument equality.
This is invalid as it never would actually deserialize to two types at once - the previous equality logic had this test erroneously passing.
@Turnerj
Copy link
Collaborator Author

Turnerj commented Dec 18, 2019

The test I've removed in cd68610 was flawed - the original ValuesJsonConverter never had a value deserializing into multiple types at once. The reason the test was passing up until now is that it played on a flaw in the equality method of the Values struct.

While I could have changed the expected data to only include a URI value (as that was the type of data that was deserialized), it would no longer fit with the spirit of the other tests in that file. It wouldn't really be any more of a test than the tests added specifically for ValuesJsonConverter or now for the various Values structs themselves.

@RehanSaeed RehanSaeed merged commit d9e5c98 into RehanSaeed:master Dec 18, 2019
@RehanSaeed
Copy link
Owner

Thank you.

@Turnerj Turnerj deleted the values-struct-equality-bug branch December 18, 2019 10:09
@RehanSaeed RehanSaeed added the enhancement Issues describing an enhancement or pull requests adding an enhancement. label Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Issues describing an enhancement or pull requests adding an enhancement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants