Skip to content

Fix SourceGen hot reload for application resources - #37896

Merged
kubaflo merged 2 commits into
net11.0from
copilot/fix-37888-app-resources
Aug 28, 2026
Merged

kubaflo merged 2 commits into
net11.0from
copilot/fix-37888-app-resources

Conversation

@StephaneDelcroix

@StephaneDelcroix StephaneDelcroix commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Summary

Fixes SourceGen XAML Hot Reload propagation for application-level resources so edits reach both existing DynamicResource consumers and consumers created after the update.

Root cause

  • Generated InitializeComponent calls XamlIncrementalHotReloadHandler.Track(this), but Track was a no-op and assumed every root had already registered a child component. Resource-only Application roots can have no registered child, so the runtime handler found no live application instance to patch.
  • A scalar value in a generated merged ResourceDictionary was treated as an independently mutable registered object. Immutable values such as x:String must instead replace their keyed entry on the owning dictionary.

Changes

  • Track every SourceGen XAML root, including resource-only Application and ResourceDictionary roots.
  • Carry the changed element through the XAML diff and replace direct keyed scalar entries on generated resource dictionary roots.
  • Treat x:Key edits as structural changes so the incremental scalar path cannot leave the old and new keys in the live dictionary.
  • Guard component registration when runtime conversion returns null, allowing subsequent generated updates to continue.
  • Add end-to-end metadata-update coverage for inline App.xaml resources and merged dictionaries, plus focused regression tests for x:Key edits and nullable converter results.
  • Extend the SourceGen Hot Reload test harness with a runtime-handler update path so the test exercises production dispatch rather than invoking UpdateComponent directly.

Validation

  • Broken baseline: Maui37888Tests failed both inline and merged cases; consumers remained at App resource V0.
  • Fixed in the original validation environment: Maui37888Tests passed both cases (2/2).
  • Review follow-up: targeted SourceGen resource, diff, and Hot Reload tests passed with 110 passed and 3 metadata-update tests skipped on this host.
  • Targeted runtime handler and component registry tests passed (33/33).
  • Targeted dotnet format completed successfully; the solution workspace reported existing load warnings.

Risk

The dictionary emitter remains intentionally limited to direct, stable-key scalar resource value edits. x:Key edits now fall back to structural handling rather than risking stale entries; general merged-dictionary structural reconciliation remains out of scope (#36732).

Fixes #37888

Track XAML roots even when they have no child components and update keyed scalar values owned by merged resource dictionaries. Add end-to-end source generator coverage for existing and new DynamicResource consumers.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: c30817d7-694e-4593-8efc-dc56ecfaeba1
Copilot AI lite review requested due to automatic review settings August 27, 2026 12:54
@StephaneDelcroix StephaneDelcroix self-assigned this Aug 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 37896

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 37896"

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

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.

Pull request overview

This pull request improves SourceGen XAML Incremental Hot Reload so that updates to application-level resources (including resource-only Application roots and generated ResourceDictionary roots) correctly propagate to both existing DynamicResource consumers and consumers created after the update.

Changes:

  • Make XamlIncrementalHotReloadHandler.Track actively register XAML roots so live instances can be enumerated even when no child components were registered.
  • Extend the SourceGen XAML diff/codegen pipeline to carry the updated element node through diffs and emit direct keyed-entry replacement for scalar resource items on ResourceDictionary roots.
  • Add an end-to-end unit test and update the hot reload test harness to exercise the production runtime-handler dispatch path.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Controls/tests/SourceGen.UnitTests/HotReload/XamlHotReloadTestHarness.cs Adds an “apply update through runtime handler” path to better mirror production XIHR dispatch in tests.
src/Controls/tests/SourceGen.UnitTests/HotReload/Maui37888Tests.cs New end-to-end test covering inline App.xaml resources and merged dictionaries, validating both existing and newly created consumers.
src/Controls/src/Xaml/HotReload/XamlIncrementalHotReloadHandler.cs Implements Track by self-registering the root in XamlComponentRegistry so resource-only roots are discoverable for live updates.
src/Controls/src/SourceGen/XamlNodeDiff.cs Augments NodeDiff to carry the full updated ElementNode when needed for owner-based updates (e.g., dictionary item replacement).
src/Controls/src/SourceGen/UpdateComponentCodeWriter.cs Emits a specialized update path to replace direct keyed scalar entries on ResourceDictionary roots and re-register the updated value.

@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 Aug 27, 2026
MauiBot

This comment was marked as outdated.

@MauiBot MauiBot added s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-win AI found a better alternative fix than the PR s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) and removed s/agent-review-in-progress AI review is currently running for this PR labels Aug 27, 2026

