Skip to content

Commit 6d0e079

Browse files
committed
C#: Consider the static constructor the enclosing callable for static member initialization. Note that a class can only have ONE static constructor (so it will be unique).
1 parent 6a40b86 commit 6d0e079

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

csharp/ql/lib/semmle/code/csharp/ExprOrStmtParent.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import csharp
88
private import internal.Location
9+
private import controlflow.internal.ControlFlowGraph
910

1011
/**
1112
* INTERNAL: Do not use.
@@ -145,6 +146,8 @@ private module Cached {
145146
parent*(cfe, c.(Constructor).getObjectInitializerCall())
146147
or
147148
parent*(cfe, any(AssignExpr init | c.(ObjectInitMethod).initializes(init)))
149+
or
150+
parent*(cfe, any(Expr init | Initializers::staticMemberInitializer(c, init)))
148151
}
149152

150153
/** Holds if the enclosing statement of expression `e` is `s`. */

0 commit comments

Comments
 (0)