Skip to content
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

F5 Hot Reload #52101

Merged
merged 7 commits into from
Mar 25, 2021
Merged

F5 Hot Reload #52101

merged 7 commits into from
Mar 25, 2021

Conversation

tmat
Copy link
Member

@tmat tmat commented Mar 24, 2021

Implements Roslyn side of https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1286563.

This change enables the debugger to query for and apply updates while the app being debugged is running, as opposed to when it's at a break state.
Previously Roslyn allowed changes to be made while the app is running but reported a warning that these changes won't be applied until the app is broken and resumed.

The previous Roslyn-debugger protocol required the following operation sequence:
StartDebuggingSession (StartEditSession EmitSolutionUpdate (CommitSolutionUpdate | DiscardSolutionUpdate | rude edits reported) EndEditSession)* EndDebuggingSession

This PR changes the sequence to:
StartDebuggingSession (EnterBreakState? EmitSolutionUpdate (CommitSolutionUpdate | DiscardSolutionUpdate | rude edits reported ))* EndDebuggingSession

  • StartDebuggingSession now starts run state edit session.
  • EnterBreakState closes current run state edit session and opens a new, break state edit session with active statements provided by the debugger
  • CommitSolutionUpdate closes current edit session and opens a new run state edit session (without active statements)
  • DiscardSolutionUpdate is called when Reports no rude edits but other EnC providers fail (2-phase commit), it keeps the current edit session open, the user can try to apply the changes again (not changed in this PR)
  • rude edits reported - when rude edits are reported from EmitSolutionUpdate the edit session remains open as well, the user can fix them and try apply again (not changed in this PR)
  • EndDebuggingSession now closes current edit session.

Follow ups:

@tmat tmat marked this pull request as ready for review March 24, 2021 18:12
@tmat tmat requested a review from a team as a code owner March 24, 2021 18:12
@@ -306,7 +324,7 @@ public void DiscardSolutionUpdate()
public async ValueTask<ImmutableArray<ImmutableArray<(LinePositionSpan, ActiveStatementFlags)>>> GetBaseActiveStatementSpansAsync(Solution solution, ImmutableArray<DocumentId> documentIds, CancellationToken cancellationToken)
{
var editSession = _editSession;
if (editSession == null)
if (editSession == null || !editSession.InBreakState)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is editSession ever null here now? Other than when EnC isn't active at all, but these calls shouldn't happen then, right? This could be a contract check perhaps?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll follow up with refactoring that cleans up edit session nullability. That can wait for Preview 3 though.

}

_activeStatementTrackingService.StartTracking();
}

public async Task ExitBreakStateAsync(CancellationToken cancellationToken)
public Task ExitBreakStateAsync(CancellationToken cancellationToken)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this still exist? Isn't this just part of CommitSolutionUpdate now?

Copy link
Member Author

Choose a reason for hiding this comment

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

No. This is still called by the debugger and signals end of break state. That's now different from end of edit session.

Copy link
Contributor

@pranavkm pranavkm left a comment

Choose a reason for hiding this comment

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

:shipit:

@@ -130,13 +121,19 @@ public void EndEditSession(out ImmutableArray<DocumentId> documentsToReanalyze)
// clear all reported rude edits:
documentsToReanalyze = session.GetDocumentsWithReportedDiagnostics();

_debuggingSessionTelemetry.LogEditSession(_editSessionTelemetry.GetDataAndClear());
// TODO: report a separate telemetry data for hot reload sessions to preserve the semantics of the current telemetry data
Copy link
Member

Choose a reason for hiding this comment

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

i woudl love threading asserts on all these methods (i.e. AssertIsForeground/AssertIsBackground/ThisCanBeCalledOnAnyThread. It makes reading and understanding potential threading/sync/consistency issues more simply.

Copy link
Member Author

Choose a reason for hiding this comment

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

Why? There is no thread affinity. By default we don't put attributes on methods that don't have affinity.

@tmat tmat merged commit 73d4432 into dotnet:main Mar 25, 2021
@ghost ghost added this to the Next milestone Mar 25, 2021
@tmat tmat deleted the RunningEnc branch March 25, 2021 21:07
333fred added a commit to 333fred/roslyn that referenced this pull request Mar 25, 2021
* upstream/main: (75 commits)
  Split BoundInterpolatedString into BoundInterpolatedString and BoundUnconvertedInterpolatedString (dotnet#52061)
  Combine VB comparers into one, and combine VB and C# comparers together (dotnet#51834)
  Use OptimizedVSCompletionList in LSP scenarios.
  F5 Hot Reload (dotnet#52101)
  Fix typescript shim
  Add tests for lazy syntax trees coming from the GeneratorDriver
  React to code review feedback.
  Simplify the lazy-initalization pattern used in GetRoot
  Remove an unnecessary override. (dotnet#52140)
  Update issue number (dotnet#52130)
  Enable CodeActions support for XAML using its own provider and CodeActionCache. The handlers are actually shared with Roslyn as is. (dotnet#52129)
  Add RestrictedIVT to dotnet watch to Features (dotnet#52087)
  Don't try to highlight operators (dotnet#52041)
  Use `null` instead of empty signature helps in LSP
  Use member type for relational pattern even in error cases (dotnet#51950)
  Update src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Extensions/SymbolExtensions.cs
  Use new QuickInfoUtilities helper
  Rebuild API shape (dotnet#52079)
  Added position parameter name
  Updated XAML QuickInfo to show more info like C# by using ISymbolDisplayService and adding more documentation parts.
  ...
@333fred 333fred mentioned this pull request Mar 25, 2021
@allisonchou allisonchou modified the milestones: Next, 16.10.P2 Mar 29, 2021
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.

5 participants