Repository navigation
Preserve Color.Empty when serializing - #1103
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Nullable empty colors lose their identity, and nullable-color array schemas reject valid null elements.
Review effort: Balanced
Findings: 1
Open (2)
What changed in this PR
Updates the built-in color converter to distinguish Color.Empty from transparent black, addressing #1102.
Changes:
- Encodes empty colors as nil while retaining ARGB integers for non-empty colors.
- Updates the schema and documentation.
- Adds round-trip tests for empty colors and transparent black.
| File | Description |
|---|---|
| test/Nerdbank.MessagePack.TUnit/BuiltInConverterTests.cs | Tests color identity and encoding. |
| src/Nerdbank.MessagePack/Converters/BclConverters.cs | Adds nil handling and updates the color schema. |
| docfx/docs/built-in-converters.md | Documents the nil-or-integer representation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Use a boolean marker for Color.Empty so nullable null remains nil, and cover nullable color schemas across dialects.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation preserves nullable semantics and integer compatibility, with targeted regression coverage and no blocking issues.
Review effort: Balanced
Findings: None
Resolved since last review (2)
Make nullable schema composition tolerate overlapping null branches and record the generated Color schemas for both dialects. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v1.4 #1103 +/- ##
==========================================
+ Coverage 82.80% 82.83% +0.02%
==========================================
Files 259 259
Lines 21296 21327 +31
Branches 2810 2814 +4
==========================================
+ Hits 17634 17666 +32
+ Misses 2762 2760 -2
- Partials 900 901 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|


Why
The built-in System.Drawing.Color converter loses Color.Empty identity because it only stores ARGB, causing the empty color to deserialize as transparent black.
What changed
Encode Color.Empty as the MessagePack boolean
falsewhile retaining ARGB integer encoding for non-empty colors. Deserialization acceptsfalseand existing integer payloads, and rejectstrue. The schema and docs describe the integer-or-falserepresentation. Tests cover both Color.Empty and transparent black.Validation
Closes #1102