Skip to content

Commit cd5f678

Browse files
committed
C#: Add IntegerCollection class to the CollectionFlow tests and update line numbers in expected test output.
1 parent da4a9b6 commit cd5f678

File tree

2 files changed

+601
-576
lines changed

2 files changed

+601
-576
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections;
23
using System.Collections.Generic;
34
using System.Linq;
45

@@ -448,4 +449,28 @@ public void CollectionExpressionSpreadElementFlow()
448449
A[] array = [.. temp];
449450
Sink(array[0]); // flow
450451
}
452+
453+
[System.Runtime.CompilerServices.CollectionBuilder(typeof(IntegerCollectionBuilder), "Create")]
454+
public class IntegerCollection : IEnumerable<int>
455+
{
456+
private int[] items;
457+
458+
public A? Payload { get; set; }
459+
460+
public IntegerCollection(ReadOnlySpan<int> items)
461+
{
462+
this.items = items.ToArray();
463+
Payload = null;
464+
}
465+
466+
public IEnumerator<int> GetEnumerator() => items.AsEnumerable<int>().GetEnumerator();
467+
468+
IEnumerator IEnumerable.GetEnumerator() => items.GetEnumerator();
469+
}
470+
471+
public static class IntegerCollectionBuilder
472+
{
473+
public static IntegerCollection Create(ReadOnlySpan<int> elements)
474+
=> new IntegerCollection(elements);
475+
}
451476
}

0 commit comments

Comments
 (0)