Making ValueObject.GetEqualityComponents return IComparable is a breaking change
robertlarkins opened this issue · comments
Previously GetEqualityComponents()
returned IEnumerable<object>
. Now it returns IEnumerable<IComparable>
. If the ValueObject holds an Entity and it is used as an Equality Component it causes a compile time error if the Entity doesn't implement IComparable.
What is the appropriate fix here? Every type that ValueObject uses as an Equality Component must now implement IComparable? Could this extend to the CSharpFunctionalExtensions Entity type so entities have it is available out-of-the-box?
What is the appropriate fix here? Every type that ValueObject uses as an Equality Component must now implement IComparable?
Yes, unfortunately, that's the only way. Otherwise, the comparisons can be inconsistent.
Could this extend to the CSharpFunctionalExtensions Entity type so entities have it is available out-of-the-box?
You mean make Entity
implement IComparable?
You mean make Entity implement IComparable?
Yes, then an Entity
could be used in a ValueObject
as an equality component without needing to explicitly implement IComparable
on the derived entity type. Id
would be the property used for the comparison.
Or is there issues I'm not seeing with Entity
implementing ICompariable
?
Yes, that's a good idea. No particular reason why it's not done yet. Appreciate if you could submit a PR.
PR #510 submitted for getting Entity to implement IComparable.
Thank you. I'll double check everything this weekend and release a new minor version then.