Attribute to hint ignore compare on float value using equality operator

The rule Compare of float numbers by equality operator warns for unintended comparison of values to a float variable value. However, we have many false positives since we need to compare them to constant values.

I suggest an attribute which can be set on the constant to ignore this rule.

public class Derp
{
    [EqualityOperatorCompareFriendly]
    public const float SpecialNullValue = 123.456;
}

Off course, we can use a resharper comment rule to disable this. However, this gets tedious and many false-positives demotivate devvers.

Please sign in to leave a comment.