.Equals(...) not working for double.NaN
MichaelMayrhofer opened this issue · comments
Hi,
I'm using version 1.7.1 with Visual Studio Professional 2017 version 15.2.
It seems [Equals] does not handle double.NaN correct. While double.NaN.Equals(double.NaN)
returns true
[Equals] returns false
.
I wrote the sample code above.
value = double.NaN
=> equalsD: true, equalsC: false
value = 0d
=> equalsD: true, equalsC: true
namespace Fody.EqualsTest
{
class Test
{
[Equals]
class DoubleContainer
{
public double Value { get; set; }
}
public void ShouldBeEqual()
{
const double value = double.NaN;
double d1 = value;
double d2 = value;
var equalsD = d1.Equals(d2);
Debug.Assert(equalsD);
DoubleContainer c1 = new DoubleContainer { Value = value };
DoubleContainer c2 = new DoubleContainer { Value = value };
var equalsC = c1.Equals(c2);
Debug.Assert(equalsC);
}
}
}