vkhorikov / CSharpFunctionalExtensions

Functional extensions for C#
MIT License
2.39k stars 301 forks source link

Is there a reason why ValueObject doesn't implement IEquatable<ValueObject> ? #287

Open gagnedavid25 opened 3 years ago

gagnedavid25 commented 3 years ago

The microsoft IEquatable<T> docs stated:

If you implement IEquatable<T>, you should also implement IComparable<T> if instances of your type can be ordered or sorted. If your type implements IComparable<T>, you almost always also implement IEquatable<T>.

vkhorikov commented 3 years ago

IEquatable was introduced to improve performance by avoiding boxing/unboxing of value types. Since ValueObject is a class and not a struct, there is no need for the the additional interface implementation. I'm not opposed to adding this, though, just for the completeness sake.

gagnedavid25 commented 3 years ago

Thanks for the answer!