Skip to content

Commit afe3c5e

Browse files
committed
C#: Re-arrange the code in constructor data flow test and update expected output.
1 parent 1520305 commit afe3c5e

File tree

2 files changed

+82
-84
lines changed

2 files changed

+82
-84
lines changed
Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,40 @@
1-
public class C_no_ctor
1+
public class Constructors
22
{
3-
private Elem s1 = Util.Source<Elem>(1);
4-
5-
void M1()
3+
public class C_no_ctor
64
{
7-
C_no_ctor c = new C_no_ctor();
8-
c.M2();
5+
private object s1 = Source<object>(1);
6+
7+
void M1()
8+
{
9+
C_no_ctor c = new C_no_ctor();
10+
c.M2();
11+
}
12+
13+
public void M2()
14+
{
15+
Sink(s1); // $ hasValueFlow=1
16+
}
917
}
1018

11-
public void M2()
19+
public class C_with_ctor
1220
{
13-
Util.Sink(s1); // $ hasValueFlow=1
14-
}
15-
}
21+
private object s1 = Source<object>(1);
1622

17-
public class C_with_ctor
18-
{
19-
private Elem s1 = Util.Source<Elem>(1);
23+
void M1()
24+
{
25+
C_with_ctor c = new C_with_ctor();
26+
c.M2();
27+
}
2028

21-
void M1()
22-
{
23-
C_with_ctor c = new C_with_ctor();
24-
c.M2();
25-
}
29+
public C_with_ctor() { }
2630

27-
public C_with_ctor() { }
28-
29-
public void M2()
30-
{
31-
Util.Sink(s1); // $ hasValueFlow=1
31+
public void M2()
32+
{
33+
Sink(s1); // $ hasValueFlow=1
34+
}
3235
}
33-
}
3436

35-
class Util
36-
{
3737
public static void Sink(object o) { }
3838

3939
public static T Source<T>(object source) => throw null;
4040
}
41-
42-
public class Elem { }

0 commit comments

Comments
 (0)