Skip to content

Commit d18fa49

Browse files
Remove unnecessary flag in diagnostics subsystem (#77882)
This flag is unneeded, due to all pull diagnostics handler running this code first: ```c# public async Task<TReturn?> HandleRequestAsync( TDiagnosticsParams diagnosticsParams, RequestContext context, CancellationToken cancellationToken) { // The progress object we will stream reports to. using var progress = BufferedProgress.Create(diagnosticsParams.PartialResultToken); // We only support this option to disable crawling in internal speedometer and ddrit perf runs to lower // noise. It is not exposed to the user. if (!this.GlobalOptions.GetOption(SolutionCrawlerRegistrationService.EnableSolutionCrawler)) { context.TraceInformation($"{this.GetType()}. Skipping due to {nameof(SolutionCrawlerRegistrationService.EnableSolutionCrawler)}={false}"); } ```
2 parents 9c09627 + 54fcff1 commit d18fa49

File tree

3 files changed

+2
-14
lines changed

3 files changed

+2
-14
lines changed

src/LanguageServer/Protocol/Features/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.Threading;
99
using System.Threading.Tasks;
1010
using Microsoft.CodeAnalysis.Options;
11-
using Microsoft.CodeAnalysis.SolutionCrawler;
1211

1312
namespace Microsoft.CodeAnalysis.Diagnostics;
1413

@@ -40,9 +39,7 @@ public DiagnosticIncrementalAnalyzer(
4039

4140
_stateManager = new StateManager(analyzerInfoCache);
4241

43-
var enabled = globalOptionService.GetOption(SolutionCrawlerRegistrationService.EnableSolutionCrawler);
44-
_diagnosticAnalyzerRunner = new InProcOrRemoteHostAnalyzerRunner(
45-
enabled, analyzerInfoCache, analyzerService.Listener);
42+
_diagnosticAnalyzerRunner = new InProcOrRemoteHostAnalyzerRunner(analyzerInfoCache, analyzerService.Listener);
4643
}
4744

4845
internal IGlobalOptionService GlobalOptions { get; }

src/LanguageServer/Protocol/Features/Diagnostics/EngineV2/InProcOrRemoteHostAnalyzerRunner.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,13 @@ namespace Microsoft.CodeAnalysis.Diagnostics;
2222

2323
internal sealed class InProcOrRemoteHostAnalyzerRunner
2424
{
25-
private readonly bool _enabled;
2625
private readonly IAsynchronousOperationListener _asyncOperationListener;
2726
public DiagnosticAnalyzerInfoCache AnalyzerInfoCache { get; }
2827

2928
public InProcOrRemoteHostAnalyzerRunner(
30-
bool enabled,
3129
DiagnosticAnalyzerInfoCache analyzerInfoCache,
3230
IAsynchronousOperationListener? operationListener = null)
3331
{
34-
_enabled = enabled;
3532
AnalyzerInfoCache = analyzerInfoCache;
3633
_asyncOperationListener = operationListener ?? AsynchronousOperationListenerProvider.NullListener;
3734
}
@@ -64,9 +61,6 @@ private async Task<DiagnosticAnalysisResultMap<DiagnosticAnalyzer, DiagnosticAna
6461
bool getTelemetryInfo,
6562
CancellationToken cancellationToken)
6663
{
67-
if (!_enabled)
68-
return DiagnosticAnalysisResultMap<DiagnosticAnalyzer, DiagnosticAnalysisResult>.Empty;
69-
7064
var result = await AnalyzeCoreAsync().ConfigureAwait(false);
7165
Debug.Assert(getTelemetryInfo || result.TelemetryInfo.IsEmpty);
7266
return result;
@@ -89,9 +83,6 @@ async Task<DiagnosticAnalysisResultMap<DiagnosticAnalyzer, DiagnosticAnalysisRes
8983

9084
public async Task<ImmutableArray<Diagnostic>> GetSourceGeneratorDiagnosticsAsync(Project project, CancellationToken cancellationToken)
9185
{
92-
if (!_enabled)
93-
return [];
94-
9586
var options = project.Solution.Services.GetRequiredService<IWorkspaceConfigurationService>().Options;
9687
var remoteHostClient = await RemoteHostClient.TryGetClientAsync(project, cancellationToken).ConfigureAwait(false);
9788
if (remoteHostClient != null)

src/VisualStudio/Core/Test.Next/Services/VisualStudioDiagnosticAnalyzerExecutorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ void Method()
212212
}
213213

214214
private static InProcOrRemoteHostAnalyzerRunner CreateAnalyzerRunner()
215-
=> new(enabled: true, new DiagnosticAnalyzerInfoCache());
215+
=> new(new DiagnosticAnalyzerInfoCache());
216216

217217
private static async Task<DiagnosticAnalysisResult> AnalyzeAsync(TestWorkspace workspace, ProjectId projectId, Type analyzerType, bool isHostAnalyzer, CancellationToken cancellationToken = default)
218218
{

0 commit comments

Comments
 (0)