File tree Expand file tree Collapse file tree 7 files changed +59
-0
lines changed
csharp/ql/test/library-tests/csharp11 Expand file tree Collapse file tree 7 files changed +59
-0
lines changed Original file line number Diff line number Diff line change
1
+ // TODO: Test needs to be enabled when .NET 7 is used as the runtime.
2
+ namespace structassembly;
3
+
4
+ public class MyEmptyClass { }
5
+
6
+ public ref struct RefStruct
7
+ {
8
+ public int MyInt;
9
+ public ref byte MyByte;
10
+ public ref object MyObject;
11
+ internal ref MyEmptyClass MyEmptyClass;
12
+ public ref readonly byte MyReadonlyByte;
13
+ public readonly ref object MyReadonlyObject;
14
+ public readonly ref readonly string MyReadonlyString;
15
+ }
Original file line number Diff line number Diff line change
1
+ namespace structassembly;
2
+
3
+ public class MyEmptyClass { }
4
+
5
+ public ref struct RefStruct
6
+ {
7
+ public int MyInt;
8
+ public ref byte MyByte;
9
+ public ref object MyObject;
10
+ internal ref MyEmptyClass MyEmptyClass;
11
+ public ref readonly byte MyReadonlyByte;
12
+ public readonly ref object MyReadonlyObject;
13
+ public readonly ref readonly string MyReadonlyString;
14
+ }
Original file line number Diff line number Diff line change
1
+ | file://:0:0:0:0 | MyByte | Byte |
2
+ | file://:0:0:0:0 | MyEmptyClass | MyEmptyClass |
3
+ | file://:0:0:0:0 | MyObject | Object |
4
+ | file://:0:0:0:0 | MyReadonlyByte | Byte |
5
+ | file://:0:0:0:0 | MyReadonlyObject | Object |
6
+ | file://:0:0:0:0 | MyReadonlyString | String |
Original file line number Diff line number Diff line change
1
+ import cil
2
+
3
+ query predicate cilfields ( CIL:: Field f , string type ) {
4
+ f .isRef ( ) and type = f .getType ( ) .toString ( ) and f .getDeclaringType ( ) .getName ( ) = "RefStruct"
5
+ }
Original file line number Diff line number Diff line change
1
+ reffields
2
+ readonlyreffields
3
+ readonlyfield
Original file line number Diff line number Diff line change
1
+ import csharp
2
+
3
+ query predicate reffields ( Field f ) {
4
+ f .getFile ( ) .getStem ( ) = "Struct" and
5
+ f .isRef ( )
6
+ }
7
+
8
+ query predicate readonlyreffields ( Field f ) {
9
+ f .getFile ( ) .getStem ( ) = "Struct" and
10
+ f .isReadonlyRef ( )
11
+ }
12
+
13
+ query predicate readonlyfield ( Field f ) {
14
+ f .getFile ( ) .getStem ( ) = "Struct" and
15
+ f .isReadOnly ( )
16
+ }
You can’t perform that action at this time.
0 commit comments