Skip to content

Commit f305a38

Browse files
committed
C#: Recognize assertions as Guards.
1 parent 245b727 commit f305a38

File tree

1 file changed

+12
-0
lines changed
  • csharp/ql/lib/semmle/code/csharp/controlflow

1 file changed

+12
-0
lines changed

csharp/ql/lib/semmle/code/csharp/controlflow/Guards.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,18 @@ private module LogicInput implements GuardsImpl::LogicInputSig {
287287
g2 = g1.(NullCoalescingExpr).getAnOperand() and
288288
v1.isNullValue() and
289289
v2 = v1
290+
or
291+
exists(Assertion assert, AssertMethod target, int i |
292+
assert.getAssertMethod() = target and
293+
g1 = assert and
294+
v1.getDualValue().isThrowsException() and
295+
g2 = assert.getExpr(i)
296+
|
297+
target.(BooleanAssertMethod).getAnAssertionIndex(v2.asBooleanValue()) = i
298+
or
299+
target.(NullnessAssertMethod).getAnAssertionIndex(any(boolean isNull | v2.isNullness(isNull))) =
300+
i
301+
)
290302
}
291303
}
292304

0 commit comments

Comments
 (0)