Skip to content
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

Tweaks to ValueComparer nullability #24410

Merged
merged 4 commits into from
Aug 20, 2021
Merged

Conversation

roji
Copy link
Member

@roji roji commented Mar 16, 2021

Some of this came up during annotating EFCore.PG.

The main thing is that generic Snapshot shouldn't accept/return T?, but rather T (just like GetHashCode).

@roji roji requested a review from smitpatel March 16, 2021 09:48
@roji roji force-pushed the ValueComparerNullability branch 2 times, most recently from a29ced6 to ecc3222 Compare March 16, 2021 12:31
@roji roji marked this pull request as draft March 17, 2021 09:44
* Make Snapshot accept/receive non-nullable (nulls are sanitized
  externally).
* Make ValueComparer<T>.GetHashCode accept non-nullable object.
@roji roji changed the base branch from main to release/6.0 August 19, 2021 17:01
@roji roji marked this pull request as ready for review August 19, 2021 17:02
@roji roji requested a review from a team August 19, 2021 17:02
@AndriySvyryd
Copy link
Member

Consider merging this to rc1 since it impacts public API

public override int GetHashCode(object? instance)
=> instance == null ? 0 : GetHashCode((T)instance);
public override int GetHashCode(object instance)
=> instance is null ? 0 : GetHashCode((T)instance);
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that I'm leaving a runtime nullability check despite the annotation change, for better backwards compatibility.

@roji roji merged commit 8ee0305 into release/6.0 Aug 20, 2021
@roji roji deleted the ValueComparerNullability branch August 20, 2021 17:36
roji added a commit that referenced this pull request Aug 20, 2021
* Make Snapshot accept/receive non-nullable (nulls are sanitized
  externally).
* Make ValueComparer<T>.GetHashCode accept non-nullable object.
roji added a commit that referenced this pull request Aug 20, 2021
* Make Snapshot accept/receive non-nullable (nulls are sanitized
  externally).
* Make ValueComparer<T>.GetHashCode accept non-nullable object.
roji added a commit that referenced this pull request Aug 20, 2021
* Make Snapshot accept/receive non-nullable (nulls are sanitized
  externally).
* Make ValueComparer<T>.GetHashCode accept non-nullable object.
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants