Skip to content

Commit c481e82

Browse files
committed
C#: Add indexer data flow test.
1 parent 568fd9c commit c481e82

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @kind path-problem
3+
*/
4+
5+
import csharp
6+
import utils.test.InlineFlowTest
7+
import DefaultFlowTest
8+
import PathGraph
9+
10+
from PathNode source, PathNode sink
11+
where flowPath(source, sink)
12+
select sink, source, sink, "$@", source, source.toString()
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
public partial class Partial1
2+
{
3+
private object[] _backingArray = new object[10];
4+
public partial object this[int index]
5+
{
6+
get { return _backingArray[index]; }
7+
set { _backingArray[index] = value; }
8+
}
9+
}
10+
11+
public partial class Partial1
12+
{
13+
public partial object this[int index] { get; set; }
14+
}
15+
16+
public partial class Partial2
17+
{
18+
public partial object this[int index]
19+
{
20+
get { return null; }
21+
set { }
22+
}
23+
}
24+
25+
public partial class Partial2
26+
{
27+
public partial object this[int index] { get; set; }
28+
}
29+
30+
public partial class PartialTest
31+
{
32+
public void M()
33+
{
34+
var o = Source<object>(1);
35+
36+
var p1 = new Partial1();
37+
p1[0] = o;
38+
Sink(p1[0]); // $ hasValueFlow=1
39+
40+
var p2 = new Partial2();
41+
p2[0] = o;
42+
Sink(p2[0]); // no flow
43+
}
44+
45+
public static void Sink(object o) { }
46+
47+
static T Source<T>(object source) => throw null;
48+
}

0 commit comments

Comments
 (0)