mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Merge pull request #4656 from tamasvajk/feature/csharp9-not-pattern
C#: Extract unary patterns
This commit is contained in:
@@ -20,6 +20,9 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
case TypePatternSyntax typePattern:
|
||||
return Expressions.TypeAccess.Create(cx, typePattern.Type, parent, child);
|
||||
|
||||
case UnaryPatternSyntax unaryPattern:
|
||||
return new UnaryPattern(cx, unaryPattern, parent, child);
|
||||
|
||||
case DeclarationPatternSyntax declPattern:
|
||||
// Creates a single local variable declaration.
|
||||
{
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Semmle.Extraction.Entities;
|
||||
using Semmle.Extraction.Kinds;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
internal class UnaryPattern : Expression
|
||||
{
|
||||
public UnaryPattern(Context cx, UnaryPatternSyntax syntax, IExpressionParentEntity parent, int child) :
|
||||
base(new ExpressionInfo(cx, NullType.Create(cx), cx.Create(syntax.GetLocation()), ExprKind.NOT_PATTERN, parent, child, false, null))
|
||||
{
|
||||
Pattern.Create(cx, syntax.Pattern, this, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,6 +115,7 @@ namespace Semmle.Extraction.Kinds
|
||||
SWITCH_CASE = 118,
|
||||
ASSIGN_COALESCE = 119,
|
||||
SUPPRESS_NULLABLE_WARNING = 120,
|
||||
NAMESPACE_ACCESS = 121
|
||||
NAMESPACE_ACCESS = 121,
|
||||
NOT_PATTERN = 126
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user