Repository navigation
Description
Current behavior
When Roslyn throws while emitting a Hot Reload delta, the DevServer reports the operation as InternalError, and so does every later edit. Nothing tells the user what to do: neither the restart that clears it nor the undo that also works.
Every exception in a Hot Reload pass ends up in the catch-all of HotReloadManager.ProcessFileChanges (L166-L171), which logs Internal error while processing hot-reload and completes the operation as InternalError. That catch-all also handles a compiler crash inside _watchService.EmitSolutionUpdateAsync (L304), such as dotnet/roslyn#86045, which MVUX's generated code hits when a command's parameters change (unoplatform/uno.extensions#3227).
Since the edit is never accepted, the server's baseline stays at the last good version, and every later pass emits a delta that still contains the crashing change:
| Step (desktop, fresh DevServer) | Server op |
|---|---|
E1: add IState<int> Step to an MVUX model |
#1 Success |
E2: change Increment(CancellationToken) to Increment(int step, CancellationToken) |
#2 InternalError |
| E3: any other edit, keeping E2 | #3 InternalError (and so on until restart) |
Undoing the edit recovers without a restart. Reverting E2 instead of moving on:
| Step | Server op | |
|---|---|---|
| R: revert E2 (source back to the E1 state) | #3 NoChanges | the baseline never moved past E1 |
E3: a body edit to Increment that prints a marker |
#4 Success | the app prints the marker when the command runs: the new code is live |
So the session isn't broken. The one edit can't be applied, but nothing reports it that way. The NoChanges after the undo is accurate but looks wrong to clients: the App MCP, for example, explains it as an edit made before Hot Reload was ready.
Expected behavior
A compiler exception during the emit is reported as the edit being unappliable, with a way forward: undo the edit, or restart the app.
- In VS terms that's a rude edit, and every client already handles
RudeEditas "this edit needs a restart". IDEs, the App MCP and itsuno_app_restarthints, and the uno-testing agent hook would all react correctly with no change on their side. Today the agent hook has to special-caseInternalError(recheck, then restart) to get there: fix(skills): the uno-testing hook blocks only on a compile failure studio#190. InternalErrorstays for exceptions anywhere else in the pass, which are DevServer bugs.
Proposal
Catch exceptions around the EmitSolutionUpdateAsync call only, and complete the operation as RudeEdit with a synthesized diagnostic, for example:
The compiler could not produce a Hot Reload update for this change (). Undo the change to keep going, or restart the app.
Keep the Warn log with the full exception, so compiler bugs stay visible in the DevServer log and telemetry.
How to reproduce
On an app created from the recommended preset (MVUX, Navigation), Skia desktop, fresh DevServer:
public partial record MainModel
{
public IState<int> Count => State.Value(this, () => 0);
public async ValueTask Increment(CancellationToken ct) => await Count.UpdateAsync(c => c + 1, ct);
}- Add
public IState<int> Step => State.Value(this, () => 10);and save: applied. - Change
Increment(CancellationToken ct)toIncrement(int step, CancellationToken ct)(andc + 1toc + step) and save:InternalError. - Undo step 2 and save:
NoChanges. - Change the command's body, for example
c => { Console.WriteLine("E3-RAN " + c); return c + 10; }, save, and click: applied, and the app printsE3-RAN.
The first edit matters. With a body-only edit as step 1, the signature change applies; the crash needs a previous generation that regenerated MainViewModel. Separately, after step 1 the bound count no longer follows the model (unoplatform/uno.extensions#3226), which is why step 4 checks stdout and not the UI.
Scripted run (driven through the App MCP)
[E1 add Step state] exit=0 | edit to 'Preflight\Presentation\MainModel.cs': applied (server op #1 Success in 3.5s, local op #2 Success in 0.4s, types: MainModel, MainViewModel)
tap after E1 (+1): CountText 0 -> 0 (delta 0) invoke exit=0
[E2 command signature Increment(int step)] exit=1 | edit to 'Preflight\Presentation\MainModel.cs': NOT applied - server op #2 InternalError in 0.5s.
[R revert E2 (source back to the E1 state)] exit=1 | edit to 'Preflight\Presentation\MainModel.cs': no changes (server op #3 NoChanges in 0.6s) - the file shows no difference from the server's baseline. If you edited it before Hot Reload was Ready, the edit was folded into that baseline and the app still runs the old code: restart with uno_app_start.
[E3 command body prints E3-RAN, after the revert] exit=0 | edit to 'Preflight\Presentation\MainModel.cs': applied (server op #4 Success in 0.3s, local op #3 Success in 0s, types: MainModel)
tap after E3: CountText 0 -> 0 (delta 0) invoke exit=0
app stdout E3-RAN lines: 1 ['E3-RAN 0']
DevServer log at E2:
[Warn] Internal error while processing hot-reload (Unexpected value 'Preflight.Presentation.MainViewModel.<>c__DisplayClass10_0.<<__Reactive_BindableInitializeForUpdatedModel>b__4#2>d.<>o.<>p__0' of type 'Microsoft.CodeAnalysis.CSharp.Symbols.SynthesizedFieldSymbol').
Environment
- Uno.WinUI / DevServer host 7.0.0-dev.2270, Uno.Extensions 8.0.0-dev.76, Uno.Sdk 7.0.0-dev.73
- .NET SDK 10.0.400 (Roslyn 5.9.0-1.26379.115)
- Skia desktop, Windows 11
Related
- EnC: adding an async lambda that awaits a
dynamiccall throws InvalidOperationException in DeltaMetadataWriter.GetFieldDefinitionHandle dotnet/roslyn#86045: the compiler crash that exposes this - [HR][MVUX] Generated command lambdas await a dynamic value, which crashes Roslyn EnC; cast the call before awaiting uno.extensions#3227: MVUX generator workaround for that crash
Activity
fix(hr): report a compiler crash during the delta emit as a rude edit
fix(hr): report a compiler crash during the delta emit as a rude edit