Skip to content

Conversation

tmat
Copy link
Member

@tmat tmat commented Apr 19, 2025

Implements support for auto-restarting of projects with rude edits or changes that have no effect.

"No effect" change is a change in top-level code or static constructor that is unlikely to be executed again until the app is restarted.

For each running project the host (dotnet-watch/VS/VS Code) determines whether or not a rude edit that affects this project (the edit is directly in the project itself or in any of its dependencies) should trigger automatic restart of the project. For example, dotnet-watch will enable this restart for all projects if --no-interactive is specified. Otherwise, a project can set HotReloadAutoRestart build property to opt-into auto-restart.

A new overload of GetUpdatesAsync is added that can be used to pass this information from the host to Roslyn.

If no-effect change is encountered in a project or its dependencies and any running projects that support auto-restart will be restarted. A warning will be reported for projects that do not support auto-restart.

After Roslyn calculates deltas it also produces a set of projects to restart and a set of projects to rebuild.
For each project to restart Roslyn now also calculates the set of projects that caused the restart (e.g. had a rude edit). This can be used by the host to determine whether or not to report rude edits as errors. For example, dotnet-watch will print out rude edits in verbose mode if rude edits are reported for a project that has auto-restart enabled. It will only present rude edits as errors if it prompts the user to confirm restart (not in auto-restart mode).

Related: #78009

Follow ups:

@tmat tmat marked this pull request as ready for review April 24, 2025 23:37
@tmat tmat requested a review from a team as a code owner April 24, 2025 23:37
@tmat
Copy link
Member Author

tmat commented Apr 24, 2025

@DustinCampbell ptal

Copy link
Member

@DustinCampbell DustinCampbell left a comment

Choose a reason for hiding this comment

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

Many thanks for the added comments!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Interactive untriaged Issues and PRs which have not yet been triaged by a lead VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants