Open DanAvni opened 6 months ago
Hey @DanAvni 👋
Thanks for the bug report, that does seem against expectations (see below).
It’s been a while since the last activity on this library - myself, I’ve been over in Go- and Python-land. If you have the bandwidth to prepare a PR, that’d go a long way towards getting the change in. ComparableArg.double.cs is a starting place.
I don’t have concerns over using a method call here instead of ==, since the result is incorrect today. We do want to avoid boxing/allocations on the happy path to decrease upgrade-cost to consumers (double.Equals
instead of casting to an IComparable as mentioned below should do the job efficiently).
If that’s not possible at this time, you could use the Extension Method support to locally add…
static double IsNotNaN(this Param<double> src)
double
typehint is lost in EnsureThat, and IComparable<double>
is kept instead, the result is true
(The IComparable method uses CompareTo, the double override-method uses ==)
Please add support for checking if a double or float has or does not have a value of NaN. checking that a double or float has a value like this
Ensure.That(x).IsNot(double.NaN)
does not work. see https://learn.microsoft.com/en-us/dotnet/api/system.double.nan?view=net-8.0