Refactor Hot Reload loop cancellation#53048
Merged
tmat merged 2 commits intodotnet:release/10.0.3xxfrom Feb 19, 2026
Merged
Conversation
e8e2831 to
d0d1a1a
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors process cancellation handling in the dotnet-watch Hot Reload infrastructure. The main change is to simplify the lifecycle management of the processTerminationSource by moving its creation from being a parameter passed to launcher methods to being created internally within CompilationHandler.TrackRunningProjectAsync. This change reduces parameter coupling and makes the cancellation token lifecycle more encapsulated.
Changes:
- Moved
processTerminationSourcecreation from caller toCompilationHandler.TrackRunningProjectAsyncwith proper disposal - Simplified process exit code handling in
ProcessRunnerby consolidating signal-based termination detection - Added
onExitcallback inHotReloadDotNetWatcherto cancel iteration when root process exits - Added test coverage for Ctrl+R restart behavior during build and while waiting for file changes
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/BuiltInTools/Watch/Process/ProjectLauncher.cs | Removed processTerminationSource parameter from TryLaunchProcessAsync |
| src/BuiltInTools/Watch/HotReload/CompilationHandler.cs | Moved processTerminationSource creation inside TrackRunningProjectAsync and added to disposables |
| src/BuiltInTools/Watch/Aspire/AspireServiceFactory.cs | Removed processTerminationSource variable and parameter |
| src/BuiltInTools/Watch/Process/ProcessRunner.cs | Simplified exit code checking by consolidating OS-specific termination codes |
| src/BuiltInTools/Watch/Process/RunningProject.cs | Updated comment to clarify auto-restart behavior |
| src/BuiltInTools/Watch/HotReload/HotReloadDotNetWatcher.cs | Added onExit callback to cancel iteration on root process exit, simplified Hot Reload loop logic |
| src/BuiltInTools/Watch/UI/IReporter.cs | Added new Restarting message descriptor |
| test/dotnet-watch.Tests/HotReload/RuntimeProcessLauncherTests.cs | Removed parameter from test call, added two new tests for Ctrl+R restart scenarios |
| test/dotnet-watch.Tests/HotReload/ApplyDeltaTests.cs | Added test identifiers to CombinatorialData tests for proper test isolation |
test/dotnet-watch.Tests/HotReload/RuntimeProcessLauncherTests.cs
Outdated
Show resolved
Hide resolved
test/dotnet-watch.Tests/HotReload/RuntimeProcessLauncherTests.cs
Outdated
Show resolved
Hide resolved
test/dotnet-watch.Tests/HotReload/RuntimeProcessLauncherTests.cs
Outdated
Show resolved
Hide resolved
e4b2c12 to
0ffc01d
Compare
Member
Author
|
@DustinCampbell ptal |
DustinCampbell
approved these changes
Feb 19, 2026
| extendTimeout = false; | ||
| // If the changes include addition/deletion wait a little bit more for possible matching deletion/addition. | ||
| // This eliminates reevaluations caused by teared add + delete of a temp file or a move of a file. | ||
| if (changedFilesAccumulator.Any(change => change.Kind is ChangeKind.Add or ChangeKind.Delete)) |
Member
There was a problem hiding this comment.
Suggested change
| if (changedFilesAccumulator.Any(change => change.Kind is ChangeKind.Add or ChangeKind.Delete)) | |
| if (changedFilesAccumulator.Any(static change => change.Kind is ChangeKind.Add or ChangeKind.Delete)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Simplify and prepare for Aspire changes.