@kubaflo kubaflo 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.

Could you please check the ai's suggestions?

Treat x:Key edits as structural changes so incremental updates cannot leave stale dictionary entries. Guard component registration when runtime conversion returns null and add focused regression coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: c30817d7-694e-4593-8efc-dc56ecfaeba1
Copilot AI review requested due to automatic review settings August 28, 2026 12:59
@StephaneDelcroix

Copy link
Copy Markdown
Contributor Author

@kubaflo I independently checked the AI review and pushed 635c99bac8f.

  • Stale entry after an x:Key rename: valid. x:Key edits now use structural fallback instead of the direct scalar replacement path; XKey_Changed_ReturnsNull covers this.
  • A null converter result aborting later updates: valid. Dictionary assignment is preserved, but registry registration is skipped for null; the regression test verifies the guard and that the following resource update is still emitted.
  • “No tests detected”: a gate-detection false negative; this PR already contained end-to-end tests, and the follow-up adds focused coverage for both findings.
  • Alternative live resource-graph approach: not adopted; the submitted root-registration path is narrower and avoids traversing application resources before UI-thread dispatch.

Targeted validation: SourceGen 110 passed / 3 metadata-update tests skipped on this host; runtime handler/registry 33 passed; formatting completed. GitHub currently reports no review threads (including resolved/outdated), so there was nothing to reply to or resolve. Please re-review.

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.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

src/Controls/tests/SourceGen.UnitTests/HotReload/XamlHotReloadTestHarness.cs:523

  • ApplyUpdateThroughRuntimeHandler passes only the root type into XamlIncrementalHotReloadHandler.UpdateApplication, but the runtime hot-reload infrastructure provides the full set of updated types for the delta. If multiple generated roots are updated in one metadata apply, this can miss updates and make the harness diverge from production behavior.
		var (nextVersion, semanticEdits) = PrepareUpdate(versionIndex);
		ApplyMetadataUpdate(nextVersion, semanticEdits);
		global::Microsoft.Maui.Controls.Xaml.XamlIncrementalHotReloadHandler.UpdateApplication([_pageType!]);

Assert.Equal("Text", prop.PropertyName.LocalName);
Assert.NotNull(prop.NewNode); // complex markup
// Child list change: Entry added
// Child list change: Entry added
@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added s/agent-review-in-progress AI review is currently running for this PR and removed s/agent-review-in-progress AI review is currently running for this PR labels Aug 28, 2026
@kubaflo kubaflo added the s/agent-review-in-progress AI review is currently running for this PR label Aug 28, 2026

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Expert Review — 2 findings

See inline comments for details.

if (valueExpression is null)
return false;

codeWriter.WriteLine($"var {varName} = {valueExpression};");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔍 AI-Generated Review (multi-model)

[critical] Logic and Correctness — var {varName} = {valueExpression}; infers the resource's own type, so the guard emitted two lines below (if ({varName} is not null)) is a null constant pattern against a non-nullable value type whenever the resource is a struct. That is a hard compile error, not a warning: error CS0037: Cannot convert null to 'double' because it is a non-nullable value type (verified against Roslyn with var x = 14d; if (x is not null)).

