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;