Skip to content

Latest commit

 

History

History
157 lines (138 loc) · 10.3 KB

File metadata and controls

157 lines (138 loc) · 10.3 KB
description CodeQL AST node reference for the C# language

CodeQL AST nodes for csharp language

CodeQL's core AST classes for csharp language

Based on the C# PrintAst.expected test results, here are the core CodeQL AST classes for the C# language:

Declarations and Members

  • Class - Class declaration
  • NamespaceDeclaration - Namespace declaration
  • Method - Method declaration
  • Property - Property declaration
  • Field - Field declaration
  • Parameter - Method parameter
  • DelegateType - Delegate type declaration
  • InstanceConstructor - Instance constructor
  • StaticConstructor - Static constructor
  • Destructor - Destructor/finalizer

Type System

  • TypeMention - Reference to a type
  • TypeParameter - Generic type parameter
  • TypeAccess - Access to a type
  • TypeAccessPatternExpr - Type access in pattern expressions

Statements

  • BlockStmt - Block statement {...}
  • ExprStmt - Expression statement
  • LocalVariableDeclStmt - Local variable declaration statement
  • ReturnStmt - Return statement
  • IfStmt - If statement
  • TryStmt - Try statement
  • ThrowStmt - Throw statement
  • UsingBlockStmt - Using statement with block
  • FixedStmt - Fixed statement (for unsafe code)
  • LabelStmt - Label statement
  • EmptyStmt - Empty statement ;

Expressions

  • LocalVariableDeclAndInitExpr - Local variable declaration and initialization
  • LocalVariableAccess - Access to local variable
  • ParameterAccess - Access to parameter
  • FieldAccess - Access to field
  • PropertyCall - Property access/call
  • MethodCall - Method call
  • MethodAccess - Method access
  • ObjectCreation - Object creation expression new T()
  • AnonymousObjectCreation - Anonymous object creation
  • ArrayCreation - Array creation expression
  • ArrayAccess - Array element access
  • AssignExpr - Assignment expression =
  • AssignAddExpr - Addition assignment +=
  • AssignSubExpr - Subtraction assignment -=
  • ThisAccess - this access
  • CastExpr - Type cast expression
  • IsExpr - Type check expression is
  • DefaultValueExpr - Default value expression default(...)

Arithmetic and Logical Expressions

  • AddExpr - Addition expression +
  • SubExpr - Subtraction expression -
  • DivExpr - Division expression /
  • BitwiseAndExpr - Bitwise AND expression &
  • LogicalOrExpr - Logical OR expression ||
  • LTExpr - Less than expression <
  • GEExpr - Greater than or equal expression >=
  • PostIncrExpr - Post-increment expression ++
  • OperatorCall - Operator call

Literals

  • IntLiteral - Integer literal
  • StringLiteralUtf16 - String literal
  • BoolLiteral - Boolean literal (true/false)
  • DoubleLiteral - Double literal
  • CharLiteral - Character literal
  • NullLiteral - Null literal

Object and Collection Initialization

  • ObjectInitializer - Object initializer { ... }
  • MemberInitializer - Member initializer in object initializer
  • CollectionInitializer - Collection initializer { ..., ... }
  • ElementInitializer - Element initializer in collection
  • ArrayInitializer - Array initializer { ..., ... }

Delegates and Events

  • DelegateCall - Delegate call
  • ImplicitDelegateCreation - Implicit delegate creation
  • ExplicitDelegateCreation - Explicit delegate creation
  • EventAccess - Event access
  • EventCall - Event call
  • AddEventExpr - Event subscription +=
  • RemoveEventExpr - Event unsubscription -=

Properties and Accessors

  • Getter - Property getter
  • Setter - Property setter

Special Members and Access

  • MemberConstantAccess - Access to member constant
  • LocalFunctionAccess - Access to local function
  • AddressOfExpr - Address-of expression & (unsafe code)

Expected test results for local PrintAst.ql query

This repo contains a variant of the open-source PrintAst.ql query for csharp language, with modifications for local testing:

Expected test results for open-source PrintAst.ql query

The following links can be fetched to get the expected results for different unit tests of the open-source PrintAst.ql query for the csharp language: