Matches implicit casts; that is, casts that are not explicitly stated but are performed by the C# compiler.
This pattern only matches nodes of type expression.
Properties
castOperatorImplicit produces a record that contains the following properties:
| Name | Type | Description |
|---|---|---|
kind |
enum castKind |
Always `implicit`.
See castKind.
|
operandExpression |
expression |
The expression being cast |
Inherits properties from:
Example
In the following snippet of C#:
int num = 2147483647;
long bigNum = num;
... there is an implicit cast between the int and the long. To detect such a cast, you could use the following pattern:
pattern implicitCastFromString {
castOperatorImplicit {
.operandExpression == expression {
.type == integralType {
.kind == `int`
}
}
}
};