Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Default
The default behavior for Equals(Object) and GetHashCode() on types marked with InlineArrayAttribute is now to throw a NotSupportedException. Library authors should override these two methods if they're expected to not throw.
Previous behavior
Previously, the default implementations only used the placeholder ref
field when computing equality or the hash code.
New behavior
Starting in .NET 9, a NotSupportedException is always thrown from the default implementations for Equals(Object) and GetHashCode() when InlineArrayAttribute is applied to a type.
Version introduced
.NET 9 Preview 6
Type of breaking change
This change is a behavioral change.
Reason for change
The current behavior is incorrect for both determining equality and computing the hash code, and users are led into a false sense of correctness when calling these functions.
Recommended action
Library authors should implement both Equals(Object) and GetHashCode() on all types marked with InlineArrayAttribute.