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

Report external build errors using the platform's diagnostic brokered #73477

Merged
merged 2 commits into from
May 15, 2024

Conversation

dibarbet
Copy link
Member

@dibarbet dibarbet commented May 14, 2024

service instead of via Roslyn

Looks like
image

Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2032334

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels May 14, 2024
@dibarbet dibarbet force-pushed the external_errors_support branch 7 times, most recently from 9c076e0 to 9972d99 Compare May 15, 2024 04:26
_externalErrorReporter = new ProjectExternalErrorReporter(ProjectSystemProject.Id, externalErrorReportingPrefix, language, workspaceImpl);
var projectHierarchyGuid = GetProjectIDGuid(hierarchy);

_externalErrorReporter = new ProjectExternalErrorReporter(ProjectSystemProject.Id, projectHierarchyGuid, externalErrorReportingPrefix, language, workspaceImpl);
Copy link
Member Author

Choose a reason for hiding this comment

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

hierarchy guid is required for the current project filter to work in the error list.

{
using var _ = CodeAnalysis.PooledObjects.ArrayBuilder<DiagnosticData>.GetInstance(out var builder);

var buildDiagnostics = _buildErrorDiagnosticService.GetBuildErrors().Where(d => d.ProjectId != null && d.Severity != DiagnosticSeverity.Hidden);
Copy link
Member Author

@dibarbet dibarbet May 15, 2024

Choose a reason for hiding this comment

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

This never returned diagnostics with LSP on (and cannot). per convo with @CyrusNajmabadi removing this is fine.


namespace Microsoft.CodeAnalysis.Diagnostics;

[ExportWorkspaceServiceFactory(typeof(IBuildOnlyDiagnosticsService), ServiceLayer.Default), Shared]
Copy link
Member Author

Choose a reason for hiding this comment

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

Dead - does not return build only diagnostic with LSP pull

@@ -116,9 +116,6 @@ internal partial class CodeFixService : ICodeFixService
var copilotDiagnostics = await GetCopilotDiagnosticsAsync(document, range, priorityProvider.Priority, cancellationToken).ConfigureAwait(false);
allDiagnostics = allDiagnostics.AddRange(copilotDiagnostics);

var buildOnlyDiagnosticsService = document.Project.Solution.Services.GetRequiredService<IBuildOnlyDiagnosticsService>();
Copy link
Member Author

@dibarbet dibarbet May 15, 2024

Choose a reason for hiding this comment

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

Dead - this would always get an empty set with LSP pull.

@@ -219,7 +169,7 @@ void computeDiagnosticsToFix(IUIThreadOperationContext context)
// snapshots. Otherwise, get all diagnostics from the diagnostic service.
var diagnosticsToFixTask = selectedEntriesOnly
? _suppressionStateService.GetSelectedItemsAsync(isAddSuppression, cancellationToken)
: GetAllBuildDiagnosticsAsync(shouldFixInProject, cancellationToken);
: Task.FromResult<ImmutableArray<DiagnosticData>>([]);
Copy link
Member Author

Choose a reason for hiding this comment

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

didn't feel comfortable removing a ton more things here for servicing. can re-evaluate in main how much (if any) of this type is needed.

/// </summary>
[Export(typeof(ExternalErrorDiagnosticUpdateSource))]
Copy link
Member Author

Choose a reason for hiding this comment

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

meat of the change in this type. The change here is to report build diagnostics to the editor's diagnostic brokered service. Without this, the build diagnostics reported here go into the void. THis was fine for CPS projects because they are responsible for reporting build errors to the service.

However legacy csproj project system was not updated to do the same, so build diagnostics for legacy csproj went into the void.

This changes our reporter to instead report the build diagnostics to the brokered service. Long term legacy csproj should be updated to use the brokered service themselves, but requires additional work to enable brokered service usage in C++.

@dibarbet dibarbet marked this pull request as ready for review May 15, 2024 19:42
@dibarbet dibarbet requested a review from a team as a code owner May 15, 2024 19:42
@dibarbet dibarbet merged commit 91c7736 into dotnet:release/dev17.10 May 15, 2024
21 of 27 checks passed
@dibarbet dibarbet deleted the external_errors_support branch May 15, 2024 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants