From 4c6d210198584ea360f3f3825c665a72ad639862 Mon Sep 17 00:00:00 2001 From: Levi Broderick Date: Thu, 9 May 2024 15:29:58 -0700 Subject: [PATCH] Update MainMethod to understand new Main method syntaxes --- csharp/ql/lib/semmle/code/csharp/commons/Util.qll | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/csharp/ql/lib/semmle/code/csharp/commons/Util.qll b/csharp/ql/lib/semmle/code/csharp/commons/Util.qll index 3b2a166b9adb..9ec3725ed8b7 100644 --- a/csharp/ql/lib/semmle/code/csharp/commons/Util.qll +++ b/csharp/ql/lib/semmle/code/csharp/commons/Util.qll @@ -8,10 +8,17 @@ class MainMethod extends Method { ( this.hasName("Main") or + // generated by the C# compiler for executables utilizing top-level statements this.hasFullyQualifiedName("Program", "
$") ) and this.isStatic() and - (this.getReturnType() instanceof VoidType or this.getReturnType() instanceof IntType) and + ( + this.getReturnType() instanceof VoidType + or + this.getReturnType() instanceof IntType + or + this.getReturnType().hasFullyQualifiedName("System.Threading.Tasks", ["Task", "Task"]) + ) and if this.getNumberOfParameters() = 1 then this.getParameter(0).getType().(ArrayType).getElementType() instanceof StringType else this.getNumberOfParameters() = 0