Skip to content

Commit f23438e

Browse files
committed
C#: Add test showing false positive
1 parent 8c00671 commit f23438e

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

csharp/ql/test/query-tests/Likely Bugs/DangerousNonShortCircuitLogic/DangerousNonShortCircuitLogic.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ void M()
2020
var b = true;
2121
b &= c.Method(); // GOOD
2222
b |= c[0]; // GOOD
23+
24+
if (c == null | c.Method(out _)) ; // GOOD (false positive)
2325
}
2426

2527
class C
@@ -28,6 +30,7 @@ class C
2830
public string Property { get; set; }
2931
public bool this[int i] { get { return false; } set { } }
3032
public bool Method() { return false; }
33+
public bool Method(out int x) { x = 0; return false; }
3134
}
3235
}
3336

csharp/ql/test/query-tests/Likely Bugs/DangerousNonShortCircuitLogic/DangerousNonShortCircuitLogic.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
| DangerousNonShortCircuitLogic.cs:16:13:16:40 | ... \| ... | Potentially dangerous use of non-short circuit logic. |
33
| DangerousNonShortCircuitLogic.cs:17:13:17:28 | ... \| ... | Potentially dangerous use of non-short circuit logic. |
44
| DangerousNonShortCircuitLogic.cs:18:13:18:34 | ... \| ... | Potentially dangerous use of non-short circuit logic. |
5+
| DangerousNonShortCircuitLogic.cs:24:13:24:39 | ... \| ... | Potentially dangerous use of non-short circuit logic. |

0 commit comments

Comments
 (0)