Window 10 22H2
Visual Studio 2019 V16.11.27
sonarlint 6.16.0.69538 VB.net
When switching from Debug to Release mode I get 915 “AD0001” warnings. Restarting Visual Studio resolves the issue.
All warnings are similar to this:
Severity Code Description Project File Line Source
Warning AD0001 Analyzer 'SonarAnalyzer.Rules.VisualBasic.SymbolicExecutionRunner' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
Exception occurred with following context:
Compilation: PropixFL
SyntaxTree: C:\Development\IPDS and Propix\PropixFL\PropixFL\clsEHs.vb
SyntaxNode: Public Function Count() As Integer ... [MethodBlockSyntax]@[1853..1938) (70,4)-(74,16)
System.NullReferenceException: Object reference not set to an instance of an object.
at lambda_method(Closure , Object , SyntaxTree , String , CancellationToken , ReportDiagnostic& )
at StyleCop.Analyzers.Lightup.SyntaxTreeOptionsProviderWrapper.TryGetDiagnosticValue(SyntaxTree tree, String diagnosticId, CancellationToken cancellationToken, ReportDiagnostic& severity)
at SonarAnalyzer.Rules.SymbolicExecutionRunnerBase.IsEnabled(SonarSyntaxNodeReportingContext context, DiagnosticDescriptor descriptor)
at SonarAnalyzer.Rules.SymbolicExecutionRunnerBase.<>c__DisplayClass17_0.<AnalyzeRoslyn>b__0(KeyValuePair`2 x)
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at System.Linq.Lookup`2.Create[TSource](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at System.Linq.GroupedEnumerable`3.GetEnumerator()
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at SonarAnalyzer.Rules.SymbolicExecutionRunnerBase.AnalyzeRoslyn(SonarAnalysisContext analysisContext, SonarSyntaxNodeReportingContext nodeContext, SyntaxNode body, ISymbol symbol)
at SonarAnalyzer.Rules.SymbolicExecutionRunnerBase.Analyze(SonarAnalysisContext analysisContext, SonarSyntaxNodeReportingContext nodeContext, SyntaxNode body, ISymbol symbol)
at SonarAnalyzer.Rules.SymbolicExecutionRunnerBase.Analyze[TNode](SonarAnalysisContext analysisContext, SonarSyntaxNodeReportingContext context, Func`2 getBody)
at SonarAnalyzer.Rules.VisualBasic.SymbolicExecutionRunner.<>c__DisplayClass4_0.<Initialize>b__0(SonarSyntaxNodeReportingContext c)
at SonarAnalyzer.AnalysisContext.SonarAnalysisContext.Execute[TSonarContext,TRoslynContext](TSonarContext context, Action`1 action, SyntaxTree sourceTree, GeneratedCodeRecognizer generatedCodeRecognizer)
at SonarAnalyzer.AnalysisContext.SonarAnalysisContext.<>c__DisplayClass23_0`1.<RegisterNodeAction>b__0(SyntaxNodeAnalysisContext c)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__62`1.<ExecuteSyntaxNodeAction>b__62_0(ValueTuple`2 data)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info)
-----
Suppress the following diagnostics to disable this analyzer: S2222, S2259, S3655, S3900 PropixFL 1 IntelliSense
This is constant issue with several different applications. Tried removing and re-installing SonarLink but issue still exist. The issue also occurs when switching from Debug to Release. Any thoughts on how to fix this?
Thanks for checking @David_Hitchner. I’ve asked the Languages team who wrote the analysis rule to take a look as the issue doesn’t seem to be related to SonarLint per se.
Mary, Sorry, I cannot share the file but I can tell you that “AD0001” errors show for all files in the project as well as in other projects. So far I have not been able to tie it down to any specific file or cause. I can also say that the problem does not appear in Visual Studio 2022 on the same system. I could resolve the issue by using 2022 but because it is 64-bit I need to replace some of the controls in some of the projects before that can happen.
Do you have maybe different configuration files for analysis between debug and release modes (such files are editorconfig, global configuration files, or ruleset files)?
Mary,
Thanks for your suggestions. I had hoped that this provided a solution because I did have different rulesets for debug and release. Changing the ruleset does trigger the issue. I changed debug and release to use the same ruleset “Microsoft Managed Recommended Rules”. I then exited Visual Studio and re-opened the application. Going from debug to release or release to debug still causes the AD0001 warnings.
Just to make sure I understood properly, from your side this is the only extra ruleset that you provide?
From what I understood from a previous post you mentioned that you use different rulesets for debug and release modes.
Would it be possible to provide me with these (unless I understood wrong)?
Could you also tell me how you pass the rulesets to your projects?
I apologize for the late reply.
Unfortunately, I still cannot reproduce the issue.
I’m working with VS 2019 16.11, a VB.NET project targeting NET5, providing at project level the rulesets (the ones you provided) and changing them between Release and Debug. Behavior is so far as expected.
Could you please tell me which framework you are targeting in your project?
Is it possible that you have customized the project build somehow?
Would you be willing to build your project with a more recent MSBuild/VS version (VS22, for example) to see if you have the same issue?
Could you please tell me if there’s something different in your project from the setup I described in my previous message?
which framework do you target?
do you maybe have altered the build somehow? With targets for example?
One more note: I noticed that you mentioned Visual Studio 2019 V16.11.27.
Could you try updating to the latest patch 16.11.30?
I noticed that I tested with 16.11.29 - so this might do the trick.
It has happened in the past that there was a bug for a certain MSBuild version and it got resolved in a patch later.
Mary, I am running Visual Studio 2019 Version 16.11.30 and targeting .NET Framework 4.6.2. I have another solution that has the same issue and it targets .NET Framework 4.5.2.
The first solution targeting 4.6.2 does not experience the issue in Visual Studio 2022. I am unable to try the second solution due to the use of 32-bit controls.