Report unnamed TextStyle colours as fixed-width #AARRGGBB so they round trip [patch] - #168
Merged
Merged
Conversation
…y round trip [patch] The Foreground/Background getters returned Color.Name, which for an unnamed colour drops leading zeros. An alpha of 0x01-0x0F gave a seven-digit name the setter rejected, and an alpha of 0x00 gave six digits the setter read back as an opaque RRGGBB. Known colours keep their names; every other colour is now emitted as #AARRGGBB. Fixes #142 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NFZqEcFcZzrKRzQvofupG6
…ternary [patch] Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NFZqEcFcZzrKRzQvofupG6
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #142
What was wrong
TextStyle.Foreground/BackgroundreturnedColor.Name. For an unnamed colour that isConvert.ToString(argb, 16), which drops leading zeros:0x01–0x0Fgave a 7-digit name (a123456), which the setter rejects withArgumentException0x00gave 6 digits (123456), which the setter reads as opaqueRRGGBB, so the copy silently becameFF123456Color.FromArgb(0)gave"0", which also throwsChange
FormatColorhelper backs both getters: known colours keep their name, every other colour is emitted as fixed-width#AARRGGBB, whichTryParseHexColoralready accepts.TryParseHexColordoc now names the form the getters emit.Tests
UnnamedColorRoundTripsThroughTheStringPropertyis now data-driven over alpha0xFF,0x80,0x10,0x0F,0x0A,0x01,0x00,0x00000001and0, for both foreground and background.UnnamedColorReadsBackAsFixedWidthHexpins the#0A123456format.🤖 Generated with Claude Code
https://claude.ai/code/session_01NFZqEcFcZzrKRzQvofupG6
Generated by Claude Code