Equality implementation
I thought we agreed to use direct operator equality/valuetuple equality. That might come later.
Originally posted by @amis92 in https://github.com/amis92/RecordGenerator/pull/56
There are a couple of areas where we can certainly improve. Let's list them and discuss them.
Found a problem as well, GeneratedCodeAttribute isn't applied on generated operator overloads (==/!=)
edit: moved to #77
operator == should defer to direct left.Equals(right) call instead of using EqualityComparer.
This could be an optimization when we know we implement ObjectEquals and/or EquatableEquals. If not, we could probably check if the input class already implements either and if so, use that as well.
Prioritization of calls should be:
-
IEquatable<T>.Equals(T)if interface is implemented (by us or not) -
object.Equals(object)if overridden -
EqualityComparer<T>.Equals(T, T)as a fallback