- Notifications
You must be signed in to change notification settings - Fork 5.3k
Open
Labels
Milestone
Description
Description
Array implements IStructuralEquatable, but its Equals implementation throws if a multi-dimensional array is passed.
Reproduction Steps
var arr1 = new int[2,2]; var arr2 = new int[2,2]; Console.WriteLine(typeof(IStructuralEquatable).IsAssignableFrom(arr1.GetType())); // True Console.WriteLine(StructuralComparisons.StructuralEqualityComparer.Equals(arr1, arr2)); // throwsExpected behavior
The method is expected to return true or false.
Actual behavior
Exception:
Unhandled exception. System.ArgumentException: Array was not a one-dimensional array. at System.Array.GetValue(Int32 index) at System.Array.System.Collections.IStructuralEquatable.Equals(Object other, IEqualityComparer comparer) at System.Collections.StructuralEqualityComparer.Equals(Object x, Object y) at Program.<Main>$(String[] args) in /home/roji/projects/test/Program.cs:line 20 Regression?
No response
Known Workarounds
One can avoid using IStructuralEquatable or StructuralComparisons.StructuralEqualityComparer specifically for multidimensional arrays.
Configuration
.NET 6, Ubuntu impish, x64.
Other information
No response
timcassell