Repository navigation
fix(hr): never commit an EnC baseline for an update that was not applied - #24085
Conversation
|
Claude finished @dr1rrb's task in 9m 16s —— View job Review: fix(hr): never commit an EnC baseline for an update that was not appliedVerdict: ship — 1 low-severity issue, 3 informational notes. What was reviewedThe four commits stacked on #24072:
The bulk of the diff (80+ files) is mechanical: generated Issues found1 low-severity | inline — 3 informational (no blocking):
What's correct
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24085/wasm-skia-net9/index.html |
|
|
Re-enabling the suite left 12 cases red, which would keep the whole build red and so hold up the re-enablement itself. Mark them ignored, following the mechanism the harness already has for IsCrashingRoslyn -- a flag in Scenario.json and Assert.Inconclusive -- rather than [Ignore], which MSTest only applies to a whole method and would take all 250 data-driven cases with it. An ignored case reads as a pass to everything looking at the run, so each one carries the reason and where it is being addressed: - the 8 When_Base_Type_* cases (4 scenarios x NetCore/MonoVM) report no diagnostic where ENC0014 is expected, because hot reload commits a rude edit as the EnC baseline on the Roslyn 5.x line. Fixed by #24085, which should drop these entries. - the 4 When_Style_MarkupExtension_*Remove_Inc_Ext cases remove a file, which deletes a type; Roslyn 5.6 reports ENC0033 for it -- correctly, since Edit-and-Continue can delete members but not types -- while the expectations declare no diagnostic. Whether to record it or to stop treating a file removal as a rude edit is a product decision, so it is left open rather than quietly re-baselined. The suite is now green: 482 tests, 468 pass, 14 ignored (these 12 plus the 2 already known to crash Roslyn).
46fe545 to
c7d9995
Compare
|
Claude finished @kazo0's task in 24s —— View job Review: fix(hr): never commit an EnC baseline for an update that was not appliedVerdict: ship, with one low-severity fix suggested. I read Counts: 0 high, 0 medium, 1 low, 2 informational. These match the inline comments already posted on this PR (the overload lookup, Cross-cutting notes
|
|
Claude finished @kazo0's task in 16s —— View job Review update after new pushVerdict: ship, with the open items below. I made no code changes. The pushes since the last review are test-only: Still open from the earlier review (not repeated inline):
Cross-cutting:
|
There was a problem hiding this comment.
🔵 Needs a closer look
It reworks a critical hot-reload subsystem through reflection over Roslyn internals and contains a latent ProjectsToRestart entry-type bug, so it warrants human review.
1 open finding
What changed in this PR
This PR fixes a hot-reload session-corruption bug (#25378): on the Roslyn 5.x line a rude edit is reported as ModuleUpdateStatus.Ready with zero updates (the project moved to ProjectsToRebuild), so UnitTestingHotReloadService's commit-on-Ready policy committed a baseline for an update the application never received — silently poisoning every later edit. The fix drives Roslyn's Edit-and-Continue engine directly (via a reflection shim, EnCEngine/EngineShape), committing exactly when deltas are handed to the application and discarding the pending update otherwise. It replaces the positional emit tuple with a richer HotReloadEmitResult record and re-enables the previously-ignored When_Base_Type_* scenarios.
Changes:
- Replace
UnitTestingHotReloadService.EmitSolutionUpdateAsyncwrapper usage with a direct, reflection-based EnC drive that owns the commit/discard decision and surfacesProjectsToRebuild/Restart/Redeploy. - Introduce
HotReloadEmitResult/HotReloadEmitStatusandRequiresRebuildOrRestart, wire a new "must be rebuilt" message intoHotReloadManager, and thread anIReporterthroughWatchHotReloadServicefor engine-shape warnings. - Add isolated plain-C# EnC recovery/shape tests, un-ignore the four
When_Base_Type_*scenarios, and re-point the still-ignoredWhen_Style_MarkupExtension_*scenarios to an issue URL.
| File | Description |
|---|---|
src/Uno.HotReload/Microsoft/WatchHotReloadService.Emit.cs |
New EnCEngine/EngineShape reflection shim; contains the ProjectsToRestart entry-type bug noted inline. |
src/Uno.HotReload/Microsoft/WatchHotReloadService.cs |
Drives the engine directly; constructor now takes IReporter and emits shape warnings. |
src/Uno.HotReload/Microsoft/WatchHotReloadService.uno.cs |
CreateAsync forwards the new IReporter parameter. |
src/Uno.HotReload/Microsoft/IWatchHotReloadService.cs |
Emit return type changed to HotReloadEmitResult. |
src/Uno.HotReload/HotReloadEmitResult.cs |
New public record/enum capturing the full emit outcome. |
src/Uno.HotReload/HotReloadManager.cs |
Consumes the record; adds rebuild/restart reporting and Blocked emit-failure path. |
src/Uno.HotReload.Tests/TestUtils/HotReloadManagerHarness.cs |
Stub adapted to the new result shape. |
src/Uno.HotReload.Tests/TestUtils/EnCHarness.cs |
Adds RecordingReporter, RawText helper. |
src/Uno.HotReload.Tests/Microsoft/Given_WatchHotReloadService.RudeEditRecovery.cs |
New recovery tests isolating the bug in plain C#. |
src/Uno.HotReload.Tests/Microsoft/Given_WatchHotReloadService.EngineShape.cs |
New canary for reflective shape reading. |
src/Uno.HotReload.Tests/Microsoft/Given_WatchHotReloadService.References.cs |
Updated to the new result shape. |
src/SourceGenerators/.../HotReloadWorkspaceProvider.cs |
Passes ConsoleReporter; consumes new result. |
.../Scenarios/When_Base_Type_*/Scenario.json (×4) |
Removed Ignore — now pass. |
.../Scenarios/When_Style_MarkupExtension_*Remove_Inc_Ext/Scenario.json (×2) |
Ignore tracking URL re-pointed to an issue. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24085/wasm-skia-net9/index.html |
|
|
On Roslyn 5.x a rude edit answers ModuleUpdateStatus.Ready with zero updates and moves the project into ProjectsToRebuild (4.x answered RestartRequired). UnitTestingHotReloadService commits on Ready, so the rejected solution became the next baseline: the same edit then reported nothing, and reverting it looked like a new rude edit. Drive the Edit-and-Continue engine directly and commit only when deltas are handed out; otherwise discard. A Ready emit always ends in a commit or a discard, even if reading its results throws, since a pending update makes EndSession throw. An emit with an error or a project to rebuild or restart hands out nothing, so a mixed multi-project emit never moves the rejected project's baseline. The emit returns an internal HotReloadEmitResult carrying the deltas, diagnostics and projects to rebuild/restart. The reflected members are resolved once per session and fail at session creation, naming the member, when Roslyn moves one. Reflection invokes no longer wrap exceptions, so cancellation and real errors surface as themselves. The manager completes an emit that names projects to rebuild as a RudeEdit, and says the app must be rebuilt at Output only when the set of projects changes. The public replacement, ExternalAccess.HotReload.HotReloadService, ships in no released package yet; move to it when it does. Fixes #25378 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VeCSvPDzotdW75dHUPyYcf
The When_Base_Type_* scenarios pass now that a rejected rude edit no longer becomes the baseline. The two *Remove_Inc_Ext ignores now point at #25500: Roslyn 5.6 reports ENC0033 for deleting a type. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VeCSvPDzotdW75dHUPyYcf
91b2dd2 to
c737228
Compare
|
Claude finished @kazo0's task in 22s —— View job Review update (by inspection only, nothing built or run)Verdict: fix-first. One new medium finding, posted inline, replaces my earlier "ship" for this push. Counts: 0 high, 1 medium, 0 new low.
Cross-cutting
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24085/wasm-skia-net9/index.html |
The entry type of a project set was taken from the property type's first generic argument. For the 5.x ProjectsToRestart, an ImmutableDictionary<ProjectId, ...>, that is the key type, so entries were read as ProjectIds and the set always came out empty. Take it from the closed IEnumerable<T> instead. Also resolve EmitSolutionUpdateAsync through RequireMethod, so an added overload fails with the shape-mismatch message. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VeCSvPDzotdW75dHUPyYcf
|
Claude finished @kazo0's task in 14s —— View job Review update (by inspection only, nothing built or run)Verdict: ship. The HEAD commit Counts: 0 high, 0 medium, 0 low open. Resolved in the current code (
Remaining notes
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24085/wasm-skia-net9/index.html |
|
|
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
…edit-baseline-6.7 fix(hr): never commit an EnC baseline for an update that was not applied (backport #24085) (6.7)
…edit-baseline-6.8 fix(hr): never commit an EnC baseline for an update that was not applied (backport #24085) (6.8)
…ied (6.8, backport of unoplatform#24085) Backport of unoplatform#24085 to servicing/6.8, on top of the backport of unoplatform#25420 (unoplatform#25495), which it builds on. Applies cleanly. (cherry picked from commit 503b548) Co-Authored-By: Claude Opus 5.5 <[email protected]>

GitHub Issue: closes #25378 (follow-up to #24072)
PR Type:
🐞 Bugfix
What changed? 🚀
Re-enabling the hot-reload scenario suite in #24072 left 12 failures. Eight of them turned out to be
a hot-reload bug that corrupts the Edit-and-Continue session on the Roslyn 5.x line, not stale
test expectations. This fixes it; those eight scenarios now pass without a single expectation being
touched.
The bug
A rude edit — an edit hot reload cannot apply — silently poisoned the session. The very next cycle
reported nothing at all, and undoing the edit produced a phantom rude edit. In between, the
application kept running code that no longer matched its sources, with no diagnostic, for the rest
of the run.
Measured on 4.14 vs 5.6 from identical sources, by calling the engine directly:
ModuleUpdates.StatusRestartRequiredReadyModuleUpdates.UpdatesProjectsToRebuildENC0014ENC0014In 4.x, "this edit is not applicable" was said with the status. In 5.x the status only describes
whether the delta emit ran; a project that cannot be updated is moved into
ProjectsToRebuildinstead.
UnitTestingHotReloadServicestill branches on the old meaning:So on 5.x it commits the rejected solution as the baseline of the next emit. Everything else
follows mechanically: re-emitting the same source no longer differs from that (wrong) baseline, hence
the silence; reverting differs from it, hence the phantom rude edit.
The same wrapper also returns only
(updates, diagnostics), droppingProjectsToRebuild/ProjectsToRestart, which is how 5.x says a project cannot be updated.The fix
EnCEngine(WatchHotReloadService.Emit.cs) drives the engine directly and decides the commititself: commit only when the emit produces deltas to hand out, discard otherwise.
The decision covers the whole solution, so a mixed multi-project emit never moves the rejected
project's baseline.
Ready, andEndSessionthrows while oneis pending. A
Readyemit therefore always ends in a commit or a discard: the results are readfirst, commit/discard is the last step, and if reading throws, the update is discarded before the
exception propagates.
IHotReloadHandler.OnHotReloadAsyncapplies them. That ordering is unchanged from before this PR.
Roslyn's own API for this,
ExternalAccess.HotReload.HotReloadService, returns the projects torebuild/restart and leaves commit/discard to the caller. It is not on nuget.org (only prerelease
builds on the dnceng
dotnet-toolsfeed, and a private copy insidedotnet-watch), hence thereflection. Moving to it is tracked in #25506.
Along with it
HotReloadEmitResult(internal) replaces the positional tuple andcarries the status, the deltas, the diagnostics, and the projects to rebuild and restart.
RequiresRebuildOrRestartanswers the question a host actually has on both lines, which say itdifferently: 5.x keeps
Readyand names the projects, 4.x names none and answersRestartRequired.RudeEdit, even without anENCerror, and says the app must be rebuilt (or restarted). That line goes to Output only whenthe set of projects changes, and to Verbose on later saves.
is required and checked against the type it should have, so a Roslyn bump that moves one fails at
session creation, naming it. Reflection calls don't wrap exceptions, so a cancellation or a real
emit error reaches the manager as itself.
Results
On the Roslyn 5.6 line (net10.0):
Uno.HotReload.Tests: 155 pass, 1 skipped (a Unix-only test).Given_HotReloadService): 244 pass, 0 fail, 7 skipped. The fourWhen_Base_Type_*scenarios had been marked
Ignoreonmasterpending this PR. TheirIgnoreentries are removedhere and all 16
When_Base_Type_*cases pass without any expectation being edited.Uno.HotReload,Uno.HotReload.TestsandUno.UI.SourceGenerators.Tests.Tests added in
Given_WatchHotReloadService_RudeEditRecovery, in plain C# with no XAML or generators:clean. A control case reverts an applicable edit instead.
policy.
When_EditedWhileRudeEditPending_Then_StaysRejectedUntilReverted: the [HotReload] DevServer 7.0.0-dev.2270 keeps a rejected rude edit in its baseline: every later edit is lost (server Success, app applies nothing / InternalError) until the app restarts #25378 shape, on a sessionthat already applied an update.
When_RudeEditInOtherProject_Then_NothingAppliedUntilReverted: two projects, an applicable edit inone and a rude edit in the other. Nothing is handed out, and reverting the rude edit applies the
held edit.
Given_HotReloadManager.When_ProjectRequiresRebuild_Then_RudeEdit_AndReportedOncecovers themanager's outcome and the once-only Output line.
Live validation against #25378
Same versions as the issue: Uno.Sdk
7.0.0-dev.73app (net10.0-desktop) on DevServer7.0.0-dev.2270,host launched directly with the app attached. Stock is the package as shipped; this PR is the
same DevServer with only
Uno.HotReload.dllswapped for this branch's build. A probe in the app wroteout what its code actually returns after each edit (
Benign.Value()/Marked.Value()):ENC0014ENC0014, plus "must be rebuilt (or restarted)"ENC0014)Marked.Value()returns"b2", a string from another classOn the stock DevServer the runtime accepted the deltas built on the reset baseline without any error and
ran incorrect code. With this PR the app logged 4 applied reloads (S1, S4, S5, S6) and no exceptions.
This live run was done before the review changes in this PR's current fix commit (trimmed result
record, discard on read failure, rebuild-required outcome). Those are covered by the tests above but
were not re-run against a live app.
One difference from #25378's "Expected" section: while a rude edit is pending, no edit is applied,
in that project or any other. Later edits are reported as rude edits (not lost) and apply together
with the revert (S4). Applying edits to unaffected projects sooner would need a partial update, which
this PR does not attempt.
Not run: net11.0 (same Roslyn 5.6; no .NET 11 SDK on the machine used), XAML edits and the
record→classchange from #25378, theInternalErrorvariant, and the DevServer CLI / App MCPlaunch path.
Still ignored, deliberately
The remaining 4 runs are the two
When_Style_MarkupExtension_*Remove_Inc_Extscenarios (still markedIgnore): deleting a.csfile deletes a type, and 5.6 reportsENC0033for it, correctly, sinceEdit-and-Continue can delete members but not types. Those expectations declare zero diagnostics.
Whether to record
ENC0033there or to decide that deleting a file should not be a rude edit is aproduct call, tracked in #25500, so they are left ignored rather than quietly re-baselined.
PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code
https://claude.ai/code/session_01VeCSvPDzotdW75dHUPyYcf