Repository navigation
fix(hr): don't block hot reload on non-fatal source-generator errors - #24012
Conversation
Roslyn 5.x's Edit-and-Continue refuses to emit any metadata update while a source generator reports an Error-severity diagnostic, even when the C# compilation itself succeeds. A corrupt .resw makes the Uno XAML generator report UXAML0003 (Error) on every pass while the assembly still compiles, so a single broken generator input froze all hot reload -- including valid edits to unrelated files -- until it was fixed. Roslyn 4.x did not gate on generator diagnostics. Generator diagnostics never appear in compilation.GetDiagnostics() (only via the internal Project.GetSourceGeneratorDiagnosticsAsync()), so the change-set-scoped blocked-compilation audit (spec 054) could not see them: the pass just reported NoChanges, with no visible reason. Read the change-set projects' source-generator error diagnostics and suppress them for the EnC emit, so a non-fatal generator error degrades to stale generated output instead of blocking hot reload. Generated code that genuinely does not compile still reports a C# error and stays blocked via the existing audit / rude-edit paths. The suppression is applied to the emit itself, not as a retry: EmitSolutionUpdateAsync advances the EnC baseline as a side effect, so a throwaway first emit would consume the change. Also centralizes hot-reload diagnostic reporting (compilation / emit / solution-update / the new generator diagnostics) into a per-cycle DiagnosticsReporter -- severity coloring, per-category WASM formatting caps; GetCompilationErrors is now a pure getter. Surfaced by unoplatform/studio.live#3317 (Uno SDK 6.7.0-dev.914 -> dev.938, embedded Roslyn 4.14 -> 5.6). Verified: studio.live ReswSupportTests When_ReswCorruptedDuringHotReload now passes (Desktop) with its 4 sibling resw tests; Uno.HotReload.Tests 135/135.
|
Claude finished @dr1rrb's task in 3m 36s —— View job Review complete
Overall verdict: fix-first (2 inline findings, 1 cross-cutting concern)The root cause diagnosis is correct and the fix strategy is sound — suppressing generator errors at the emit level rather than as a retry preserves the EnC baseline, and the 2 inline comments posted:
Cross-cutting concern (no specific line): No unit test was added to What looks good:
|
|
Claude finished @dr1rrb's task in 3m 13s —— View job Code Review
Verdict: ship with minor items addressed The overall design is sound: reading source-generator diagnostics through the internal Roslyn API (reflection-bound, matching the Studio Live approach) and suppressing them via Issues found (3 inline comments):
Cross-cutting observations (no inline comment needed):
|
|
@Mergifyio backport release/stable/6.7 |
✅ Backports have been createdDetails
Cherry-pick of c0ce315 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
There was a problem hiding this comment.
Pull request overview
This PR updates Uno.HotReload to prevent Roslyn 5.x Edit-and-Continue from freezing hot reload when source generators report error-severity diagnostics that don’t actually break C# compilation (e.g., a corrupt .resw causing UXAML0003). It does so by collecting generator diagnostics for the changed-project scope and suppressing their IDs only for the EnC emit, plus centralizing diagnostic formatting/reporting in a per-cycle reporter.
Changes:
- Add reflection-based access to
Project.GetSourceGeneratorDiagnosticsAsync()and utilities to suppress diagnostics IDs viaSpecificDiagnosticOptionsfor a single emit. - In
HotReloadManager.ProcessSolutionChanged, detect generator error diagnostics for the audited project scope and suppress them duringEmitSolutionUpdateAsyncso hot reload can continue. - Introduce
DiagnosticsReporterto centralize diagnostic formatting, severity coloring, and WASM-side reporting caps.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Uno.HotReload/Utils/RoslynExtensions.GeneratorDiagnostics.cs | Adds reflection-bound access to internal generator diagnostics and a helper to suppress diagnostic IDs during compilation/emit. |
| src/Uno.HotReload/Tracking/DiagnosticsReporter.cs | Adds a per-cycle diagnostics reporter to format/color/cap diagnostics output consistently across categories. |
| src/Uno.HotReload/HotReloadManager.cs | Integrates generator-error suppression into the EnC emit path and routes diagnostic reporting through DiagnosticsReporter. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24012/wasm-skia-net9/index.html |
|
|
When_Reorder_DragDrop_ScrollsAwayFromDraggedItem_KeepsExtentAndPositions fails intermittently on the iOS Skia CI leg, always on the mid-drag extent assertion and always with the same values: ExtentHeight 1560 instead of 1440, exactly 3 phantom 40px rows. Observed on master build 225991 (attempt 1, passed on retry), PR #24007 build 226424, and PR #24012 build 226524 where 5/5 stage attempts failed on this single test across different hosted agents. The identical values every failure point at a timing-dependent residue of the extent estimation fixed by #23946 surfacing on the iOS simulator profile — tracked in #24013. Desktop and Android Skia legs keep running the test, so the regression coverage #23946 added stays in place. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NsWEWZN3E2AtwQm7UU1cFm
|
Claude finished @kazo0's task in 2m 35s —— View job Review complete
Overall verdict: fix-first (1 blocking finding, 3 low-severity)The root cause analysis is correct and the approach — collecting generator errors via reflection then suppressing them in 4 inline comments posted:
What looks good:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ListViewBase.cs:5511
- This PR is described as a hot-reload Roslyn/source-generator diagnostic fix, but this hunk also changes ListViewBase runtime-test platform coverage by excluding Skia-iOS. To keep the PR scope auditable, please either mention this test change in the PR description (with rationale/issue link) or move it to a dedicated PR.
// Skia-iOS is excluded: the mid-drag extent intermittently measures 3 rows too large there (1560 vs 1440),
// same values every failure — tracked in the linked issue; Desktop/Android Skia keep covering the regression.
[PlatformCondition(ConditionMode.Include, RuntimeTestPlatforms.Skia & ~RuntimeTestPlatforms.SkiaIOS)]
[GitHubWorkItem("https://github.com/unoplatform/uno/issues/24013")]
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24012/wasm-skia-net9/index.html |
When_Reorder_DragDrop_ScrollsAwayFromDraggedItem_KeepsExtentAndPositions fails intermittently on the iOS Skia CI leg, always on the mid-drag extent assertion and always with the same values: ExtentHeight 1560 instead of 1440, exactly 3 phantom 40px rows. Observed on master build 225991 (attempt 1, passed on retry), PR #24007 build 226424, and PR #24012 build 226524 where 5/5 stage attempts failed on this single test across different hosted agents. The identical values every failure point at a timing-dependent residue of the extent estimation fixed by #23946 surfacing on the iOS simulator profile — tracked in #24013. Desktop and Android Skia legs keep running the test, so the regression coverage #23946 added stays in place. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NsWEWZN3E2AtwQm7UU1cFm (cherry picked from commit c0ce315) # Conflicts: # src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ListViewBase.cs
…6.7/pr-24012 fix(hr): don't block hot reload on non-fatal source-generator errors (backport #24012)
#24012 suppresses source-generator errors for the EnC emit so a non-fatal generator error degrades to stale generated output instead of freezing hot reload. It reports them to the console, but `diagnostics` is then assigned `emitDiagnostics` outright, so they never reach the operation consumers see. That loses the only actionable message for the file the user just edited. Invalid XAML reports UXAML0001 among the generator errors, while the emit — handed a degraded generated tree — reports a rude edit such as ENC0020 "Renaming method 'IMainPage_Bindings.UpdateResources()' requires restarting the application", naming generated code the user never wrote. Consumers were shown only the misleading half. Carry the suppressed generator errors alongside the emit diagnostics. No dedup is required, unlike the compilation-error FIXME below it: generator diagnostics never appear in compilation.GetDiagnostics(), so they cannot already be present in emitDiagnostics. They are also already scoped to the change set's projects via auditedProjects. Fixes #24022 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
#24012 suppresses source-generator errors for the EnC emit so a non-fatal generator error degrades to stale generated output instead of freezing hot reload. It reports them to the console, but `diagnostics` is then assigned `emitDiagnostics` outright, so they never reach the operation consumers see. That loses the only actionable message for the file the user just edited. Invalid XAML reports UXAML0001 among the generator errors, while the emit — handed a degraded generated tree — reports a rude edit such as ENC0020 "Renaming method 'IMainPage_Bindings.UpdateResources()' requires restarting the application", naming generated code the user never wrote. Consumers were shown only the misleading half. Carry the suppressed generator errors alongside the emit diagnostics. No dedup is required, unlike the compilation-error FIXME below it: generator diagnostics never appear in compilation.GetDiagnostics(), so they cannot already be present in emitDiagnostics. They are also already scoped to the change set's projects via auditedProjects. Fixes #24022 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit 67e44b2)
Problem
Surfaced by unoplatform/studio.live#3317 (Uno SDK
6.7.0-dev.914→6.7.0-dev.938, which moves embedded Roslyn4.14→5.6). The regression guardReswSupportTests.When_ReswCorruptedDuringHotReload_Then_XamlEditsStillWorkpasses on914and fails on938.Root cause. Roslyn 5.x's Edit-and-Continue (
UnitTestingHotReloadService.EmitSolutionUpdateAsync) refuses to emit any metadata update while a source generator reports an Error-severity diagnostic — even when the C# compilation itself succeeds. A corrupt.reswmakes the Uno XAML generator reportUXAML0003(Error) on every generator pass while the assembly still compiles, so a single broken generator input froze all hot reload (including valid edits to unrelated files) until the.reswwas fixed. Roslyn 4.x did not gate on generator diagnostics — hence914green,938red.The trap: source-generator diagnostics never appear in
Compilation.GetDiagnostics()(only via the internalProject.GetSourceGeneratorDiagnosticsAsync()), so the change-set-scoped blocked-compilation audit (spec 054) can't see them — the pass reportsNoChanges, notFailed, and the reason is invisible.Confirmed with a source-generated-document dump: after the XAML edit with a corrupt
.resw, the generatedMainPagecode does contain the edit (the generator is innocent), yet EnC emits 0 updates whileUXAML0003is present and emits normally once it is gone. (EnC baseline /commitUpdatesis not the cause — hot reload recovers as soon as the.reswis valid again.)Fix
In
HotReloadManager.ProcessSolutionChanged, read the change-set projects' source-generator error diagnostics (viaProject.GetSourceGeneratorDiagnosticsAsync, resolved through the sameResolveAuditProjectsscope as the spec-054 audit) and suppress them for the EnC emit (SpecificDiagnosticOptions → Suppress). A non-fatal generator error then degrades to stale generated output instead of frozen hot reload, restoring 4.x behavior. Generated code that genuinely does not compile still reports a C# (CSxxxx) error and stays blocked through the existing audit / rude-edit paths, so this never lets non-compiling code hot-reload. The bypassed errors are surfaced in the HR log so a broken.reswisn't silent.The suppression is applied to the emit itself, not as a retry after a blocked emit:
EmitSolutionUpdateAsyncadvances the EnC baseline as a side effect, so a throwaway first emit would consume the change and leave a second nothing to apply.Also centralizes hot-reload diagnostic reporting — compilation errors, EnC emit diagnostics, solution-update diagnostics, and the new bypassed-generator diagnostics — into a per-cycle
DiagnosticsReporter(severity coloring, per-category WASM formatting caps since memory.grow() is irreversible);GetCompilationErrorsbecomes a pure getter.Verification
ReswSupportTests—When_ReswCorruptedDuringHotReload+ all 4 sibling resw tests pass (Desktop; the Wasm rows are unrelated to this fix — they need thewasm-toolsworkload to build the sample).Uno.HotReload.Tests— 135/135 pass.