mirror of
https://github.com/github/codeql.git
synced 2026-07-21 11:18:20 +02:00
3.1 KiB
3.1 KiB
Improvements to C# analysis
Changes to existing queries
| Query | Expected impact | Change |
|---|---|---|
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. |
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. |
Useless upcast (cs/useless-upcast) |
Fewer false positive results | Results have been removed where the upcast is used to disambiguate the target of a constructor call. |
Changes to code extraction
-
The following C# 8 features are now extracted:
- Range expressions
- Recursive patterns
- Using declaration statements
staticmodifiers on local functions- Null-coalescing assignment expressions
-
The
unmanagedtype parameter constraint is now extracted.
Changes to QL libraries
- The class
Attributehas two new predicates:getConstructorArgument()andgetNamedArgument(). The first predicate returns arguments to the underlying constructor call and the latter returns named arguments for initializing fields and properties. - The class
TypeParameterConstraintshas a new predicatehasUnmanagedTypeConstraint(), indicating that the type parameter has theunmanagedconstraint. - The following QL classes have been added to model C# 8 features:
- Class
AssignCoalesceExprmodels null-coalescing assignment, for examplex ??= y - Class
IndexExprmodels from-end index expressions, for example^1 - Class
PatternExpris anExprthat appears in a pattern. It has the new subclassesDiscardPatternExpr,LabeledPatternExpr,RecursivePatternExpr,TypeAccessPatternExpr,TypePatternExpr, andVariablePatternExpr. - Class
PatternMatchmodels a pattern being matched. It has the subclassesCaseandIsExpr. - Class
PositionalPatternExprmodels position patterns, for example(int x, int y) - Class
PropertyPatternExprmodels property patterns, for exampleLength: int len - Class
RangeExprmodels range expressions, for example1..^1 - Class
SwitchCaseExprmodels the arm of a switch expression, for example(false, false) => true - Class
SwitchExprmodelsswitchexpressions, for example(a, b) switch { ... } - Classes
IsConstantExpr,IsTypeExprandIsPatternExprare deprecated in favour ofIsExpr - Class
Switchmodels bothSwitchExprandSwitchStmt - Class
Casemodels bothCaseStmtandSwitchCaseExpr - Class
UsingStmtmodels bothUsingBlockStmtandUsingDeclStmt
- Class