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

Do not attempt to report EnC diagnostics for non-host workspaces #75138

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading