Skip to content

Fix Color equality for derived types - #36075

Closed
jfversluis wants to merge 1 commit into
mainfrom
jfversluis-fix-color-derived-equality
Closed

Fix Color equality for derived types#36075
jfversluis wants to merge 1 commit into
mainfrom
jfversluis-fix-color-derived-equality

Conversation

@jfversluis

Copy link
Copy Markdown
Member

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Fixes #36034.

This restores the pre-.NET 11 Preview 3 behavior where a Color subclass with the same ARGB value compares equal to a base Color instance. The regression was introduced by #33824 / commit 797df24 when Color was converted to a record class, which added record EqualityContract checks for derived types.

The fix keeps Color as a normal class, preserves the [ImmutableObject(true)] metadata intended by #33824, and aligns GetHashCode() with the existing byte-precision equality contract.

Added regression coverage for base-vs-derived Color equality in both directions, EqualityComparer<Color>.Default, and matching hash codes.

cc @AdamEssenmacher, could you review this since you reported the issue?

Keep Color as a class while preserving the immutability metadata, and align hash codes with byte-precision equality so derived Color values compare correctly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 36075

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 36075"

@github-actions github-actions Bot added the area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing label Jun 23, 2026
@jfversluis

Copy link
Copy Markdown
Member Author

Closing this because it was opened against main by mistake. The regression exists on net11.0; superseded by #36076.

@jfversluis jfversluis closed this Jun 23, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Color record conversion changes equality for derived Color types

1 participant