While writing this method for a custom NUnit Constraint.
private void AddMatchFailure(string failureName, TExpected expected, TActu
Don't change the code - just ignore the warning. If the type parameter is a non-nullable value type, the comparison will always fail and it'll always call ToString()
instead. I don't know whether it's actually JITted away, but I wouldn't be surprised... and this doesn't sound like it's performance-critical code anyway :)
I'd personally leave the warning "on", but ignore it in this particular case - possibly with a comment.
I think I came across the same warning a few times when reimplementing LINQ to Objects.