Concrete scenario: a standalone x:Class ResourceDictionary containing <x:Double x:Key="FontSizeBody">14</x:Double> — the shape shipped by the MAUI project templates in Styles.xaml. Editing 14 → 16 produces exactly one __MAUI_Content__ Set diff on a keyed root-level element with a single ValueNode, so every gate in TryEmitResourceDictionaryItemChange passes and BuildResourceValueExpression returns a double-typed expression via ConvertTo. The generated UpdateComponent() then fails to compile and the hot-reload edit is lost. Same for Thickness, GridLength, CornerRadius, x:Int32, x:Boolean, Size, Point — all common root-level RD entries. Reference-typed resources (Color, x:String) are unaffected, which is why this is invisible today.

Fix is local: declare the local as object? so the boxing conversion is explicit and the null guard is legal:

codeWriter.WriteLine($"object? {varName} = {valueExpression};");

The following this["..."] = {varName}; (indexer is object) and XamlComponentRegistry.Register(this, ..., {varName}) (parameter is object) both already expect object, so no other emitted line changes.

xmlns:local="clr-namespace:TestMaui37888"
x:Class="{{rootClass}}">
<local:NullResource x:Key="NullResource">{{value}}</local:NullResource>
<x:String x:Key="FollowingResource">{{value}}</x:String>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔍 AI-Generated Review (multi-model)

[major] Regression Prevention and Test Coverage — Every resource exercised by the new tests is reference-typed: x:String here and at lines 118/155, plus the custom local:NullResource class at line 81. NullConvertedResource_GuardsComponentRegistration asserts the generated text "if (__uc_0 is not null)" is present, but because both fixtures are classes the assertion cannot discriminate the case where that emitted guard is invalid C# — a value-typed resource (see the CS0037 finding on UpdateComponentCodeWriter.cs:1050). The suite also only inspects generated source and never compiles it for this path, so the break stays green.

Add a case with a struct resource at the dictionary root — e.g. <x:Double x:Key="FontSizeBody">14</x:Double> edited to 16, or a Thickness — and drive it through the live-session harness (ApplyUpdateThroughRuntimeHandler) rather than string-matching, so the generated UpdateComponent() is actually compiled and the updated value is asserted on Resources["FontSizeBody"]. That is the negative case the current fixtures conflate away.

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI Review Summary

@StephaneDelcroix — new AI review results are available based on commit 635c99b.

Gate Passed Confidence High Platform Android


🗂️ Review Sessions — click to expand
🚦 Gate — Test Before & After Fix

Gate Result: ✅ PASSED

Platform: ANDROID · Base: net11.0 · Merge base: e4b0c0a1

Test Without Fix (expect FAIL) With Fix (expect PASS)
🧪 Maui37888Tests Maui37888Tests ✅ FAIL — 78s ✅ PASS — 28s
🧪 XamlNodeDiffTests XamlNodeDiffTests ✅ FAIL — 17s ✅ PASS — 14s
🔴 Without fix — 🧪 Maui37888Tests: FAIL ✅ · 78s

Error-relevant lines (filtered from the build log):

     at Microsoft.Maui.Controls.SourceGen.UnitTests.Maui37888Tests.NullConvertedResource_GuardsComponentRegistration() in /_/src/Controls/tests/SourceGen.UnitTests/HotReload/Maui37888Tests.cs:line 94
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
🟢 With fix — 🧪 Maui37888Tests: PASS ✅ · 28s

(no coded error found; showing last 1200 chars)

en.UnitTests.dll (.NETCoreApp,Version=v11.0)
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:00.01] xUnit.net VSTest Adapter v2.8.2+699d445a1a (64-bit .NET 11.0.0-rc.1.26379.102)
[xUnit.net 00:00:00.22]   Discovering: Microsoft.Maui.Controls.SourceGen.UnitTests
[xUnit.net 00:00:00.39]   Discovered:  Microsoft.Maui.Controls.SourceGen.UnitTests
[xUnit.net 00:00:00.40]   Starting:    Microsoft.Maui.Controls.SourceGen.UnitTests
[xUnit.net 00:00:00.50]     Microsoft.Maui.Controls.SourceGen.UnitTests.Maui37888Tests.ApplicationResourceUpdate_ReachesExistingAndNewConsumers [SKIP]
[xUnit.net 00:00:00.50]       Requires runtime support for applying metadata updates. Set DOTNET_MODIFIABLE_ASSEMBLIES=debug in the environment to run these tests.
  Skipped Microsoft.Maui.Controls.SourceGen.UnitTests.Maui37888Tests.ApplicationResourceUpdate_ReachesExistingAndNewConsumers [1 ms]
[xUnit.net 00:00:05.05]   Finished:    Microsoft.Maui.Controls.SourceGen.UnitTests
  Passed Microsoft.Maui.Controls.SourceGen.UnitTests.Maui37888Tests.NullConvertedResource_GuardsComponentRegistration [4 s]
Test Run Successful.
Total tests: 2
     Passed: 1
    Skipped: 1
 Total time: 6.3361 Seconds
🔴 Without fix — 🧪 XamlNodeDiffTests: FAIL ✅ · 17s

Error-relevant lines (filtered from the build log):

     at Microsoft.Maui.Controls.SourceGen.UnitTests.XamlNodeDiffTests.XKey_Changed_ReturnsNull() in /_/src/Controls/tests/SourceGen.UnitTests/XamlNodeDiffTests.cs:line 987
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
🟢 With fix — 🧪 XamlNodeDiffTests: PASS ✅ · 14s

(no coded error found; showing last 1200 chars)

.SourceGen.UnitTests.XamlNodeDiffTests.SameBinding_NoDiff [< 1 ms]
  Passed Microsoft.Maui.Controls.SourceGen.UnitTests.XamlNodeDiffTests.MultipleChangedNodes_ReturnsAllNodeDiffs [< 1 ms]
  Passed Microsoft.Maui.Controls.SourceGen.UnitTests.XamlNodeDiffTests.NodeId_Root_IsEmptyString [< 1 ms]
  Passed Microsoft.Maui.Controls.SourceGen.UnitTests.XamlNodeDiffTests.SequentialEdits_GrowingLayout [2 ms]
  Passed Microsoft.Maui.Controls.SourceGen.UnitTests.XamlNodeDiffTests.NewPropertyWithBinding_ProducesPropertyDiff [< 1 ms]
[xUnit.net 00:00:00.80]   Finished:    Microsoft.Maui.Controls.SourceGen.UnitTests
  Passed Microsoft.Maui.Controls.SourceGen.UnitTests.XamlNodeDiffTests.BindingToStaticResource_ProducesComplexPropertyDiff [< 1 ms]
  Passed Microsoft.Maui.Controls.SourceGen.UnitTests.XamlNodeDiffTests.SmartMatching_MixedTypes_OnlyDuplicatesUseSmartMatch [1 ms]
  Passed Microsoft.Maui.Controls.SourceGen.UnitTests.XamlNodeDiffTests.AttachedPropertyChangedToBinding_ReturnsMarkupNodeDiff [< 1 ms]
  Passed Microsoft.Maui.Controls.SourceGen.UnitTests.XamlNodeDiffTests.IdenticalTree_ReturnsEmptyDiff [< 1 ms]
Test Run Successful.
Total tests: 103
     Passed: 103
 Total time: 1.8806 Seconds
📁 Fix files reverted (3 files)
  • src/Controls/src/SourceGen/UpdateComponentCodeWriter.cs
  • src/Controls/src/SourceGen/XamlNodeDiff.cs
  • src/Controls/src/Xaml/HotReload/XamlIncrementalHotReloadHandler.cs

