question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PartitionKey.Equals throws NullReferenceException

See original GitHub issue

Describe the bug PartitionKey.Equals throws NullReferenceException for default(PartitionKey).

To Reproduce var b = default(PartitionKey).Equals(default(PartitionKey))

Alternatively, use NSubstitute for unit testing and set up a return value for CreateItemAsync with Arg.Any<PartitionKey>() for the PartitionKey condition.

Expected behavior Should not throw a NullReferenceException.

default(PartitionKey).Equals() should correctly evaluate against the parameter without throwing an exception.

Actual behavior Throws NullReferenceException

Environment summary SDK Version: NETStandard.Library 2.0.3 OS Version (e.g. Windows, Linux, MacOSX): Windows 10 Pro

Additional context I recently updated to Microsoft.Azure.Cosmos 3.7.0 and this has broken a number of my unit tests, as it fails during test setup.

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
GrimGadgetcommented, Mar 26, 2020

OK, sorry. I picked the wrong dot in my assumption.

I looked at the PR referenced, and it doesn’t actually address this specific problem, other than some discussion and an apparent dismissal.

Also, the unit tests in that PR should probably add some checks where the left-side operand is default(PartitionKey), PartitionKey.None, and PartitionKey.Null for completeness.

0reactions
GrimGadgetcommented, Mar 26, 2020

Edited the original post to correct the assumption as to root cause.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Equals method throws NullReferenceException
I recently came about this problem. I have a base Stamp class. Then I made two inherited classes OwnedStamp and AuctionStamp .
Read more >
Troubleshoot issues with the Azure Functions trigger for ...
Your Azure function fails to start, with error message "The lease collection, if partitioned, must have partition key equal to id".
Read more >
com.amazonaws.services.kinesis.model. ...
@return Returns a reference to this object so that method calls can be chained together. */ public PutRecordRequest withPartitionKey(String partitionKey) ...
Read more >
21 DynamoDB .NET / C# Query Code Examples
This cheat sheet covers the most important C# query examples that you can copy-paste-tweak for your next DynamoDB .NET project.
Read more >
Querying azure table storage for null values
The problem is that because azure table storage does not have a schema, the null column actually doesn't exist. This is why your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found