Skip to content

Commit c21bf5d

Browse files
committed
C#: Add tests for qualified delegate calls
1 parent 2d95ac9 commit c21bf5d

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
| delegates.cs:72:13:72:20 | delegate call | delegates.cs:72:13:72:15 | access to local variable cd1 |
2+
| delegates.cs:74:13:74:23 | delegate call | delegates.cs:74:13:74:15 | access to local variable cd7 |
3+
| delegates.cs:79:22:79:26 | delegate call | delegates.cs:79:22:79:23 | access to local variable pi |
4+
| delegates.cs:79:30:79:35 | delegate call | delegates.cs:79:30:79:31 | access to local variable ps |
5+
| delegates.cs:93:13:93:25 | delegate call | delegates.cs:93:13:93:16 | this access |
6+
| delegates.cs:94:13:94:28 | delegate call | delegates.cs:94:13:94:16 | this access |
7+
| delegates.cs:95:13:95:20 | delegate call | delegates.cs:95:13:95:17 | access to field Field |
8+
| delegates.cs:96:13:96:23 | delegate call | delegates.cs:96:13:96:20 | access to property Property |
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import csharp
2+
3+
from DelegateCall dc
4+
select dc, dc.getExpr()

csharp/ql/test/library-tests/delegates/PrintAst.expected

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,33 @@ delegates.cs:
249249
# 81| 16: [LocalVariableDeclStmt] ... ...;
250250
# 81| 0: [LocalVariableDeclExpr] ContextCallback d
251251
# 81| 0: [TypeMention] ContextCallback
252+
# 86| 10: [Class] E
253+
# 88| 5: [Field] Field
254+
# 88| -1: [TypeMention] Action<int>
255+
# 88| 1: [TypeMention] int
256+
# 89| 6: [Property] Property
257+
# 89| -1: [TypeMention] Action<int>
258+
# 89| 1: [TypeMention] int
259+
# 89| 3: [Getter] get_Property
260+
# 89| 4: [Setter] set_Property
261+
#-----| 2: (Parameters)
262+
# 89| 0: [Parameter] value
263+
# 91| 7: [Method] M
264+
# 91| -1: [TypeMention] Void
265+
# 92| 4: [BlockStmt] {...}
266+
# 93| 0: [ExprStmt] ...;
267+
# 93| 0: [DelegateCall] delegate call
268+
# 93| -1: [ThisAccess] this access
269+
# 93| 0: [IntLiteral] 0
270+
# 94| 1: [ExprStmt] ...;
271+
# 94| 0: [DelegateCall] delegate call
272+
# 94| -1: [ThisAccess] this access
273+
# 94| 0: [IntLiteral] 0
274+
# 95| 2: [ExprStmt] ...;
275+
# 95| 0: [DelegateCall] delegate call
276+
# 95| -1: [FieldAccess] access to field Field
277+
# 95| 0: [IntLiteral] 0
278+
# 96| 3: [ExprStmt] ...;
279+
# 96| 0: [DelegateCall] delegate call
280+
# 96| -1: [PropertyCall] access to property Property
281+
# 96| 0: [IntLiteral] 0

csharp/ql/test/library-tests/delegates/delegates.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,17 @@ static void Main()
8383

8484
}
8585

86+
class E
87+
{
88+
Action<int> Field;
89+
Action<int> Property { get; set; }
90+
91+
void M()
92+
{
93+
this.Field(0);
94+
this.Property(0);
95+
Field(0);
96+
Property(0);
97+
}
98+
}
8699
}

0 commit comments

Comments
 (0)