Skip to content

Commit 9cc9991

Browse files
committed
C#: Update ContentDataFlow test
Illustrates missing flow when the sink is inside a method that is also part of a `subpath`.
1 parent 909ad2a commit 9cc9991

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

csharp/ql/test/library-tests/dataflow/content/ContentFlow.cs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,36 @@ public class B
1616
public void M(A a, B b)
1717
{
1818
var a1 = new A();
19-
Sink(a1.FieldA.FieldB);
19+
Sink(Through(a1.FieldA.FieldB));
2020

2121
a.FieldA.FieldB = new B();
22-
Sink(a);
22+
Sink(Through(a));
2323

2424
var a2 = new A();
2525
b.FieldB.FieldA = a2.FieldB.FieldA;
26-
Sink(b);
26+
Sink(Through(b));
27+
28+
Sink(Through(Out()));
29+
30+
In(new A().FieldA.FieldB);
2731
}
2832

2933
public static void Sink<T>(T t) { }
3034

35+
public T Through<T>(T t)
36+
{
37+
Sink(t);
38+
return t;
39+
}
40+
41+
public void In<T>(T t)
42+
{
43+
Sink(t);
44+
}
45+
46+
public B Out()
47+
{
48+
var a = new A();
49+
return a.FieldA.FieldB;
50+
}
3151
}
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
| ContentFlow.cs:18:18:18:24 | object creation of type A | field FieldB.field FieldA. | ContentFlow.cs:19:14:19:29 | access to field FieldB | | true |
2-
| ContentFlow.cs:21:27:21:33 | object creation of type B | | ContentFlow.cs:22:14:22:14 | access to parameter a | field FieldA.field FieldB. | true |
3-
| ContentFlow.cs:24:18:24:24 | object creation of type A | field FieldA.field FieldB. | ContentFlow.cs:26:14:26:14 | access to parameter b | field FieldB.field FieldA. | true |
1+
| ContentFlow.cs:18:18:18:24 | object creation of type A | field FieldB.field FieldA. | ContentFlow.cs:19:14:19:38 | call to method Through<B> | | true |
2+
| ContentFlow.cs:21:27:21:33 | object creation of type B | | ContentFlow.cs:22:14:22:23 | call to method Through<A> | field FieldA.field FieldB. | true |
3+
| ContentFlow.cs:24:18:24:24 | object creation of type A | field FieldA.field FieldB. | ContentFlow.cs:26:14:26:23 | call to method Through<B> | field FieldB.field FieldA. | true |
4+
| ContentFlow.cs:30:12:30:18 | object creation of type A | field FieldB.field FieldA. | ContentFlow.cs:43:14:43:14 | access to parameter t | | true |
5+
| ContentFlow.cs:48:17:48:23 | object creation of type A | field FieldB.field FieldA. | ContentFlow.cs:28:14:28:27 | call to method Through<B> | | true |

0 commit comments

Comments
 (0)