-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implement auto-restarting on rude edit or no-effect change #48752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
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 implements auto-restarting behavior when a rude edit or a no-effect change is detected. Key changes include:
- Updated tests (in ApplyDeltaTests.cs, RuntimeProcessLauncherTests.cs, and CompilationHandlerTests.cs) to validate auto-restart on both rude edits and changes with no effect.
- Adjustments to the hot reload logic in CompilationHandler.cs and HotReloadDotNetWatcher.cs to incorporate a new GlobalOptions parameter and to handle project auto-restart determination.
- Addition of the IsAutoRestartEnabled extension method in ProjectGraphNodeExtensions.cs to support the new auto-restart configuration.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
test/dotnet-watch.Tests/HotReload/RuntimeProcessLauncherTests.cs | Removed an outdated process output check to align with the new restart behavior. |
test/dotnet-watch.Tests/HotReload/CompilationHandlerTests.cs | Updated CompilationHandler instantiation with an extra GlobalOptions parameter. |
test/dotnet-watch.Tests/HotReload/ApplyDeltaTests.cs | Added new theory tests for auto-restart on rude and no-effect edits and updated assertion messages accordingly. |
test/TestAssets/TestProjects/WatchHotReloadApp/Program.cs | Updated the class C placeholder to include a comment for later source modifications. |
src/BuiltInTools/dotnet-watch/Utilities/ProjectGraphNodeExtensions.cs | Added the IsAutoRestartEnabled extension to check the HotReloadAutoRestart property. |
src/BuiltInTools/dotnet-watch/HotReloadDotNetWatcher.cs | Modified CompilationHandler instantiation to provide Context.Options to the new parameter. |
src/BuiltInTools/dotnet-watch/HotReload/CompilationHandler.cs | Updated constructor signatures, diagnostic reporting, and process restart logic to support auto-restart. |
@@ -45,6 +45,9 @@ public static string GetAssemblyName(this ProjectGraphNode projectNode) | |||
public static IEnumerable<string> GetCapabilities(this ProjectGraphNode projectNode) | |||
=> projectNode.ProjectInstance.GetItems("ProjectCapability").Select(item => item.EvaluatedInclude); | |||
|
|||
public static bool IsAutoRestartEnabled(this ProjectGraphNode projectNode) | |||
=> bool.TryParse(projectNode.ProjectInstance.GetPropertyValue("HotReloadAutoRestart"), out var result) && result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this constant be defined somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kind of that definition. I can make it a const field, but it's ever going to be used here.
Co-authored-by: Dustin Campbell <dustin@teamcampbell.org>
Using APIs added in dotnet/roslyn#78220, implements auto-restart of a project that have
HotReloadAutoRestart
property set, or any project if--non-interactive
is passed on command line.dotnet-watch automatically terminates associated processes, rebuilds and re-launches the project whenever a rude edit or no-effect change is detected.