Skip to content

Commit fc0fc74

Browse files
committed
C#: Add test for extension method calls
1 parent f73960d commit fc0fc74

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
methodCallTargets
2+
| methods.cs:19:13:19:22 | call to method Ext0 | methods.cs:8:28:8:34 | Ext0 | Ext0<int>(string, int) |
3+
| methods.cs:20:13:20:27 | call to method Ext0 | methods.cs:8:28:8:34 | Ext0 | Ext0<int>(string, int) |
4+
| methods.cs:21:13:21:30 | call to method Ext0 | methods.cs:8:28:8:34 | Ext0 | Ext0<double>(double) |
5+
| methods.cs:22:13:22:33 | call to method Ext0 | methods.cs:8:28:8:34 | Ext0 | Ext0<object>(object) |
6+
| methods.cs:23:13:23:34 | call to method Ext0 | methods.cs:8:28:8:34 | Ext0 | Ext0<int>(string, int) |
7+
| methods.cs:24:13:24:39 | call to method Ext0 | methods.cs:8:28:8:34 | Ext0 | Ext0<int>(string, int) |
8+
| methods.cs:25:13:25:42 | call to method Ext0 | methods.cs:8:28:8:34 | Ext0 | Ext0<double>(string, double) |
9+
| methods.cs:26:13:26:45 | call to method Ext0 | methods.cs:8:28:8:34 | Ext0 | Ext0<object>(string, object) |
10+
| methods.cs:28:13:28:22 | call to method Ext1 | methods.cs:10:28:10:31 | Ext1 | Ext1(string, int) |
11+
| methods.cs:29:13:29:34 | call to method Ext1 | methods.cs:10:28:10:31 | Ext1 | Ext1(string, int) |
12+
| methods.cs:31:13:31:21 | call to method Ext2 | methods.cs:12:28:12:34 | Ext2 | Ext2<int>(int, int) |
13+
| methods.cs:32:13:32:26 | call to method Ext2 | methods.cs:12:28:12:34 | Ext2 | Ext2<int>(int, int) |
14+
| methods.cs:33:13:33:22 | call to method Ext2 | methods.cs:12:28:12:34 | Ext2 | Ext2<string>(string, int) |
15+
| methods.cs:34:13:34:30 | call to method Ext2 | methods.cs:12:28:12:34 | Ext2 | Ext2<string>(string, int) |
16+
| methods.cs:35:13:35:30 | call to method Ext2 | methods.cs:12:28:12:34 | Ext2 | Ext2<object>(object, int) |
17+
| methods.cs:36:13:36:33 | call to method Ext2 | methods.cs:12:28:12:34 | Ext2 | Ext2<int>(int, int) |
18+
| methods.cs:37:13:37:38 | call to method Ext2 | methods.cs:12:28:12:34 | Ext2 | Ext2<int>(int, int) |
19+
| methods.cs:38:13:38:34 | call to method Ext2 | methods.cs:12:28:12:34 | Ext2 | Ext2<string>(string, int) |
20+
| methods.cs:39:13:39:42 | call to method Ext2 | methods.cs:12:28:12:34 | Ext2 | Ext2<string>(string, int) |
21+
| methods.cs:40:13:40:42 | call to method Ext2 | methods.cs:12:28:12:34 | Ext2 | Ext2<object>(object, int) |
22+
genericMethodCallTargets
23+
| methods.cs:19:13:19:22 | call to method Ext0 | methods.cs:8:28:8:34 | Ext0 | Ext0<int>(string, int) | methods.cs:8:28:8:34 | Ext0 | Ext0<T>(string, T) |
24+
| methods.cs:20:13:20:27 | call to method Ext0 | methods.cs:8:28:8:34 | Ext0 | Ext0<int>(string, int) | methods.cs:8:28:8:34 | Ext0 | Ext0<T>(string, T) |
25+
| methods.cs:21:13:21:30 | call to method Ext0 | methods.cs:8:28:8:34 | Ext0 | Ext0<double>(double) | methods.cs:8:28:8:34 | Ext0 | Ext0<T>(string, T) |
26+
| methods.cs:22:13:22:33 | call to method Ext0 | methods.cs:8:28:8:34 | Ext0 | Ext0<object>(object) | methods.cs:8:28:8:34 | Ext0 | Ext0<T>(string, T) |
27+
| methods.cs:23:13:23:34 | call to method Ext0 | methods.cs:8:28:8:34 | Ext0 | Ext0<int>(string, int) | methods.cs:8:28:8:34 | Ext0 | Ext0<T>(string, T) |
28+
| methods.cs:24:13:24:39 | call to method Ext0 | methods.cs:8:28:8:34 | Ext0 | Ext0<int>(string, int) | methods.cs:8:28:8:34 | Ext0 | Ext0<T>(string, T) |
29+
| methods.cs:25:13:25:42 | call to method Ext0 | methods.cs:8:28:8:34 | Ext0 | Ext0<double>(string, double) | methods.cs:8:28:8:34 | Ext0 | Ext0<T>(string, T) |
30+
| methods.cs:26:13:26:45 | call to method Ext0 | methods.cs:8:28:8:34 | Ext0 | Ext0<object>(string, object) | methods.cs:8:28:8:34 | Ext0 | Ext0<T>(string, T) |
31+
| methods.cs:31:13:31:21 | call to method Ext2 | methods.cs:12:28:12:34 | Ext2 | Ext2<int>(int, int) | methods.cs:12:28:12:34 | Ext2 | Ext2<T>(T, int) |
32+
| methods.cs:32:13:32:26 | call to method Ext2 | methods.cs:12:28:12:34 | Ext2 | Ext2<int>(int, int) | methods.cs:12:28:12:34 | Ext2 | Ext2<T>(T, int) |
33+
| methods.cs:33:13:33:22 | call to method Ext2 | methods.cs:12:28:12:34 | Ext2 | Ext2<string>(string, int) | methods.cs:12:28:12:34 | Ext2 | Ext2<T>(T, int) |
34+
| methods.cs:34:13:34:30 | call to method Ext2 | methods.cs:12:28:12:34 | Ext2 | Ext2<string>(string, int) | methods.cs:12:28:12:34 | Ext2 | Ext2<T>(T, int) |
35+
| methods.cs:35:13:35:30 | call to method Ext2 | methods.cs:12:28:12:34 | Ext2 | Ext2<object>(object, int) | methods.cs:12:28:12:34 | Ext2 | Ext2<T>(T, int) |
36+
| methods.cs:36:13:36:33 | call to method Ext2 | methods.cs:12:28:12:34 | Ext2 | Ext2<int>(int, int) | methods.cs:12:28:12:34 | Ext2 | Ext2<T>(T, int) |
37+
| methods.cs:37:13:37:38 | call to method Ext2 | methods.cs:12:28:12:34 | Ext2 | Ext2<int>(int, int) | methods.cs:12:28:12:34 | Ext2 | Ext2<T>(T, int) |
38+
| methods.cs:38:13:38:34 | call to method Ext2 | methods.cs:12:28:12:34 | Ext2 | Ext2<string>(string, int) | methods.cs:12:28:12:34 | Ext2 | Ext2<T>(T, int) |
39+
| methods.cs:39:13:39:42 | call to method Ext2 | methods.cs:12:28:12:34 | Ext2 | Ext2<string>(string, int) | methods.cs:12:28:12:34 | Ext2 | Ext2<T>(T, int) |
40+
| methods.cs:40:13:40:42 | call to method Ext2 | methods.cs:12:28:12:34 | Ext2 | Ext2<object>(object, int) | methods.cs:12:28:12:34 | Ext2 | Ext2<T>(T, int) |
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import csharp
2+
3+
query predicate methodCallTargets(MethodCall mc, Method m, string sig) {
4+
m = mc.getTarget() and sig = m.toStringWithTypes()
5+
}
6+
7+
query predicate genericMethodCallTargets(
8+
MethodCall mc, ConstructedMethod cm, string sig1, UnboundGenericMethod ugm, string sig2
9+
) {
10+
cm = mc.getTarget() and
11+
sig1 = cm.toStringWithTypes() and
12+
ugm = cm.getUnboundGeneric() and
13+
sig2 = ugm.toStringWithTypes()
14+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
3+
namespace Test
4+
{
5+
6+
public static class Extensions
7+
{
8+
public static void Ext0<T>(this string self, T arg) { }
9+
10+
public static void Ext1(this string self, int arg) { }
11+
12+
public static void Ext2<T>(this T self, int arg) { }
13+
}
14+
15+
public class Program
16+
{
17+
public static void M()
18+
{
19+
"".Ext0(1);
20+
"".Ext0<int>(1);
21+
"".Ext0<double>(1);
22+
"".Ext0<object>(null);
23+
Extensions.Ext0("", 1);
24+
Extensions.Ext0<int>("", 1);
25+
Extensions.Ext0<double>("", 1);
26+
Extensions.Ext0<object>("", null);
27+
28+
"".Ext1(1);
29+
Extensions.Ext1("", 1);
30+
31+
1.Ext2(1);
32+
1.Ext2<int>(1);
33+
"".Ext2(1);
34+
"".Ext2<string>(1);
35+
"".Ext2<object>(1);
36+
Extensions.Ext2(1, 1);
37+
Extensions.Ext2<int>(1, 1);
38+
Extensions.Ext2("", 1);
39+
Extensions.Ext2<string>("", 1);
40+
Extensions.Ext2<object>("", 1);
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)