Skip to content

Commit 6c6e58b

Browse files
committed
C#: Add PrintAst test to implicit ToString test.
1 parent a4049b1 commit 6c6e58b

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
implicitToString.cs:
2+
# 3| [Class] TestClass
3+
# 5| 5: [Class] MyClass
4+
# 5| 4: [InstanceConstructor,PrimaryConstructor] MyClass
5+
# 7| 5: [Method] ToString
6+
# 7| -1: [TypeMention] string
7+
# 8| 4: [BlockStmt] {...}
8+
# 9| 0: [ReturnStmt] return ...;
9+
# 9| 0: [StringLiteralUtf16] "tainted"
10+
# 13| 6: [Method] Sink
11+
# 13| -1: [TypeMention] Void
12+
#-----| 2: (Parameters)
13+
# 13| 0: [Parameter] o
14+
# 13| -1: [TypeMention] object
15+
# 13| 4: [BlockStmt] {...}
16+
# 15| 7: [Method] M1
17+
# 15| -1: [TypeMention] Void
18+
# 16| 4: [BlockStmt] {...}
19+
# 17| 0: [LocalVariableDeclStmt] ... ...;
20+
# 17| 0: [LocalVariableDeclAndInitExpr] MyClass x1 = ...
21+
# 17| -1: [TypeMention] MyClass
22+
# 17| 0: [LocalVariableAccess] access to local variable x1
23+
# 17| 1: [ObjectCreation] object creation of type MyClass
24+
# 17| 0: [TypeMention] MyClass
25+
# 18| 1: [LocalVariableDeclStmt] ... ...;
26+
# 18| 0: [LocalVariableDeclAndInitExpr] String x2 = ...
27+
# 18| -1: [TypeMention] string
28+
# 18| 0: [LocalVariableAccess] access to local variable x2
29+
# 18| 1: [AddExpr] ... + ...
30+
# 18| 0: [StringLiteralUtf16] "Hello"
31+
# 18| 1: [MethodCall] call to method ToString
32+
# 18| -1: [LocalVariableAccess] access to local variable x1
33+
# 19| 2: [ExprStmt] ...;
34+
# 19| 0: [MethodCall] call to method Sink
35+
# 19| 0: [LocalVariableAccess] access to local variable x2
36+
# 22| 8: [Method] M2
37+
# 22| -1: [TypeMention] Void
38+
# 23| 4: [BlockStmt] {...}
39+
# 24| 0: [LocalVariableDeclStmt] ... ...;
40+
# 24| 0: [LocalVariableDeclAndInitExpr] MyClass x1 = ...
41+
# 24| -1: [TypeMention] MyClass
42+
# 24| 0: [LocalVariableAccess] access to local variable x1
43+
# 24| 1: [ObjectCreation] object creation of type MyClass
44+
# 24| 0: [TypeMention] MyClass
45+
# 25| 1: [LocalVariableDeclStmt] ... ...;
46+
# 25| 0: [LocalVariableDeclAndInitExpr] String x2 = ...
47+
# 25| -1: [TypeMention] string
48+
# 25| 0: [LocalVariableAccess] access to local variable x2
49+
# 25| 1: [AddExpr] ... + ...
50+
# 25| 0: [StringLiteralUtf16] "Hello"
51+
# 26| 2: [ExprStmt] ...;
52+
# 26| 0: [MethodCall] call to method Sink
53+
# 26| 0: [LocalVariableAccess] access to local variable x2
54+
# 29| 9: [Method] M3
55+
# 29| -1: [TypeMention] Void
56+
# 30| 4: [BlockStmt] {...}
57+
# 31| 0: [LocalVariableDeclStmt] ... ...;
58+
# 31| 0: [LocalVariableDeclAndInitExpr] MyClass x1 = ...
59+
# 31| -1: [TypeMention] MyClass
60+
# 31| 0: [LocalVariableAccess] access to local variable x1
61+
# 31| 1: [ObjectCreation] object creation of type MyClass
62+
# 31| 0: [TypeMention] MyClass
63+
# 32| 1: [LocalVariableDeclStmt] ... ...;
64+
# 32| 0: [LocalVariableDeclAndInitExpr] String x2 = ...
65+
# 32| -1: [TypeMention] string
66+
# 32| 0: [LocalVariableAccess] access to local variable x2
67+
# 32| 1: [InterpolatedStringExpr] $"..."
68+
# 32| 0: [StringLiteralUtf16] "Hello "
69+
# 32| 1: [MethodCall] call to method ToString
70+
# 32| -1: [LocalVariableAccess] access to local variable x1
71+
# 33| 2: [ExprStmt] ...;
72+
# 33| 0: [MethodCall] call to method Sink
73+
# 33| 0: [LocalVariableAccess] access to local variable x2
74+
# 36| 10: [Method] M4
75+
# 36| -1: [TypeMention] Void
76+
# 37| 4: [BlockStmt] {...}
77+
# 38| 0: [LocalVariableDeclStmt] ... ...;
78+
# 38| 0: [LocalVariableDeclAndInitExpr] MyClass x1 = ...
79+
# 38| -1: [TypeMention] MyClass
80+
# 38| 0: [LocalVariableAccess] access to local variable x1
81+
# 38| 1: [ObjectCreation] object creation of type MyClass
82+
# 38| 0: [TypeMention] MyClass
83+
# 39| 1: [LocalVariableDeclStmt] ... ...;
84+
# 39| 0: [LocalVariableDeclAndInitExpr] String x2 = ...
85+
# 39| -1: [TypeMention] string
86+
# 39| 0: [LocalVariableAccess] access to local variable x2
87+
# 39| 1: [InterpolatedStringExpr] $"..."
88+
# 39| 0: [StringLiteralUtf16] "Hello "
89+
# 40| 2: [ExprStmt] ...;
90+
# 40| 0: [MethodCall] call to method Sink
91+
# 40| 0: [LocalVariableAccess] access to local variable x2
92+
# 25| [LocalVariableAccess] access to local variable x1
93+
# 39| [LocalVariableAccess] access to local variable x1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
shared/PrintAst.ql

0 commit comments

Comments
 (0)