Skip to content

[NET12][Enhancement] Add style-class support to Span - #40290

Open
BagavathiPerumal wants to merge 34 commits into
mainfrom
Net12-Span-StyleClass
Open

BagavathiPerumal wants to merge 34 commits into
mainfrom
Net12-Span-StyleClass

Conversation

@BagavathiPerumal

@BagavathiPerumal BagavathiPerumal commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Target Branch

This PR is for Initial base
New features, API changes, or .NET 12 work (including .NET 12 fixes) main
.NET 11 servicing fixes net11, for review
Older servicing, release integration, infrastructure, or documentation The branch designated for that work

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 class-based styling to Span through the new StyleClass property and its class alias.

Individual spans within a single Label.FormattedText can 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.Style support and the existing formatted-text architecture.

Public API

Member Purpose
Span.StyleClass Gets or sets the IList<string> used to resolve class styles for the span. Defaults to null.
Span.class (@class in C#) Alias exposing the same class-list reference.

Both properties use ListStringTypeConverter for comma-separated XAML values. They are CLR properties, not bindable properties; no StyleClassProperty, constructor, method, or event is added.

Span explicitly implements the existing internal IStyleSelectable.Classes member by returning StyleClass. Its inheritance from GestureElement remains unchanged.

Applications update classes by replacing the list:

span.StyleClass = new[] { "accent", "emphasis" };

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

<ContentPage.Resources>
    <Style TargetType="Span" Class="accent">
        <Setter Property="TextColor"
                Value="{AppThemeBinding Light=#005A9E, Dark=#80CFFF}" />
    </Style>
    <Style TargetType="Span" Class="warning">
        <Setter Property="TextColor"
                Value="{AppThemeBinding Light=#A4262C, Dark=#FFB3B8}" />
    </Style>
    <Style TargetType="Span" Class="emphasis">
        <Setter Property="FontAttributes" Value="Bold" />
    </Style>
</ContentPage.Resources>

<Label>
    <Label.FormattedText>
        <FormattedString>
            <Span Text="Accent text" StyleClass="accent" />
            <Span Text=" / " />
            <Span Text="Warning text" class="warning" />
            <Span Text=" / " />
            <Span Text="Accent and bold" StyleClass="accent,emphasis" />
        </FormattedString>
    </Label.FormattedText>
</Label>

C#

// Resources in scope declare the corresponding Span class styles.
var span = new Span
{
    Text = "Accent and bold",
    StyleClass = new[] { "accent", "emphasis" }
};

span.StyleClass = new[] { "warning" };
span.@class = new[] { "accent" };
span.StyleClass = Array.Empty<string>();

What Changed

Shared API and style logic

File Change
src/Controls/src/Core/Span.cs Adds both public class-list properties, their XAML type converters, and the explicit internal styling-interface member. Reuses the existing merged-style instance.
src/Controls/src/Core/MergedStyle.cs Resets tracked class-style properties for every different list assignment and explicitly recalculates styles after resource registration, including null, empty, and unresolved lists. Retains the existing stylesheet reapplication condition without adding Span CSS support.
Target-specific PublicAPI.Unshipped.txt files Required to record the new public accessors; completeness and nullable shape must be verified before merge.

Output Reference

Windows Android iOS Mac

Windows-StyleClassSupportToSpan.mp4

Android-StyleClassSupportToSpan.mov

iOS-StyleClassSupportToSpan.mov

Mac-StyleClassSupportToSpan.mov

Platform implementations

Platform Files Implementation
Android No platform-specific changes proposed. Uses shared Controls styling and the existing formatted-text rendering path; native redraw and theme transitions require runtime validation.
iOS / Mac Catalyst No platform-specific changes proposed. Uses the same shared styling contract without native handler changes; runtime validation remains pending.
Windows No platform-specific changes proposed. Uses the existing formatted-text rendering path; runtime validation remains pending.
Sandbox sample src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml, MainPage.xaml.cs Demonstrates explicit and class styles, independent span colors, composed emphasis, theme switching, and runtime class swapping, clearing, and resetting.

Key Behaviors

  • Each span owns its class list; class names are not automatically copied from the parent Label.
  • Multiple classes compose through existing class-style ordering and specificity, without a new conflict-resolution rule.
  • Classes can be assigned before or after parenting. Resource replacement and reparenting use existing dynamic-resource lookup.
  • Replacing classes removes obsolete class effects and applies the replacement's effective values.
  • Assigning null or an empty list removes class formatting while retaining other applicable styling layers.
  • Replacing classes with unresolved names uses existing missing-resource behavior and removes obsolete class effects.
  • Explicit styles and local property values remain available according to existing style precedence; this feature does not change specificity.
  • Theme-aware setters use existing AppThemeBinding behavior. Removed class bindings must not restore obsolete colors during later theme changes.
  • Derived spans follow existing target-type compatibility and ApplyToDerivedTypes rules.
  • The shared class-removal correction also affects existing merged-style consumers and requires regression validation.
  • This enhancement does not add CSS stylesheet support, nested spans, triggers, data triggers, or observable class-list semantics.
  • The design document identifies automated coverage but does not establish passing test results or completed platform validation. API review, focused test execution, native rendering verification, and CI confirmation remain required before merge.

Let AI finish this PR

  • Let the MAUI agent address review feedback and fix remaining issues on this PR. Maintainers still decide whether it is merged. For PRs from forks, keep "Allow edits by maintainers" on so the agent can push to your branch; otherwise it opens a follow-up PR that keeps your commits.

@github-actions

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Nov 16, 2026
@BagavathiPerumal BagavathiPerumal added the community ✨ Community Contribution label Nov 16, 2026
@vishnumenon2684

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Nov 16, 2026
@kubaflo

kubaflo commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

/rebase

@github-actions
github-actions Bot force-pushed the Net12-Span-StyleClass branch from b50d480 to 82449bc Compare November 16, 2026 12:17
@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@MauiBot

MauiBot commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@BagavathiPerumal — existing-test verification; Setup did not capture a tested commit.

Result INCONCLUSIVE Platform iOS


🧪 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.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 16, 2026
@vishnumenon2684

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 2 findings

Reviewed commit 82449bc.

See inline comments for details.

Comment thread src/Controls/src/Core/MergedStyle.cs Resolved
Comment thread src/Controls/src/Core/Span.cs Resolved
@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Nov 16, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/Controls/src/Core/MergedStyle.cs Resolved
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed because base-style refresh can disrupt trigger precedence and shared-base setter retention across multiple style paths.

No open issues 🎉

Review effort: Balanced

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/Controls/src/Core/Style.cs Resolved
Comment thread src/Controls/src/Core/Style.cs Resolved
github-actions Bot and others added 3 commits December 1, 2026 04:56
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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human review is needed because style refreshes can unexpectedly change trigger precedence and replay actions, including when final trigger conditions remain unchanged.

No open issues 🎉

Review effort: Balanced

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/Controls/src/Core/MergedStyle.cs Outdated
}

