Skip to content

Commit

Permalink
Nullability: verify ReferenceCount<object>(null) GetHashCode (#539)
Browse files Browse the repository at this point in the history
  • Loading branch information
bitfaster authored Dec 9, 2023
1 parent ef211dd commit 3e8504c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions BitFaster.Caching.UnitTests/ReferenceCountTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,15 @@ public void WhenObjectsAreDifferentHashcodesAreDifferent()

a.GetHashCode().Should().NotBe(b.GetHashCode());
}

[Fact]
public void WhenObjectIsNullGetHashCodeDoesntThrow()
{
var a = new ReferenceCount<object>(null);

// nullable static analysis suggests this is broken, but it is legal to call
// EqualityComparer<TValue>.Default.GetHashCode(null)
a.GetHashCode();
}
}
}

0 comments on commit 3e8504c

Please sign in to comment.