Skip to content

Hot Reload: Temporarily disable project-level analysis - #81729

Merged
tmat merged 1 commit into
dotnet:mainfrom
tmat:DisableProjectLevelAnalysis
Jun 16, 2026
Merged

Hot Reload: Temporarily disable project-level analysis#81729
tmat merged 1 commit into
dotnet:mainfrom
tmat:DisableProjectLevelAnalysis

Conversation

@tmat

@tmat tmat commented Dec 16, 2025

Copy link
Copy Markdown
Member

Disable project change detection and reporting project-level rude edits until https://devdiv.visualstudio.com/DevDiv/_queries/edit/1835505 is implemented.

When a solution is opened the following operations may take place:

  1. Project is loaded, restored and DTB is kicked off. The Project System sends data to Roslyn to initialize Roslyn project from the results of DTB.
  2. User hits F5/Ctrl+F5.
  3. Debugger calls Roslyn to start Hot Reload session. Roslyn captures the current project state.
  4. User hits "Apply Hot Reload" (either explicitly or implicitly through other debugger operations such as stepping).
  5. Debugger tells Roslyn to apply changes. Roslyn compares the current project state with the state captured at (3).

Currently, (2) and (3) may occur before (1) is complete. Roslyn Hot Reload then concludes changes were made to the project and reports rude edits or tries to apply them. These changes are just artifacts of Roslyn's project representation being updated by the Project System, not real changes made by the user.

We need to block project launch until Roslyn projects are entirely initialized.

Workaround for https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2606868

@tmat
tmat requested a review from a team as a code owner December 16, 2025 23:34
@tmat

tmat commented Dec 16, 2025

Copy link
Copy Markdown
Member Author

@DustinCampbell @dbreshears ptal

@DustinCampbell DustinCampbell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good to me. 👍

@tmat
tmat merged commit 9e84c21 into dotnet:main Jun 16, 2026
27 checks passed
@tmat

tmat commented Jun 16, 2026

Copy link
Copy Markdown
Member Author

/backport to release/insiders

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/insiders (link to workflow run)

tmat added a commit that referenced this pull request Jun 19, 2026
…ysis (#84161)

Backport of #81729 to release/insiders

Disable project change detection and reporting project-level rude edits
until https://devdiv.visualstudio.com/DevDiv/_queries/edit/1835505 is
implemented.

When a solution is opened the following operations may take place:
 
1) Project is loaded, restored and DTB is kicked off. The Project System
sends data to Roslyn to initialize Roslyn project from the results of
DTB.
2) User hits F5/Ctrl+F5.
3) Debugger calls Roslyn to start Hot Reload session. Roslyn captures
the current project state.
4) User hits "Apply Hot Reload" (either explicitly or implicitly through
other debugger operations such as stepping).
5) Debugger tells Roslyn to apply changes. Roslyn compares the current
project state with the state captured at (3).
 
Currently, (2) and (3) may occur before (1) is complete. Roslyn Hot
Reload then concludes changes were made to the project and reports rude
edits or tries to apply them. These changes are just artifacts of
Roslyn's project representation being updated by the Project System, not
real changes made by the user.

We need to block project launch until Roslyn projects are entirely
initialized.

Workaround for
https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2606868

## Customer Impact

## Regression

- [x] Yes
- [ ] No

#79239

## Testing

No testing other than existing tests. The workaround is for a race
condition between project system and Roslyn. Automated validation would
require test infra that forces ordering of certain operations.

## Risk

Medium. Not reporting rude edits for project changes might lead to
applying incorrect deltas and corrupt the user application. That was
however a possibility prior to
#79239.

Co-authored-by: tmat <tomas.matousek@microsoft.com>
akoeplinger added a commit to dotnet/sdk that referenced this pull request Jul 2, 2026
dotnet/roslyn#81729 introduced AbstractEditAndContinueAnalyzer.EnableProjectLevelAnalysis
(default false) and only sets it to true in the HotReloadService(HostWorkspaceServices, ...)
constructor overload. dotnet-watch uses the other primary constructor
(SolutionServices, Func<...>), so the flag stays false. This disables detection of
project-level changes (e.g. newly added <ProjectReference>), causing hot reload to
apply deltas against a stale project graph and the watched app to crash with
FileNotFoundException on the missing dependency.

Enable the flag via reflection until Roslyn sets it in both constructors.
akoeplinger added a commit to dotnet/sdk that referenced this pull request Jul 7, 2026
dotnet/roslyn#81729 introduced AbstractEditAndContinueAnalyzer.EnableProjectLevelAnalysis
(default false) and only sets it to true in the HotReloadService(HostWorkspaceServices, ...)
constructor overload. dotnet-watch uses the other primary constructor
(SolutionServices, Func<...>), so the flag stays false. This disables detection of
project-level changes (e.g. newly added <ProjectReference>), causing hot reload to
apply deltas against a stale project graph and the watched app to crash with
FileNotFoundException on the missing dependency.

Enable the flag via reflection until Roslyn sets it in both constructors.

(cherry picked from commit 9a7cdc5)
tmat added a commit that referenced this pull request Jul 7, 2026
… of HotReloadService (#84422)

Backport of #84404 to release/insiders

/cc @tmat

## Customer Impact

Breaks dotnet-watch.

## Regression

- [x] Yes
- [ ] No

Regressed by #81729

## Testing

dotnet-watch tests

## Risk

Low

---------

Co-authored-by: Tomáš Matoušek <tmat@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants