From 3a51c80ff3f3efcb82b5c24d387e75691a069890 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Matou=C5=A1ek?= Date: Fri, 18 Jun 2021 16:03:49 -0700 Subject: [PATCH] Use compile-time solution in VS HotReload service (#54184) --- .../EditAndContinue/ManagedHotReloadLanguageService.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/VisualStudio/Core/Def/Implementation/EditAndContinue/ManagedHotReloadLanguageService.cs b/src/VisualStudio/Core/Def/Implementation/EditAndContinue/ManagedHotReloadLanguageService.cs index 06e156a4c3b0c..e9a5c2fa869f1 100644 --- a/src/VisualStudio/Core/Def/Implementation/EditAndContinue/ManagedHotReloadLanguageService.cs +++ b/src/VisualStudio/Core/Def/Implementation/EditAndContinue/ManagedHotReloadLanguageService.cs @@ -11,6 +11,7 @@ using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.EditAndContinue; using Microsoft.CodeAnalysis.ErrorReporting; +using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Text; using Microsoft.VisualStudio.Debugger.Contracts.EditAndContinue; @@ -78,6 +79,9 @@ private RemoteDebuggingSessionProxy GetDebuggingSession() return debuggingSession; } + private Solution GetCurrentCompileTimeSolution() + => _proxy.Workspace.Services.GetRequiredService().GetCompileTimeSolution(_proxy.Workspace.CurrentSolution); + public async ValueTask StartSessionAsync(CancellationToken cancellationToken) { if (_disabled) @@ -87,7 +91,7 @@ public async ValueTask StartSessionAsync(CancellationToken cancellationToken) try { - var solution = _proxy.Workspace.CurrentSolution; + var solution = GetCurrentCompileTimeSolution(); _debuggingSession = await _proxy.StartDebuggingSessionAsync(solution, _debuggerService, captureMatchingDocuments: false, reportDiagnostics: true, cancellationToken).ConfigureAwait(false); } catch (Exception e) when (FatalError.ReportAndCatchUnlessCanceled(e, cancellationToken)) @@ -107,7 +111,7 @@ public async ValueTask GetUpdatesAsync(CancellationToke try { - var solution = _proxy.Workspace.CurrentSolution; + var solution = GetCurrentCompileTimeSolution(); var (moduleUpdates, diagnosticData, rudeEdits) = await GetDebuggingSession().EmitSolutionUpdateAsync(solution, s_solutionActiveStatementSpanProvider, _diagnosticService, _diagnosticUpdateSource, cancellationToken).ConfigureAwait(false); var updates = moduleUpdates.Updates.SelectAsArray(