-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Remove build-only diagnostics functionality no longer used in product #72941
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,22 +12,17 @@ | |
| namespace Microsoft.CodeAnalysis.Diagnostics; | ||
|
|
||
| [ExportWorkspaceServiceFactory(typeof(IBuildOnlyDiagnosticsService), ServiceLayer.Default), Shared] | ||
| internal sealed class BuildOnlyDiagnosticsServiceFactory : IWorkspaceServiceFactory | ||
| [method: ImportingConstructor] | ||
| [method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] | ||
| internal sealed class BuildOnlyDiagnosticsServiceFactory() : IWorkspaceServiceFactory | ||
| { | ||
| [ImportingConstructor] | ||
| [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] | ||
| public BuildOnlyDiagnosticsServiceFactory() | ||
| { | ||
| } | ||
|
|
||
| public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) | ||
| => new BuildOnlyDiagnosticsService(workspaceServices.Workspace); | ||
|
|
||
| private sealed class BuildOnlyDiagnosticsService : IBuildOnlyDiagnosticsService | ||
| { | ||
| private readonly object _gate = new(); | ||
| private readonly Dictionary<DocumentId, ImmutableArray<DiagnosticData>> _documentDiagnostics = []; | ||
| private readonly Dictionary<ProjectId, ImmutableArray<DiagnosticData>> _projectDiagnostics = []; | ||
|
|
||
| public BuildOnlyDiagnosticsService(Workspace workspace) | ||
| { | ||
|
|
@@ -61,18 +56,12 @@ private void OnWorkspaceChanged(object? sender, WorkspaceChangeEventArgs e) | |
| } | ||
| } | ||
|
|
||
| public void AddBuildOnlyDiagnostics(Solution solution, ProjectId? projectId, DocumentId? documentId, ImmutableArray<DiagnosticData> diagnostics) | ||
| public void AddBuildOnlyDiagnostics(DocumentId documentId, ImmutableArray<DiagnosticData> diagnostics) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since nothing was reading the project side, we only need to call this for teh document side of things. |
||
| { | ||
| lock (_gate) | ||
| { | ||
| if (documentId != null) | ||
| { | ||
| _documentDiagnostics[documentId] = diagnostics; | ||
| } | ||
| else if (projectId != null) | ||
| { | ||
| _projectDiagnostics[projectId] = diagnostics; | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -81,7 +70,6 @@ private void ClearAllDiagnostics() | |
| lock (_gate) | ||
| { | ||
| _documentDiagnostics.Clear(); | ||
| _projectDiagnostics.Clear(); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -103,43 +91,24 @@ private void ClearDiagnostics(Project? project) | |
|
|
||
| lock (_gate) | ||
| { | ||
| _projectDiagnostics.Remove(project.Id); | ||
| foreach (var documentId in project.DocumentIds) | ||
| _documentDiagnostics.Remove(documentId); | ||
| } | ||
| } | ||
|
|
||
| public void ClearBuildOnlyDiagnostics(Solution solution, ProjectId? projectId, DocumentId? documentId) | ||
| public void ClearBuildOnlyDiagnostics(Project project, DocumentId? documentId) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. passing in a project-id here meant 'clear out project diags, and all diags for any document in this project'. So, maintaining that logic here. |
||
| { | ||
| if (documentId != null) | ||
| ClearDiagnostics(documentId); | ||
| else | ||
| ClearDiagnostics(solution.GetProject(projectId)); | ||
| ClearDiagnostics(project); | ||
| } | ||
|
|
||
| public ImmutableArray<DiagnosticData> GetBuildOnlyDiagnostics(DocumentId documentId) | ||
| { | ||
| lock (_gate) | ||
| { | ||
| if (_documentDiagnostics.TryGetValue(documentId, out var diagnostics)) | ||
| { | ||
| return diagnostics; | ||
| } | ||
|
|
||
| return []; | ||
| } | ||
| } | ||
|
|
||
| public ImmutableArray<DiagnosticData> GetBuildOnlyDiagnostics(ProjectId projectId) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. only called in a single test method, no other product code called this. |
||
| { | ||
| lock (_gate) | ||
| { | ||
| if (_projectDiagnostics.TryGetValue(projectId, out var diagnostics)) | ||
| { | ||
| return diagnostics; | ||
| } | ||
|
|
||
| return []; | ||
| return _documentDiagnostics.TryGetValue(documentId, out var diagnostics) ? diagnostics : []; | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data in this was never read in any product code. only in a single test. remove it, and updated codepaths affected by it.