Skip to content

Commit 6b38a81

Browse files
committed
C#: Add some test cases for primary constructor inititalizers and a failing dataflow test.
1 parent d1d213d commit 6b38a81

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

csharp/ql/test/library-tests/dataflow/constructors/ConstructorFlow.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
testFailures
2+
| Constructors.cs:113:25:113:43 | // ... | Missing result:hasValueFlow=6 |
23
edges
34
| Constructors.cs:5:24:5:25 | [post] this access : C_no_ctor [field s1] : Object | Constructors.cs:9:27:9:41 | object creation of type C_no_ctor : C_no_ctor [field s1] : Object | provenance | |
45
| Constructors.cs:5:29:5:45 | call to method Source<Object> : Object | Constructors.cs:5:24:5:25 | [post] this access : C_no_ctor [field s1] : Object | provenance | |

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,18 @@ public void M4()
101101
Sink(c2.Obj22); // $ hasValueFlow=5
102102
}
103103

104+
public class C3(object o31param)
105+
{
106+
public object Obj31 => o31param;
107+
}
108+
109+
public void M5()
110+
{
111+
var o31 = Source<object>(6);
112+
var c3 = new C3(o31);
113+
Sink(c3.Obj31); // $ hasValueFlow=6
114+
}
115+
104116
public static void Sink(object o) { }
105117

106118
public static T Source<T>(object source) => throw null;

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2406,3 +2406,15 @@ expressions.cs:
24062406
# 512| 0: [IntLiteral] 10
24072407
# 515| 5: [Field] myInlineArrayElements
24082408
# 515| -1: [TypeMention] int
2409+
# 518| 22: [Class] ClassC1
2410+
# 518| 4: [InstanceConstructor,PrimaryConstructor] ClassC1
2411+
#-----| 2: (Parameters)
2412+
# 518| 0: [Parameter] oc1
2413+
# 518| -1: [TypeMention] object
2414+
# 520| 23: [Class] ClassC2
2415+
#-----| 3: (Base types)
2416+
# 520| 0: [TypeMention] ClassC1
2417+
# 520| 4: [InstanceConstructor,PrimaryConstructor] ClassC2
2418+
#-----| 2: (Parameters)
2419+
# 520| 0: [Parameter] oc2
2420+
# 520| -1: [TypeMention] object

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,4 +514,8 @@ struct MyInlineArray
514514
{
515515
private int myInlineArrayElements;
516516
}
517+
518+
class ClassC1(object oc1) { }
519+
520+
class ClassC2(object oc2) : ClassC1(oc2) { }
517521
}

0 commit comments

Comments
 (0)