-
Notifications
You must be signed in to change notification settings - Fork 729
Closed
dotnet/roslyn
#69419Labels
Description
I am intermittently seeing the below exception in C# extension when changing background analysis scope option for compiler and analyzer diagnostics:
[Error - 11:54:21 AM] [LanguageServerHost]System.ArgumentException: Argument cannot be empty. (Parameter 'analyzers')
at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.VerifyAnalyzersArgumentForStaticApis(ImmutableArray`1 analyzers, Boolean allowDefaultOrEmpty) in /_/src/Compilers/Core/Portable/DiagnosticAnalyzer/CompilationWithAnalyzers.cs:line 136
at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.VerifyExistingAnalyzersArgument(ImmutableArray`1 analyzers) in /_/src/Compilers/Core/Portable/DiagnosticAnalyzer/CompilationWithAnalyzers.cs:line 171
at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.GetAnalysisResultAsync(SyntaxTree tree, Nullable`1 filterSpan, ImmutableArray`1 analyzers, CancellationToken cancellationToken) in /_/src/Compilers/Core/Portable/DiagnosticAnalyzer/CompilationWithAnalyzers.cs:line 507
at Microsoft.CodeAnalysis.Diagnostics.Extensions.GetAnalysisResultAsync(CompilationWithAnalyzers compilationWithAnalyzers, DocumentAnalysisScope documentAnalysisScope, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/Diagnostics/Extensions.cs:line 349
at Microsoft.CodeAnalysis.Diagnostics.Extensions.GetAnalysisResultAsync(CompilationWithAnalyzers compilationWithAnalyzers, DocumentAnalysisScope documentAnalysisScope, Project project, DiagnosticAnalyzerInfoCache analyzerInfoCache, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/Diagnostics/Extensions.cs:line 325
at Microsoft.CodeAnalysis.Diagnostics.InProcOrRemoteHostAnalyzerRunner.AnalyzeInProcAsync(DocumentAnalysisScope documentAnalysisScope, Project project, CompilationWithAnalyzers compilationWithAnalyzers, RemoteHostClient client, Boolean logPerformanceInfo, Boolean getTelemetryInfo, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Features/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer.InProcOrRemoteHostAnalyzerRunner.cs:line 100
at Microsoft.CodeAnalysis.Diagnostics.InProcOrRemoteHostAnalyzerRunner.<>c__DisplayClass7_0.<<AnalyzeAsync>g__AnalyzeCoreAsync|0>d.MoveNext() in /_/src/Features/LanguageServer/Protocol/Features/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer.InProcOrRemoteHostAnalyzerRunner.cs:line 84
--- End of stack trace from previous location ---
at Microsoft.CodeAnalysis.Diagnostics.InProcOrRemoteHostAnalyzerRunner.AnalyzeAsync(DocumentAnalysisScope documentAnalysisScope, Project project, CompilationWithAnalyzers compilationWithAnalyzers, Boolean isExplicit, Boolean forceExecuteAllAnalyzers, Boolean logPerformanceInfo, Boolean getTelemetryInfo, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Features/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer.InProcOrRemoteHostAnalyzerRunner.cs:line 69
at Microsoft.CodeAnalysis.Diagnostics.DocumentAnalysisExecutor.GetAnalysisResultAsync(DocumentAnalysisScope analysisScope, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Features/Diagnostics/DocumentAnalysisExecutor.cs:line 188
at Microsoft.CodeAnalysis.Diagnostics.DocumentAnalysisExecutor.GetSyntaxDiagnosticsAsync(DiagnosticAnalyzer analyzer, Boolean isCompilerAnalyzer, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Features/Diagnostics/DocumentAnalysisExecutor.cs:line 242
at Microsoft.CodeAnalysis.Diagnostics.DocumentAnalysisExecutor.ComputeDiagnosticsAsync(DiagnosticAnalyzer analyzer, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Features/Diagnostics/DocumentAnalysisExecutor.cs:line 153
at Microsoft.CodeAnalysis.Diagnostics.EngineV2.DiagnosticIncrementalAnalyzer.LatestDiagnosticsForSpanGetter.ComputeDocumentDiagnosticsForAnalyzerCoreAsync(DiagnosticAnalyzer analyzer, DocumentAnalysisExecutor executor, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Features/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer_GetDiagnosticsForSpan.cs:line 576
at Microsoft.CodeAnalysis.Diagnostics.EngineV2.DiagnosticIncrementalAnalyzer.LatestDiagnosticsForSpanGetter.ComputeDocumentDiagnosticsCoreAsync(DocumentAnalysisExecutor executor, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Features/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer_GetDiagnosticsForSpan.cs:line 556
at Microsoft.CodeAnalysis.Diagnostics.EngineV2.DiagnosticIncrementalAnalyzer.LatestDiagnosticsForSpanGetter.ComputeDocumentDiagnosticsAsync(ImmutableArray`1 analyzersWithState, AnalysisKind kind, Nullable`1 span, ArrayBuilder`1 builder, Boolean incrementalAnalysis, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Features/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer_GetDiagnosticsForSpan.cs:line 547
at Microsoft.CodeAnalysis.Diagnostics.EngineV2.DiagnosticIncrementalAnalyzer.LatestDiagnosticsForSpanGetter.TryGetAsync(ArrayBuilder`1 list, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Features/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer_GetDiagnosticsForSpan.cs:line 275
at Microsoft.CodeAnalysis.Diagnostics.EngineV2.DiagnosticIncrementalAnalyzer.TryAppendDiagnosticsForSpanAsync(TextDocument document, Nullable`1 range, ArrayBuilder`1 result, Func`2 shouldIncludeDiagnostic, Boolean includeSuppressedDiagnostics, Boolean includeCompilerDiagnostics, ICodeActionRequestPriorityProvider priorityProvider, Boolean blockForData, Func`2 addOperationScope, DiagnosticKind diagnosticKinds, Boolean isExplicit, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Features/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer_GetDiagnosticsForSpan.cs:line 34
at Microsoft.CodeAnalysis.Diagnostics.EngineV2.DiagnosticIncrementalAnalyzer.GetDiagnosticsForSpanAsync(TextDocument document, Nullable`1 range, Func`2 shouldIncludeDiagnostic, Boolean includeSuppressedDiagnostics, Boolean includeCompilerDiagnostics, ICodeActionRequestPriorityProvider priorityProvider, Boolean blockForData, Func`2 addOperationScope, DiagnosticKind diagnosticKinds, Boolean isExplicit, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Features/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer_GetDiagnosticsForSpan.cs:line 51
at Microsoft.CodeAnalysis.CodeFixes.CodeFixService.StreamFixesAsync(TextDocument document, TextSpan range, ICodeActionRequestPriorityProvider priorityProvider, CodeActionOptionsProvider fallbackOptions, Func`2 addOperationScope, CancellationToken cancellationToken)+MoveNext() in /_/src/Features/LanguageServer/Protocol/Features/CodeFixes/CodeFixService.cs:line 194
at Microsoft.CodeAnalysis.CodeFixes.CodeFixService.StreamFixesAsync(TextDocument document, TextSpan range, ICodeActionRequestPriorityProvider priorityProvider, CodeActionOptionsProvider fallbackOptions, Func`2 addOperationScope, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
at Microsoft.CodeAnalysis.Shared.Extensions.IAsyncEnumerableExtensions.ToImmutableArrayAsync[T](IAsyncEnumerable`1 values, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/Shared/Extensions/IAsyncEnumerableExtensions.cs:line 32
at Microsoft.CodeAnalysis.Shared.Extensions.IAsyncEnumerableExtensions.ToImmutableArrayAsync[T](IAsyncEnumerable`1 values, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/Shared/Extensions/IAsyncEnumerableExtensions.cs:line 32
at Microsoft.CodeAnalysis.UnifiedSuggestions.UnifiedSuggestedActionsSource.GetFilterAndOrderCodeFixesAsync(Workspace workspace, ICodeFixService codeFixService, TextDocument document, TextSpan selection, ICodeActionRequestPriorityProvider priorityProvider, CodeActionOptionsProvider fallbackOptions, Func`2 addOperationScope, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Features/UnifiedSuggestions/UnifiedSuggestedActionsSource.cs:line 48
at Microsoft.CodeAnalysis.LanguageServer.Handler.CodeActions.CodeActionHelpers.GetActionSetsAsync(Document document, CodeActionOptionsProvider fallbackOptions, ICodeFixService codeFixService, ICodeRefactoringService codeRefactoringService, Range selection, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionHelpers.cs:line 319
at Microsoft.CodeAnalysis.LanguageServer.Handler.CodeActions.CodeActionHelpers.GetVSCodeActionsAsync(CodeActionParams request, Document document, CodeActionOptionsProvider fallbackOptions, ICodeFixService codeFixService, ICodeRefactoringService codeRefactoringService, Boolean hasVsLspCapability, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionHelpers.cs:line 40
at Microsoft.CodeAnalysis.LanguageServer.Handler.CodeActionsHandler.HandleRequestAsync(CodeActionParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionsHandler.cs:line 61
at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 176
[Error - 11:54:21 AM] Request textDocument/codeAction failed.
Message: Argument cannot be empty. (Parameter 'analyzers')
Code: -32000
I believe there seems to be a missing check for empty trimmed down analyzers based on these options.