Skip to content

Commit 3e8504c

Browse files
authored
Nullability: verify ReferenceCount<object>(null) GetHashCode (#539)
1 parent ef211dd commit 3e8504c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

BitFaster.Caching.UnitTests/ReferenceCountTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,15 @@ public void WhenObjectsAreDifferentHashcodesAreDifferent()
5858

5959
a.GetHashCode().Should().NotBe(b.GetHashCode());
6060
}
61+
62+
[Fact]
63+
public void WhenObjectIsNullGetHashCodeDoesntThrow()
64+
{
65+
var a = new ReferenceCount<object>(null);
66+
67+
// nullable static analysis suggests this is broken, but it is legal to call
68+
// EqualityComparer<TValue>.Default.GetHashCode(null)
69+
a.GetHashCode();
70+
}
6171
}
6272
}

0 commit comments

Comments
 (0)