Skip to content

Commit 4083348

Browse files
committed
C#: Add a primary constructor QL library test.
1 parent ff29679 commit 4083348

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| constructors.cs:23:18:23:19 | C1 |
2+
| constructors.cs:28:18:28:19 | C2 |
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @name Test for primary constructors
3+
*/
4+
5+
import csharp
6+
7+
from PrimaryConstructor c
8+
select c

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,30 @@ constructors.cs:
1717
# 16| -1: [TypeMention] int
1818
# 16| 0: [LocalVariableAccess] access to local variable i
1919
# 16| 1: [IntLiteral] 0
20+
# 21| [NamespaceDeclaration] namespace ... { ... }
21+
# 23| 1: [Class] C1
22+
# 23| 4: [InstanceConstructor,PrimaryConstructor] C1
23+
#-----| 2: (Parameters)
24+
# 23| 0: [Parameter] o
25+
# 23| -1: [TypeMention] object
26+
# 23| 1: [Parameter] s
27+
# 23| -1: [TypeMention] string
28+
# 25| 5: [InstanceConstructor] C1
29+
#-----| 2: (Parameters)
30+
# 25| 0: [Parameter] o
31+
# 25| -1: [TypeMention] object
32+
# 25| 3: [ConstructorInitializer] call to constructor C1
33+
# 25| 0: [ParameterAccess] access to parameter o
34+
# 25| 1: [StringLiteralUtf16] "default"
35+
# 25| 4: [BlockStmt] {...}
36+
# 28| 2: [Class] C2
37+
#-----| 3: (Base types)
38+
# 28| 0: [TypeMention] C1
39+
# 28| 4: [InstanceConstructor,PrimaryConstructor] C2
40+
#-----| 2: (Parameters)
41+
# 28| 0: [Parameter] o
42+
# 28| -1: [TypeMention] object
43+
# 28| 1: [Parameter] s
44+
# 28| -1: [TypeMention] string
45+
# 28| 2: [Parameter] i
46+
# 28| -1: [TypeMention] int

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,13 @@ static Class()
1717
}
1818
}
1919
}
20+
21+
namespace PrimaryConstructors
22+
{
23+
public class C1(object o, string s)
24+
{
25+
public C1(object o) : this(o, "default") { }
26+
}
27+
28+
public class C2(object o, string s, int i) : C1(o, s) { }
29+
}

0 commit comments

Comments
 (0)