From 4c9fa4dddc7e9f5759f80709918333ed3ac61def Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 22 Jun 2026 09:37:24 +0000 Subject: [PATCH 1/3] Emit catch type mentions without variables --- .../Entities/Statements/Catch.cs | 4 +++- csharp/ql/test/library-tests/regressions/Program.cs | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/csharp/extractor/Semmle.Extraction.CSharp/Entities/Statements/Catch.cs b/csharp/extractor/Semmle.Extraction.CSharp/Entities/Statements/Catch.cs index f3a10f4ef68..30669aae78f 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp/Entities/Statements/Catch.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp/Entities/Statements/Catch.cs @@ -23,7 +23,9 @@ namespace Semmle.Extraction.CSharp.Entities.Statements } else if (isSpecificCatchClause) // A catch clause of the form 'catch(Ex) { ... }' { - trapFile.catch_type(this, Type.Create(Context, Context.GetType(Stmt.Declaration!.Type)).TypeRef, true); + var type = Type.Create(Context, Context.GetType(Stmt.Declaration!.Type)); + trapFile.catch_type(this, type.TypeRef, true); + TypeMention.Create(Context, Stmt.Declaration!.Type, this, type); } else // A catch clause of the form 'catch { ... }' { diff --git a/csharp/ql/test/library-tests/regressions/Program.cs b/csharp/ql/test/library-tests/regressions/Program.cs index dd73876f1a3..38a1afaa5ae 100644 --- a/csharp/ql/test/library-tests/regressions/Program.cs +++ b/csharp/ql/test/library-tests/regressions/Program.cs @@ -50,6 +50,19 @@ class TypeMentions } } +class CatchTypeMentions +{ + void F() + { + try + { + } + catch (Exception) + { + } + } +} + class NameOfMethodGroups { int MethodGroup() => 0; From bd84fb31e1598e973d0d7ae0bf5df30252e44e6a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 22 Jun 2026 09:41:55 +0000 Subject: [PATCH 2/3] Add regression for catch type mention extraction --- .../test/library-tests/regressions/Program.cs | 26 +++++++++---------- .../regressions/TypeMentions.expected | 2 ++ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/csharp/ql/test/library-tests/regressions/Program.cs b/csharp/ql/test/library-tests/regressions/Program.cs index 38a1afaa5ae..74bcf994681 100644 --- a/csharp/ql/test/library-tests/regressions/Program.cs +++ b/csharp/ql/test/library-tests/regressions/Program.cs @@ -50,19 +50,6 @@ class TypeMentions } } -class CatchTypeMentions -{ - void F() - { - try - { - } - catch (Exception) - { - } - } -} - class NameOfMethodGroups { int MethodGroup() => 0; @@ -207,3 +194,16 @@ class C3 : C2> { } class C4 : C2> { } class C5 : C4 { } + +class CatchTypeMentions +{ + void F() + { + try + { + } + catch (Exception) + { + } + } +} diff --git a/csharp/ql/test/library-tests/regressions/TypeMentions.expected b/csharp/ql/test/library-tests/regressions/TypeMentions.expected index 6c9e25efd0a..c5aad0df1bd 100644 --- a/csharp/ql/test/library-tests/regressions/TypeMentions.expected +++ b/csharp/ql/test/library-tests/regressions/TypeMentions.expected @@ -100,3 +100,5 @@ | Program.cs:194:21:194:21 | T | | Program.cs:196:12:196:17 | C4 | | Program.cs:196:15:196:16 | C5 | +| Program.cs:200:5:200:8 | Void | +| Program.cs:205:16:205:24 | Exception | From ac7ed0612d1ea633e7ba40186c8cd764f456c234 Mon Sep 17 00:00:00 2001 From: Anders Schack-Mulligen Date: Mon, 22 Jun 2026 13:00:55 +0200 Subject: [PATCH 3/3] C#: Accept test change. --- csharp/ql/test/library-tests/csharp6/PrintAst.expected | 1 + 1 file changed, 1 insertion(+) diff --git a/csharp/ql/test/library-tests/csharp6/PrintAst.expected b/csharp/ql/test/library-tests/csharp6/PrintAst.expected index 78747650190..140a63c941c 100644 --- a/csharp/ql/test/library-tests/csharp6/PrintAst.expected +++ b/csharp/ql/test/library-tests/csharp6/PrintAst.expected @@ -101,6 +101,7 @@ csharp6.cs: # 32| 0: [IntLiteral] 2 # 32| 0: [IntLiteral] 1 # 34| 1: [SpecificCatchClause] catch (...) {...} +# 34| 0: [TypeMention] IndexOutOfRangeException # 35| 1: [BlockStmt] {...} # 34| 2: [EQExpr] ... == ... # 34| 0: [PropertyCall] access to property Value