Unfixed R# CodeGen bug might introduce subtle bugs in your code
Many of us use a nice code generation ability of Resharper to quickly implement IEquality<T> interface. Wonderful as it is, there is a very subtle bug R# creates in the generated code whenever it deals with double and float types.
The problem is due to the fact that double.NaN != double.NaN, while double.NaN.Equals(double.NaN) is true.
When R# generates bool Equals(T other), it makes the code "pretier" by replacing all _x.Equals(other._x) with _x == other._x. Even though this looks much easier to read, it WILL FAIL when _x is double, float, or any other user-defined type that may handle NaNs explicitly.
In short - any time you use your custom object with a double/float field as a key in a dictionary, and you set the field to NaN, dictionary will never find it!
The bug is critical because users generate code just once, and will NOT review it later after R# gets fixed!
The bug was filed as RSRP-104969 a long time ago, but still no fix
Please sign in to leave a comment.
Yuri Astrakhan wrote:
#1 for that, i found this too, and was suprised when finding the error!
--
R# team has changed the priority to critical, yet still no fix