Add null-safe comparisons in model Equals methods
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 85
- Forks
- 18
- Avg merge
- 23h 28m
- Merged PRs (30d)
- 3
Description
Description
Several model classes in the SDK contain Equals methods that may throw NullReferenceException when comparing nullable properties. The current pattern uses:
this.Property == input.Property || this.Property.Equals(input.Property)
This will throw if this.Property is null and input.Property is non-null.
Affected Classes
Known affected models:
WriteRequestWrites(OnDuplicate property)WriteRequestDeletes(OnMissing property)
All other model classes with nullable properties should be audited for similar issues.
Proposed Fix
Replace unsafe comparisons with null-safe alternatives:
object.Equals(this.Property, input.Property)
Or:
this.Property == input.Property || (this.Property \!= null && this.Property.Equals(input.Property))
Context
Identified during review of PR #120.
Referenced by: @rhamzeh
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect the Equals methods in WriteRequestWrites and WriteRequestDeletes first, focusing on OnDuplicate and OnMissing, then audit other model classes for the same nullable-property pattern. Confirm that comparisons where either property is null no longer throw a NullReferenceException and that existing equality behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- authorization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100