-
Notifications
You must be signed in to change notification settings - Fork 232
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
Symbolic execution engine should not throw on TypePattern and RelationalPattern (introduced in .Net 5) #4104
Comments
This also happens with relational patterns like |
Hi @KraftyKanuck. This problem appears due to the fact that we don't yet support the As a result the analysis for snippets like:
is not yet supported. We will do a first step this sprint to not throw but proper support will be added later this year. |
Same problem appears for
|
For the reference, I think I also run into this (or some closely related bug) on the following code. The Upgrading to version 8.29.0.36737 helped; at least versions 8.22.0.31243 through 8.28.0.36354 exhibit the bug. string lexeme = typeReference.TypeSpecifier.Lexeme;
switch (lexeme)
{
case "int" or "Int32":
typeReference.ClrType = typeof(int);
break;
case "long" or "Int64":
typeReference.ClrType = typeof(long);
break;
case "double" or "Double":
typeReference.ClrType = typeof(double);
break;
case "string" or "String":
typeReference.ClrType = typeof(string);
break;
case "void":
typeReference.ClrType = typeof(void);
break;
// Other types means ClrType will remain `null`; this is then handled elsewhere (in
// TypesResolvedValidator)
} |
Description
When not specifying a discard operator during a case for a switch with a generic type, sonar analyzer throws a SymbolicExecutionRunner
Severity Code Description Project Path File Line Suppression State
Error AD0001 Analyzer 'SonarAnalyzer.Rules.SymbolicExecution.SymbolicExecutionRunner' threw an exception of type 'SonarAnalyzer.SymbolicExecution.SymbolicExecutionException' with message 'Error processing method: Evaluate ## Method file: MyPath\SonarExample.cs ## Method line: 17,8 ## Inner exception: System.NotSupportedException: TypePattern ## at SonarAnalyzer.SymbolicExecution.CSharpExplodedGraph.VisitInstruction(ExplodedGraphNode node) ## at SonarAnalyzer.SymbolicExecution.AbstractExplodedGraph.Walk() ## at SonarAnalyzer.Rules.SymbolicExecution.SymbolicExecutionRunner.Analyze(CSharpExplodedGraph explodedGraph, SyntaxNodeAnalysisContext context) ## at SonarAnalyzer.Extensions.SonarAnalysisContextExtensions.Analyze(CSharpSyntaxNode declarationBody, ISymbol symbol, Action`2 runAnalysis, SyntaxNodeAnalysisContext context) ## '. MyProject MyPath MyPath\CSC 1 Active
Repro steps
Known workarounds
Change:
case ClassTwo<int>:
to
case ClassTwo<int> _:
or
case ClassTwo<int> foo:
Related information
The text was updated successfully, but these errors were encountered: