Skip to content

Commit 9f14c7c

Browse files
authored
Merge pull request github#15297 from michaelnebel/csharp/typealias
C# 12: Type alias [Test only]
2 parents e408078 + ef73fc3 commit 9f14c7c

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
3+
using TupleType1 = (int, object);
4+
using TupleType2 = (int, string);
5+
using TupleType3 = (int, object);
6+
using Point = (int x, int y);
7+
8+
public class TupleMethods
9+
{
10+
public void M1(TupleType1 t)
11+
{
12+
var x = t.Item1;
13+
var y = t.Item2;
14+
}
15+
16+
public void M2(TupleType2 t)
17+
{
18+
var x = t.Item1;
19+
var y = t.Item2;
20+
M1(t);
21+
}
22+
23+
public void M3(Point p)
24+
{
25+
var x = p.x;
26+
var y = p.y;
27+
}
28+
29+
public void M4(TupleType3 t) { }
30+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
| alias.cs:10:17:10:18 | M1 | alias.cs:10:31:10:31 | t | (Int32,Object) |
2+
| alias.cs:16:17:16:18 | M2 | alias.cs:16:31:16:31 | t | (Int32,String) |
3+
| alias.cs:23:17:23:18 | M3 | alias.cs:23:26:23:26 | p | (Int32,Int32) |
4+
| alias.cs:29:17:29:18 | M4 | alias.cs:29:31:29:31 | t | (Int32,Object) |
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import csharp
2+
3+
from Method m, Parameter p, Type t
4+
where
5+
m.fromSource() and
6+
p = m.getAParameter() and
7+
p.getType() = t
8+
select m, p, t.toString()

0 commit comments

Comments
 (0)