📋 Pre-Flight — Context & Validation

PR #37896 Pre-Flight

Context

  • Title: Fix SourceGen hot reload for application resources
  • Base: net11.0 at e4b0c0a1fb
  • Review commit: 4beb9ea4c5 (PR #37896 squashed for review)
  • Issue: #37888, SourceGen application-level resource edits do not reach existing or newly created DynamicResource consumers.
  • Requested platform: Android. The affected code and selected validation are cross-platform SourceGen/runtime paths.
  • Gate: Passed previously; do not rerun baseline verification.

Observed failure

With SourceGen XAML inflation and Hot Reload enabled, edits to inline Application.Resources or a merged ResourceDictionary are reported as applied but consumers retain the old value. Page-owned resources update correctly.

PR approach

The PR addresses two propagation boundaries:

  1. XamlIncrementalHotReloadHandler.Track now registers every XAML root so resource-only Application and ResourceDictionary roots can be enumerated by the runtime handler.
  2. XamlNodeDiff carries the new element to UpdateComponentCodeWriter, which replaces a direct keyed scalar on a generated ResourceDictionary instead of trying to mutate the registered scalar object.

It also treats x:Key edits as structural fallback and guards component registration when conversion returns null.

Changed files

Production:

  • src/Controls/src/SourceGen/UpdateComponentCodeWriter.cs
  • src/Controls/src/SourceGen/XamlNodeDiff.cs
  • src/Controls/src/Xaml/HotReload/XamlIncrementalHotReloadHandler.cs

Tests/harness:

  • src/Controls/tests/SourceGen.UnitTests/HotReload/Maui37888Tests.cs
  • src/Controls/tests/SourceGen.UnitTests/HotReload/XamlHotReloadTestHarness.cs
  • src/Controls/tests/SourceGen.UnitTests/XamlNodeDiffTests.cs

Direct diff assessment

The existing fix is intentionally narrow: only direct, stable-key scalar entries on a generated root ResourceDictionary use dictionary replacement. General collection reconciliation remains out of scope. Alternative candidates must not repeat the PR's combined "carry ElementNode in NodeDiff and special-case it in UpdateComponentCodeWriter" mechanism, and should preserve root tracking, x:Key safety, and null-conversion behavior required by the tests.

Bounded validation

Run only the detected primary test and mandatory regression class in one invocation:

dotnet test src/Controls/tests/SourceGen.UnitTests/SourceGen.UnitTests.csproj --filter "FullyQualifiedName~Maui37888Tests|FullyQualifiedName~XamlNodeDiffTests"
  • Primary: Maui37888Tests
  • Mandatory regression: XamlNodeDiffTests
  • One implementation/test pass is allowed, plus at most one focused correction/retest.

🔬 Code Review — Deep Analysis

Expert Evaluation — PR #37896

Verdict: NEEDS_CHANGES

Confidence: high

The submitted fix correctly addresses the two observed SourceGen Hot Reload failure mechanisms:

  • XamlIncrementalHotReloadHandler.Track now registers XAML roots, allowing resource-only Application and ResourceDictionary instances to be found by runtime metadata-update dispatch.
  • NodeDiff.NewNode and TryEmitResourceDictionaryItemChange let direct keyed scalar entries on a generated ResourceDictionary be replaced through the owning dictionary. Treating x:Key changes as structural is also appropriate because an incremental value assignment cannot remove the old key safely.

The expert review found one blocking code-generation defect. TryEmitResourceDictionaryItemChange emits var __uc_N = <valueExpression>; followed by if (__uc_N is not null). For non-nullable value-type resources such as x:Double, x:Int32, Thickness, or GridLength, the generated variable has a non-nullable value type and the null pattern fails compilation with CS0037. Existing PR coverage uses reference-typed resources, so it does not exercise this ordinary resource shape.

The consolidated reviewer improvement is to emit the temporary as object?, preserving dictionary assignment and registry behavior for both reference and value types, and to add a focused value-type resource regression case that compiles and applies the generated update through the runtime handler.


🛠️ Try-Fix — Analysis & Comparison

Try-Fix Aggregate

Candidate 1 — PASS

Candidate 1 separates root discovery from component registration by maintaining a handler-owned weak root table, and resolves changed resource elements from the existing new-tree ID map instead of adding parser-node state to NodeDiff. It writes direct keyed scalar changes through the root dictionary owner, guards registration of null converted values, and retains structural fallback for x:Key.

The exact bounded test command completed with 0 failed, 104 passed, 1 skipped. All XamlNodeDiffTests and the executable null-conversion test passed. The metadata-update theory covering live runtime dispatch skipped because this host does not support applying metadata updates, so the handler-owned root table was not exercised locally. One compile-only edit error was corrected in the single permitted correction round before the passing retest.

Self-review recorded one minor lifecycle concern: roots are pruned lazily and do not participate in XamlComponentRegistry.Unregister. The complete narrative and candidate diff are in ../try-fix-1/content.md; raw artifacts are in attempt-1/.

EstablishBrokenBaseline.ps1 -Restore reported Restored True.

The attempt also committed pre-existing tracked agent-infrastructure changes as 020191322f to satisfy the baseline script's clean-tree precondition. That commit is unrelated to the candidate implementation.

Candidate 2 — PASS

Candidate 2 retains no root tracking. At dispatch time it derives the current application and generated resource-dictionary roots by walking Application.Current and its reachable merged-dictionary graph, deduplicating them with component-registry instances. It carries only compact scalar ownership metadata (x:Key) in NodeDiff, then combines that key with the existing XML type and new text to regenerate and replace the dictionary entry.

This differs from both the PR's synthetic component registration/parser-node transport and Candidate 1's weak root table/new-tree ID lookup. It also avoids Candidate 1's lazy-unregister concern because no extra roots are retained.

The exact bounded test command completed with 0 failed, 104 passed, 1 skipped. All 103 XamlNodeDiffTests and the executable Maui37888Tests null-conversion test passed. The live metadata-update theory again skipped because this host cannot apply metadata updates, so runtime resource-graph dispatch was not exercised by that theory. The first implementation passed; no correction or retest was used.

Self-review recorded 0 findings. The complete narrative and candidate diff are in ../try-fix-2/content.md; raw artifacts are in attempt-2/.

EstablishBrokenBaseline.ps1 -Restore reported Restored True.

Aggregate Outcome

Exactly two candidates were attempted and both passed the executable bounded tests:

Candidate Root discovery Scalar-entry derivation Tests Self-review
1 Handler-owned weak root table Existing new-tree ID map 104 passed, 1 skipped 1 minor
2 Live Application.Current resource-graph traversal Compact key/type/text diff metadata 104 passed, 1 skipped Clean

Neither candidate obtained runtime execution of ApplicationResourceUpdate_ReachesExistingAndNewConsumers; that metadata-update theory skipped on this host. Candidate 2 is the narrower lifecycle model because it stores no roots, while Candidate 1 preserves discovery of tracked roots that are not reachable from Application.Current.


🏁 Report — Final Recommendation

⚠️ Final Recommendation: REQUEST CHANGES

Winner: pr-plus-reviewer

pr-plus-reviewer is the strongest candidate because it preserves the submitted fix's complete root-tracking behavior and narrow owner-directed resource replacement while correcting the expert review's verified value-type code-generation failure. Its focused regression test makes the previously untested x:Double case compile, and the required bounded validation passed with 105 passed, 1 metadata-update test skipped, and 0 failed.

The submitted PR should not be approved as-is: the generated if (__uc_N is not null) is illegal when var __uc_N infers a non-nullable value type. Common root resources such as x:Double, x:Int32, Thickness, and GridLength can therefore produce CS0037 instead of a usable Hot Reload patch. The trusted Gate passed for the reported application-resource regression, but its reference-typed fixtures do not cover this adjacent value-type failure.

Comparative evaluation

Rank Candidate Focused result Strengths Remaining risk / reason for rank
1 pr-plus-reviewer PASS: 105 passed, 1 skipped, 0 failed Keeps the PR's tracking of every generated XAML root; boxes replacement values before the null guard; adds compile-enforced value-type coverage Live metadata-update theory skipped on this host, so runtime dispatch relies on the trusted Gate and prior successful environment
2 pr Trusted Gate PASS; submitted targeted validation reported passing Directly fixes both propagation boundaries; tracks resource-only roots; replaces stable-key scalar entries through their owner; includes x:Key and null-conversion safeguards Blocking: inferred value-type local followed by is not null generates CS0037; no value-type fixture exposes it
3 try-fix-1 PASS: 104 passed, 1 skipped, 0 failed Separates root discovery into a handler-owned weak table and avoids carrying ElementNode in NodeDiff; can discover tracked roots outside Application.Current Retains the same value-type var/null-guard compile defect; live root discovery was skipped; weak roots are only pruned lazily and do not participate in registry unregister
4 try-fix-2 PASS: 104 passed, 1 skipped, 0 failed Avoids retained root state by traversing the live Application.Current resource graph; carries compact key/type/text metadata Retains the same value-type var/null-guard compile defect; live graph dispatch was skipped; only roots reachable from the current application graph are discoverable

Why the alternatives do not win

Both STEP 5a candidates passed their recorded bounded suites, so neither is demoted for a recorded regression-test failure. However, both emit the same inferred var followed by a null pattern and therefore preserve the expert review's concrete compile failure for value-typed resources. Their different root-discovery designs add lifecycle or reachability tradeoffs without solving that defect.

The raw PR ranks above the try-fix alternatives because its synthetic root registration is simpler, already integrated with the registry's weak instance tracking, and covers generated roots independently of Application.Current reachability. It still loses to pr-plus-reviewer because only the latter removes the blocking codegen error and proves the corrected output compiles.

Required change

Apply pr-plus-reviewer/reviewer.patch: emit the resource replacement temporary as object? and include the focused value-type compilation regression. No broader redesign is needed.


📱 UI Tests — Button,Label,Layout

Detected UI test categories: Button,Label,Layout

✅ Deep UI tests — 360 passed, 0 failed, 7 skipped across 3 categories on platform-pool agent (replaces in-process counts above).

🧪 UI Test Execution Results (deep, platform pool)

Category Tests Snapshot diffs
Button 71/73 (2 skipped) ✓ —
Label 97/99 (2 skipped) ✓ —
Layout 192/195 (3 skipped) ✓ —
📎 Download drop-deep-uitests artifact (TRX + snapshot diffs)

🧭 Next Steps — reviewer changes required

The reviewer-enhanced candidate identified changes that are not yet in the submitted PR.

Why: The reviewer-enhanced PR preserves the submitted fix's broad root tracking while correcting a verified CS0037 code-generation failure for value-typed resources. Its new x:Double regression compiles successfully, and the bounded validation passed with 105 tests passed, 1 host-skipped, and none failed.

Address the actionable findings in this review before merging.

@MauiBot MauiBot added s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) and removed s/agent-review-in-progress AI review is currently running for this PR labels Aug 28, 2026
@kubaflo
kubaflo merged commit 00db49a into net11.0 Aug 28, 2026
30 of 34 checks passed
@kubaflo
kubaflo deleted the copilot/fix-37888-app-resources branch August 28, 2026 16:23
@github-actions github-actions Bot added this to the .NET 11.0-preview7 milestone Aug 28, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-xaml XAML, CSS, Triggers, Behaviors s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-win AI found a better alternative fix than the PR s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants