Skip to content

Commit

Permalink
Do not attempt to report EnC diagnostics for non-host workspaces (#75138
Browse files Browse the repository at this point in the history
)
  • Loading branch information
tmat authored Sep 16, 2024
1 parent 876ea36 commit 7b7951a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ public override async Task<ImmutableArray<DiagnosticData>> GetDiagnosticsAsync(R
var designTimeSolution = designTimeDocument.Project.Solution;
var services = designTimeSolution.Services;

// avoid creating and synchronizing compile-time solution if Hot Reload/EnC session is not active
if (services.GetService<IEditAndContinueWorkspaceService>()?.SessionTracker is not { IsSessionActive: true } sessionStateTracker)
// Do not report EnC diagnostics for a non-host workspace, or if Hot Reload/EnC session is not active.
if (designTimeSolution.WorkspaceKind != WorkspaceKind.Host ||
services.GetService<IEditAndContinueWorkspaceService>()?.SessionTracker is not { IsSessionActive: true } sessionStateTracker)
{
return [];
}

var applyDiagnostics = sessionStateTracker.ApplyChangesDiagnostics.WhereAsArray(static (data, id) => data.DocumentId == id, designTimeDocument.Id);

// Only create and synchronize compile-time solution if we need it.
var compileTimeSolution = services.GetRequiredService<ICompileTimeSolutionProvider>().GetCompileTimeSolution(designTimeSolution);

var compileTimeDocument = await CompileTimeSolutionProvider.TryGetCompileTimeDocumentAsync(designTimeDocument, compileTimeSolution, cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public override Task<ImmutableArray<DiagnosticData>> GetDiagnosticsAsync(Request

public static async ValueTask<ImmutableArray<IDiagnosticSource>> CreateWorkspaceDiagnosticSourcesAsync(Solution solution, Func<Document, bool> isDocumentOpen, CancellationToken cancellationToken)
{
if (solution.Services.GetService<IEditAndContinueWorkspaceService>()?.SessionTracker is not { IsSessionActive: true } sessionStateTracker)
// Do not report EnC diagnostics for a non-host workspace, or if Hot Reload/EnC session is not active.
if (solution.WorkspaceKind != WorkspaceKind.Host ||
solution.Services.GetService<IEditAndContinueWorkspaceService>()?.SessionTracker is not { IsSessionActive: true } sessionStateTracker)
{
return [];
}
Expand Down

0 comments on commit 7b7951a

Please sign in to comment.