Skip to content

ArgumentException when running diagnostic service on .net core #46687

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

Closed
genlu opened this issue Aug 10, 2020 · 16 comments
Closed

ArgumentException when running diagnostic service on .net core #46687

genlu opened this issue Aug 10, 2020 · 16 comments
Assignees
Labels
Area-IDE Concept-Continuous Improvement Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented
Milestone

Comments

@genlu
Copy link
Member

genlu commented Aug 10, 2020

Only happens when runing on servicehub core, don't repro on desktop. Deployed code is based on this PR #46026

servicehub log

08/10/2020 14:59:06 Pacific Standard Time: Error : 1 :[dotnet:27160] Unexpected exception: System.ArgumentException: Argument cannot be empty. (Parameter 'analyzers')
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.VerifyAnalyzersArgumentForStaticApis(ImmutableArray`1 analyzers, Boolean allowDefaultOrEmpty) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 176
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.VerifyArguments(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 161
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers..ctor(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 127
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers..ctor(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 121
   at Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzerExtensions.WithAnalyzers(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\DiagnosticAnalyzerExtensions.cs:line 34
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.<CreateCompilationWithAnalyzersCacheEntryAsync>g__CreateCompilationWithAnalyzerAsync|13_0(Project project, ImmutableArray`1 analyzers, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 262
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.CreateCompilationWithAnalyzersCacheEntryAsync(Project project, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 228
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.<>c__DisplayClass12_0.<<GetOrCreateCompilationWithAnalyzersAsync>g__GetOrCreateCacheEntryAsync|0>d.MoveNext() in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 201
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.GetOrCreateCompilationWithAnalyzersAsync(Project project, Boolean isDocumentAnalysis, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 185
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.GetDiagnosticsAsync(IEnumerable`1 analyzerIds, Boolean reportSuppressedDiagnostics, Boolean logPerformanceInfo, Boolean getTelemetryInfo, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 71
   at Microsoft.CodeAnalysis.Remote.CodeAnalysisService.<>c__DisplayClass17_0.<<CalculateDiagnosticsAsync>b__0>d.MoveNext() in C:\Users\gel\roslyn2\src\Workspaces\Remote\ServiceHub\Services\CodeAnalysisService_Diagnostics.cs:line 41
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.CodeAnalysis.Remote.ServiceBase.RunServiceAsync(Func`1 callAsync, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\ServiceHub\Shared\ServiceBase.cs:line 120
08/10/2020 14:59:06 Pacific Standard Time: Error : 1 :[dotnet:27160] Unexpected exception: System.ArgumentException: Argument cannot be empty. (Parameter 'analyzers')
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.VerifyAnalyzersArgumentForStaticApis(ImmutableArray`1 analyzers, Boolean allowDefaultOrEmpty) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 176
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.VerifyArguments(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 161
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers..ctor(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 127
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers..ctor(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 121
   at Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzerExtensions.WithAnalyzers(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\DiagnosticAnalyzerExtensions.cs:line 34
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.<CreateCompilationWithAnalyzersCacheEntryAsync>g__CreateCompilationWithAnalyzerAsync|13_0(Project project, ImmutableArray`1 analyzers, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 262
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.CreateCompilationWithAnalyzersCacheEntryAsync(Project project, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 228
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.<>c__DisplayClass12_0.<<GetOrCreateCompilationWithAnalyzersAsync>g__GetOrCreateCacheEntryAsync|0>d.MoveNext() in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 201
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.GetOrCreateCompilationWithAnalyzersAsync(Project project, Boolean isDocumentAnalysis, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 185
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.GetDiagnosticsAsync(IEnumerable`1 analyzerIds, Boolean reportSuppressedDiagnostics, Boolean logPerformanceInfo, Boolean getTelemetryInfo, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 71
   at Microsoft.CodeAnalysis.Remote.CodeAnalysisService.<>c__DisplayClass17_0.<<CalculateDiagnosticsAsync>b__0>d.MoveNext() in C:\Users\gel\roslyn2\src\Workspaces\Remote\ServiceHub\Services\CodeAnalysisService_Diagnostics.cs:line 41
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.CodeAnalysis.Remote.ServiceBase.RunServiceAsync(Func`1 callAsync, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\ServiceHub\Shared\ServiceBase.cs:line 120
08/10/2020 14:59:06 Pacific Standard Time: Error : 1 :[dotnet:27160] Unexpected exception: System.ArgumentException: Argument cannot be empty. (Parameter 'analyzers')
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.VerifyAnalyzersArgumentForStaticApis(ImmutableArray`1 analyzers, Boolean allowDefaultOrEmpty) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 176
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.VerifyArguments(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 161
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers..ctor(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 127
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers..ctor(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 121
   at Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzerExtensions.WithAnalyzers(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\DiagnosticAnalyzerExtensions.cs:line 34
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.<CreateCompilationWithAnalyzersCacheEntryAsync>g__CreateCompilationWithAnalyzerAsync|13_0(Project project, ImmutableArray`1 analyzers, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 262
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.CreateCompilationWithAnalyzersCacheEntryAsync(Project project, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 228
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.<>c__DisplayClass12_0.<<GetOrCreateCompilationWithAnalyzersAsync>g__GetOrCreateCacheEntryAsync|0>d.MoveNext() in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 201
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.GetOrCreateCompilationWithAnalyzersAsync(Project project, Boolean isDocumentAnalysis, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 185
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.GetDiagnosticsAsync(IEnumerable`1 analyzerIds, Boolean reportSuppressedDiagnostics, Boolean logPerformanceInfo, Boolean getTelemetryInfo, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 71
   at Microsoft.CodeAnalysis.Remote.CodeAnalysisService.<>c__DisplayClass17_0.<<CalculateDiagnosticsAsync>b__0>d.MoveNext() in C:\Users\gel\roslyn2\src\Workspaces\Remote\ServiceHub\Services\CodeAnalysisService_Diagnostics.cs:line 41
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.CodeAnalysis.Remote.ServiceBase.RunServiceAsync(Func`1 callAsync, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\ServiceHub\Shared\ServiceBase.cs:line 120
08/10/2020 14:59:07 Pacific Standard Time: Error : 1 :[dotnet:27160] Unexpected exception: System.ArgumentException: Argument cannot be empty. (Parameter 'analyzers')
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.VerifyAnalyzersArgumentForStaticApis(ImmutableArray`1 analyzers, Boolean allowDefaultOrEmpty) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 176
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.VerifyArguments(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 161
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers..ctor(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 127
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers..ctor(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 121
   at Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzerExtensions.WithAnalyzers(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\DiagnosticAnalyzerExtensions.cs:line 34
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.<CreateCompilationWithAnalyzersCacheEntryAsync>g__CreateCompilationWithAnalyzerAsync|13_0(Project project, ImmutableArray`1 analyzers, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 262
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.CreateCompilationWithAnalyzersCacheEntryAsync(Project project, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 228
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.<>c__DisplayClass12_0.<<GetOrCreateCompilationWithAnalyzersAsync>g__GetOrCreateCacheEntryAsync|0>d.MoveNext() in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 201
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.GetOrCreateCompilationWithAnalyzersAsync(Project project, Boolean isDocumentAnalysis, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 185
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.GetDiagnosticsAsync(IEnumerable`1 analyzerIds, Boolean reportSuppressedDiagnostics, Boolean logPerformanceInfo, Boolean getTelemetryInfo, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 71
   at Microsoft.CodeAnalysis.Remote.CodeAnalysisService.<>c__DisplayClass17_0.<<CalculateDiagnosticsAsync>b__0>d.MoveNext() in C:\Users\gel\roslyn2\src\Workspaces\Remote\ServiceHub\Services\CodeAnalysisService_Diagnostics.cs:line 41
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.CodeAnalysis.Remote.ServiceBase.RunServiceAsync(Func`1 callAsync, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\ServiceHub\Shared\ServiceBase.cs:line 120
08/10/2020 14:59:07 Pacific Standard Time: Error : 1 :[dotnet:27160] Unexpected exception: System.ArgumentException: Argument cannot be empty. (Parameter 'analyzers')
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.VerifyAnalyzersArgumentForStaticApis(ImmutableArray`1 analyzers, Boolean allowDefaultOrEmpty) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 176
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.VerifyArguments(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 161
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers..ctor(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 127
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers..ctor(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 121
   at Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzerExtensions.WithAnalyzers(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\DiagnosticAnalyzerExtensions.cs:line 34
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.<CreateCompilationWithAnalyzersCacheEntryAsync>g__CreateCompilationWithAnalyzerAsync|13_0(Project project, ImmutableArray`1 analyzers, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 262
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.CreateCompilationWithAnalyzersCacheEntryAsync(Project project, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 228
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.<>c__DisplayClass12_0.<<GetOrCreateCompilationWithAnalyzersAsync>g__GetOrCreateCacheEntryAsync|0>d.MoveNext() in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 201
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.GetOrCreateCompilationWithAnalyzersAsync(Project project, Boolean isDocumentAnalysis, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 185
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.GetDiagnosticsAsync(IEnumerable`1 analyzerIds, Boolean reportSuppressedDiagnostics, Boolean logPerformanceInfo, Boolean getTelemetryInfo, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 71
   at Microsoft.CodeAnalysis.Remote.CodeAnalysisService.<>c__DisplayClass17_0.<<CalculateDiagnosticsAsync>b__0>d.MoveNext() in C:\Users\gel\roslyn2\src\Workspaces\Remote\ServiceHub\Services\CodeAnalysisService_Diagnostics.cs:line 41
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.CodeAnalysis.Remote.ServiceBase.RunServiceAsync(Func`1 callAsync, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\ServiceHub\Shared\ServiceBase.cs:line 120
08/10/2020 14:59:11 Pacific Standard Time: Error : 1 :[dotnet:27160] Unexpected exception: System.ArgumentException: Argument cannot be empty. (Parameter 'analyzers')
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.VerifyAnalyzersArgumentForStaticApis(ImmutableArray`1 analyzers, Boolean allowDefaultOrEmpty) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 176
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.VerifyArguments(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 161
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers..ctor(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 127
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers..ctor(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 121
   at Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzerExtensions.WithAnalyzers(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\DiagnosticAnalyzerExtensions.cs:line 34
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.<CreateCompilationWithAnalyzersCacheEntryAsync>g__CreateCompilationWithAnalyzerAsync|13_0(Project project, ImmutableArray`1 analyzers, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 262
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.CreateCompilationWithAnalyzersCacheEntryAsync(Project project, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 228
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.<>c__DisplayClass12_0.<<GetOrCreateCompilationWithAnalyzersAsync>g__GetOrCreateCacheEntryAsync|0>d.MoveNext() in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 201
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.GetOrCreateCompilationWithAnalyzersAsync(Project project, Boolean isDocumentAnalysis, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 185
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.GetDiagnosticsAsync(IEnumerable`1 analyzerIds, Boolean reportSuppressedDiagnostics, Boolean logPerformanceInfo, Boolean getTelemetryInfo, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 71
   at Microsoft.CodeAnalysis.Remote.CodeAnalysisService.<>c__DisplayClass17_0.<<CalculateDiagnosticsAsync>b__0>d.MoveNext() in C:\Users\gel\roslyn2\src\Workspaces\Remote\ServiceHub\Services\CodeAnalysisService_Diagnostics.cs:line 41
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.CodeAnalysis.Remote.ServiceBase.RunServiceAsync(Func`1 callAsync, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\ServiceHub\Shared\ServiceBase.cs:line 120
08/10/2020 14:59:17 Pacific Standard Time: Error : 1 :[dotnet:27160] Unexpected exception: System.ArgumentException: Argument cannot be empty. (Parameter 'analyzers')
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.VerifyAnalyzersArgumentForStaticApis(ImmutableArray`1 analyzers, Boolean allowDefaultOrEmpty) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 176
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.VerifyArguments(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 161
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers..ctor(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 127
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers..ctor(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 121
   at Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzerExtensions.WithAnalyzers(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\DiagnosticAnalyzerExtensions.cs:line 34
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.<CreateCompilationWithAnalyzersCacheEntryAsync>g__CreateCompilationWithAnalyzerAsync|13_0(Project project, ImmutableArray`1 analyzers, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 262
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.CreateCompilationWithAnalyzersCacheEntryAsync(Project project, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 228
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.<>c__DisplayClass12_0.<<GetOrCreateCompilationWithAnalyzersAsync>g__GetOrCreateCacheEntryAsync|0>d.MoveNext() in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 201
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.GetOrCreateCompilationWithAnalyzersAsync(Project project, Boolean isDocumentAnalysis, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 185
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.GetDiagnosticsAsync(IEnumerable`1 analyzerIds, Boolean reportSuppressedDiagnostics, Boolean logPerformanceInfo, Boolean getTelemetryInfo, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 71
   at Microsoft.CodeAnalysis.Remote.CodeAnalysisService.<>c__DisplayClass17_0.<<CalculateDiagnosticsAsync>b__0>d.MoveNext() in C:\Users\gel\roslyn2\src\Workspaces\Remote\ServiceHub\Services\CodeAnalysisService_Diagnostics.cs:line 41
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.CodeAnalysis.Remote.ServiceBase.RunServiceAsync(Func`1 callAsync, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\ServiceHub\Shared\ServiceBase.cs:line 120
08/10/2020 14:59:21 Pacific Standard Time: Error : 1 :[dotnet:27160] Unexpected exception: System.ArgumentException: Argument cannot be empty. (Parameter 'analyzers')
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.VerifyAnalyzersArgumentForStaticApis(ImmutableArray`1 analyzers, Boolean allowDefaultOrEmpty) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 176
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.VerifyArguments(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 161
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers..ctor(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 127
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers..ctor(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 121
   at Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzerExtensions.WithAnalyzers(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions) in C:\Users\gel\roslyn2\src\Compilers\Core\Portable\DiagnosticAnalyzer\DiagnosticAnalyzerExtensions.cs:line 34
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.<CreateCompilationWithAnalyzersCacheEntryAsync>g__CreateCompilationWithAnalyzerAsync|13_0(Project project, ImmutableArray`1 analyzers, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 262
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.CreateCompilationWithAnalyzersCacheEntryAsync(Project project, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 228
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.<>c__DisplayClass12_0.<<GetOrCreateCompilationWithAnalyzersAsync>g__GetOrCreateCacheEntryAsync|0>d.MoveNext() in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 201
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.GetOrCreateCompilationWithAnalyzersAsync(Project project, Boolean isDocumentAnalysis, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 185
   at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.GetDiagnosticsAsync(IEnumerable`1 analyzerIds, Boolean reportSuppressedDiagnostics, Boolean logPerformanceInfo, Boolean getTelemetryInfo, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\Core\Diagnostics\DiagnosticComputer.cs:line 71
   at Microsoft.CodeAnalysis.Remote.CodeAnalysisService.<>c__DisplayClass17_0.<<CalculateDiagnosticsAsync>b__0>d.MoveNext() in C:\Users\gel\roslyn2\src\Workspaces\Remote\ServiceHub\Services\CodeAnalysisService_Diagnostics.cs:line 41
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.CodeAnalysis.Remote.ServiceBase.RunServiceAsync(Func`1 callAsync, CancellationToken cancellationToken) in C:\Users\gel\roslyn2\src\Workspaces\Remote\ServiceHub\Shared\ServiceBase.cs:line 120

@genlu genlu added the Area-IDE label Aug 10, 2020
@genlu
Copy link
Member Author

genlu commented Aug 10, 2020

FYI @mavasani

@mavasani
Copy link
Contributor

Only happens when runing on servicehub core, don't repro on desktop

Are you somehow passing in empty analyzers? I can handle a graceful bail out to return zero diagnostics when queries with zero analyzers, but I think there might be something on your side to investigate why there are no analyzers being passed in. Note that the current implementation for all invocations into remote side has validation on in-proc side to not even call into the remote side for no analyzers or all suppressed analyzers case.

@mavasani
Copy link
Contributor

More specifically:

Debug.Assert(analyzerIds.Length > 0);

@mavasani
Copy link
Contributor

Paging in @tmat. I had an offline sync with Gen, and the issue seems to be happening in the DefaultAnalyzerAssemblyLoader when executed on core:

protected virtual Assembly LoadImpl(string fullPath) => _loadContext.LoadFromAssemblyPath(fullPath);

image

Basically, we export the compiler diagnostic analyzer from Microsoft.CodeAnalysis.CSharp.dll and mark it as an analyzer asset from Roslyn VSIX:

/// <summary>
/// DiagnosticAnalyzer for C# compiler's syntax/semantic/compilation diagnostics.
/// </summary>
[DiagnosticAnalyzer(LanguageNames.CSharp)]
internal sealed class CSharpCompilerDiagnosticAnalyzer : CompilerDiagnosticAnalyzer

<Asset Type="Microsoft.VisualStudio.Analyzer" Path="Microsoft.CodeAnalysis.CSharp.dll" />

Attempting to load analyzer assembly Microsoft.CodeAnalysis.CSharp.dll using the DefaultAnalyzerAssemblyLoader succeeds on desktop, but seems to fail on core with the assembly already loaded exception @genlu mentioned above. We use ShadowCopyAnalyzerAssemblyLoader for NuGet analyzer assemblies and DefaultAnalyzerAssemblyLoader for VSIX based ones, which seems reasonable as we don't expect assemblies from VSIX to be changed during a VS session (not sure that is true with OOP mode though).

@genlu
Copy link
Member Author

genlu commented Aug 14, 2020

@tmat thoughts?

@tmat
Copy link
Member

tmat commented Aug 14, 2020

DefaultAnalyzerAssemblyLoader.Core.cs uses the load context that Roslyn assemblies are loaded into. When loading an assembly from a path it does not check whether given assembly has already been loaded or not. It makes sense then that if we try to load a Roslyn assembly again it fails with the above error. Seems like we are missing quite a bit of test coverage here.

@genlu
Copy link
Member Author

genlu commented Aug 14, 2020

@tmat Do you know what a proper fix would be? Also @sharwell is trying to enable workspace tests on core, I assume that would cover this?
#45813

@tmat
Copy link
Member

tmat commented Aug 15, 2020

@genlu There are multiple possible fixes depending on what we want our policy of loading analyzer assemblies and their dependencies to be.
One option would be that each analyzer package (directory) has its own AssemblyLoadContext and its dependencies are loaded to this context and thus isolated from other analyzers. Roslyn assemblies would be loaded to a shared context since all analyzers need Roslyn types.

@mavasani
Copy link
Contributor

@genlu @sharwell I have tagged this to be discussed at today's meeting so @genlu can be unblocked here. @tmat Would you be able to attend the design meeting today?

@JoeRobich
Copy link
Member

In this week's design meeting, it was decided this issue didn't need review.

@mavasani
Copy link
Contributor

@sharwell @tmat do we have conclusion on this one?

@mavasani mavasani modified the milestones: 16.8, 16.9 Sep 24, 2020
@jinujoseph jinujoseph modified the milestones: 16.9, 16.10 Mar 28, 2021
@mavasani
Copy link
Contributor

In this week's design meeting, it was decided this issue didn't need review.

@JoeRobich This was marked for design review based on @tmat's comment here: #46687 (comment). Do you recall why this was marked as not needing review?

@sharwell
Copy link
Contributor

The analyzer driver on .NET Core needs to create an Assembly Load Context (ALC) for each unique directory containing one or more analyzer references. This should eliminate the conflict.

@JoeRobich
Copy link
Member

Do you recall why this was marked as not needing review?

@mavasani In the meeting @sharwell said that it seemed like an implementation detail and he had a proposal for the compiler team.

The analyzer driver on .NET Core needs to create an Assembly Load Context (ALC) for each unique directory containing one or more analyzer references.

Also, recommend using the AssemblyDepenencyResolver within the custom load context. This is a change (dotnet/format#1128) we recently made in dotnet-format to load the Razor source generator dependencies as they no longer ship in the same folder. This class will load them from the "deps.json" that is packaged with the assembly being loaded.

@genlu
Copy link
Member Author

genlu commented Jul 9, 2021

Hey @mavasani, any update on this?

@jinujoseph jinujoseph modified the milestones: 16.10, Backlog Jul 16, 2021
@genlu genlu assigned genlu and unassigned mavasani Jul 16, 2021
@genlu genlu modified the milestones: Backlog, 17.0 Jul 16, 2021
@genlu
Copy link
Member Author

genlu commented Aug 9, 2021

The proposed ALC change is a duplicate of #52177, and is implemented in #55098

@genlu genlu closed this as completed Aug 9, 2021
@genlu genlu added the Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented label Aug 9, 2021
@sharwell sharwell moved this to Complete in IDE: Design review Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Concept-Continuous Improvement Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented
Projects
Archived in project
Development

No branches or pull requests

6 participants