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

Compare case for default(PartitionKey) #1312

Merged
merged 3 commits into from
Mar 27, 2020
Merged

Conversation

ealsur
Copy link
Member

@ealsur ealsur commented Mar 26, 2020

Pull Request Template

Description

PartitionKey is a struct. default(struct) initializes all referenced properties to their default values (ref https://docs.microsoft.com/dotnet/csharp/language-reference/language-specification/structs#class-and-struct-differences)

The default value of a struct is the value produced by setting all value type fields to their default value and all reference type fields to null (Default values).

Due to this behavior, comparisons using default(PartitionKey) were causing NullRefs.

This PR handles the case of default(PartitionKey) by assigning it the Null value for comparison purposes.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Closing issues

Closes #1307

@ealsur ealsur added the bug Something isn't working label Mar 26, 2020
@ealsur ealsur self-assigned this Mar 26, 2020
j82w
j82w previously approved these changes Mar 26, 2020
@ealsur ealsur dismissed stale reviews from j82w and FabianMeiswinkel via c552ed3 March 26, 2020 23:38
@ealsur ealsur merged commit 9afe9c4 into master Mar 27, 2020
@ealsur ealsur deleted the users/ealsur/pkequalnull branch March 27, 2020 17:48
@j82w j82w mentioned this pull request Mar 30, 2020
ealsur added a commit that referenced this pull request Apr 23, 2020
kirankumarkolli pushed a commit that referenced this pull request Apr 27, 2020
* Partitionkey add methods for comparison (#1265)

* Implements comparrision operators, methods

* Add test for partition key comparison

* changelog

* Refactor Equals Method

* Update SDKAPI

* Refactor tests

* Sort TypeTree by InvariantComparer

* Remove IComparable form PartitionKey

* Update DotNetSDKAPI.json

* undo

* Compare case for default(PartitionKey) (#1312)

* default case

* changelog

* tests

* contract

Co-authored-by: Kristián Jakubík <jakubikkristian@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PartitionKey.Equals throws NullReferenceException
3 participants