CodeQL library for C#
codeql/csharp-all 1.0.5-dev (changelog, source)
Search

Module Expr

Provides all expression classes.

All expressions have the common base class Expr.

Import path

import semmle.code.csharp.exprs.Expr

Imports

Access

Provides all access expression classes.

ArithmeticOperation

Provides all arithmetic operation classes.

Assignment

Provides all assignment classes.

BitwiseOperation

Provides all bitwise operation classes.

Call

Provides all call classes.

ComparisonOperation

Provides all comparison operation classes.

ControlFlowElement

Provides the class ControlFlowElement.

Creation

Provides expression classes for creating various types of object.

Dynamic

Provides all dynamic expression classes.

Literal

Provides all literal classes.

Location

Provides the Location class to give a location for each program element.

LogicalOperation

Provides all logical operation classes.

Stmt

Provides all statement classes.

Type

Provides classes for types.

Classes

AddressOfExpr

An address-of expression, for example &n on line 4 in

AndPatternExpr

A binary and pattern. For example, < 1 and > 2.

AsExpr

An as expression, for example x as string.

AwaitExpr

An await expression, for example await AsyncMethodThatReturnsTask().

BinaryOperation

A binary operation. Either a binary arithmetic operation (BinaryArithmeticOperation), a binary bitwise operation (BinaryBitwiseOperation), a comparison operation (ComparisonOperation), or a binary logical operation (BinaryLogicalOperation).

BinaryPatternExpr

A binary pattern. For example, 1 or 2.

BindingPatternExpr

A pattern that may bind a variable, for example string s in x is string s.

Case

A case expression or statement.

Cast

A cast. Either an as expression (AsExpr) or a cast expression (CastExpr).

CastExpr

A cast expression, for example (string) x.

CheckedExpr

A checked expression, for example checked(2147483647 + ten).

CollectionExpression

A collection expression, for example [1, 2, 3] on line 1 in csharp int[] x = [1, 2, 3];

ConstantPatternExpr

A constant pattern, for example false in x is (_, false).

DefaultValueExpr

A default expression, for example default or default(string).

DefineSymbolExpr

A preprocessor symbol inside an expression, such as DEBUG in line 2 csharp #define DEBUG #if (DEBUG == true) Console.WriteLine("Debug version"); #endif

DiscardExpr

A discard expression, for example _ in

DiscardPatternExpr

A discard pattern, for example _ in x is (_, false)

ExplicitCast

An explicit cast. For example, the explicit cast from object to string on line 2 in

Expr

An expression. Either an access (Access), a call (Call), an object or collection initializer (ObjectOrCollectionInitializer), a delegate creation (DelegateCreation), an array initializer (ArrayInitializer), an array creation (ArrayCreation), an anonymous function (AnonymousFunctionExpr), a local variable declaration (LocalVariableDeclExpr), an operation (Operation), a parenthesized expression (ParenthesizedExpr), a checked expression (CheckedExpr), an unchecked expression (UncheckedExpr), an is expression (IsExpr), an as expression (AsExpr), a cast (CastExpr), a typeof expression (TypeofExpr), a default expression (DefaultValueExpr), an await expression (AwaitExpr), a nameof expression (NameOfExpr), an interpolated string (InterpolatedStringExpr), a qualifiable expression (QualifiableExpr), or a literal (Literal).

GEPattern

A greater-than or equals pattern, for example >= 10 in x is >= 10

GTPattern

A greater-than pattern, for example > 10 in x is > 10.

ImplicitCast

An implicit cast. For example, the implicit cast from string to object on line 3 in

IndexExpr

An index expression, for example ^1 meaning “1 from the end”.

InterpolatedStringExpr

An interpolated string, for example $"Hello, {name}!" on line 2 in

IsExpr

An is expression.

LEPattern

A less-than or equals pattern, for example <= 10 in x is <= 10.

LTPattern

A less-than pattern, for example < 10 in x is < 10.

LabeledPatternExpr

A labeled pattern in a property pattern, for example Length: 5 in { Length: 5 }.

LateBindableExpr

An expression whose target may be late bound when using dynamic subexpressions. Either a method call (MethodCall), an operator call (OperatorCall), a constructor call (ObjectCreation), a dynamic member access (DynamicMemberAccess), or a dynamic element access (DynamicElementAccess).

ListPatternExpr

A list pattern. For example [1, 2, int y] in x is [1, 2, int y].

LocalConstantDeclExpr

A local constant declaration, for example const int i = 0.

LocalVariableDeclExpr

A local variable declaration, for example var i = 0.

NameOfExpr

A nameof expression, for example nameof(s) on line 3 in

NotPatternExpr

A not pattern. For example, not 1.

Operation

An operation. Either an assignment (Assignment), a unary operation (UnaryOperation), a binary operation (BinaryOperation), or a ternary operation (TernaryOperation).

OrPatternExpr

A binary or pattern. For example, 1 or 2.

ParenthesizedExpr

A parenthesized expression, for example (2 + 3) in

PatternExpr

A pattern expression, for example (_, false) in

PatternMatch

An expression or statement that matches the value of an expression against a pattern. Either an is expression or a case expression/statement.

PointerIndirectionExpr

A pointer indirection operation, for example *pn on line 7, pa->M() on line 13, and cp[1] on line 18 in

PositionalPatternExpr

A positional pattern. For example, (int x, int y).

PropertyPatternExpr

A property pattern. For example, { Length: 5 }.

QualifiableExpr

An expression that may have a qualifier. Either a member access (MemberAccess), an element access (ElementAccess), a method call (MethodCall) or a property access (PropertyAccess), or an accessor call (AccessorCall).

RangeExpr

A range expression, used to create a System.Range. For example csharp 1..3 1..^1 3.. .. ..5 ..^1

RecursivePatternExpr

A recursive pattern expression, for example string { Length: 5 } s in x is string { Length: 5 } s.

RefExpr

A reference expression, for example ref a[i] on line 2 in

RelationalPatternExpr

A relational pattern, for example >1 in x is >1.

SizeofExpr

A sizeof expression, for example sizeof(int).

SlicePatternExpr

A slice pattern. For example .. in `x is [1, .., 2].

SpreadElementExpr

A spread element expression, for example .. x in [1, 2, .. x]

SuppressNullableWarningExpr

A nullable warning suppression expression, for example x! in csharp string GetName() { string? x = ...; return x!; }

Switch

A switch expression or statement.

SwitchCaseExpr

An arm of a switch expression, for example (false, false) => true.

SwitchExpr

A switch expression, for example csharp (a,b) switch { (false, false) => true, _ => false };

TernaryOperation

A ternary operation, that is, a ternary conditional operation (ConditionalExpr).

ThrowElement

A throw element. Either a throw expression (ThrowExpr) or a throw statement (ThrowStmt).

ThrowExpr

A throw expression, for example throw new ArgumentException("i") in return i != 0 ? 1 / i : throw new ArgumentException("i");

TupleExpr

An expression representing a tuple, for example (1, 2) on line 2 or (var x, var y) on line 5 in

TypeAccessPatternExpr

A type access pattern, for example string in x is string.

TypePatternExpr

A type pattern, for example string in x is string, string s in x is string s, or string _ in x is string _.

TypeofExpr

A typeof expression, for example typeof(string).

UnaryOperation

A unary operation. Either a unary arithmetic operation (UnaryArithmeticOperation), a unary bitwise operation (UnaryBitwiseOperation), a sizeof operation (SizeofExpr), a pointer indirection operation (PointerIndirectionExpr), an address-of operation (AddressOfExpr), or a unary logical operation (UnaryLogicalOperation).

UnaryPatternExpr

A unary pattern. For example, not 1.

UncheckedExpr

An unchecked expression, for example unchecked(ConstantMax + 10).

VariablePatternExpr

A variable declaration pattern, for example string s in x is string s.

WithExpr

A with expression called on a record.