Skip to content

Commit 6efbd5f

Browse files
committed
C#: Add data-flow test for List.Clear()
1 parent 9d8052a commit 6efbd5f

File tree

2 files changed

+82
-51
lines changed

2 files changed

+82
-51
lines changed

csharp/ql/test/library-tests/dataflow/collections/CollectionFlow.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,17 @@ public void ParamsNoFlow(A other)
358358
SinkParams(new A[] { other }); // no flow
359359
}
360360

361+
public void ListAddClearNoFlow()
362+
{
363+
var a = new A();
364+
var list = new List<A>();
365+
list.Add(a);
366+
list.Clear();
367+
Sink(list[0]); // no flow [FALSE NEGATIVE]
368+
SinkListElem(list); // no flow [FALSE NEGATIVE]
369+
Sink(ListFirst(list)); // no flow [FALSE NEGATIVE]
370+
}
371+
361372
public static void Sink<T>(T t) { }
362373

363374
public static void SinkElem<T>(T[] ts) => Sink(ts[0]);

0 commit comments

Comments
 (0)