J2N
J2N copied to clipboard
Structural Equality: Treat ImmutableArray<T> the same as Array
Since ImmutableArray<T>
is yet another array implementation of IStructuralEquatable
that could be compared against Array
, it must be treated like an Array
, not compared using IStructuralEquatable
.
There are several places in the codebase where we do this:
-
CollectionUtil
- https://github.com/NightOwl888/J2N/blob/b7f80ca424af2b077b5d42beff4d9fbad8b05ef5/src/J2N/Collections/ArrayEqualityUtil.cs#L114
- https://github.com/NightOwl888/J2N/blob/b7f80ca424af2b077b5d42beff4d9fbad8b05ef5/src/J2N/Collections/ArrayEqualityUtil.cs#L259
-
StructuralEqualityComparer
- https://github.com/NightOwl888/J2N/blob/b7f80ca424af2b077b5d42beff4d9fbad8b05ef5/src/J2N/Collections/StructuralEqualityComparer.cs#L83
- https://github.com/NightOwl888/J2N/blob/b7f80ca424af2b077b5d42beff4d9fbad8b05ef5/src/J2N/Collections/StructuralEqualityComparer.cs#L133
- https://github.com/NightOwl888/J2N/blob/b7f80ca424af2b077b5d42beff4d9fbad8b05ef5/src/J2N/Collections/StructuralEqualityComparer.cs#L177
- https://github.com/NightOwl888/J2N/blob/b7f80ca424af2b077b5d42beff4d9fbad8b05ef5/src/J2N/Collections/StructuralEqualityComparer.cs#L208
Unfortunately, we have some challenges to deal with, since if we don't know the generic closing type of ImmutableArray<T>
, we will need to do some work to materialize it before we can compare it.