You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following invalid code results in AD0001 diagnostics:
staticvoidMain(){varx=$"{nameof()}";}
Stack trace:
Severity Code Description Project File Line Suppression State Detail Description
Warning AD0001 Analyzer 'SonarAnalyzer.Rules.CSharp.NullPointerDereference' threw an exception of type 'System.InvalidOperationException' with message 'This operation does not apply to an empty instance.'. ConsoleApp1 1 Active Analyzer 'SonarAnalyzer.Rules.CSharp.NullPointerDereference' threw the following exception:
'Exception occurred with following context:
Compilation: ConsoleApp1
SyntaxTree: ...
SyntaxNode: static void Main() ... [MethodDeclarationSyntax]@[183..272) (10,8)-(13,9)
System.InvalidOperationException: This operation does not apply to an empty instance.
at System.Collections.Immutable.ImmutableStack`1.Peek()
at SonarAnalyzer.Helpers.FlowAnalysis.Common.ProgramState.PopValue(SymbolicValue& poppedValue)
at SonarAnalyzer.Helpers.FlowAnalysis.Common.InvocationVisitor.HandleNameofExpression()
at SonarAnalyzer.Helpers.FlowAnalysis.Common.InvocationVisitor.ProcessInvocation()
at SonarAnalyzer.Helpers.FlowAnalysis.CSharp.ExplodedGraph.VisitInstruction(ExplodedGraphNode node)
at SonarAnalyzer.Helpers.FlowAnalysis.Common.ExplodedGraph.Walk()
at SonarAnalyzer.Rules.CSharp.NullPointerDereference.CheckForNullDereference(ExplodedGraph explodedGraph, SyntaxNodeAnalysisContext context)
at SonarAnalyzer.Rules.CSharp.NullPointerDereference.<>c.<Initialize>b__5_0(ExplodedGraph e, SyntaxNodeAnalysisContext c)
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)
-----
'.
The text was updated successfully, but these errors were encountered:
Could you please send us a minimal project that can be used to reproduce the problem? I wasn't able to reproduce it with just the provided snipped and I tried with several variants... You can send it directly to my email: valeri dot hristov at sonarsource dot com
Description
The following invalid code results in AD0001 diagnostics:
Stack trace:
The text was updated successfully, but these errors were encountered: