Skip to content

ValueTuple.IStructuralComparable/Equatable throws NRE instead of ArgumentNullException #19275

@hughbe

Description

@hughbe

The following tests demonstrates this.

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

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

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

Spun off from #19265

/cc @karelz (who can help triage this :) )

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions