mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
C#: Add a test for type alias.
This commit is contained in:
30
csharp/ql/test/library-tests/typealias/alias.cs
Normal file
30
csharp/ql/test/library-tests/typealias/alias.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
|
||||
using TupleType1 = (int, object);
|
||||
using TupleType2 = (int, string);
|
||||
using TupleType3 = (int, object);
|
||||
using Point = (int x, int y);
|
||||
|
||||
public class TupleMethods
|
||||
{
|
||||
public void M1(TupleType1 t)
|
||||
{
|
||||
var x = t.Item1;
|
||||
var y = t.Item2;
|
||||
}
|
||||
|
||||
public void M2(TupleType2 t)
|
||||
{
|
||||
var x = t.Item1;
|
||||
var y = t.Item2;
|
||||
M1(t);
|
||||
}
|
||||
|
||||
public void M3(Point p)
|
||||
{
|
||||
var x = p.x;
|
||||
var y = p.y;
|
||||
}
|
||||
|
||||
public void M4(TupleType3 t) { }
|
||||
}
|
||||
4
csharp/ql/test/library-tests/typealias/alias.expected
Normal file
4
csharp/ql/test/library-tests/typealias/alias.expected
Normal file
@@ -0,0 +1,4 @@
|
||||
| alias.cs:10:17:10:18 | M1 | alias.cs:10:31:10:31 | t | (Int32,Object) |
|
||||
| alias.cs:16:17:16:18 | M2 | alias.cs:16:31:16:31 | t | (Int32,String) |
|
||||
| alias.cs:23:17:23:18 | M3 | alias.cs:23:26:23:26 | p | (Int32,Int32) |
|
||||
| alias.cs:29:17:29:18 | M4 | alias.cs:29:31:29:31 | t | (Int32,Object) |
|
||||
8
csharp/ql/test/library-tests/typealias/alias.ql
Normal file
8
csharp/ql/test/library-tests/typealias/alias.ql
Normal file
@@ -0,0 +1,8 @@
|
||||
import csharp
|
||||
|
||||
from Method m, Parameter p, Type t
|
||||
where
|
||||
m.fromSource() and
|
||||
p = m.getAParameter() and
|
||||
p.getType() = t
|
||||
select m, p, t.toString()
|
||||
Reference in New Issue
Block a user