Skip to content

[XAML Hot Reload] Reconcile complex property and collection updates #36732

Open

Description

@Redth

Description

The source-generator incremental XAML Hot Reload writer currently declines several element-valued, attached, and collection-shaped mutations instead of reconciling the existing live object graph. Generated UpdateComponent code emits explicit skipped/untouched markers, so the app remains running, but the requested edit is not applied.

The affected behavior families share one architectural requirement: rebuild or reconcile a complex subtree while preserving lifecycle semantics and current runtime state. The planned regression suite in #36730 covers:

  • active VisualStateManager.VisualStateGroups setter edits and state add/remove/re-add fallback
  • Behaviors remove/re-add with exactly-once detach/attach
  • merged dictionary reorder/removal and winner recomputation
  • Style.BasedOn and trigger removal/re-attachment
  • MultiBinding child remove/re-add without duplicate expressions
  • BindableLayout.ItemTemplate replacement without duplicate generated children
  • non-root/nested resource dictionaries and custom converter resources

These are intentionally tracked together because fixing them independently with ad hoc assignments would risk stale state, duplicate subscriptions, orphaned children, or incorrect resource precedence.

Steps to Reproduce

  1. Enable source-generator incremental XAML Hot Reload on the net11.0 branch.
  2. Create a live page containing one of the structures above, for example a Label in an active visual state with a BackgroundColor setter.
  3. Apply a XAML update that changes the active setter, removes and re-adds the state, reorders merged dictionaries, removes/re-adds a behavior, or changes another complex collection.
  4. Inspect the generated UpdateComponent source and the retained live object.

Expected: the edit is applied to the retained object; removal restores the correct local/style/default fallback; re-add creates one current object/subscription; current state and unrelated object identity are preserved.

Actual: generated code emits an explicit complex-property/attached-property skipped or untouched marker and the live graph keeps the previous structure/state.

Draft PR #36730 adds green documentation guards plus skip-gated live probes for these scenarios so each can be enabled as reconciliation support lands.

Link to public reproduction project repository

#36730

Version with bug

Nightly / CI build (current net11.0 source-generator incremental Hot Reload implementation)

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android, Windows, and macOS. The gap is in cross-platform generated update code; individual handler/host effects may vary.

Affected platform versions

Not platform-version-specific.

Did you find any workaround?

Use a full rebuild/restart for these structural edits. The generator intentionally declines unsupported mutations rather than emitting a potentially corrupt partial update.

Relevant log output

Generated UpdateComponent output contains comments such as Complex property '<name>' ... skipped (not yet supported), Complex attached property '<name>' ... skipped, or resource entries marked untouched.

