-
Notifications
You must be signed in to change notification settings - Fork 231
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
S6934 throws AD0001 a lot - SymbolStartAnalysisContextWrapper uncaught exception #9022
Comments
Thanks @cg110 for raising this. Do you have a small reproducer that could help us? Otherwise, yes, we'd need the full binary logs. |
How are you using this to compile? You are not using the .NET SDK (dotnet build or msbuild)?
Out of curiosity, what version of SQ are you using? |
It's a bit complicated, the compiler nuget is included in every build job, so it's used instead of the sdk one (mainly just trying to keep on top of everything upstream) We use the 8.0.3 sdk at the moment (8.0.203) We use the Roslyn analyzer nuget directly in nearly all builds. We don't use sonar msbuild for most builds as it crippled our build times, so it's used for key branches (main & releases as 99% of the warnings are found by the Roslyn analyzer, and the security ones from sq server are rare to flag anything). I'd have to check the version, it's fairly recent. I tried to repro it on the file with the problem but it wouldn't do it could be it needs a full build env and use of shared compilation, so the compiler processes are reused. |
Scanner (when used is 5.14.0) and server is 9.9 as the server is maintained on LTS versions. |
Hi @cg110 We weren't able to reproduce this without manually removing the "Microsoft.CodeAnalysis.VisualBasic" DLL from the "microsoft.net.compilers.toolset" NuGet. Because of this, we won't do a fix before SQ 10.5 (to be released next week), because we wouldn't be sure of the underlying problem. To test a workaround: could you please check if disabling rules S6931 and S6934 from your Quality Profile removes the issue? Also, we need the binlogs to continue investigation.
Thank you for helping to find this. |
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:
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.
Related information
The text was updated successfully, but these errors were encountered: