Repository navigation
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 40260Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 40260" |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
The Android tests only count spans, leaving underline color, native thickness, flag clearing, and fallback behavior unverified.
1 open issue
What changed in this PR
Adds optional decoration colors to MAUI formatted-text spans, implementing #40259 while preserving text-colored decorations by default.
Changes:
- Adds
Span.TextDecorationColor, public API entries, and documentation of platform limits. - Supports colored underlines and strikethroughs on iOS/Mac Catalyst, and colored underlines on Android API 29+.
- Adds unit and device tests for defaults, change notifications, and native decoration mapping.
| File | Description |
|---|---|
src/Core/AndroidNative/maui/src/main/java/com/microsoft/maui/PlatformUnderlineColorSpan.java |
Draws colored Android underlines with an older-API fallback. |
src/Controls/tests/DeviceTests/Elements/FormattedStringTests.cs |
Tests native decoration mapping with and without a color. |
src/Controls/tests/Core.UnitTests/SpanTests.cs |
Tests the null default and formatted-text change notification. |
src/Controls/src/Core/Span.cs |
Defines the bindable property and documents platform support. |
src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt |
Records the new API for .NET Standard. |
src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt |
Records the new API for .NET. |
src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt |
Records the new API for Windows. |
src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt |
Records the new API for Mac Catalyst. |
src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt |
Records the new API for iOS. |
src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt |
Records the new API for Android. |
src/Controls/src/Core/Platform/iOS/Extensions/FormattedStringExtensions.cs |
Applies native underline and strikethrough color attributes. |
src/Controls/src/Core/Platform/Android/Extensions/FormattedStringExtensions.cs |
Selects the colored underline span when a color is specified. |
Review effort: Balanced
This comment has been minimized.
This comment has been minimized.
|
/rebase |
23ef3f5 to
e12535c
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
/rebase |
|
No pipelines are associated with this pull request. |
…lor) Span.TextDecorationColor draws a span's TextDecorations in a color other than the text color. Null (the default) keeps today's behavior. - iOS / Mac Catalyst: NSUnderlineColor / NSStrikethroughColor on the span's attributed string. - Android: PlatformUnderlineColorSpan (Java) sets TextPaint.underlineColor on API 29+ and falls back to a text-colored underline below that. Android has no public strikethrough color, so strikethrough stays in the text color. - Windows: not supported; decorations stay in the text color (documented). Fixes #40259 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Span.TextDecorationThickness sets the thickness of a span's decorations in device-independent units. Zero or less (default -1) keeps the font's own thickness. - Android API 29+: the underline span (renamed PlatformUnderlineSpan, as it now carries a color and / or a thickness) sets TextPaint.underlineThickness; without a decoration color the underline keeps the text color. Strikethrough has no public thickness API and is unchanged. - iOS / Mac Catalyst: UIKit only has styles, so underline and strikethrough use the nearer of NSUnderlineStyle.Single (about 1) and Thick (about 2). - Windows: not supported. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Exercise native paint and attributed-string output across decoration flags, color settings, and thickness boundaries. Keep Android custom underlines visible when the font reports a zero thickness metric. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Convert decoration thickness using display density without layout rounding and verify subpixel values against native metrics. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
/review expert-review-with-gate |
|
Warning Your |
There was a problem hiding this comment.
Expert Review — 0 findings
Reviewed commit c83329a.
c83329a to
3fd956e
Compare
|
/azp run maui-pr-devicetests The authorized rebase is now pushed at 3fd956e; requesting device validation for this head. 🤖 AI-authored reply via Agency Finish PR. |
|
/azp run maui-pr-uitests The authorized rebase is now pushed at 3fd956e; requesting UI validation for this head. 🤖 AI-authored reply via Agency Finish PR. |
|
No pipelines are associated with this pull request. |
1 similar comment
|
No pipelines are associated with this pull request. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Expert Review — 0 findings
Reviewed commit 3fd956e.
|
The rebased-head build 1695721 completed its compilation, packaging, and integration stages successfully. Its only failing task was Monitor Helix Jobs, which reported zero submitted jobs. The submission logs actually contain four Helix job IDs (Debug, Release). Direct Helix checks found two jobs still unscheduled and two empty job placeholders, with no completed test work. This is a submission/discovery infrastructure failure, not evidence of a Span assertion failure; the unit tests cannot be called passed. Azure DevOps accepted one retry of the HelixTests stage, including its submission jobs. Successful build, pack, and integration stages are not being rerun. No source changes, skipped tests, or weakened checks were introduced. 🤖 AI-authored reply via Agency Finish PR. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Expert Review — 0 findings
Reviewed commit 3fd956e.
Preserve the Span decoration APIs alongside newly added APIs from main. All 15 focused Span unit tests pass with the selected branch SDK. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Review follow-up: merged current main in Validation after the merge:
The review’s remaining caveats are valid: Apple automated native validation, Android pre-29 fallback validation, and maintainer API sign-off are still outstanding. Existing native captures and the earlier 50/50 Android run do not substitute for those missing checks. No test or approval requirements were removed. 🤖 AI-authored reply via Agency Finish PR. |
|
/review expert-review |
There was a problem hiding this comment.
Expert Review — 0 findings
Reviewed commit f4242b3.
Source assessment incomplete (7/8 dimensions); finding count is partial.


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!
Target Branch
mainnet11, for reviewmain.For .NET 11 fixes, only a maintainer retargets the approved PR to the active
inflight lane and merges it after CI validates that final base. Do not merge
individual fixes directly into
net11; agents must not retarget or merge.Description of Change
Adds
Span.TextDecorationColorandSpan.TextDecorationThickness, so a span's underline / strikethrough can be drawn in a color other than the text color and at a chosen thickness. A typical use is a term or link inside running text: normal text color, a thin accent-colored underline. Spec: #40259.Platforms
FormattedStringExtensions.ToNSAttributedStringaddsNSUnderlineColorAttributeName/NSStrikethroughColorAttributeNamewhen a color is set. UIKit has no exact decoration thickness, only styles, so a thickness of 1.5 or more usesNSUnderlineStyle.Thickand anything elseSingle(today's style).FormattedStringExtensions.ToSpannableStringuses a new JavaPlatformUnderlineSpan(next toPlatformFontSpan/PlatformLineHeightSpan, so drawing stays in Java) when a color and / or thickness is set.TextPaint.underlineColor(the text color when no decoration color is set) andunderlineThickness(the given thickness multiplied by display density without layout rounding, or the font's own with Android's standard minimum of one native pixel). Explicit positive thicknesses remain fractional, including subpixel values; the one-pixel minimum applies only to the default font-metric fallback. This minimum keeps custom-colored underlines visible when a font reports a zero thickness metric. Below API 29 it draws the usual text-colored underline.TextBlockdecorations use the foreground and the font's thickness. Documented in the properties' remarks.With neither set, nothing changes:
UnderlineSpanand the existing attributes are used exactly as before.Public API:
Span.TextDecorationColor{get,set},Span.TextDecorationColorProperty,Span.TextDecorationThickness{get,set}andSpan.TextDecorationThicknessPropertyare added to every ControlsPublicAPI.Unshipped.txt. The Java span is bound as internal byTransforms/Metadata.xml, so Core's API is unchanged.Tests
Controls.Core.UnitTests:SpanTests.TextDecorationColorDefaultsToNull,TextDecorationThicknessDefaultsToFontThickness, andChangingTextDecorationColor/ThicknessUpdatesLabelFormattedText(a change re-maps the label's formatted text). All pass locally.Controls.DeviceTests:FormattedStringTests.TextDecorationsApplyNativeColorAndThicknesscovers 48 combinations: no decoration, underline, strikethrough, or both; with and without a decoration color; and thicknesses -1, 0, 0.25, 1, 1.5, and 2.TextPaintand checks the requested color, fractional density-converted thickness independently against native display metrics, positive default-thickness fallback, cleared standard underline flag, and unchanged text foreground. The test includes assertions for the pre-29 standard underline fallback; that older-API branch was not executed locally.What I verified locally (macOS, .NET 11.0.100):
Controls.Corebuilds for all TFMs except Windows: netstandard, net11.0, Android (Gradle compiles and binds the new Java span), iOS and Mac Catalyst. The PublicAPI analyzers are clean.SpanTests: 15/15).FormattedStringTests: 50/50 passed on an API 37 emulator, including all 48 decoration combinations. The strengthened independent thickness assertions caught 16 failures before the fractional-conversion correction; all pass with it. At density 2.4375, 0.25 DIP now correctly produces 0.609375 pixels instead of 1. Four default-thickness colored-underline cases also previously failed before the minimum-one-pixel fallback fix.TextPaint.underlineThicknesson Android,NSUnderlineStyle.SinglevsThickon iOS) run in a shipping app (Pool Math), on iOS 27 and Android 16, light and dark.Issues Fixed
Fixes #40259
🤖 Generated with Claude Code
Screenshots
Click a screenshot to view it at full size.