Repository navigation
[NET12][Enhancement] Add style-class support to Span - #40290
BagavathiPerumal wants to merge 34 commits into
Conversation
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.
This comment has been minimized.
This comment has been minimized.
|
/rebase |
b50d480 to
82449bc
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
PR Test Gate
🧪 Gate analysis — click to expand⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect. No interpretable test-group summary was produced. No additional test execution is inferred. Setup did not capture a verified PR head; no commit is claimed as tested. No immutable without-fix baseline was prepared. |
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.
There was a problem hiding this comment.
Expert Review — 3 findings · ⚠️ 1 breaking change
Reviewed commit cdcc924.
Warning
Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:
See inline comments for details.
| .Select(p => (Target.GetValue(p) as IList<Style>)?.FirstOrDefault(s => s.CanBeAppliedTo(TargetType))) | ||
| .Where(style => style != null) | ||
| .ToList(); | ||
| if (!classStyles.SequenceEqual(ClassStyles ?? Array.Empty<Style>())) |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - Equivalent class-list reassignment no longer refreshes existing controls. On a parented Label with one resolved accent class and no stylesheet, change the class Setter.Value from blue to red and assign a fresh ["accent"] array. Previously registration reapplied the style and displayed red; SequenceEqual now compares the same Style instance and leaves blue displayed. Active class triggers also change from synchronously running ExitActions/EnterActions to running neither, as ReplacingStyleClassWithSameResolvedClassDoesNotReapplyTriggers explicitly requires. This affects existing controls across platforms without using Span. Provide a compatibility opt-in/opt-out preserving the previous refresh behavior and an explicit breaking-change/release-note callout with migration guidance. InvalidateStyle() requires changing existing app code, not selecting compatibility behavior. Prior acknowledgment does not supply that mechanism or disclosure.
There was a problem hiding this comment.
MAUI Autopilot · round 4
❌ Not changed. Skipping reapplication for an equivalent class list is deliberate. InvalidateStyle() is an explicit refresh, not a compatibility switch; whether to preserve the old behavior or document the change needs a maintainer decision.
| foreach (var classStyle in classStyles) | ||
| classStyle.UnApply(Target, owner, oldBase); | ||
| foreach (var classStyle in classStyles) | ||
| ((IStyle)classStyle).Apply(Target, new SetterSpecificity(SetterSpecificity.StyleLocal, 0, 1, 0)); |
There was a problem hiding this comment.
[major] Logic and Correctness Verification - Trigger-bearing base replacements still reverse class-versus-explicit trigger precedence. Give a Label classes ["accent", "warning"], with accent using BaseResourceKey="base", warning containing an active IsEnabled=True trigger setting TextColor=Red, and its explicit Style containing an active trigger setting TextColor=Green. Initially green wins. Replace Resources["base"] with a style containing an active trigger that only sets FontSize. This branch reattaches warning but leaves the explicit trigger attached. TriggerBase.OnAttachedTo assigns ranks using ++bindable._triggerCount, so warning now outranks the explicit trigger and displays red although neither color definition nor condition changed. An unused source-generated lazy replacement also takes this branch even when its deferred content contains only setters. Preserve relative trigger precedence for these replacements and add competing-trigger coverage; the new composed-refresh tests replace bases with eager setter-only styles and do not exercise this branch.
There was a problem hiding this comment.
MAUI Autopilot · round 4
❌ Not changed. The regression reproduces with eager and lazy trigger-bearing bases. The candidate fixes either still let a newly attached base trigger outrank the explicit trigger or correct that rank only after the wrong value can be observed, reapplying unrelated active setters in the process.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Expert Review — 5 findings · ⚠️ 1 breaking change
Reviewed commit 239152d.
Warning
Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:
See inline comments for details.
| .Select(p => (Target.GetValue(p) as IList<Style>)?.FirstOrDefault(s => s.CanBeAppliedTo(TargetType))) | ||
| .Where(style => style != null) | ||
| .ToList(); | ||
| if (!classStyles.SequenceEqual(ClassStyles ?? Array.Empty<Style>())) |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - Equivalent class-list reassignment no longer refreshes existing controls. On a parented Label with one resolved accent class and no stylesheet, change its TextColor Setter.Value from blue to red, then assign a fresh ["accent"] array. Previously registration reapplied the style and displayed red; SequenceEqual now compares the same Style instance and leaves blue displayed. Active class triggers likewise change from synchronously running ExitActions/EnterActions to running neither, as ReplacingStyleClassWithSameResolvedClassDoesNotReapplyTriggers explicitly requires. This affects existing controls across platforms without using Span. Provide a compatibility opt-in/opt-out preserving the previous refresh behavior and an explicit breaking-change/release-note callout with migration guidance. InvalidateStyle() requires changing existing app code, is documented for infrastructure use, and is not a compatibility switch. Prior acknowledgment establishes intent but supplies neither the compatibility mechanism nor release-note disclosure; the frozen context does not identify the target branch.
There was a problem hiding this comment.
MAUI Autopilot · round 5
❌ Not changed. The PR deliberately skips reapplying styles when a fresh class list resolves to the same styles, and a test records that behavior. Whether to retain that change, provide a compatibility switch, or document migration guidance is a maintainer decision.
| foreach (var classStyle in classStyles) | ||
| classStyle.UnApply(Target, owner, oldBase); | ||
| foreach (var classStyle in classStyles) | ||
| ((IStyle)classStyle).Apply(Target, new SetterSpecificity(SetterSpecificity.StyleLocal, 0, 1, 0)); |
There was a problem hiding this comment.
[major] Logic and Correctness Verification - Trigger-bearing base replacements still reverse class-versus-explicit trigger precedence. Give a Label classes ["accent", "warning"], accent using BaseResourceKey="base", warning containing an active IsEnabled=True trigger setting TextColor=Red, and its explicit Style containing an active trigger setting TextColor=Green. Initially green wins. Replace Resources["base"] with a style containing an active trigger that only sets FontSize. This branch reattaches warning while leaving the explicit trigger attached. TriggerBase.OnAttachedTo assigns ranks using ++bindable._triggerCount, so warning now outranks the explicit trigger and displays red although neither color definition nor condition changed. An uninitialized lazy replacement also takes this branch even if its eventual content contains only setters. Preserve relative trigger precedence and add competing-trigger replacement coverage; ReplacingClassBaseWithSetterOnlyStylePreservesExplicitTriggerPrecedence only exercises the eager setter-only branch.
There was a problem hiding this comment.
MAUI Autopilot · round 5
❌ Not changed. The precedence bug still applies. Reattaching the explicit style reruns unchanged trigger actions, while the rank-moving alternatives can collide with keyed or reentrant attachments or disrupt style-valued setters. None of the candidates preserved both precedence and setter lifecycle safely.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Expert Review — 4 findings · ⚠️ 1 breaking change
Reviewed commit 15e6630.
Warning
Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:
See inline comments for details.
| .Select(p => (Target.GetValue(p) as IList<Style>)?.FirstOrDefault(s => s.CanBeAppliedTo(TargetType))) | ||
| .Where(style => style != null) | ||
| .ToList(); | ||
| if (!classStyles.SequenceEqual(ClassStyles ?? Array.Empty<Style>())) |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - Equivalent class-list reassignment no longer refreshes existing controls. On a parented Label with one resolved accent class and no stylesheet, change its TextColor Setter.Value from blue to red, then assign a fresh ["accent"] array. Previously registration reapplied the style and displayed red; SequenceEqual now sees the same Style instance and leaves blue displayed. Active class triggers likewise change from synchronously running ExitActions/EnterActions to running neither. This affects existing controls across platforms without using Span. Provide a compatibility opt-in/opt-out preserving the previous refresh behavior and an explicit breaking-change callout with migration guidance. Prior acknowledgment and the changed-behavior test do not supply a compatibility mechanism; InvalidateStyle() requires changing existing app code.
There was a problem hiding this comment.
MAUI Autopilot · round 6
❌ Not changed. The PR deliberately skips trigger replay on equivalent class reassignment, as its regression test specifies. Restoring the previous default or adding a compatibility switch requires a maintainer decision; the release-note and migration guidance remain open.
| } | ||
|
|
||
| foreach (var classStyle in classStyles) | ||
| classStyle.UnApply(Target, owner, oldBase); |
There was a problem hiding this comment.
[major] Logic and Correctness Verification - Trigger-bearing base replacements reverse class-versus-explicit trigger precedence. Give a Label classes ["accent", "warning"], accent using BaseResourceKey="base", warning containing an active IsEnabled=True trigger setting TextColor=Red, and its explicit Style containing an active trigger setting TextColor=Green. Initially green wins. Replace Resources["base"] with a style containing an active trigger that only sets FontSize. This branch reattaches warning while leaving the explicit trigger attached. TriggerBase.OnAttachedTo assigns ranks using ++bindable._triggerCount, so warning now outranks the explicit trigger and displays red although neither color definition nor condition changed. Uninitialized lazy replacement styles also enter this branch. Preserve relative trigger precedence and add competing-trigger coverage for these replacements; ReplacingClassBaseWithSetterOnlyStylePreservesExplicitTriggerPrecedence only exercises the eager setter-only branch.
There was a problem hiding this comment.
MAUI Autopilot · round 6
❌ Not changed. Reattaching the explicit layer restores which trigger wins but replays its unrelated actions. Renumbering live trigger setters can itself change a condition mid-refresh. Neither candidate preserved both precedence and action behavior for trigger-bearing or lazy replacements.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| foreach (var classStyle in classStyles) | ||
| classStyle.UnApply(Target, owner, oldBase, IsRetainedOutsideClasses); | ||
| foreach (var classStyle in classStyles) | ||
| ((IStyle)classStyle).Apply(Target, new SetterSpecificity(SetterSpecificity.StyleLocal, 0, 1, 0)); |
There was a problem hiding this comment.
MAUI Autopilot · round 7
❌ Not changed. The triggered refresh still has an ordering and replay issue. Reranking the style triggers would either change precedence relative to directly attached triggers or risk collisions with their ranks, so I left this open.
There was a problem hiding this comment.
Expert Review — 6 findings · ⚠️ 1 breaking change
Reviewed commit 3bd554e.
Warning
Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:
Source assessment incomplete (8/9 dimensions); finding count is partial.
See inline comments for details.
| .Select(p => (Target.GetValue(p) as IList<Style>)?.FirstOrDefault(s => s.CanBeAppliedTo(TargetType))) | ||
| .Where(style => style != null) | ||
| .ToList(); | ||
| if (!classStyles.SequenceEqual(ClassStyles ?? Array.Empty<Style>())) |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - Equivalent class-list reassignment no longer refreshes existing controls. On a parented Label with one resolved accent class, no stylesheet and no local TextColor, change the class's TextColor Setter.Value from blue to red, then assign a fresh ["accent"] array. Previously registration reapplied the style and displayed red; SequenceEqual now compares the same Style instance and leaves blue displayed. Active class triggers also change from synchronously running ExitActions/EnterActions to running neither, as ReplacingStyleClassWithSameResolvedClassDoesNotReapplyTriggers requires. This affects existing controls across platforms without using Span. Provide a compatibility opt-in/opt-out preserving the previous refresh behavior and an explicit breaking-change/release-note callout with supported migration guidance. InvalidateStyle() requires changing existing app code, not selecting compatibility behavior. Prior acknowledgment supplies neither the compatibility mechanism nor release-note disclosure; the frozen context does not identify the target branch.
There was a problem hiding this comment.
MAUI Autopilot · round 7
❌ Not changed. Commit 9437ebac72 deliberately skips refresh when the resolved class list is unchanged and adds a test for that behavior. Restoring legacy replay or documenting the behavioral change needs a maintainer decision.
| foreach (var classStyle in classStyles) | ||
| classStyle.UnApply(Target, owner, oldBase, IsRetainedOutsideClasses); | ||
| foreach (var classStyle in classStyles) | ||
| ((IStyle)classStyle).Apply(Target, new SetterSpecificity(SetterSpecificity.StyleLocal, 0, 1, 0)); |
There was a problem hiding this comment.
[major] Logic and Correctness Verification - Trigger-bearing base replacements still reverse class-versus-explicit trigger precedence. Give a Label classes ["accent", "warning"], accent using BaseResourceKey="base", warning containing an active IsEnabled=True trigger setting TextColor=Red, and its explicit Style containing an active trigger setting TextColor=Green. Initially green wins. Replace Resources["base"] with a style containing an active trigger that only sets FontSize. This branch reattaches warning while leaving the explicit trigger attached. TriggerBase.OnAttachedTo assigns ranks using ++bindable._triggerCount, so warning now outranks the explicit trigger and displays red although neither color definition nor condition changed. An uninitialized source-generated lazy replacement also enters this branch even if its deferred content contains only setters, making the result differ from an eager setter-only replacement. Preserve relative trigger precedence and cover both trigger-bearing and uninitialized lazy replacements; the competing-trigger regression only exercises the eager setter-only branch.
There was a problem hiding this comment.
MAUI Autopilot · round 7
❌ Not changed. Trigger-bearing and lazy class replacements can still promote class triggers above an unchanged explicit trigger. The candidate fixes did not preserve precedence against directly attached triggers, so I did not take them.
| { | ||
| if (newValue?.MayAttachTriggers() == true) | ||
| { | ||
| RefreshOwner(); |
There was a problem hiding this comment.
[major] Logic and Correctness Verification - Nested implicit refresh still reverses trigger precedence when the replacement can attach triggers. Use an implicit Label style BasedOn=keyed with an active IsEnabled=True trigger setting TextColor=Green; keyed has BaseResourceKey="base" and an active trigger setting TextColor=Red. Initially the outer trigger attaches last and green wins. Replace the setter-only base with a style containing an active trigger that sets only FontSize. RefreshNestedOwner takes this fallback, detaches and reattaches keyed's trigger through RefreshOwner, and gives it a larger trigger rank than the still-attached outer trigger. TextColor becomes red. RefreshSettersAbove restores only ordinary setters, not the outer trigger's rank. Preserve the nested chain's trigger ordering for trigger-bearing and lazy replacements too; the expanded nested-implicit test supplies only eager setter-only replacements.
There was a problem hiding this comment.
MAUI Autopilot · round 7
❌ Not changed. Replacing a triggered keyed base can still move it above the outer implicit trigger. Moving the outer trigger to the newest rank can put it above directly attached triggers and reapply active setters, so I left this open.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Expert Review — 4 findings · ⚠️ 1 breaking change
Reviewed commit 677a3cd.
Warning
Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:
See inline comments for details.
| .Select(p => (Target.GetValue(p) as IList<Style>)?.FirstOrDefault(s => s.CanBeAppliedTo(TargetType))) | ||
| .Where(style => style != null) | ||
| .ToList(); | ||
| if (!classStyles.SequenceEqual(ClassStyles ?? Array.Empty<Style>())) |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - Equivalent class-list reassignment no longer refreshes existing controls. On a parented Label with one resolved accent class, no stylesheet and no local TextColor, change the class's TextColor Setter.Value from blue to red, then assign a fresh ["accent"] array. Previously registration reapplied the style and displayed red; SequenceEqual now compares the same Style instance and leaves blue displayed. Active class triggers also change from synchronously running ExitActions/EnterActions to running neither, as ReplacingStyleClassWithSameResolvedClassDoesNotReapplyTriggers requires. This affects existing controls across platforms without using Span. Provide a compatibility opt-in/opt-out preserving the previous refresh behavior and an explicit breaking-change/release-note callout with supported migration guidance. Prior acknowledgment establishes intent but does not supply the compatibility mechanism; InvalidateStyle() requires changing application code and is documented for infrastructure use. The frozen context does not identify the target branch.
There was a problem hiding this comment.
MAUI Autopilot · round 8
❌ Not changed. Equivalent class-list reassignment no longer reapplies setters or replays trigger actions. Whether to retain that behavior, offer a compatibility switch, or document a migration is a maintainer decision.
| classStyle.UnApply(Target, owner, oldBase, IsRetainedOutsideClasses); | ||
| RestoreImplicitSetters(); | ||
| foreach (var classStyle in classStyles) | ||
| ((IStyle)classStyle).Apply(Target, new SetterSpecificity(SetterSpecificity.StyleLocal, 0, 1, 0)); |
There was a problem hiding this comment.
[major] Logic and Correctness Verification - Trigger-bearing base replacements still reverse class-versus-explicit trigger precedence. Give a Label classes ["accent", "warning"], accent using BaseResourceKey="base", warning containing an active IsEnabled=True trigger setting TextColor=Red, and its explicit Style containing an active trigger setting TextColor=Green. Initially green wins. Replace the setter-only base with a style containing an active trigger that sets only FontSize. This branch reattaches warning while leaving the explicit trigger attached. TriggerBase.OnAttachedTo assigns warning a newer _triggerCount rank, so TextColor becomes red although neither color trigger changed. An uninitialized LazyInitialization replacement also takes this branch even if it eventually creates only setters. Preserve relative trigger precedence without replaying unchanged actions, and cover trigger-bearing and uninitialized lazy replacements; the competing-trigger regression only exercises an eager setter-only replacement.
There was a problem hiding this comment.
MAUI Autopilot · round 8
❌ Not changed. The trigger-bearing and uninitialized lazy class replacement paths still need a fix. Restoring ranks after reattachment replays unchanged actions, while globally reassigning ranks can change precedence relative to directly attached triggers.
| style.ApplyCore(bindable, (Style)newValue, (SetterSpecificity)objectspecificity); | ||
| void RefreshOwner() | ||
| { | ||
| UnApplyCore(bindable, oldValue); |
There was a problem hiding this comment.
[major] Logic and Correctness Verification - RefreshOwner does not preserve the other layers when an implicit style owns BaseResourceKey. Give the implicit Label style an active IsEnabled=True trigger setting TextColor=Red and an explicit style an active trigger setting TextColor=Green. Replacing the implicit base with an eager setter-only style changing only FontSize reattaches the implicit trigger at a newer rank than the still-attached explicit trigger, changing green to red. TryRefreshImplicitSettersAbove excludes the implicit root itself. Its nested-owner fallback also reverses keyed-versus-outer implicit trigger precedence when the replacement can attach triggers: RefreshSettersAbove restores ordinary setters, not the outer trigger's rank.
The same unqualified teardown loses shared ancestors: let shared set FontSize=30, the implicit style use BaseResourceKey="base" resolving to shared, and class accent have BasedOn=shared. Setting Resources["base"]=null fully unapplies shared, removing its class-base setter and target registration, while accent remains selected and is not restored. FontSize falls to its default. Preserve surviving layers and their trigger order for implicit-owner refreshes too; the shared-base fixtures only exercise a class releasing its base. Add the reversed ownership and competing-trigger cases.
There was a problem hiding this comment.
MAUI Autopilot · round 8
❌ Not changed for a newly attached trigger-bearing base. Commit bbbc3e23c7 fixes the setter-only replacement and removal cases: ReplacingImplicitBasePreservesHigherTriggerAndClassAncestor fails before and passes after for both. The nested trigger-bearing replacement can still reorder triggers, so this thread stays open.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Expert Review — 6 findings · ⚠️ 1 breaking change
Reviewed commit b330f8d.
Warning
Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:
See inline comments for details.
| .Select(p => (Target.GetValue(p) as IList<Style>)?.FirstOrDefault(s => s.CanBeAppliedTo(TargetType))) | ||
| .Where(style => style != null) | ||
| .ToList(); | ||
| if (!classStyles.SequenceEqual(ClassStyles ?? Array.Empty<Style>())) |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - Equivalent class-list reassignment no longer refreshes existing controls. On a parented Label with one resolved accent class, no stylesheet and no local TextColor, change the class's TextColor Setter.Value from blue to red, then assign a fresh ["accent"] array. Previously registration reapplied the style and displayed red; SequenceEqual now compares the same Style instance and leaves blue displayed. Active class triggers also change from synchronously running ExitActions/EnterActions to running neither, as ReplacingStyleClassWithSameResolvedClassDoesNotReapplyTriggers requires. This affects existing controls across platforms without using Span. Provide a compatibility opt-in/opt-out preserving the previous refresh behavior and an explicit breaking-change/release-note callout with supported migration guidance. Prior acknowledgment establishes intent but does not supply the compatibility mechanism; InvalidateStyle() requires changing application code and is documented for infrastructure use.
There was a problem hiding this comment.
MAUI Autopilot · round 9
❌ Not changed. Skipping reapplication for an unchanged resolved class list is intentional and tested. Restoring same-list refresh or adding a compatibility switch would change that contract and needs a maintainer decision.
| classStyle.UnApply(Target, owner, oldBase, IsRetainedOutsideClasses); | ||
| RestoreImplicitSetters(); | ||
| foreach (var classStyle in classStyles) | ||
| ((IStyle)classStyle).Apply(Target, new SetterSpecificity(SetterSpecificity.StyleLocal, 0, 1, 0)); |
There was a problem hiding this comment.
[major] Logic and Correctness Verification - Trigger-bearing base replacement still reverses class-versus-explicit trigger precedence. Give a Label classes ["accent", "warning"], accent using BaseResourceKey="base", warning containing an active IsEnabled=True trigger setting TextColor=Red, and an explicit Style containing an active trigger setting TextColor=Green. Initially green wins. Replace the setter-only base with a style containing an active trigger that sets only FontSize. This branch reattaches warning while leaving the explicit trigger attached; TriggerBase.OnAttachedTo assigns warning a newer _triggerCount rank, so TextColor becomes red although neither color trigger changed. An uninitialized LazyInitialization replacement also enters this branch even if it eventually creates only setters, making the result differ from an eager setter-only replacement. Preserve relative trigger precedence without replaying unchanged actions, and cover trigger-bearing and uninitialized lazy replacements; the competing-trigger regression only exercises an eager setter-only replacement.
There was a problem hiding this comment.
MAUI Autopilot · round 9
❌ Not changed. An incoming class-base trigger can still outrank the unchanged explicit-style trigger because ranks are assigned on attachment. Reattaching the explicit layer to restore its rank would replay unchanged trigger actions; this round does not make that trade-off.
| } | ||
| if (!keepReplacement && newValue?.MayAttachTriggers() == true) | ||
| { | ||
| RefreshOwner(); |
There was a problem hiding this comment.
[major] Logic and Correctness Verification - The implicit-owner fallback still promotes a nested keyed style's triggers above its containing implicit style. Use an implicit Label style BasedOn=keyed with an active IsEnabled=True trigger setting TextColor=Green; keyed has BaseResourceKey="base" and an active trigger setting TextColor=Red. Initially the outer trigger attaches last and green wins. Replace the setter-only base with a new style containing an active trigger that sets only FontSize. RefreshNestedOwner calls RefreshOwner here, detaching and reattaching keyed's red trigger at a newer rank than the still-attached outer trigger. The Label becomes red; RefreshSettersAbove restores ordinary setters but not the outer trigger's priority. Preserve the chain's trigger ordering for trigger-bearing and lazy replacements too. ReplacingNestedImplicitBasePreservesOuterSetters supplies only eager setter-only replacement bases.
There was a problem hiding this comment.
MAUI Autopilot · round 9
❌ Not changed. The trigger-bearing fallback can still assign the keyed owner’s triggers newer ranks than the enclosing implicit style. Reapplying that enclosing style would replay its unchanged actions, and the setter-only fix does not address trigger ranks.
| { | ||
| if (!UsesHigherLayer(ancestor) && implicitStyle.ContainsStyle(ancestor, Target)) | ||
| { | ||
| implicitStyle.RestoreImplicitSetterChain(Target, UsesHigherLayer); |
There was a problem hiding this comment.
[major] Logic and Correctness Verification - Releasing a shared class base restores implicit setters but leaves its triggers at class-era attachment ranks. Let shared contain an active IsEnabled=True trigger setting TextColor=Blue, an implicit Label style derive from shared and contain an active trigger setting TextColor=Red, and class accent use BaseResourceKey="base" resolving to shared. Apply accent after parenting: shared's trigger is reattached after the implicit root's trigger, so blue wins. Set Resources["base"]=null. IsSharedWithOtherLayers retains shared for the implicit chain, but this restoration only rebuilds ordinary setters; shared's blue trigger keeps its newer rank and still overrides the implicit root's red trigger after accent has lost that base. Restore surviving implicit trigger precedence as well. ClearingClassBaseRestoresImplicitSetterPrecedence checks ordinary setters only and misses this null-replacement case.
There was a problem hiding this comment.
MAUI Autopilot · round 9
❌ Not changed. Restoring implicit setters does not change the attachment ranks of retained shared triggers. Detaching and reattaching those triggers would run unchanged actions; this round leaves their ordering open rather than changing the action lifecycle.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Expert Review — 5 findings · ⚠️ 1 breaking change
Reviewed commit 2da02a5.
Warning
Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:
See inline comments for details.
| .Select(p => (Target.GetValue(p) as IList<Style>)?.FirstOrDefault(s => s.CanBeAppliedTo(TargetType))) | ||
| .Where(style => style != null) | ||
| .ToList(); | ||
| if (!classStyles.SequenceEqual(ClassStyles ?? Array.Empty<Style>())) |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - Equivalent class-list reassignment no longer refreshes existing controls. On a parented Label with one resolved accent class, no stylesheet and no local TextColor, change its TextColor Setter.Value from blue to red, then assign a fresh ["accent"] array. Previously registration reapplied the style and displayed red; SequenceEqual now compares the same Style instance and leaves blue displayed. Active class triggers also change from synchronously running ExitActions/EnterActions to running neither, as ReplacingStyleClassWithSameResolvedClassDoesNotReapplyTriggers requires. This affects existing controls across platforms without using Span. Provide a compatibility opt-in/opt-out preserving the previous refresh behavior and an explicit breaking-change/release-note callout with supported migration guidance. Prior acknowledgment establishes intent but supplies neither the compatibility mechanism nor release-note disclosure; InvalidateStyle() requires changing application code and is documented for infrastructure use.
There was a problem hiding this comment.
MAUI Autopilot · round 10
❌ Not changed. The SequenceEqual guard intentionally skips setter refresh and trigger replay when the resolved class list is unchanged. Restoring that behavior, adding a compatibility switch, or documenting it as a breaking change requires a maintainer decision.
| classStyle.UnApply(Target, owner, oldBase, IsRetainedOutsideClasses); | ||
| RestoreImplicitSetters(); | ||
| foreach (var classStyle in classStyles) | ||
| ((IStyle)classStyle).Apply(Target, new SetterSpecificity(SetterSpecificity.StyleLocal, 0, 1, 0)); |
There was a problem hiding this comment.
[major] Logic and Correctness Verification - Trigger-bearing base replacement reverses class-versus-explicit trigger precedence. Give a Label classes ["accent", "warning"], accent using BaseResourceKey="base", warning containing an active IsEnabled=True trigger setting TextColor=Red, and an explicit Style containing an active trigger setting TextColor=Green. Initially green wins. Replace the setter-only base with a style containing an active trigger that sets only FontSize. This branch reattaches warning while leaving the explicit trigger attached; TriggerBase.OnAttachedTo assigns warning a newer _triggerCount rank, so TextColor becomes red although neither color trigger changed. An uninitialized LazyInitialization replacement also enters this branch, even if it eventually creates only setters, unlike an equivalent eager setter-only replacement. Preserve relative trigger precedence without replaying unchanged actions. The explicit-trigger regression only covers eager setter-only replacements; the eager/lazy dispatch test has no competing explicit trigger.
There was a problem hiding this comment.
MAUI Autopilot · round 10
❌ Not changed. Replacing an eager or lazy class base can still promote the warning trigger above the explicit style. The candidate avoided reattaching unchanged triggers, but removing and reapplying their active setters can still replay actions when one trigger controls another trigger’s condition.
| bool keepReplacement = newValue?.HasHigherSpecificity(bindable, baseSpecificity) == true; | ||
| if (!keepReplacement && newValue?.MayAttachTriggers() == true) | ||
| { | ||
| RefreshOwner(); |
There was a problem hiding this comment.
[major] Logic and Correctness Verification - The trigger-bearing fallback promotes a nested keyed style's triggers above its containing implicit style. Use an implicit Label style BasedOn=keyed with an active IsEnabled=True trigger setting TextColor=Green; keyed has BaseResourceKey="base" and an active trigger setting TextColor=Red. Initially the outer trigger attaches last and green wins. Replace the setter-only base with a new style containing an active trigger that sets only FontSize. RefreshOwner detaches and reattaches keyed's red trigger at a newer rank than the still-attached outer trigger, making the Label red. RefreshSettersAbove restores ordinary setters but not the outer trigger's priority. Preserve the chain's trigger ordering for trigger-bearing and uninitialized lazy replacements too; ReplacingNestedImplicitBasePreservesOuterSetters supplies only eager setter-only replacement bases.
There was a problem hiding this comment.
MAUI Autopilot · round 10
❌ Not changed. The nested keyed trigger can still outrank the enclosing implicit trigger. Restoring ordinary setters does not restore trigger rank, and the proposed rank swap exposes intermediate property values that can make unchanged triggers exit and reenter.
| { | ||
| if (!UsesHigherLayer(ancestor) && implicitStyle.ContainsStyle(ancestor, Target)) | ||
| { | ||
| implicitStyle.RestoreImplicitSetterChain(Target, UsesHigherLayer); |
There was a problem hiding this comment.
[major] Logic and Correctness Verification - Releasing a shared class base restores implicit setters but leaves its triggers at class-era attachment ranks. Let shared contain an active IsEnabled=True trigger setting TextColor=Blue, an implicit Label style derive from shared and contain an active trigger setting TextColor=Red, and class accent use BaseResourceKey="base" resolving to shared. Apply accent after parenting: shared's trigger is reattached after the implicit root's trigger, so blue wins. Set Resources["base"]=null. IsSharedWithOtherLayers retains shared for the implicit chain, but RestoreImplicitSetterChain only rebuilds ordinary setters; shared's blue trigger keeps its newer rank and still overrides the implicit root's red trigger after accent has lost that base. Restore surviving implicit trigger precedence as well. ClearingClassBaseRestoresImplicitSetterPrecedence checks ordinary setters only and misses this null-replacement case.
There was a problem hiding this comment.
MAUI Autopilot · round 10
❌ Not changed. Clearing the class base can leave the shared trigger at its old class rank. The candidate enumerated shared triggers at their first use, which does not preserve normal ordering when a later class reapplies the same ancestor.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Target Branch
mainnet11, for reviewFor .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 class-based styling to
Spanthrough the newStyleClassproperty and itsclassalias.Individual spans within a single
Label.FormattedTextcan resolve independent reusable class styles and compose multiple classes, such as a theme-aware text color and bold formatting.Both properties use the existing merged-style infrastructure for resource lookup, style application, specificity, and theme bindings. The shared class-list setter also recalculates styles when classes are cleared or replaced with unresolved classes, removing obsolete setters and exposing the remaining applicable values.
Issues Fixed
Fixes #16432
Motivation
Developers need to apply different reusable formatting combinations to spans within the same Label. Styling the parent Label cannot express independent accent and warning colors, while creating a combined explicit style for every formatting combination increases the number of style definitions.
This enhancement provides the class-list API already familiar from existing controls while retaining explicit
Span.Stylesupport and the existing formatted-text architecture.Public API
Span.StyleClassIList<string>used to resolve class styles for the span. Defaults tonull.Span.class(@classin C#)Both properties use
ListStringTypeConverterfor comma-separated XAML values. They are CLR properties, not bindable properties; noStyleClassProperty, constructor, method, or event is added.Spanexplicitly implements the existing internalIStyleSelectable.Classesmember by returningStyleClass. Its inheritance fromGestureElementremains unchanged.Applications update classes by replacing the list:
In-place collection changes are not observed, and reassigning the same list reference is a no-op. Required target-specific public API baseline entries and nullable annotations remain subject to analyzer verification and API review.
Usage
XAML
C#
What Changed
Shared API and style logic
src/Controls/src/Core/Span.cssrc/Controls/src/Core/MergedStyle.csPublicAPI.Unshipped.txtfilesOutput Reference
Windows-StyleClassSupportToSpan.mp4
Android-StyleClassSupportToSpan.mov
iOS-StyleClassSupportToSpan.mov
Mac-StyleClassSupportToSpan.mov
Platform implementations
src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml,MainPage.xaml.csKey Behaviors
nullor an empty list removes class formatting while retaining other applicable styling layers.AppThemeBindingbehavior. Removed class bindings must not restore obsolete colors during later theme changes.ApplyToDerivedTypesrules.Let AI finish this PR