Skip to content

Commit 64f13fa

Browse files
committed
C#: Exclude call inside static field initializers from consistency check
1 parent 9f79890 commit 64f13fa

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

csharp/ql/consistency-queries/DataFlowConsistency.ql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import csharp
22
import cil
33
import semmle.code.csharp.dataflow.internal.DataFlowPrivate
44
import semmle.code.csharp.dataflow.internal.DataFlowPublic
5+
import semmle.code.csharp.dataflow.internal.DataFlowDispatch
56
import semmle.code.csharp.dataflow.internal.DataFlowImplConsistency::Consistency
67

78
private class MyConsistencyConfiguration extends ConsistencyConfiguration {
@@ -14,6 +15,15 @@ private class MyConsistencyConfiguration extends ConsistencyConfiguration {
1415
)
1516
}
1617

18+
override predicate uniqueCallEnclosingCallableExclude(DataFlowCall call) {
19+
// TODO: Remove once static initializers are folded into the
20+
// static constructors
21+
exists(ControlFlow::Node cfn |
22+
cfn.getElement() = any(FieldOrProperty f | f.isStatic()).getAChild+() and
23+
cfn = call.getControlFlowNode()
24+
)
25+
}
26+
1727
override predicate uniqueNodeLocationExclude(Node n) {
1828
// Methods with multiple implementations
1929
n instanceof ParameterNode

0 commit comments

Comments
 (0)