J2N icon indicating copy to clipboard operation
J2N copied to clipboard

Structural Equality: Treat ImmutableArray<T> the same as Array

Open NightOwl888 opened this issue 2 years ago • 0 comments

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.

NightOwl888 avatar Nov 02 '21 01:11 NightOwl888