Skip to content

fix(hr): never commit an EnC baseline for an update that was not applied (backport #24085) (6.7) - #25947

Merged
agneszitte merged 8 commits into
release/stable/6.7from
dev/agzi/backport-hr-rude-edit-baseline-6.7
Nov 3, 2026
Merged

agneszitte merged 8 commits into
release/stable/6.7from
dev/agzi/backport-hr-rude-edit-baseline-6.7

Conversation

@agneszitte

Copy link
Copy Markdown
Member

GitHub Issue: Related to #25378

Backport of #24085 to release/stable/6.7. Studio 3.3 needs it (confirmed by Steve).

Merge after #25945 (the 6.7 backport of #25420). This fix builds on it, so this branch also contains its commits. Once it merges, this PR shows only its own commit.

PR Type:

🐞 Bugfix

What changed? 🚀

After one rude edit, every later Hot Reload edit was reported as applied but was lost until the app restarted (Roslyn 5.x, which 6.7 uses for .NET 10 apps). A rejected update no longer moves the Edit-and-Continue baseline: the emit now commits or discards it explicitly.

Same product change as the master PR. The two When_Style_MarkupExtension_*_Inc_Ext scenario files keep 6.7's version: on master the change only rewords an Ignore reason that these scenarios don't have on 6.7.

PR Checklist ✅

  • 🧪 Tests included (from the master PR). Uno.HotReload.Tests pass locally (157 passed, 1 Unix-only skipped), and Uno.HotReload builds for net9.0 and net10.0
  • ❗ Contains NO breaking changes

🤖 Generated with Claude Code

kazo0 and others added 8 commits November 2, 2026 20:14
When Roslyn throws while emitting a Hot Reload delta (e.g. dotnet/roslyn#86045),
the pass fell into the manager's catch-all and completed as InternalError. The
EnC baseline does not move, so every later edit failed the same way until the
app restarted, with nothing telling the user that undoing the edit recovers.

Exceptions thrown by EmitSolutionUpdateAsync (cancellation excepted) now
complete the operation as RudeEdit with a synthesized UNOHR0001 diagnostic
asking the user to undo the change or restart the app. The full exception is
still logged at Warn level. Exceptions anywhere else in the pass stay
InternalError.

Fixes #25418

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WjQPjTHecnxjgcqBhM8z3e
(cherry picked from commit 2f6759a)
Adds a Hot Reload Errors section to the error codes page: what the
diagnostic means, that undoing the change or restarting the app
recovers, and the known cause (dotnet/roslyn#86045). Adds UNOHR to the
cSpell word list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WjQPjTHecnxjgcqBhM8z3e
(cherry picked from commit a59b726)
The emit failure now uses Roslyn's ENC1002 ("Cannot apply changes --
unexpected error"), which Roslyn itself uses for an internal error
treated as a blocking rude edit, so no Uno-specific id is needed.

This reverts commit a59b726.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WjQPjTHecnxjgcqBhM8z3e
(cherry picked from commit 2d90b5b)
Roslyn already has an id for this case: ENC1002 ("Cannot apply changes
-- unexpected error"), which EmitSolutionUpdateResults.CreateFromInternalError
uses for an internal error treated as a blocking rude edit. The
synthesized diagnostic now uses it, keeping the message that says how to
recover, and the rude-edit filter is back to accepting ENC ids only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WjQPjTHecnxjgcqBhM8z3e
(cherry picked from commit 855e34d)
ENC ids belong to Roslyn. The synthesized diagnostic goes back to an Uno
id, UNOHR0001, and the rude-edit filter accepts it alongside the ENC ids.

This reverts commit 855e34d.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0113rBQqDXVtD6eMXC8Eygn7
(cherry picked from commit 12a7866)
Restores the Hot Reload Errors entry for UNOHR0001 and the UNOHR cSpell
word.

This reverts commit 2d90b5b.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0113rBQqDXVtD6eMXC8Eygn7
(cherry picked from commit d5d3473)
…ied (6.7, backport of #24085)

Backport of #24085 to release/stable/6.7, on top of the
backport of #25420 (#25945),
which it builds on.

The two When_Style_MarkupExtension_*_Inc_Ext scenarios keep 6.7's version: on master the change
only rewords an "Ignore" reason that these scenarios don't have on 6.7. No other scenario file
changes on 6.7.

(cherry picked from commit 503b548)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added area/code-generation Categorizes an issue or PR as relevant to code generation area/build Categorizes an issue or PR as relevant to build infrastructure kind/documentation labels Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @agneszitte's task in 6m 48s —— View job


PR Review: fix(hr): never commit an EnC baseline for an update that was not applied (backport #24085) (6.7)

Verdict: ship — 2 issues found, both minor; the correctness of the core fix is solid.


Summary

The root cause (Roslyn 5.x answers Ready for a rejected rude edit, so the old UnitTestingHotReloadService wrapper committed the baseline for an update that was never applied) is correctly identified and fixed. The fix bypasses the wrapper and drives the EnC engine directly, committing or discarding the pending update explicitly after reading the deltas.

Severity Count
Medium 1
Low 1

Medium — orphaned using System.Runtime.CompilerServices; in WatchHotReloadService.cs (see inline comment): this PR deleted the ITuple-based code that was the only consumer. EnforceCodeStyleInBuild (IDE0005) will flag it on CI.

Low — EngineShape.RequireMethod uses SingleOrDefault (see inline comment): if a future Roslyn adds a second matching overload, the exception bypasses the informative Missing(...) message. Low probability but easy to harden.


What looks good

  • Core fix is correct: EnCEngine.EmitAsync calls CommitSolutionUpdate only when deltas are non-empty; a rude edit (empty deltas) calls DiscardSolutionUpdate, keeping the baseline at the last successfully applied update. The guard against a Read() exception while pending (catch when (pending)) ensures Roslyn never holds a stranded pending update across EndSession.
  • Cancellation discipline: the when (e is not OperationCanceledException || !ct.IsCancellationRequested) filter correctly lets the pass's own cancellation propagate while treating an OCE from a Roslyn-internal token (or a compiler bug) as a recoverable rude edit. Matches the master PR's intent.
  • RequiresRebuildOrRestart routing: the switch condition now includes !emit.RequiresRebuildOrRestart, correctly routing Roslyn 5.x's implicit rude-edit signal (naming projects instead of emitting ENC diagnostics) through HotReloadOperationResult.RudeEdit without requiring an ENC error code.
  • _reportedRebuildSubject deduplication: parallel to _reportedPins, outputs "must be rebuilt" at Output only when the subject changes — repeated saves don't flood the log.
  • EngineShape fail-fast binding: all reflective lookups happen at session creation with named Missing(...) exceptions; a Roslyn bump that moves a member fails immediately with a diagnostic message rather than mid-session.
  • Test coverage: comprehensive — Given_WatchHotReloadService_RudeEditRecovery covers baseline-not-moving (the primary issue), re-emission, revert, the multi-project mixed case, and a baseline-has-moved control. Given_HotReloadManager_EmitFailure covers the compiler-exception path end-to-end.
  • HotReloadEmitResult sealed record: clean value type with an Empty singleton; with expression in the exception handler creates a correct defensive copy.
  • InternalsVisibleTo("Uno.HotReload.Tests") already present in AssemblyInfo.cs — EngineShape.RequireProjectSet is accessible from the test project.

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@agneszitte
agneszitte merged commit 96a0f07 into release/stable/6.7 Nov 3, 2026
44 of 48 checks passed
@agneszitte
agneszitte deleted the dev/agzi/backport-hr-rude-edit-baseline-6.7 branch November 3, 2026 04:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build Categorizes an issue or PR as relevant to build infrastructure area/code-generation Categorizes an issue or PR as relevant to code generation kind/documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants