Giving the following code:
private struct C : IComparable<float>
{
public C(float v) => this.V = v;
public float V { get; }
public int CompareTo(float other) => this.V.CompareTo(other);
}
public void TestMethod()
{
C x = new C(1.1f);
float y = 1.0f;
Assert.That(x.CompareTo(y), Is.GreaterThan(0));
Assert.That(x,Is.GreaterThan(y));
}
The last test fails because NunitComparer.Compare checks y is IComparable before checking for xType.CompareTo(yType) and hence calls the Single.CompareTo(Object) method instead of C.CompareTo(float) method.
Can I switch the order such that the two tests on IComparable are last thereby preferencing IComparable<T> over IComparable?
I you think there are no unforeseen issues, I will raise a PR.
Giving the following code:
The last test fails because
NunitComparer.Comparechecksy is IComparablebefore checking forxType.CompareTo(yType)and hence calls theSingle.CompareTo(Object)method instead ofC.CompareTo(float)method.Can I switch the order such that the two tests on
IComparableare last thereby preferencingIComparable<T>overIComparable?I you think there are no unforeseen issues, I will raise a PR.