Skip to content

[watch] Avoid updating running processes state in GetManagedCodeUpdatesAsync - #55160

Merged
tmat merged 3 commits into
dotnet:release/10.0.4xxfrom
tmat:RunnningProjects1
Jul 10, 2026
Merged

tmat merged 3 commits into
dotnet:release/10.0.4xxfrom
tmat:RunnningProjects1

Conversation

@tmat

@tmat tmat commented Jul 7, 2026 •

Copy link
Copy Markdown
Member

Refactor GetManagedCodeUpdatesAsync to only populate HotReloadProjectUpdatesBuilder but not terminate processes or discard updates.

Avoid capturing snapshot of running processes multiple times.
Move capturing of the snapshot from TerminatePeripheralProcessesAsyncto the callers.
Move previous update discarding from GetManagedCodeUpdatesAsync to ApplyManagedCodeAndStaticAssetUpdatesAndRelaunchAsync

Move capturing of the snapshot from TerminatePeripheralProcessesAsync to the callers.
Copilot AI review requested due to automatic review settings July 7, 2026 02:10
@tmat
tmat requested a review from a team as a code owner July 7, 2026 02:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors dotnet watch Hot Reload process-termination flow to avoid repeatedly capturing snapshots of running processes inside CompilationHandler.TerminatePeripheralProcessesAsync, shifting snapshot selection to the callers.

Changes:

  • Move peripheral-process termination out of CompilationHandler.GetManagedCodeUpdatesAsync and into HotReloadDotNetWatcher (and the Aspire control path).
  • Change TerminatePeripheralProcessesAsync to accept concrete RunningProject instances rather than project-path selectors.
  • Expose the current running-project map to callers via CompilationHandler.CurrentRunningProjects.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/Dotnet.Watch/Watch/HotReload/HotReloadDotNetWatcher.cs Terminates peripheral processes based on the already-computed restart set before handling root-process restart/build steps.
src/Dotnet.Watch/Watch/HotReload/CompilationHandler.cs Refactors termination API to take RunningProject instances, adjusts update-building flow, and exposes current running projects.
src/Dotnet.Watch/Watch.Aspire/Server/WatchControlReader.cs Captures running-project snapshot from CompilationHandler and uses it to terminate/restart requested projects.

@tmat tmat changed the title Avoid capturing snapshot of running processes multiple times GetManagedCodeUpdatesAsync Jul 7, 2026
@tmat tmat changed the title GetManagedCodeUpdatesAsync Avoid updating state in GetManagedCodeUpdatesAsync Jul 7, 2026
@tmat tmat changed the title Avoid updating state in GetManagedCodeUpdatesAsync [watch] Avoid updating state in GetManagedCodeUpdatesAsync Jul 7, 2026
@tmat tmat changed the title [watch] Avoid updating state in GetManagedCodeUpdatesAsync [watch] Avoid updating running processes state in GetManagedCodeUpdatesAsync Jul 7, 2026
@tmat

tmat commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

@DustinCampbell ptal

Comment on lines +393 to +394
=> (currentSolution.GetProject(projectId) ?? throw new InvalidOperationException($"Project {projectId} doesn't exist"))
.FilePath ?? throw new InvalidOperationException($"Project {projectId} does not have a file path.");

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.

I don't recall - are exception messages supposed to be localized?

@tmat tmat Jul 10, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We are currently not localizing much in dotnet-watch. These specific ones no one will ever see, unless we have a bug and then it's for us to read.

@tmat
tmat merged commit 6ad2ac3 into dotnet:release/10.0.4xx Jul 10, 2026
28 checks passed
@tmat
tmat deleted the RunnningProjects1 branch July 10, 2026 17:49
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-rc1 milestone Jul 31, 2026
@wtgodbe wtgodbe removed this from the 11.0-rc1 milestone Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants