whortleberrybearer / AutoEquality

Simple library to help generate IEqualityComparer<T> instances.
MIT License
1 stars 0 forks source link

Comparing enumerables #18

Open whortleberrybearer opened 6 years ago

whortleberrybearer commented 6 years ago

When using an enumerable as the type when creating an equality comparer, the result is true, even if the collections provided are not equal.

whortleberrybearer commented 6 years ago

There is possibly quite a bit to this and handling all types of enumerable. The false value of true is being returned as there are no properties on an enumerable to match, and it does not evaluate the items contained within. Even for lists, it does have some properties to match on, but still does not consider the contained items.

As enumerable properties contained within a class are compared for types and order, I think the same should happen when the enumerable is the outer type (with optional any order). WithComparer method would still be used to compare the containing types (for an object / derived list, the comparer specific to the type would be used).

There is already a SequenceEqual method on enumerables, that does take an EqualityComparer parameter.