Skip to content

Commit b628060

Browse files
committed
C#: Address review comments.
1 parent e16cbe0 commit b628060

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

change-notes/1.21/analysis-csharp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
| **Query** | **Expected impact** | **Change** |
66
|------------------------------|------------------------|-----------------------------------|
77
| Class defines a field that uses an ICryptoTransform class in a way that would be unsafe for concurrent threads (`cs/thread-unsafe-icryptotransform-field-in-class`) | Fewer false positive results | The criteria for a result has changed to include nested properties, nested fields and collections. The format of the alert message has changed to highlight the static field. |
8-
| Constant condition (`cs/constant-condition`) | Fewer results | Results have been removed where the `null` value is in a conditional expression in the left hand side of a null-coalescing expression. For example, in `(a ? b : null) ?? c`, `null` is not considered to be a constant condition. |
8+
| Constant condition (`cs/constant-condition`) | Fewer false positive results | Results have been removed where the `null` value is in a conditional expression on the left hand side of a null-coalescing expression. For example, in `(a ? b : null) ?? c`, `null` is not considered to be a constant condition. |
99

1010
## Changes to code extraction
1111

csharp/ql/test/query-tests/Bad Practices/Control-Flow/ConstantCondition/ConstantCondition.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ void M2(int i)
5050
j = (int?)i ?? 1; // BAD
5151
s = ""?.CommaJoinWith(s); // BAD
5252
s = s ?? ""; // GOOD
53-
s = (i==0 ? s : null) ?? s;
53+
s = (i==0 ? s : null) ?? s; // GOOD
54+
var k = (i==0 ? s : null)?.Length; // GOOD
5455
}
5556
}
5657

csharp/ql/test/query-tests/Bad Practices/Control-Flow/ConstantCondition/ConstantCondition.expected

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
| ConstantCondition.cs:49:17:49:18 | "" | Expression is never 'null'. |
55
| ConstantCondition.cs:50:13:50:19 | (...) ... | Expression is never 'null'. |
66
| ConstantCondition.cs:51:13:51:14 | "" | Expression is never 'null'. |
7-
| ConstantCondition.cs:63:18:63:18 | 2 | Pattern never matches. |
8-
| ConstantCondition.cs:65:18:65:18 | 3 | Pattern always matches. |
9-
| ConstantCondition.cs:76:18:76:20 | access to type Int32 | Pattern never matches. |
7+
| ConstantCondition.cs:64:18:64:18 | 2 | Pattern never matches. |
8+
| ConstantCondition.cs:66:18:66:18 | 3 | Pattern always matches. |
9+
| ConstantCondition.cs:77:18:77:20 | access to type Int32 | Pattern never matches. |
1010
| ConstantConditionBad.cs:5:16:5:20 | ... > ... | Condition always evaluates to 'false'. |
1111
| ConstantConditionalExpressionCondition.cs:11:22:11:34 | ... == ... | Condition always evaluates to 'true'. |
1212
| ConstantConditionalExpressionCondition.cs:12:21:12:25 | false | Condition always evaluates to 'false'. |

0 commit comments

Comments
 (0)