Skip to content

Hot reload: a no-op pass still forks the solution and emits an empty EnC update #24616

Closed

Description

@dr1rrb

Current behavior

A hot-reload pass that mutates nothing still forks the solution snapshot, so
HotReloadManager.ProcessSolutionChanged misses its result.Solution == originalSolution ->
NoChanges short-circuit and reaches EmitSolutionUpdateAsync with nothing to emit.

Two paths in SolutionUpdater.UpdateAsync do that:

  • the analyzer-config refresh is gated on changeSet.HasAddOrRemove — what the batch requested —
    and rewrites every .editorconfig without comparing content. An add whose document is already in
    the project is de-duplicated by the updater itself (PathEquals), mutates nothing, and forks the
    snapshot all the same. That is what a re-observed file creation looks like;
  • the removes are applied even when both remove lists are empty.

Spec 055 R1 established the rule these two paths break: a pass that changes nothing must return the
original Solution instance.

Impact

The empty update is not a wasted roundtrip. Roslyn resolves it to status: None and the edit
session's deleted-member bookkeeping is corrupted; the failure then lands on the next real edit:

System.NullReferenceException
   at Microsoft.CodeAnalysis.Emit.DefinitionMap.GetPreviousPropertyHandle(...)
   at Microsoft.CodeAnalysis.Emit.DeltaMetadataWriter.CreateDeletedMemberDefs(...)
   at Uno.HotReload.Microsoft.WatchHotReloadService.EmitSolutionUpdateAsync(...)

Hot reload stays dead for the rest of the session. This is dotnet/roslyn#79898 (open), and the
empty update is the only prerequisite an application can control.

Cycles reaching the updater without an UpdateFile request — so without the per-request
HotReloadInfo.g.cs change that normally guarantees a non-empty update: the NoChanges auto-retry
(HotReloadOperation.EnableAutoRetryIfNoChanges, 3 attempts / 500 ms), the re-observation of
HotReloadInfo.g.cs (kept by FileSystemObserver.HasInterest despite living under obj/), and
trailing inotify events.

Expected behavior

A pass that applies no document mutation returns the original solution instance and never reaches
the EnC emit.

Activity

  1. Jen-Uno commented on Sep 30, 2026

    @Jen-Uno
    Contributor

    QA: this fix will be verified together with a related issue fixed by the same PR, and this issue will follow that result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions