I am trying to build a SeparatedList
using a dynamically-generated IEnumerable
sequence (which is constructed by an Enumerable.Select()
function call). The API function to create a SeparatedList
takes two parameters, an IEnumerable<T>
and an IEnumerable<SyntaxToken>
. I have provided a simple function, Repeat
, that is an infinite sequence generator which yields as many commas, in this case, as are requested.
The SeparatedList
function appears to consume as many of the first sequence (parameter types here) as there are entries in the second sequence, which messes me up. Have I misunderstood how the function is supposed to work and has anyone else done this? Thanks
Syntax.SeparatedList<ParameterSyntax>(
functionParameterTypes,Repeat(i=>Syntax.Token(SyntaxKind.CommaToken)))
(Edit: I should add that converting the functionParameterTypes
to a List<>
and passing another List<>
with one fewer token than elements in functionParameterTypes
does work but I am trying to do this without having to explicitly build the list ahead of time.)