-
Notifications
You must be signed in to change notification settings - Fork 237
Description
Description
Since upgrading to 9.23.0 and 9.23.1 (I had hoped 9.23.1 would fix this as it's mentioned in the release notes) we've seen an increase in the number of AD0001 from SQ - rules S6934 :
CSC error AD0001: Analyzer 'SonarAnalyzer.Rules.CSharp.SpecifyRouteAttribute' threw an exception of type 'System.TypeInitializationException' with message 'The type initializer for 'SonarAnalyzer.ShimLayer.AnalysisContext.SymbolStartAnalysisContextWrapper' threw an exception.'.
Binary log provides a full stack:
System.TypeInitializationException: The type initializer for 'SonarAnalyzer.ShimLayer.AnalysisContext.SymbolStartAnalysisContextWrapper' threw an exception.
---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.CodeAnalysis.VisualBasic, Version=1.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
File name: 'Microsoft.CodeAnalysis.VisualBasic, Version=1.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
at SonarAnalyzer.ShimLayer.AnalysisContext.SymbolStartAnalysisContextWrapper..cctor()
--- End of inner exception stack trace ---
at lambda_method2(Closure , SymbolStartAnalysisContext )
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c.<ExecuteSymbolStartActions>b__42_0(ValueTuple`2 data)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken)
It suggests disabling S6934:
Suppress the following diagnostics to disable this analyzer: S6934
Note that we're using the latest compiler via nuget:
microsoft.net.compilers.toolset 4.9.2
We're seeing this on build servers and locally, with VS 2022 17.9.2 and 17.9.5.
My impression is that it only seems to be in multi-framework dlls, and seems to impact the .net 6, 7 & 8 builds.
Repro steps
It seems to be intermittent, and doesn't happen on every build..
The code it tends to dislike is related to WCF. I'll look into raising a support case if you need full binary logs.
Known workarounds
I'm looking at downgrading to 9.22 or disabling S6934.