Skip to content

Tuple.IStructuralComparable/Equatable throws NRE #19265

@hughbe

Description

@hughbe

The following tests demonstrates this.

[Fact]
public void IStructuralEquatable_Equals_NullEqualityComparer_ThrowsNullReferenceException()
{
    IStructuralEquatable structuralEquatable = Tuple.Create(1);
    Assert.Throws<NullReferenceException>(() => structuralEquatable.Equals(Tuple.Create(1), null));
}

[Fact]
public void IStructuralEquatable_GetHashCode_NullEqualityComparer_ThrowsNullReferenceException()
{
    IStructuralEquatable structuralEquatable = Tuple.Create(1);
    Assert.Throws<NullReferenceException>(() => structuralEquatable.GetHashCode(null));
}

[Fact]
public void IStructuralComparable_CompareTo_NullEqualityComparer_ThrowsNullReferenceException()
{
    IStructuralComparable structuralComparable = Tuple.Create(1);
    Assert.Throws<NullReferenceException>(() => structuralComparable.CompareTo(Tuple.Create(1), null));
}

I can send in a PR fixing this to throw ArgumentNullException, but there might be breaking change so I'll let you guys approve it before I go wasting my time ;)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions