Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C#: Update MainMethod to understand new Main method syntaxes #65

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion csharp/ql/lib/semmle/code/csharp/commons/Util.qll
Original file line number Diff line number Diff line change
Expand Up @@ -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", "<Main>$")
) 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<System.Int32>"])
) and
if this.getNumberOfParameters() = 1
then this.getParameter(0).getType().(ArrayType).getElementType() instanceof StringType
else this.getNumberOfParameters() = 0
Expand Down