foreach (var classStyle in classStyles)
classStyle.UnApply(Target, owner, oldBase);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/Controls/src/Core/MergedStyle.cs Resolved
Comment thread src/Controls/src/Core/Style.cs Resolved
github-actions Bot and others added 2 commits December 1, 2026 05:59
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Reattaching triggers during base-style replacement breaks precedence, allowing class or nested-style triggers to override explicit or outer implicit-style triggers.

1 open issue

Review effort: Balanced

Comment on lines +188 to +191
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));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/Controls/src/Core/MergedStyle.cs Resolved
Comment thread src/Controls/src/Core/MergedStyle.cs Resolved
github-actions Bot and others added 3 commits December 1, 2026 07:44
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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed because shared-style interactions can overwrite specificity or remove ancestor setters still required by other active style layers.

1 open issue

Review effort: Balanced

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/Controls/src/Core/Style.cs Resolved
github-actions Bot and others added 3 commits December 1, 2026 08:59
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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed because shared-style replacement and class clearing can incorrectly lower style specificity or remove base setters still required by a surviving implicit style.

1 open issue

Review effort: Balanced

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/Controls/src/Core/Style.cs Resolved
{
if (!UsesHigherLayer(ancestor) && implicitStyle.ContainsStyle(ancestor, Target))
{
implicitStyle.RestoreImplicitSetterChain(Target, UsesHigherLayer);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

github-actions Bot and others added 2 commits December 1, 2026 10:02
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Replacing a class base with a trigger-bearing style reattaches class triggers after explicit-style triggers, incorrectly allowing class triggers to override the explicit style.

1 open issue

Review effort: Balanced

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Trigger-bearing base replacements reattach class triggers after unchanged explicit-style triggers, reversing intended precedence and causing incorrect style values to win.

1 open issue

Review effort: Balanced

This branch was previously deployed

1 inactive (outdated) deployment
copilot-pat-pool — 5b3e8c36 Deployed Nov 16, 2026 by BagavathiPerumal via conclusion #3000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-label Label, Span community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android platform/ios platform/macos macOS / Mac Catalyst platform/windows t/enhancement ☀️ New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Span doesn't have a StyleClass property

6 participants