Skip to content

Commit 96acf7f

Browse files
Simplify processing of errors reported by the build (#79964)
2 parents 2a2f7bb + f6daf7d commit 96acf7f

File tree

6 files changed

+79
-260
lines changed

6 files changed

+79
-260
lines changed

src/Features/Core/Portable/Diagnostics/IDiagnosticAnalyzerService.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,6 @@ Task<ImmutableArray<DiagnosticData>> GetDiagnosticsForSpanAsync(
8787
Task<ImmutableArray<DiagnosticDescriptor>> GetDiagnosticDescriptorsAsync(
8888
Solution solution, ProjectId projectId, AnalyzerReference analyzerReference, string language, CancellationToken cancellationToken);
8989

90-
/// <summary>
91-
/// Given a list of errors ids (like CS1234), attempts to find an associated descriptor for each id.
92-
/// </summary>
93-
Task<ImmutableDictionary<string, DiagnosticDescriptor>> TryGetDiagnosticDescriptorsAsync(
94-
Solution solution, ImmutableArray<string> diagnosticIds, CancellationToken cancellationToken);
95-
9690
/// <inheritdoc cref="HostDiagnosticAnalyzers.GetDiagnosticDescriptorsPerReference(DiagnosticAnalyzerInfoCache)"/>
9791
Task<ImmutableDictionary<string, ImmutableArray<DiagnosticDescriptor>>> GetDiagnosticDescriptorsPerReferenceAsync(
9892
Solution solution, CancellationToken cancellationToken);

src/Features/Core/Portable/Diagnostics/Service/DiagnosticAnalyzerService_RemoteOrLocalDispatcher.cs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -60,35 +60,6 @@ public async Task<ImmutableArray<DiagnosticDescriptor>> GetDiagnosticDescriptors
6060
.SelectManyAsArray(this._analyzerInfoCache.GetDiagnosticDescriptors);
6161
}
6262

63-
public async Task<ImmutableDictionary<string, DiagnosticDescriptor>> TryGetDiagnosticDescriptorsAsync(
64-
Solution solution, ImmutableArray<string> diagnosticIds, CancellationToken cancellationToken)
65-
{
66-
var client = await RemoteHostClient.TryGetClientAsync(solution.Services, cancellationToken).ConfigureAwait(false);
67-
if (client is not null)
68-
{
69-
var map = await client.TryInvokeAsync<IRemoteDiagnosticAnalyzerService, ImmutableDictionary<string, DiagnosticDescriptorData>>(
70-
solution,
71-
(service, solution, cancellationToken) => service.TryGetDiagnosticDescriptorsAsync(solution, diagnosticIds, cancellationToken),
72-
cancellationToken).ConfigureAwait(false);
73-
74-
if (!map.HasValue)
75-
return ImmutableDictionary<string, DiagnosticDescriptor>.Empty;
76-
77-
return map.Value.ToImmutableDictionary(
78-
kvp => kvp.Key,
79-
kvp => kvp.Value.ToDiagnosticDescriptor());
80-
}
81-
82-
var builder = ImmutableDictionary.CreateBuilder<string, DiagnosticDescriptor>();
83-
foreach (var diagnosticId in diagnosticIds)
84-
{
85-
if (this._analyzerInfoCache.TryGetDescriptorForDiagnosticId(diagnosticId, out var descriptor))
86-
builder[diagnosticId] = descriptor;
87-
}
88-
89-
return builder.ToImmutable();
90-
}
91-
9263
public async Task<ImmutableDictionary<string, ImmutableArray<DiagnosticDescriptor>>> GetDiagnosticDescriptorsPerReferenceAsync(Solution solution, CancellationToken cancellationToken)
9364
{
9465
var client = await RemoteHostClient.TryGetClientAsync(solution.Services, cancellationToken).ConfigureAwait(false);

src/VisualStudio/Core/Def/TaskList/ExternalErrorDiagnosticUpdateSource.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.TaskList;
4040
internal sealed class ExternalErrorDiagnosticUpdateSource : IDisposable
4141
{
4242
private readonly Workspace _workspace;
43-
public readonly IAsynchronousOperationListener Listener;
44-
public readonly CancellationToken DisposalToken;
4543
private readonly IServiceBroker _serviceBroker;
4644

4745
/// <summary>
@@ -70,17 +68,14 @@ public ExternalErrorDiagnosticUpdateSource(
7068
[Import(typeof(SVsFullAccessServiceBroker))] IServiceBroker serviceBroker,
7169
IThreadingContext threadingContext)
7270
{
73-
DisposalToken = threadingContext.DisposalToken;
7471
_workspace = workspace;
75-
Listener = listenerProvider.GetListener(FeatureAttribute.ErrorList);
7672

7773
_serviceBroker = serviceBroker;
7874
_taskQueue = new AsyncBatchingWorkQueue<Func<CancellationToken, Task>>(
7975
TimeSpan.Zero,
8076
processBatchAsync: ProcessTaskQueueItemsAsync,
81-
Listener,
82-
DisposalToken
83-
);
77+
listenerProvider.GetListener(FeatureAttribute.ErrorList),
78+
threadingContext.DisposalToken);
8479

8580
// This pattern ensures that we are called whenever the build starts/completes even if it is already in progress.
8681
KnownUIContexts.SolutionBuildingContext.WhenActivated(() =>

0 commit comments

Comments
 (0)