Activity

  1. added
    t/bug
    on Jul 22, 2026
  2. added
    s/triaged
    on Jul 22, 2026
  3. added
    area-tooling
    platform/macos
    on Jul 22, 2026
  4. noiseonwires commented on Nov 6, 2026

    @noiseonwires
    Member

    Adding measured follow-up evidence on the build containing #39928. These are managed generator/runtime results, not a claim that every case was manually tested in a native VS/watch UI session.

    Exact environment and methodology

    For each case: generate/compile the baseline; make one edit on a single linear generator driver; generate/compile the edited XAML independently as the fresh-build oracle; create retained consumers; emit and apply a real metadata/IL/PDB delta with MetadataUpdater.ApplyUpdate; invoke MAUI's actual XamlIncrementalHotReloadHandler.UpdateApplication; compare retained state and identity with the independent new build. UI dispatch uses MAUI's synchronous main-thread test hook, as in upstream managed XIHR tests.

    Each of 41 scenarios ran twice with matching results. The driver is not forked or evaluated speculatively, intentionally isolating these coverage gaps from #36937.

    Structural/reconciliation cases relevant here

    Edit Retained managed state after successful delta/application
    Implicit Style inside inline ContentPage.Resources Old Red remains; fresh build is Blue
    Implicit Style inside nested merged dictionary Old Red remains
    Setter literal -> StaticResource, DynamicResource, Binding, or Color element Old Red remains; each independent edited build is Blue
    Existing Setter resource-expression key changes Old Red remains
    Scalar Setter edit inside active VisualState Old Red remains; Selected state active before apply
    Scalar Setter edit inside active Trigger Old Red remains; trigger condition active before apply
    Add/remove a Setter New value absent / removed Setter contribution remains
    Change Setter.Property TextColor -> BackgroundColor Old foreground remains; background not applied
    Change Style.BasedOn to a different base style Old base value remains
    Add/remove implicit Style Existing consumer does not receive addition / retains removed style
    Nested Color resource edit Old DynamicResource value remains
    Reorder merged dictionaries Old winner remains
    Remove winning merged dictionary Fallback value not applied
    Change merged dictionary Source Old winner remains
    Remove winning resource key Earlier-dictionary fallback not applied
    Replace DataTemplate root Label -> Button in BindableLayout Existing child remains old Label; independently rebuilt/new instances use Button

    Positive controls: scalar edits in root implicit styles (including classless Source= dictionaries, an existing BasedOn, and non-shared resources) pass; direct keyed Color + DynamicResource passes; simple Text edits in materialized DataTemplate and ControlTemplate children pass. In particular, this is not a blanket claim that templates or dictionary updates never work.

    Changing Style.TargetType produces a different, isolated compiler defect (incremental CS0200 for a read-only assignment, clean edited build succeeds); filed separately as #39983. Keyed/class style scalar edits and lazy-vs-eager brush mutations are being separated into focused reports rather than treating every matrix row as a distinct bug.

    Complete minimal example: merged-dictionary winner is not recomputed

    Use the exact package above in a MAUI app, enable Debug XIHR, and make Cases.TestPage the startup page. These are also the inputs for the verified generator/runtime case.

    A.xaml:

    <ResourceDictionary xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
                        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
        <Color x:Key="Accent">Red</Color>
    </ResourceDictionary>

    B.xaml: identical except <Color x:Key="Accent">Blue</Color>.

    Styles.xaml:

    <ResourceDictionary xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
                        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                        x:Class="Cases.Styles">
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="A.xaml" />
            <ResourceDictionary Source="B.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

    TestPage.xaml:

    <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:local="clr-namespace:Cases"
                 x:Class="Cases.TestPage">
        <ContentPage.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <local:Styles />
                </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>
        </ContentPage.Resources>
        <Label x:Name="Subject" Text="Resource consumer"
               TextColor="{DynamicResource Accent}" />
    </ContentPage>

    Code-behind:

    namespace Cases;
    public partial class Styles : Microsoft.Maui.Controls.ResourceDictionary
    {
        public Styles() => InitializeComponent();
    }
    public partial class TestPage : Microsoft.Maui.Controls.ContentPage
    {
        public TestPage() => InitializeComponent();
    }
    1. Baseline: B is last, so retained Label.TextColor is Blue.
    2. Change only the merge order in Styles.xaml to B followed by A.
    3. Generate/apply the delta and invoke XIHR on the retained page/dictionary.
    4. Expected: same Label becomes Red. Actual: Label remains Blue. A fresh generation/build correctly produces Red.
    5. Independently test removing B, changing the B Source to A, or clearing B's Accent key. Those also leave the retained winner stale in the managed tests.

    The reorder update contains an explicit marker:

    // Complex root property 'MergedDictionaries' (ListNode) — skipped (not yet supported)

    Additional isolated shape: active VisualState setter

    In a root implicit Label Style use:

    <Setter Property="VisualStateManager.VisualStateGroups">
        <VisualStateGroupList>
            <VisualStateGroup Name="CommonStates">
                <VisualState Name="Normal" />
                <VisualState Name="Selected">
                    <VisualState.Setters>
                        <Setter Property="TextColor" Value="Red" />
                    </VisualState.Setters>
                </VisualState>
            </VisualStateGroup>
        </VisualStateGroupList>
    </Setter>

    Activate VisualStateManager.GoToState(label, "Selected") and verify Red before the edit. Change only this active state's Setter.Value to Blue. After the real delta and XIHR handler, the retained managed Label stays Red; independently rebuilding and activating Selected gives Blue. This differs from editing an ordinary direct Setter in an implicit Style that happens to contain visual states; the latter can use #39928's replacement path.

    Scope cautions

    • Existing one-time StaticResource references to replaced Color objects were classified separately, not called a new runtime defect.
    • An eager converter's mutable Prefix changed, but an existing Binding did not reevaluate. Converter mutation is not normally a notification to rerun bindings; clarify the desired Hot Reload contract before treating that as a separate defect.
    • Structural initializer changes in the small harness do not use a general EnC syntax map; new-root construction after those updates was not claimed. Every edited snapshot was still compiled/run independently from scratch. Retained-object results above were observed after real metadata application.
    • This run does not cover every family originally listed here: e.g. Behaviors and MultiBinding lifecycle cases were not tested. No native device rendering claims are made.

    Generated before/after patches, input XAML, fresh-build observations, and per-case repeated results were saved. These failures should be grouped by resource ownership/reconciliation mechanism rather than filed as one issue per row.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-toolingplatform/androidplatform/iosplatform/macosplatform/windowss/triagedt/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions