C# extractor: extract catch(ExceptionType) type as TypeAccess instead of TypeMention#22037
Merged
Merged
Conversation
Copilot
AI
changed the title
C# extractor: extract
C# extractor: extract Jun 23, 2026
catch(Ex) type as TypeAccess instead of TypeMentioncatch(ExceptionType) type as TypeAccess instead of TypeMention
Copilot created this pull request from a session on behalf of
aschackmull
June 23, 2026 09:03
View session
5310acc to
b254aa7
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Updates C# catch-clause extraction so catch (T) (type present, no variable) produces a TypeAccess expression instead of a TypeMention, enabling downstream control-flow/CFG work while preserving existing catch variants.
Changes:
- Extract
catch (T)’s type as anExpression(yielding aTypeAccessat child 0) in the C# extractor. - Add a
SpecificCatchClause.getTypeAccess()accessor in the C# QL library for the no-variable case. - Adjust CFG child selection to avoid including skipped control-flow nodes (including the newly introduced
TypeAccess) as statement children.
Show a summary per file
| File | Description |
|---|---|
| csharp/extractor/Semmle.Extraction.CSharp/Entities/Statements/Catch.cs | Switches catch (T) extraction from TypeMention to Expression to create a TypeAccess child. |
| csharp/ql/lib/semmle/code/csharp/Stmt.qll | Adds getTypeAccess() on SpecificCatchClause for catch (T) without a variable. |
| csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll | Updates statement-child selection to respect skipControlFlow, preventing TypeAccess from being pulled into the CFG. |
| csharp/ql/test/library-tests/csharp6/PrintAst.expected | Updates expected AST output to reflect the new TypeAccess node structure. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 0
hvitved
approved these changes
Jun 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For
catch(Exception)clauses (type present, no variable), the exception type was extracted as aTypeMentionrather than aTypeAccess. Changing this makes it an expression, and makes it easier to include in the CFG (will be done in another PR).Changes
Catch.cs: For case 2 (catch(T)without variable), replaceTypeMention.Create(...)withExpression.Create(...), producing aTypeAccessat child 0.Stmt.qll: AddgetTypeAccess()predicate toSpecificCatchClause, returning theTypeAccessat child 0 when noVariableDeclExpris present.ControlFlowGraph.qll: Addnot skipControlFlow(result)togetStmtChild0— consistent withgetExprChild0— so the newTypeAccess(aControlFlowElement) doesn't pollute the CFG.The three catch variants for reference: