Description
The default behavior for Equals() and GetHashCode() on types marked with InlineArrayAttribute is now to throw a NotSupportedException. The user is required to override those methods if these functions are expected to not throw.``
Version
.NET 9 Preview 6
Previous behavior
The previous default implementation will only use the placeholder ref field when computing equality or the hash code.
New behavior
A NotSupportedException will always be thrown from the default implementations for Equals() and GetHashCode() when InlineArrayAttribute is applied to a type.
Type of breaking change
Reason for change
The current behavior is not correct for either determining equality or hash code. Users are led into a false sense of correctness when calling these functions currently.
Recommended action
Users should implement both Equals() and GetHashCode() on all types marked with InlineArrayAttribute.
Feature area
Core .NET libraries
Affected APIs
System.ValueType.Equals(object) and System.ValueType.GetHashCode()
Associated WorkItem - 281894
Description
The default behavior for
Equals()andGetHashCode()on types marked withInlineArrayAttributeis now to throw aNotSupportedException. The user is required to override those methods if these functions are expected to not throw.``Version
.NET 9 Preview 6
Previous behavior
The previous default implementation will only use the placeholder
reffield when computing equality or the hash code.New behavior
A
NotSupportedExceptionwill always be thrown from the default implementations forEquals()andGetHashCode()whenInlineArrayAttributeis applied to a type.Type of breaking change
Reason for change
The current behavior is not correct for either determining equality or hash code. Users are led into a false sense of correctness when calling these functions currently.
Recommended action
Users should implement both
Equals()andGetHashCode()on all types marked withInlineArrayAttribute.Feature area
Core .NET libraries
Affected APIs
System.ValueType.Equals(object)andSystem.ValueType.GetHashCode()Associated WorkItem - 281894