The error code AD0001 shows up:
Severity Code Description Project File Line Suppression State Detail Description
Warning AD0001 Analyzer 'SonarAnalyzer.Rules.CSharp.ObjectsShouldNotBeDisposedMoreThanOnce' threw an exception of type 'System.InvalidCastException' with message 'Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Syntax.IdentifierNameSyntax' to type 'Microsoft.CodeAnalysis.CSharp.Syntax.MemberAccessExpressionSyntax'.'. Datastructures 1 Active Analyzer 'SonarAnalyzer.Rules.CSharp.ObjectsShouldNotBeDisposedMoreThanOnce' threw the following exception:
'Exception occurred with following context:
Compilation: HBAS.Datastructures
SyntaxTree: C:\Users\jcurl\Documents\Programming\HELIOS\helios.base\framework\datastructures\code\Diagnostic\Process.cs
SyntaxNode: private void DisposeWithException ... [MethodDeclarationSyntax]@[30218..30446) (659,8)-(664,9)
System.InvalidCastException: Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Syntax.IdentifierNameSyntax' to type 'Microsoft.CodeAnalysis.CSharp.Syntax.MemberAccessExpressionSyntax'.
at SonarAnalyzer.Rules.CSharp.ObjectsShouldNotBeDisposedMoreThanOnce.ObjectDisposedPointerCheck.VisitInvocationExpression(InvocationExpressionSyntax instruction, ProgramState programState)
at SonarAnalyzer.Rules.CSharp.ObjectsShouldNotBeDisposedMoreThanOnce.ObjectDisposedPointerCheck.PreProcessInstruction(ProgramPoint programPoint, ProgramState programState)
at SonarAnalyzer.Helpers.FlowAnalysis.CSharp.ExplodedGraph.VisitInstruction(ExplodedGraphNode node)
at SonarAnalyzer.Helpers.FlowAnalysis.Common.ExplodedGraph.Walk()
at SonarAnalyzer.Rules.CSharp.ObjectsShouldNotBeDisposedMoreThanOnce.CheckForMultipleDispose(ExplodedGraph explodedGraph, SyntaxNodeAnalysisContext context)
at SonarAnalyzer.Helpers.FlowAnalysis.CSharp.FlowAnalysisExtensions.Analyze(CSharpSyntaxNode declarationBody, ISymbol symbol, Action`2 analyze, SyntaxNodeAnalysisContext context)
at SonarAnalyzer.Helpers.FlowAnalysis.CSharp.FlowAnalysisExtensions.<>c__DisplayClass0_0.<RegisterExplodedGraphBasedAnalysis>b__1(SyntaxNodeAnalysisContext c)
at SonarAnalyzer.Helpers.DiagnosticAnalyzerContextHelper.<>c__DisplayClass0_0`1.<RegisterSyntaxNodeActionInNonGenerated>b__0(SyntaxNodeAnalysisContext c)
at SonarAnalyzer.Helpers.SonarAnalysisContext.<>c__DisplayClass12_0`1.<RegisterSyntaxNodeAction>b__0(SyntaxNodeAnalysisContext c)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__DisplayClass42_1`1.<ExecuteSyntaxNodeAction>b__1()
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock(DiagnosticAnalyzer analyzer, Action analyze, Nullable`1 info)
-----
'.
I'm not able to identify the code location in my project that shows the problem. As the exception indicates a particular file, I'm attaching that.
Process.zip
No error AD0001
AD0001 shows up
Ignoring it for now...
Hi @jcurl, thanks for the feedback, we will provide a fix as soon as possible!
HI, I just want to mention, that I've had to drop down to v3.2.1 of SonarLint as for some projects it only shows this error and then stops scanning in the IDE. So it appears it wasn't there in 3.2.1.
Hi @jcurl,
You are right we changed the way the rule works and it seems like we have some uncovered cases.
@Evangelink thank you for fixing this. When will a SonarAnalyzer.CSharp package with this fix be release?
Hi @ohadschn we will release the RC today and will release the final Wednesday.