diff --git a/Generators/SuperLinq.Async.Generator/EquiZip.sbntxt b/Generators/SuperLinq.Async.Generator/EquiZip.sbntxt
index b7e4c58d..4e255eec 100644
--- a/Generators/SuperLinq.Async.Generator/EquiZip.sbntxt
+++ b/Generators/SuperLinq.Async.Generator/EquiZip.sbntxt
@@ -1,9 +1,8 @@
-{{
- $arity = arity
- $ordinals = ordinals
- $cardinals = cardinals
-}}
-
+{{~
+ $arity = arity
+ $ordinals = ordinals
+ $cardinals = cardinals
+~}}
namespace SuperLinq.Async;
#nullable enable
@@ -11,54 +10,57 @@ namespace SuperLinq.Async;
public static partial class AsyncSuperEnumerable
{
{{~ for $i in 2..4 ~}}
- ///
+ ///
///
/// Applies a specified function to the corresponding elements of {{ $ordinals[$i] }} sequences,
/// producing a sequence of the results.
///
/// The resulting sequence has the same length as the input sequences.
/// If the input sequences are of different lengths, an exception is thrown.
- ///
- ///
- /// The type of the elements of the result sequence.
- /// A projection function that combines
- /// elements from all of the sequences.
- /// A sequence of elements returned by .
- ///
- /// This method uses deferred execution and stream its results.
- ///
- /// or any of the input sequences is null.
- ///
+ ///
+ ///
+ /// The type of the elements of the result sequence.
+ /// A projection function that combines
+ /// elements from all of the sequences.
+ /// A sequence of elements returned by .
+ ///
+ /// This method uses deferred execution and stream its results.
+ ///
+ /// or any of the input sequences is null.
+ ///
/// Any of the input sequences are shorter than the others.
///
{{~ for $j in 1..$i ~}}
- /// The type of the elements of .
+ /// The type of the elements of .
/// The {{ $ordinals[$j] }} sequence of elements.
{{~ end ~}}
- public static global::System.Collections.Generic.IAsyncEnumerable EquiZip<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult>(this
+ public static global::System.Collections.Generic.IAsyncEnumerable EquiZip<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult>(this
{{~ for $j in 1..$i ~}}
- global::System.Collections.Generic.IAsyncEnumerable {{ $ordinals[$j] }},
+ global::System.Collections.Generic.IAsyncEnumerable {{ $ordinals[$j] }},
{{~ end ~}}
- global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector)
+ global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector
+ )
{
{{~ for $j in 1..$i ~}}
- ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }});
+ ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }});
{{~ end ~}}
- ArgumentNullException.ThrowIfNull(resultSelector);
+ ArgumentNullException.ThrowIfNull(resultSelector);
return Core(
{{~ for $j in 1..$i ~}}
{{ $ordinals[$j] }},
{{~ end ~}}
- resultSelector);
+ resultSelector
+ );
static async global::System.Collections.Generic.IAsyncEnumerable Core(
{{~ for $j in 1..$i ~}}
global::System.Collections.Generic.IAsyncEnumerable {{ $ordinals[$j] }},
{{~ end ~}}
global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector,
- [EnumeratorCancellation] CancellationToken cancellationToken = default)
+ [EnumeratorCancellation] CancellationToken cancellationToken = default
+ )
{
{{~ for $j in 1..$i ~}}
await using var e{{ $j }} = {{ $ordinals[$j] }}.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator();
@@ -75,10 +77,10 @@ public static partial class AsyncSuperEnumerable
|| await e{{$j}}.MoveNextAsync()
{{~ end
end ~}}
- )
+ )
{
- ThrowHelper.ThrowInvalidOperationException("First sequence too short.");
- }
+ ThrowHelper.ThrowInvalidOperationException("First sequence too short.");
+ }
yield break;
}
@@ -101,26 +103,27 @@ public static partial class AsyncSuperEnumerable
///
/// Joins the corresponding elements of {{ $ordinals[$i] }} sequences,
/// producing a sequence of tuples containing them.
- ///
- /// A sequence of
+ ///
+ /// A sequence of
///
- /// containing corresponding elements from each of the sequences.
- ///
- /// This method uses deferred execution and stream its results.
- ///
- /// Any of the input sequences is null.
- ///
+ /// containing corresponding elements from each of the sequences.
+ ///
+ /// This method uses deferred execution and stream its results.
+ ///
+ /// Any of the input sequences is null.
+ ///
/// Any of the input sequences are shorter than the others.
///
{{~ for $j in 1..$i ~}}
- /// The type of the elements of .
+ /// The type of the elements of .
/// The {{ $ordinals[$j] }} sequence of elements.
{{~ end ~}}
- public static global::System.Collections.Generic.IAsyncEnumerable<({{~ for $j in 1..$i ~}}T{{ $cardinals[$j] }}{{ if !for.last }},{{ end }}{{ end }})>
+ public static global::System.Collections.Generic.IAsyncEnumerable<({{~ for $j in 1..$i ~}}T{{ $cardinals[$j] }}{{ if !for.last }},{{ end }}{{ end }})>
EquiZip<{{~ for $j in 1..$i ~}}T{{ $cardinals[$j] }}{{ if !for.last }},{{ end }}{{ end }}>(this
{{~ for $j in 1..$i ~}}
global::System.Collections.Generic.IAsyncEnumerable {{ $ordinals[$j] }}{{ if !for.last }},{{ end }}
- {{~ end ~}}) =>
- EquiZip({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create);
- {{ end ~}}
+ {{~ end ~}}
+ ) => EquiZip({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create);
+
+ {{~ end ~}}
}
diff --git a/Generators/SuperLinq.Async.Generator/Fold.sbntxt b/Generators/SuperLinq.Async.Generator/Fold.sbntxt
index d21beae2..f59bf973 100644
--- a/Generators/SuperLinq.Async.Generator/Fold.sbntxt
+++ b/Generators/SuperLinq.Async.Generator/Fold.sbntxt
@@ -1,41 +1,39 @@
-namespace SuperLinq.Async;
+namespace SuperLinq.Async;
#nullable enable
public static partial class AsyncSuperEnumerable
{
{{~ for $i in 1..16 ~}}
- ///
- /// Returns the result of applying a function to a sequence of {{$i}} element{{if $i != 1}}s{{end}}.
- ///
- ///
- /// This operator uses immediate execution and buffers as many items of the source sequence as necessary.
- ///
- /// Type of element in the source sequence
- /// Type of the result
- /// The sequence of items to fold.
- /// Function to apply to the elements in the sequence.
- /// The folded value returned by .
- /// or is null.
- ///
+ ///
+ /// Returns the result of applying a function to a sequence of {{$i}} element{{if $i != 1}}s{{end}}.
+ ///
+ ///
+ /// This operator uses immediate execution and buffers as many items of the source sequence as necessary.
+ ///
+ /// Type of element in the source sequence
+ /// Type of the result
+ /// The sequence of items to fold.
+ /// Function to apply to the elements in the sequence.
+ /// The folded value returned by .
+ /// or is null.
+ ///
/// does not contain exactly {{$i}} element{{if $i != 1}}s{{end}}.
///
- public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func<
- {{~ for $j in 1..$i ~}}
- T,
- {{~ end ~}}
- TResult> folder)
- {
+ public static global::System.Threading.Tasks.ValueTask Fold(
+ this global::System.Collections.Generic.IAsyncEnumerable source,
+ global::System.Func<{{~ for $j in 1..$i ~}}T, {{ end ~}}TResult> folder
+ )
+ {
ArgumentNullException.ThrowIfNull(source);
ArgumentNullException.ThrowIfNull(folder);
return Core(source, folder);
- static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func<
- {{~ for $j in 1..$i ~}}
- T,
- {{~ end ~}}
- TResult> folder)
+ static async global::System.Threading.Tasks.ValueTask Core(
+ global::System.Collections.Generic.IAsyncEnumerable source,
+ global::System.Func<{{~ for $j in 1..$i ~}}T, {{ end ~}}TResult> folder
+ )
{
var elements = await source.AssertCount({{$i}}).ToListAsync().ConfigureAwait(false);
@@ -46,5 +44,6 @@ public static partial class AsyncSuperEnumerable
);
}
}
- {{ end ~}}
+
+ {{~ end ~}}
}
diff --git a/Generators/SuperLinq.Async.Generator/Generator.cs b/Generators/SuperLinq.Async.Generator/Generator.cs
index fd96595d..8fb4cd13 100644
--- a/Generators/SuperLinq.Async.Generator/Generator.cs
+++ b/Generators/SuperLinq.Async.Generator/Generator.cs
@@ -1,4 +1,4 @@
-using System.Text;
+using System.Text;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Text;
using Scriban;
@@ -28,14 +28,6 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
private static SourceText GenerateArgumentNamesTemplate(string template)
{
var output = Template.Parse(template).Render(ArgumentNames.Instance);
-
- // Apply formatting since indenting isn't that nice in Scriban when rendering nested
- // structures via functions.
- output = Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ParseCompilationUnit(output)
- .NormalizeWhitespace()
- .GetText()
- .ToString();
-
return SourceText.From(output, Encoding.UTF8);
}
}
diff --git a/Generators/SuperLinq.Async.Generator/ZipLongest.sbntxt b/Generators/SuperLinq.Async.Generator/ZipLongest.sbntxt
index fca200a4..f8f19ec1 100644
--- a/Generators/SuperLinq.Async.Generator/ZipLongest.sbntxt
+++ b/Generators/SuperLinq.Async.Generator/ZipLongest.sbntxt
@@ -1,9 +1,8 @@
-{{
- $arity = arity
- $ordinals = ordinals
- $cardinals = cardinals
-}}
-
+{{~
+ $arity = arity
+ $ordinals = ordinals
+ $cardinals = cardinals
+~}}
namespace SuperLinq.Async;
#nullable enable
@@ -11,50 +10,53 @@ namespace SuperLinq.Async;
public static partial class AsyncSuperEnumerable
{
{{~ for $i in 2..4 ~}}
- ///
+ ///
/// Returns a projection of tuples, where each tuple contains the N-th
/// element from each of the argument sequences. The resulting sequence
/// will always be as long as the longest of input sequences where the
/// default value of each of the shorter sequence element types is used
/// for padding.
- ///
- ///
- /// The type of the elements of the result sequence.
- /// A projection function that combines
- /// elements from all of the sequences.
- /// A sequence of elements returned by .
- ///
- /// This method uses deferred execution and streams its results.
- ///
- /// or any of the input sequences is null.
+ ///
+ ///
+ /// The type of the elements of the result sequence.
+ /// A projection function that combines
+ /// elements from all of the sequences.
+ /// A sequence of elements returned by .
+ ///
+ /// This method uses deferred execution and streams its results.
+ ///
+ /// or any of the input sequences is null.
{{~ for $j in 1..$i ~}}
- /// The type of the elements of .
+ /// The type of the elements of .
/// The {{ $ordinals[$j] }} sequence of elements.
{{~ end ~}}
- public static global::System.Collections.Generic.IAsyncEnumerable ZipLongest<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult>(this
+ public static global::System.Collections.Generic.IAsyncEnumerable ZipLongest<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult>(this
{{~ for $j in 1..$i ~}}
- global::System.Collections.Generic.IAsyncEnumerable {{ $ordinals[$j] }},
+ global::System.Collections.Generic.IAsyncEnumerable {{ $ordinals[$j] }},
{{~ end ~}}
- global::System.Func<{{ for $j in 1..$i }}T{{ $j }}?, {{ end }}TResult> resultSelector)
+ global::System.Func<{{ for $j in 1..$i }}T{{ $j }}?, {{ end }}TResult> resultSelector
+ )
{
{{~ for $j in 1..$i ~}}
- ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }});
+ ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }});
{{~ end ~}}
- ArgumentNullException.ThrowIfNull(resultSelector);
+ ArgumentNullException.ThrowIfNull(resultSelector);
return Core(
{{~ for $j in 1..$i ~}}
{{ $ordinals[$j] }},
{{~ end ~}}
- resultSelector);
+ resultSelector
+ );
static async global::System.Collections.Generic.IAsyncEnumerable Core(
{{~ for $j in 1..$i ~}}
global::System.Collections.Generic.IAsyncEnumerable {{ $ordinals[$j] }},
{{~ end ~}}
global::System.Func<{{ for $j in 1..$i }}T{{ $j }}?, {{ end }}TResult> resultSelector,
- [EnumeratorCancellation] CancellationToken cancellationToken = default)
+ [EnumeratorCancellation] CancellationToken cancellationToken = default
+ )
{
{{~ for $j in 1..$i ~}}
await using var e{{ $j }} = {{ $ordinals[$j] }}.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator();
@@ -68,7 +70,7 @@ public static partial class AsyncSuperEnumerable
? e{{ $j }}.Current : default(T{{ $j }});
{{~ end ~}}
- if (!f1 {{ for $j in 2..$i }}&& !f{{ $j }}{{ end }})
+ if (!f1{{ for $j in 2..$i }} && !f{{ $j }}{{ end }})
yield break;
yield return resultSelector(
@@ -86,23 +88,24 @@ public static partial class AsyncSuperEnumerable
/// will always be as long as the longest of input sequences where the
/// default value of each of the shorter sequence element types is used
/// for padding.
- ///
- /// A sequence of
+ ///
+ /// A sequence of
///
- /// containing corresponding elements from each of the sequences.
- ///
- /// This method uses deferred execution and streams its results.
- ///
- /// Any of the input sequences is null.
+ /// containing corresponding elements from each of the sequences.
+ ///
+ /// This method uses deferred execution and streams its results.
+ ///
+ /// Any of the input sequences is null.
{{~ for $j in 1..$i ~}}
- /// The type of the elements of .
+ /// The type of the elements of .
/// The {{ $ordinals[$j] }} sequence of elements.
{{~ end ~}}
- public static global::System.Collections.Generic.IAsyncEnumerable<({{~ for $j in 1..$i ~}}T{{ $j }}?{{ if !for.last }},{{ end }}{{ end }})>
+ public static global::System.Collections.Generic.IAsyncEnumerable<({{~ for $j in 1..$i ~}}T{{ $j }}?{{ if !for.last }},{{ end }}{{ end }})>
ZipLongest<{{~ for $j in 1..$i ~}}T{{ $j }}{{ if !for.last }},{{ end }}{{ end }}>(this
{{~ for $j in 1..$i ~}}
global::System.Collections.Generic.IAsyncEnumerable {{ $ordinals[$j] }}{{ if !for.last }},{{ end }}
- {{~ end ~}}) =>
- ZipLongest({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create);
- {{ end ~}}
+ {{~ end ~}}
+ ) => ZipLongest({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create);
+
+ {{~ end ~}}
}
diff --git a/Generators/SuperLinq.Async.Generator/ZipShortest.sbntxt b/Generators/SuperLinq.Async.Generator/ZipShortest.sbntxt
index 1e4b1644..950612b2 100644
--- a/Generators/SuperLinq.Async.Generator/ZipShortest.sbntxt
+++ b/Generators/SuperLinq.Async.Generator/ZipShortest.sbntxt
@@ -1,9 +1,8 @@
-{{
- $arity = arity
- $ordinals = ordinals
- $cardinals = cardinals
-}}
-
+{{~
+ $arity = arity
+ $ordinals = ordinals
+ $cardinals = cardinals
+~}}
namespace SuperLinq.Async;
#nullable enable
@@ -11,48 +10,51 @@ namespace SuperLinq.Async;
public static partial class AsyncSuperEnumerable
{
{{~ for $i in 2..4 ~}}
- ///
+ ///
/// Returns a projection of tuples, where each tuple contains the N-th
/// element from each of the argument sequences. The resulting sequence
/// is as short as the shortest input sequence.
- ///
- ///
- /// The type of the elements of the result sequence.
- /// A projection function that combines
- /// elements from all of the sequences.
- /// A sequence of elements returned by .
- ///
- /// This method uses deferred execution and streams its results.
- ///
- /// or any of the input sequences is null.
+ ///
+ ///
+ /// The type of the elements of the result sequence.
+ /// A projection function that combines
+ /// elements from all of the sequences.
+ /// A sequence of elements returned by .
+ ///
+ /// This method uses deferred execution and streams its results.
+ ///
+ /// or any of the input sequences is null.
{{~ for $j in 1..$i ~}}
- /// The type of the elements of .
+ /// The type of the elements of .
/// The {{ $ordinals[$j] }} sequence of elements.
{{~ end ~}}
- public static global::System.Collections.Generic.IAsyncEnumerable ZipShortest<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult>(this
+ public static global::System.Collections.Generic.IAsyncEnumerable ZipShortest<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult>(this
{{~ for $j in 1..$i ~}}
- global::System.Collections.Generic.IAsyncEnumerable {{ $ordinals[$j] }},
+ global::System.Collections.Generic.IAsyncEnumerable {{ $ordinals[$j] }},
{{~ end ~}}
- global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector)
+ global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector
+ )
{
{{~ for $j in 1..$i ~}}
- ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }});
+ ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }});
{{~ end ~}}
- ArgumentNullException.ThrowIfNull(resultSelector);
+ ArgumentNullException.ThrowIfNull(resultSelector);
return Core(
{{~ for $j in 1..$i ~}}
{{ $ordinals[$j] }},
{{~ end ~}}
- resultSelector);
+ resultSelector
+ );
static async global::System.Collections.Generic.IAsyncEnumerable Core(
{{~ for $j in 1..$i ~}}
global::System.Collections.Generic.IAsyncEnumerable {{ $ordinals[$j] }},
{{~ end ~}}
global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector,
- [EnumeratorCancellation] CancellationToken cancellationToken = default)
+ [EnumeratorCancellation] CancellationToken cancellationToken = default
+ )
{
{{~ for $j in 1..$i ~}}
await using var e{{ $j }} = {{ $ordinals[$j] }}.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator();
@@ -60,8 +62,7 @@ public static partial class AsyncSuperEnumerable
while (
{{~ for $j in 1..$i ~}}
- {{ if !for.first }}&&{{ end }}
- await e{{$j}}.MoveNextAsync()
+ {{ if !for.first }}&& {{ end }}await e{{$j}}.MoveNextAsync()
{{~ end ~}}
)
{
@@ -80,23 +81,24 @@ public static partial class AsyncSuperEnumerable
/// will always be as long as the longest of input sequences where the
/// default value of each of the shorter sequence element types is used
/// for padding.
- ///
- /// A sequence of
+ ///
+ /// A sequence of
///
- /// containing corresponding elements from each of the sequences.
- ///
- /// This method uses deferred execution and streams its results.
- ///
- /// Any of the input sequences is null.
+ /// containing corresponding elements from each of the sequences.
+ ///
+ /// This method uses deferred execution and streams its results.
+ ///
+ /// Any of the input sequences is null.
{{~ for $j in 1..$i ~}}
- /// The type of the elements of .
+ /// The type of the elements of .
/// The {{ $ordinals[$j] }} sequence of elements.
{{~ end ~}}
- public static global::System.Collections.Generic.IAsyncEnumerable<({{~ for $j in 1..$i ~}}T{{ $cardinals[$j] }}{{ if !for.last }},{{ end }}{{ end }})>
+ public static global::System.Collections.Generic.IAsyncEnumerable<({{~ for $j in 1..$i ~}}T{{ $cardinals[$j] }}{{ if !for.last }},{{ end }}{{ end }})>
ZipShortest<{{~ for $j in 1..$i ~}}T{{ $cardinals[$j] }}{{ if !for.last }},{{ end }}{{ end }}>(this
{{~ for $j in 1..$i ~}}
global::System.Collections.Generic.IAsyncEnumerable {{ $ordinals[$j] }}{{ if !for.last }},{{ end }}
- {{~ end ~}}) =>
- ZipShortest({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create);
- {{ end ~}}
+ {{~ end ~}}
+ ) => ZipShortest({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create);
+
+ {{~ end ~}}
}
diff --git a/Generators/SuperLinq.Generator/Aggregate.sbntxt b/Generators/SuperLinq.Generator/Aggregate.sbntxt
index 328c6e3c..197f79c7 100644
--- a/Generators/SuperLinq.Generator/Aggregate.sbntxt
+++ b/Generators/SuperLinq.Generator/Aggregate.sbntxt
@@ -1,8 +1,7 @@
-{{
- $arity = arity
- $ordinals = ordinals
-}}
-
+{{~
+ $arity = arity
+ $ordinals = ordinals
+~}}
namespace SuperLinq;
#nullable enable
@@ -10,83 +9,84 @@ namespace SuperLinq;
public static partial class SuperEnumerable
{
{{~ for $i in 2..($arity.size - 1) ~}}
- ///
- /// Applies {{ $arity[$i] }} accumulators sequentially in a single pass over a
- /// sequence.
- ///
- /// The type of elements in .
- /// The type of the accumulated result.
- /// The source sequence
- ///
- /// A function that projects a single result given the result of each accumulator.
+ ///
+ /// Applies {{ $arity[$i] }} accumulators sequentially in a single pass over a
+ /// sequence.
+ ///
+ /// The type of elements in .
+ /// The type of the accumulated result.
+ /// The source sequence
+ ///
+ /// A function that projects a single result given the result of each accumulator.
///
- /// The value returned by .
- ///
- /// This operator executes immediately.
- ///
- ///
+ /// The value returned by .
+ ///
+ /// This operator executes immediately.
+ ///
+ ///
/// , or any of the accumulator functions is null.
///
{{~ for $j in 1..$i ~}}
- /// The type of the {{ $ordinals[$j] }} accumulator value.
+ /// The type of the {{ $ordinals[$j] }} accumulator value.
/// The seed value for the {{ $ordinals[$j] }} accumulator.
/// The {{ $ordinals[$j] }} accumulator.
{{~ end ~}}
- public static TResult Aggregate(
- this global::System.Collections.Generic.IEnumerable source,
+ public static TResult Aggregate(
+ this global::System.Collections.Generic.IEnumerable source,
{{~ for $j in 1..$i ~}}
- TAccumulate{{$j}} seed{{$j}}, global::System.Func accumulator{{$j}},
+ TAccumulate{{$j}} seed{{$j}}, global::System.Func accumulator{{$j}},
{{~ end ~}}
- global::System.Func<{{ for $j in 1..$i }}TAccumulate{{$j}}, {{ end }}TResult> resultSelector)
+ global::System.Func<{{ for $j in 1..$i }}TAccumulate{{$j}}, {{ end }}TResult> resultSelector
+ )
{
ArgumentNullException.ThrowIfNull(source);
{{~ for $j in 1..$i ~}}
- ArgumentNullException.ThrowIfNull(accumulator{{$j}});
+ ArgumentNullException.ThrowIfNull(accumulator{{$j}});
{{~ end ~}}
- ArgumentNullException.ThrowIfNull(resultSelector);
+ ArgumentNullException.ThrowIfNull(resultSelector);
foreach (var item in source)
{
{{~ for $j in 1..$i ~}}
- seed{{$j}} = accumulator{{$j}}(seed{{$j}}, item);
- {{~ end ~}}
+ seed{{$j}} = accumulator{{$j}}(seed{{$j}}, item);
+ {{~ end ~}}
}
return resultSelector(
{{~ for $j in 1..$i ~}}
- seed{{$j}}{{ if !for.last }},{{ end }}
- {{~ end ~}}
- );
+ seed{{$j}}{{ if !for.last }},{{ end }}
+ {{~ end ~}}
+ );
}
- ///
- /// Applies {{ $arity[$i] }} accumulators sequentially in a single pass over a
- /// sequence.
- ///
- /// The type of elements in .
- /// The source sequence
- /// A
+ ///
+ /// Applies {{ $arity[$i] }} accumulators sequentially in a single pass over a
+ /// sequence.
+ ///
+ /// The type of elements in .
+ /// The source sequence
+ /// A
///
- /// containing the result of each accumulator.
- ///
- /// This operator executes immediately.
- ///
- ///
+ /// containing the result of each accumulator.
+ ///
+ /// This operator executes immediately.
+ ///
+ ///
/// or any of the accumulator functions is null.
///
{{~ for $j in 1..$i ~}}
- /// The type of the {{ $ordinals[$j] }} accumulator value.
+ /// The type of the {{ $ordinals[$j] }} accumulator value.
/// The seed value for the {{ $ordinals[$j] }} accumulator.
/// The {{ $ordinals[$j] }} accumulator.
{{~ end ~}}
- public static ({{~ for $j in 1..$i ~}}TAccumulate{{$j}}{{ if !for.last }},{{ end }}{{ end }}) Aggregate(
- this global::System.Collections.Generic.IEnumerable source,
+ public static ({{~ for $j in 1..$i ~}}TAccumulate{{$j}}{{ if !for.last }},{{ end }}{{ end }}) Aggregate(
+ this global::System.Collections.Generic.IEnumerable source,
{{~ for $j in 1..$i ~}}
- TAccumulate{{$j}} seed{{$j}}, global::System.Func accumulator{{$j}}{{ if !for.last }},{{ end }}
- {{~ end ~}}) =>
- Aggregate(source, {{~ for $j in 1..$i ~}}seed{{$j}}, accumulator{{$j}}, {{ end }}global::System.ValueTuple.Create);
+ TAccumulate{{$j}} seed{{$j}}, global::System.Func accumulator{{$j}}{{ if !for.last }},{{ end }}
+ {{~ end ~}}
+ ) => Aggregate(source, {{~ for $j in 1..$i ~}}seed{{$j}}, accumulator{{$j}}, {{ end }}global::System.ValueTuple.Create);
- {{ end ~}}
+ {{~ end ~}}
}
diff --git a/Generators/SuperLinq.Generator/Cartesian.sbntxt b/Generators/SuperLinq.Generator/Cartesian.sbntxt
index c7a83e63..e15f56cb 100644
--- a/Generators/SuperLinq.Generator/Cartesian.sbntxt
+++ b/Generators/SuperLinq.Generator/Cartesian.sbntxt
@@ -1,8 +1,7 @@
-{{
- $arity = arity
- $ordinals = ordinals
-}}
-
+{{~
+ $arity = arity
+ $ordinals = ordinals
+~}}
namespace SuperLinq;
#nullable enable
@@ -10,56 +9,58 @@ namespace SuperLinq;
public static partial class SuperEnumerable
{
{{~ for $i in 2..($arity.size - 1) ~}}
- ///
- /// Returns the Cartesian product of {{ $arity[$i] }} sequences by enumerating all possible combinations of one item from
- /// each sequence, and applying a user-defined projection to the items in a given combination.
- ///
- ///
- /// The type of the elements of the result sequence.
+ ///
+ /// Returns the Cartesian product of {{ $arity[$i] }} sequences by enumerating all possible combinations of one item from
+ /// each sequence, and applying a user-defined projection to the items in a given combination.
+ ///
+ ///
+ /// The type of the elements of the result sequence.
///
- ///
+ ///
/// A projection function that combines elements from all of the sequences.
///
- ///
+ ///
/// A sequence of elements returned by .
///
- ///
- ///
- /// The method returns items in the same order as a nested foreach loop, but all sequences cached when iterated
- /// over. The cache is then re-used for any subsequent iterations.
+ ///
+ ///
+ /// The method returns items in the same order as a nested foreach loop, but all sequences cached when iterated
+ /// over. The cache is then re-used for any subsequent iterations.
///
- ///
- /// This method uses deferred execution and stream its results.
+ ///
+ /// This method uses deferred execution and stream its results.
///
- ///
- ///
+ ///
+ ///
/// or any of the input sequences is .
///
{{~ for $j in 1..$i ~}}
- ///
+ ///
/// The type of the elements of .
///
///
/// The {{ $ordinals[$j] }} sequence of elements.
///
{{~ end ~}}
- public static global::System.Collections.Generic.IEnumerable Cartesian<{{ for $j in 1..$i }}T{{$j}}, {{ end }}TResult>(this
+ public static global::System.Collections.Generic.IEnumerable Cartesian<{{ for $j in 1..$i }}T{{$j}}, {{ end }}TResult>(this
{{~ for $j in 1..$i ~}}
- global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }},
+ global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }},
{{~ end ~}}
- global::System.Func<{{ for $j in 1..$i }}T{{$j}}, {{ end }}TResult> resultSelector)
+ global::System.Func<{{ for $j in 1..$i }}T{{$j}}, {{ end }}TResult> resultSelector
+ )
{
{{~ for $j in 1..$i ~}}
- ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }});
+ ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }});
{{~ end ~}}
- ArgumentNullException.ThrowIfNull(resultSelector);
+ ArgumentNullException.ThrowIfNull(resultSelector);
return Core(
{{~ for $j in 1..$i ~}}
{{ $ordinals[$j] }},
{{~ end ~}}
- resultSelector);
+ resultSelector
+ );
static global::System.Collections.Generic.IEnumerable Core(
{{~ for $j in 1..$i ~}}
@@ -74,47 +75,50 @@ public static partial class SuperEnumerable
{{~ for $j in 1..$i ~}}
foreach (var item{{$j}} in {{ $ordinals[$j] }}Memo)
{{~ end ~}}
+ {
yield return resultSelector(
{{~ for $j in 1..$i ~}}
item{{$j}}{{ if !for.last }},{{ end }}
{{~ end ~}}
);
+ }
}
}
///
- /// Returns the Cartesian product of {{ $arity[$i] }} sequences by enumerating all possible combinations of one item from
- /// each sequence.
- ///
- ///
+ /// Returns the Cartesian product of {{ $arity[$i] }} sequences by enumerating all possible combinations of one item from
+ /// each sequence.
+ ///
+ ///
/// A sequence of containing elements from each of the
/// sequences.
///
- ///
- ///
- /// The method returns items in the same order as a nested foreach loop, but all sequences are cached when
- /// iterated over. The cache is then re-used for any subsequent iterations.
+ ///
+ ///
+ /// The method returns items in the same order as a nested foreach loop, but all sequences are cached when
+ /// iterated over. The cache is then re-used for any subsequent iterations.
///
- ///
- /// This method uses deferred execution and stream its results.
+ ///
+ /// This method uses deferred execution and stream its results.
///
- ///
- ///
+ ///
+ ///
/// Any of the input sequences is .
///
{{~ for $j in 1..$i ~}}
- ///
+ ///
/// The type of the elements of .
///
///
/// The {{ $ordinals[$j] }} sequence of elements.
///
{{~ end ~}}
- public static global::System.Collections.Generic.IEnumerable<({{~ for $j in 1..$i ~}}T{{$j}}{{ if !for.last }},{{ end }}{{ end }})>
+ public static global::System.Collections.Generic.IEnumerable<({{~ for $j in 1..$i ~}}T{{$j}}{{ if !for.last }},{{ end }}{{ end }})>
Cartesian<{{~ for $j in 1..$i ~}}T{{$j}}{{ if !for.last }},{{ end }}{{ end }}>(this
{{~ for $j in 1..$i ~}}
global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }}{{ if !for.last }},{{ end }}
- {{~ end ~}}) =>
- Cartesian({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create);
- {{ end ~}}
+ {{~ end ~}}
+ ) => Cartesian({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create);
+
+ {{~ end ~}}
}
diff --git a/Generators/SuperLinq.Generator/EquiZip.sbntxt b/Generators/SuperLinq.Generator/EquiZip.sbntxt
index 7e5628a3..2aafc0cc 100644
--- a/Generators/SuperLinq.Generator/EquiZip.sbntxt
+++ b/Generators/SuperLinq.Generator/EquiZip.sbntxt
@@ -1,9 +1,8 @@
-{{
- $arity = arity
- $ordinals = ordinals
- $cardinals = cardinals
-}}
-
+{{~
+ $arity = arity
+ $ordinals = ordinals
+ $cardinals = cardinals
+~}}
namespace SuperLinq;
#nullable enable
@@ -40,24 +39,25 @@ public static partial class SuperEnumerable
/// Any of the input sequences are shorter than the others.
///
{{~ for $j in 1..$i ~}}
- ///
+ ///
/// The type of the elements of .
///
///
/// The {{ $ordinals[$j] }} sequence of elements.
///
{{~ end ~}}
- public static global::System.Collections.Generic.IEnumerable EquiZip<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult>(this
+ public static global::System.Collections.Generic.IEnumerable EquiZip<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult>(this
{{~ for $j in 1..$i ~}}
- global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }},
+ global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }},
{{~ end ~}}
- global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector)
+ global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector
+ )
{
{{~ for $j in 1..$i ~}}
- ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }});
+ ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }});
{{~ end ~}}
- ArgumentNullException.ThrowIfNull(resultSelector);
+ ArgumentNullException.ThrowIfNull(resultSelector);
if (
{{~ for $j in 1..$i ~}}
@@ -68,20 +68,23 @@ public static partial class SuperEnumerable
{{~ for $j in 1..$i ~}}
list{{ $j }},
{{~ end ~}}
- resultSelector);
+ resultSelector
+ );
}
return Core(
{{~ for $j in 1..$i ~}}
{{ $ordinals[$j] }},
{{~ end ~}}
- resultSelector);
+ resultSelector
+ );
static global::System.Collections.Generic.IEnumerable Core(
{{~ for $j in 1..$i ~}}
global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }},
{{~ end ~}}
- global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector)
+ global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector
+ )
{
{{~ for $j in 1..$i ~}}
using var e{{ $j }} = {{ $ordinals[$j] }}.GetEnumerator();
@@ -98,10 +101,10 @@ public static partial class SuperEnumerable
|| e{{$j}}.MoveNext()
{{~ end
end ~}}
- )
+ )
{
- ThrowHelper.ThrowInvalidOperationException("First sequence too short.");
- }
+ ThrowHelper.ThrowInvalidOperationException("First sequence too short.");
+ }
yield break;
}
@@ -121,36 +124,36 @@ public static partial class SuperEnumerable
}
}
- ///
- /// Joins the corresponding elements of second sequences, producing a sequence of tuples containing them.
- ///
- ///
+ ///
+ /// Joins the corresponding elements of second sequences, producing a sequence of tuples containing them.
+ ///
+ ///
/// A sequence of
/// containing corresponding elements from each of the sequences.
///
- ///
- /// This method uses deferred execution and stream its results.
- ///
- ///
+ ///
+ /// This method uses deferred execution and stream its results.
+ ///
+ ///
/// Any of the input sequences is null.
///
- ///
- /// Any of the input sequences are shorter than the others.
- ///
+ ///
+ /// Any of the input sequences are shorter than the others.
+ ///
{{~ for $j in 1..$i ~}}
- ///
+ ///
/// The type of the elements of .
///
///
/// The {{ $ordinals[$j] }} sequence of elements.
///
{{~ end ~}}
- public static global::System.Collections.Generic.IEnumerable<({{~ for $j in 1..$i ~}}T{{ $cardinals[$j] }}{{ if !for.last }},{{ end }}{{ end }})>
+ public static global::System.Collections.Generic.IEnumerable<({{~ for $j in 1..$i ~}}T{{ $cardinals[$j] }}{{ if !for.last }},{{ end }}{{ end }})>
EquiZip<{{~ for $j in 1..$i ~}}T{{ $cardinals[$j] }}{{ if !for.last }},{{ end }}{{ end }}>(this
{{~ for $j in 1..$i ~}}
global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }}{{ if !for.last }},{{ end }}
- {{~ end ~}}) =>
- EquiZip({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create);
+ {{~ end ~}}
+ ) => EquiZip({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create);
private class EquiZipIterator<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult> : ListIterator
{
@@ -163,7 +166,8 @@ public static partial class SuperEnumerable
{{~ for $j in 1..$i ~}}
global::System.Collections.Generic.IList {{ $ordinals[$j] }},
{{~ end ~}}
- global::System.Func<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult> resultSelector)
+ global::System.Func<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult> resultSelector
+ )
{
{{~ for $j in 1..$i ~}}
_list{{ $j }} = {{ $ordinals[$j] }};
@@ -197,7 +201,8 @@ public static partial class SuperEnumerable
yield return _resultSelector(
{{~ for $j in 1..$i ~}}
_list{{ $j }}[i]{{ if !for.last }}, {{ end }}
- {{~ end ~}});
+ {{~ end ~}}
+ );
}
}
@@ -209,8 +214,10 @@ public static partial class SuperEnumerable
return _resultSelector(
{{~ for $j in 1..$i ~}}
_list{{ $j }}[index]{{ if !for.last }}, {{ end }}
- {{~ end ~}});
+ {{~ end ~}}
+ );
}
}
- {{ end ~}}
+
+ {{~ end ~}}
}
diff --git a/Generators/SuperLinq.Generator/Fold.sbntxt b/Generators/SuperLinq.Generator/Fold.sbntxt
index c89d22ab..b5465d52 100644
--- a/Generators/SuperLinq.Generator/Fold.sbntxt
+++ b/Generators/SuperLinq.Generator/Fold.sbntxt
@@ -1,43 +1,42 @@
-namespace SuperLinq;
+namespace SuperLinq;
#nullable enable
public static partial class SuperEnumerable
{
{{~ for $i in 1..16 ~}}
- ///
- /// Returns the result of applying a function to a sequence of {{$i}} element{{if $i != 1}}s{{end}}.
- ///
- ///
- /// This operator uses immediate execution and buffers as many items of the source sequence as necessary.
- ///
- ///
+ ///
+ /// Returns the result of applying a function to a sequence of {{$i}} element{{if $i != 1}}s{{end}}.
+ ///
+ ///
+ /// This operator uses immediate execution and buffers as many items of the source sequence as necessary.
+ ///
+ ///
/// Type of element in the source sequence
///
- ///
+ ///
/// Type of the result
///
- ///
+ ///
/// The sequence of items to fold.
///
- ///
+ ///
/// Function to apply to the elements in the sequence.
///
- ///
+ ///
/// The folded value returned by .
///
- ///
+ ///
/// or is .
///
- ///
+ ///
/// does not contain exactly {{$i}} element{{if $i != 1}}s{{end}}.
///
- public static TResult Fold(this global::System.Collections.Generic.IEnumerable source, global::System.Func<
- {{~ for $j in 1..$i ~}}
- T,
- {{~ end ~}}
- TResult> folder)
- {
+ public static TResult Fold(
+ this global::System.Collections.Generic.IEnumerable source,
+ global::System.Func<{{~ for $j in 1..$i ~}}T, {{ end ~}}TResult> folder
+ )
+ {
ArgumentNullException.ThrowIfNull(source);
ArgumentNullException.ThrowIfNull(folder);
@@ -49,5 +48,6 @@ public static partial class SuperEnumerable
{{~ end ~}}
);
}
- {{ end ~}}
+
+ {{~ end ~}}
}
diff --git a/Generators/SuperLinq.Generator/Generator.cs b/Generators/SuperLinq.Generator/Generator.cs
index d2aa44be..301b5ca0 100644
--- a/Generators/SuperLinq.Generator/Generator.cs
+++ b/Generators/SuperLinq.Generator/Generator.cs
@@ -1,4 +1,4 @@
-using System.Text;
+using System.Text;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Text;
using Scriban;
@@ -33,14 +33,6 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
private static SourceText GenerateArgumentNamesTemplate(string template)
{
var output = Template.Parse(template).Render(ArgumentNames.Instance);
-
- // Apply formatting since indenting isn't that nice in Scriban when rendering nested
- // structures via functions.
- output = Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ParseCompilationUnit(output)
- .NormalizeWhitespace()
- .GetText()
- .ToString();
-
return SourceText.From(output, Encoding.UTF8);
}
}
diff --git a/Generators/SuperLinq.Generator/ZipLongest.sbntxt b/Generators/SuperLinq.Generator/ZipLongest.sbntxt
index 3de942fc..29d266cf 100644
--- a/Generators/SuperLinq.Generator/ZipLongest.sbntxt
+++ b/Generators/SuperLinq.Generator/ZipLongest.sbntxt
@@ -1,9 +1,8 @@
-{{
- $arity = arity
- $ordinals = ordinals
- $cardinals = cardinals
-}}
-
+{{~
+ $arity = arity
+ $ordinals = ordinals
+ $cardinals = cardinals
+~}}
namespace SuperLinq;
#nullable enable
@@ -23,11 +22,11 @@ public static partial class SuperEnumerable
}
{{~ for $i in 2..4 ~}}
- ///
- /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument
- /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default
- /// value of each of the shorter sequence element types is used for padding.
- ///
+ ///
+ /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument
+ /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default
+ /// value of each of the shorter sequence element types is used for padding.
+ ///
///
/// The type of the elements of the result sequence.
///
@@ -40,28 +39,29 @@ public static partial class SuperEnumerable
///
/// This method uses deferred execution and streams its results.
///
- ///
+ ///
/// or any of the input sequences is .
///
{{~ for $j in 1..$i ~}}
- ///
+ ///
/// The type of the elements of .
///
///
/// The {{ $ordinals[$j] }} sequence of elements.
///
{{~ end ~}}
- public static global::System.Collections.Generic.IEnumerable ZipLongest<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult>(this
+ public static global::System.Collections.Generic.IEnumerable ZipLongest<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult>(this
{{~ for $j in 1..$i ~}}
- global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }},
+ global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }},
{{~ end ~}}
- global::System.Func<{{ for $j in 1..$i }}T{{ $j }}?, {{ end }}TResult> resultSelector)
+ global::System.Func<{{ for $j in 1..$i }}T{{ $j }}?, {{ end }}TResult> resultSelector
+ )
{
{{~ for $j in 1..$i ~}}
- ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }});
+ ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }});
{{~ end ~}}
- ArgumentNullException.ThrowIfNull(resultSelector);
+ ArgumentNullException.ThrowIfNull(resultSelector);
if (
{{~ for $j in 1..$i ~}}
@@ -72,20 +72,23 @@ public static partial class SuperEnumerable
{{~ for $j in 1..$i ~}}
list{{ $j }},
{{~ end ~}}
- resultSelector);
+ resultSelector
+ );
}
return Core(
{{~ for $j in 1..$i ~}}
{{ $ordinals[$j] }},
{{~ end ~}}
- resultSelector);
+ resultSelector
+ );
static global::System.Collections.Generic.IEnumerable Core(
{{~ for $j in 1..$i ~}}
global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }},
{{~ end ~}}
- global::System.Func<{{ for $j in 1..$i }}T{{ $j }}?, {{ end }}TResult> resultSelector)
+ global::System.Func<{{ for $j in 1..$i }}T{{ $j }}?, {{ end }}TResult> resultSelector
+ )
{
{{~ for $j in 1..$i ~}}
using var e{{ $j }} = {{ $ordinals[$j] }}.GetEnumerator();
@@ -94,10 +97,9 @@ public static partial class SuperEnumerable
while (
{{~ for $j in 1..$i ~}}
- {{ if !for.first }}|{{ end }}
- (f{{$j}} = DoRead(f{{$j}}, e{{$j}}, out var v{{$j}}))
+ {{ if !for.first }}| {{ end }}(f{{$j}} = DoRead(f{{$j}}, e{{$j}}, out var v{{$j}}))
{{~ end ~}}
- )
+ )
{
yield return resultSelector(
{{~ for $j in 1..$i ~}}
@@ -113,30 +115,30 @@ public static partial class SuperEnumerable
/// sequences. The resulting sequence will always be as long as the longest of input sequences where the default
/// value of each of the shorter sequence element types is used for padding.
///
- ///
+ ///
/// A sequence of containing corresponding elements from each
- /// of the sequences.
+ /// of the sequences.
///
///
/// This method uses deferred execution and streams its results.
///
- ///
+ ///
/// Any of the input sequences is .
///
{{~ for $j in 1..$i ~}}
- ///
+ ///
/// The type of the elements of .
///
///
/// The {{ $ordinals[$j] }} sequence of elements.
///
{{~ end ~}}
- public static global::System.Collections.Generic.IEnumerable<({{~ for $j in 1..$i ~}}T{{ $j }}?{{ if !for.last }},{{ end }}{{ end }})>
+ public static global::System.Collections.Generic.IEnumerable<({{~ for $j in 1..$i ~}}T{{ $j }}?{{ if !for.last }},{{ end }}{{ end }})>
ZipLongest<{{~ for $j in 1..$i ~}}T{{ $j }}{{ if !for.last }},{{ end }}{{ end }}>(this
{{~ for $j in 1..$i ~}}
global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }}{{ if !for.last }},{{ end }}
- {{~ end ~}}) =>
- ZipLongest({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create);
+ {{~ end ~}}
+ ) => ZipLongest({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create);
private sealed class ZipLongestIterator<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult> : ListIterator
{
@@ -149,7 +151,8 @@ public static partial class SuperEnumerable
{{~ for $j in 1..$i ~}}
global::System.Collections.Generic.IList {{ $ordinals[$j] }},
{{~ end ~}}
- global::System.Func<{{ for $j in 1..$i }}T{{ $j }}?, {{ end }}TResult> resultSelector)
+ global::System.Func<{{ for $j in 1..$i }}T{{ $j }}?, {{ end }}TResult> resultSelector
+ )
{
{{~ for $j in 1..$i ~}}
_list{{ $j }} = {{ $ordinals[$j] }};
@@ -167,7 +170,8 @@ public static partial class SuperEnumerable
yield return _resultSelector(
{{~ for $j in 1..$i ~}}
i < _list{{ $j }}.Count ? _list{{ $j }}[i] : default{{ if !for.last }}, {{ end }}
- {{~ end ~}});
+ {{~ end ~}}
+ );
}
}
@@ -179,8 +183,10 @@ public static partial class SuperEnumerable
return _resultSelector(
{{~ for $j in 1..$i ~}}
index < _list{{ $j }}.Count ? _list{{ $j }}[index] : default{{ if !for.last }}, {{ end }}
- {{~ end ~}});
+ {{~ end ~}}
+ );
}
}
- {{ end ~}}
+
+ {{~ end ~}}
}
diff --git a/Generators/SuperLinq.Generator/ZipShortest.sbntxt b/Generators/SuperLinq.Generator/ZipShortest.sbntxt
index 2e1903f5..fab29157 100644
--- a/Generators/SuperLinq.Generator/ZipShortest.sbntxt
+++ b/Generators/SuperLinq.Generator/ZipShortest.sbntxt
@@ -1,9 +1,8 @@
-{{
- $arity = arity
- $ordinals = ordinals
- $cardinals = cardinals
-}}
-
+{{~
+ $arity = arity
+ $ordinals = ordinals
+ $cardinals = cardinals
+~}}
namespace SuperLinq;
#nullable enable
@@ -11,44 +10,45 @@ namespace SuperLinq;
public static partial class SuperEnumerable
{
{{~ for $i in 2..4 ~}}
- ///
- /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument
- /// sequences. The resulting sequence is as short as the shortest input sequence.
- ///
- ///
- /// The type of the elements of the result sequence.
+ ///
+ /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument
+ /// sequences. The resulting sequence is as short as the shortest input sequence.
+ ///
+ ///
+ /// The type of the elements of the result sequence.
///
- ///
+ ///
/// A projection function that combines elements from all of the sequences.
///
- ///
+ ///
/// A sequence of elements returned by .
///
- ///
- /// This method uses deferred execution and streams its results.
- ///
- ///
+ ///
+ /// This method uses deferred execution and streams its results.
+ ///
+ ///
/// or any of the input sequences is .
///
{{~ for $j in 1..$i ~}}
- ///
+ ///
/// The type of the elements of .
///
///
/// The {{ $ordinals[$j] }} sequence of elements.
///
{{~ end ~}}
- public static global::System.Collections.Generic.IEnumerable ZipShortest<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult>(this
+ public static global::System.Collections.Generic.IEnumerable ZipShortest<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult>(this
{{~ for $j in 1..$i ~}}
- global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }},
+ global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }},
{{~ end ~}}
- global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector)
+ global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector
+ )
{
{{~ for $j in 1..$i ~}}
- ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }});
+ ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }});
{{~ end ~}}
- ArgumentNullException.ThrowIfNull(resultSelector);
+ ArgumentNullException.ThrowIfNull(resultSelector);
if (
{{~ for $j in 1..$i ~}}
@@ -59,20 +59,23 @@ public static partial class SuperEnumerable
{{~ for $j in 1..$i ~}}
list{{ $j }},
{{~ end ~}}
- resultSelector);
+ resultSelector
+ );
}
return Core(
{{~ for $j in 1..$i ~}}
{{ $ordinals[$j] }},
{{~ end ~}}
- resultSelector);
+ resultSelector
+ );
static global::System.Collections.Generic.IEnumerable Core(
{{~ for $j in 1..$i ~}}
global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }},
{{~ end ~}}
- global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector)
+ global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector
+ )
{
{{~ for $j in 1..$i ~}}
using var e{{ $j }} = {{ $ordinals[$j] }}.GetEnumerator();
@@ -80,8 +83,7 @@ public static partial class SuperEnumerable
while (
{{~ for $j in 1..$i ~}}
- {{ if !for.first }}&&{{ end }}
- e{{$j}}.MoveNext()
+ {{ if !for.first }}&& {{ end }}e{{$j}}.MoveNext()
{{~ end ~}}
)
{
@@ -95,34 +97,34 @@ public static partial class SuperEnumerable
}
///
- /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument
- /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default
- /// value of each of the shorter sequence element types is used for padding.
- ///
- ///
+ /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument
+ /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default
+ /// value of each of the shorter sequence element types is used for padding.
+ ///
+ ///
/// A sequence of containing corresponding elements from each
- /// of the sequences.
+ /// of the sequences.
///
///
- /// This method uses deferred execution and streams its results.
- ///
- ///
+ /// This method uses deferred execution and streams its results.
+ ///
+ ///
/// Any of the input sequences is .
///
{{~ for $j in 1..$i ~}}
- ///
+ ///
/// The type of the elements of .
///
///
/// The {{ $ordinals[$j] }} sequence of elements.
///
{{~ end ~}}
- public static global::System.Collections.Generic.IEnumerable<({{~ for $j in 1..$i ~}}T{{ $cardinals[$j] }}{{ if !for.last }},{{ end }}{{ end }})>
+ public static global::System.Collections.Generic.IEnumerable<({{~ for $j in 1..$i ~}}T{{ $cardinals[$j] }}{{ if !for.last }},{{ end }}{{ end }})>
ZipShortest<{{~ for $j in 1..$i ~}}T{{ $cardinals[$j] }}{{ if !for.last }},{{ end }}{{ end }}>(this
{{~ for $j in 1..$i ~}}
global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }}{{ if !for.last }},{{ end }}
- {{~ end ~}}) =>
- ZipShortest({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create);
+ {{~ end ~}}
+ ) => ZipShortest({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create);
private sealed class ZipShortestIterator<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult> : ListIterator
{
@@ -135,7 +137,8 @@ public static partial class SuperEnumerable
{{~ for $j in 1..$i ~}}
global::System.Collections.Generic.IList {{ $ordinals[$j] }},
{{~ end ~}}
- global::System.Func<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult> resultSelector)
+ global::System.Func<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult> resultSelector
+ )
{
{{~ for $j in 1..$i ~}}
_list{{ $j }} = {{ $ordinals[$j] }};
@@ -153,7 +156,8 @@ public static partial class SuperEnumerable
yield return _resultSelector(
{{~ for $j in 1..$i ~}}
_list{{ $j }}[i]{{ if !for.last }}, {{ end }}
- {{~ end ~}});
+ {{~ end ~}}
+ );
}
}
@@ -165,8 +169,10 @@ public static partial class SuperEnumerable
return _resultSelector(
{{~ for $j in 1..$i ~}}
_list{{ $j }}[index]{{ if !for.last }}, {{ end }}
- {{~ end ~}});
+ {{~ end ~}}
+ );
}
}
- {{ end ~}}
+
+ {{~ end ~}}
}
diff --git a/Source/SuperLinq.Async/Generated/SuperLinq.Async.Generator/SuperLinq.Async.Generator.Generator/EquiZip.g.cs b/Source/SuperLinq.Async/Generated/SuperLinq.Async.Generator/SuperLinq.Async.Generator.Generator/EquiZip.g.cs
index a20bb288..8fa20477 100644
--- a/Source/SuperLinq.Async/Generated/SuperLinq.Async.Generator/SuperLinq.Async.Generator.Generator/EquiZip.g.cs
+++ b/Source/SuperLinq.Async/Generated/SuperLinq.Async.Generator/SuperLinq.Async.Generator.Generator/EquiZip.g.cs
@@ -1,245 +1,352 @@
namespace SuperLinq.Async;
+
#nullable enable
+
public static partial class AsyncSuperEnumerable
{
- ///
- ///
- /// Applies a specified function to the corresponding elements of second sequences,
- /// producing a sequence of the results.
- ///
- /// The resulting sequence has the same length as the input sequences.
- /// If the input sequences are of different lengths, an exception is thrown.
- ///
- ///
- /// The type of the elements of the result sequence.
- /// A projection function that combines
- /// elements from all of the sequences.
- /// A sequence of elements returned by .
- ///
- /// This method uses deferred execution and stream its results.
- ///
- /// or any of the input sequences is null.
- ///
- /// Any of the input sequences are shorter than the others.
- ///
- /// The type of the elements of .
- /// The first sequence of elements.
- /// The type of the elements of .
- /// The second sequence of elements.
- public static global::System.Collections.Generic.IAsyncEnumerable EquiZip(this global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Func resultSelector)
- {
- ArgumentNullException.ThrowIfNull(first);
- ArgumentNullException.ThrowIfNull(second);
- ArgumentNullException.ThrowIfNull(resultSelector);
- return Core(first, second, resultSelector);
- static async global::System.Collections.Generic.IAsyncEnumerable Core(global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Func resultSelector, [EnumeratorCancellation] CancellationToken cancellationToken = default)
- {
- await using var e1 = first.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator();
- await using var e2 = second.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator();
- while (true)
- {
- if (!await e1.MoveNextAsync())
- {
- if (await e2.MoveNextAsync())
- {
- ThrowHelper.ThrowInvalidOperationException("First sequence too short.");
- }
-
- yield break;
- }
-
- if (!await e2.MoveNextAsync())
- ThrowHelper.ThrowInvalidOperationException("Second sequence too short.");
- yield return resultSelector(e1.Current, e2.Current);
- }
- }
- }
-
- ///
- /// Joins the corresponding elements of second sequences,
- /// producing a sequence of tuples containing them.
- ///
- /// A sequence of
- ///
- /// containing corresponding elements from each of the sequences.
- ///
- /// This method uses deferred execution and stream its results.
- ///
- /// Any of the input sequences is null.
- ///
- /// Any of the input sequences are shorter than the others.
- ///
- /// The type of the elements of .
- /// The first sequence of elements.
- /// The type of the elements of .
- /// The second sequence of elements.
- public static global::System.Collections.Generic.IAsyncEnumerable<(TFirst, TSecond)> EquiZip(this global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second) => EquiZip(first, second, global::System.ValueTuple.Create);
- ///
- ///
- /// Applies a specified function to the corresponding elements of third sequences,
- /// producing a sequence of the results.
- ///
- /// The resulting sequence has the same length as the input sequences.
- /// If the input sequences are of different lengths, an exception is thrown.
- ///
- ///
- /// The type of the elements of the result sequence.
- /// A projection function that combines
- /// elements from all of the sequences.
- /// A sequence of elements returned by .
- ///
- /// This method uses deferred execution and stream its results.
- ///
- /// or any of the input sequences is null.
- ///
- /// Any of the input sequences are shorter than the others.
- ///
- /// The type of the elements of .
- /// The first sequence of elements.
- /// The type of the elements of .
- /// The second sequence of elements.
- /// The type of the elements of .
- /// The third sequence of elements.
- public static global::System.Collections.Generic.IAsyncEnumerable EquiZip(this global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Collections.Generic.IAsyncEnumerable third, global::System.Func resultSelector)
- {
- ArgumentNullException.ThrowIfNull(first);
- ArgumentNullException.ThrowIfNull(second);
- ArgumentNullException.ThrowIfNull(third);
- ArgumentNullException.ThrowIfNull(resultSelector);
- return Core(first, second, third, resultSelector);
- static async global::System.Collections.Generic.IAsyncEnumerable Core(global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Collections.Generic.IAsyncEnumerable third, global::System.Func resultSelector, [EnumeratorCancellation] CancellationToken cancellationToken = default)
- {
- await using var e1 = first.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator();
- await using var e2 = second.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator();
- await using var e3 = third.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator();
- while (true)
- {
- if (!await e1.MoveNextAsync())
- {
- if (await e2.MoveNextAsync() || await e3.MoveNextAsync())
- {
- ThrowHelper.ThrowInvalidOperationException("First sequence too short.");
- }
-
- yield break;
- }
-
- if (!await e2.MoveNextAsync())
- ThrowHelper.ThrowInvalidOperationException("Second sequence too short.");
- if (!await e3.MoveNextAsync())
- ThrowHelper.ThrowInvalidOperationException("Third sequence too short.");
- yield return resultSelector(e1.Current, e2.Current, e3.Current);
- }
- }
- }
-
- ///
- /// Joins the corresponding elements of third sequences,
- /// producing a sequence of tuples containing them.
- ///
- /// A sequence of
- ///
- /// containing corresponding elements from each of the sequences.
- ///
- /// This method uses deferred execution and stream its results.
- ///
- /// Any of the input sequences is null.
- ///
- /// Any of the input sequences are shorter than the others.
- ///
- /// The type of the elements of .
- /// The first sequence of elements.
- /// The type of the elements of .
- /// The second sequence of elements.
- /// The type of the elements of .
- /// The third sequence of elements.
- public static global::System.Collections.Generic.IAsyncEnumerable<(TFirst, TSecond, TThird)> EquiZip(this global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Collections.Generic.IAsyncEnumerable third) => EquiZip(first, second, third, global::System.ValueTuple.Create);
- ///
- ///
- /// Applies a specified function to the corresponding elements of fourth sequences,
- /// producing a sequence of the results.
- ///
- /// The resulting sequence has the same length as the input sequences.
- /// If the input sequences are of different lengths, an exception is thrown.
- ///
- ///
- /// The type of the elements of the result sequence.
- /// A projection function that combines
- /// elements from all of the sequences.
- /// A sequence of elements returned by .
- ///
- /// This method uses deferred execution and stream its results.
- ///
- /// or any of the input sequences is null.
- ///
- /// Any of the input sequences are shorter than the others.
- ///
- /// The type of the elements of .
- /// The first sequence of elements.
- /// The type of the elements of .
- /// The second sequence of elements.
- /// The type of the elements of .
- /// The third sequence of elements.
- /// The type of the elements of .
- /// The fourth sequence of elements.
- public static global::System.Collections.Generic.IAsyncEnumerable EquiZip(this global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Collections.Generic.IAsyncEnumerable third, global::System.Collections.Generic.IAsyncEnumerable fourth, global::System.Func resultSelector)
- {
- ArgumentNullException.ThrowIfNull(first);
- ArgumentNullException.ThrowIfNull(second);
- ArgumentNullException.ThrowIfNull(third);
- ArgumentNullException.ThrowIfNull(fourth);
- ArgumentNullException.ThrowIfNull(resultSelector);
- return Core(first, second, third, fourth, resultSelector);
- static async global::System.Collections.Generic.IAsyncEnumerable Core(global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Collections.Generic.IAsyncEnumerable third, global::System.Collections.Generic.IAsyncEnumerable fourth, global::System.Func resultSelector, [EnumeratorCancellation] CancellationToken cancellationToken = default)
- {
- await using var e1 = first.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator();
- await using var e2 = second.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator();
- await using var e3 = third.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator();
- await using var e4 = fourth.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator();
- while (true)
- {
- if (!await e1.MoveNextAsync())
- {
- if (await e2.MoveNextAsync() || await e3.MoveNextAsync() || await e4.MoveNextAsync())
- {
- ThrowHelper.ThrowInvalidOperationException("First sequence too short.");
- }
-
- yield break;
- }
-
- if (!await e2.MoveNextAsync())
- ThrowHelper.ThrowInvalidOperationException("Second sequence too short.");
- if (!await e3.MoveNextAsync())
- ThrowHelper.ThrowInvalidOperationException("Third sequence too short.");
- if (!await e4.MoveNextAsync())
- ThrowHelper.ThrowInvalidOperationException("Fourth sequence too short.");
- yield return resultSelector(e1.Current, e2.Current, e3.Current, e4.Current);
- }
- }
- }
-
- ///
- /// Joins the corresponding elements of fourth sequences,
- /// producing a sequence of tuples containing them.
- ///
- /// A sequence of
- ///
- /// containing corresponding elements from each of the sequences.
- ///
- /// This method uses deferred execution and stream its results.
- ///
- /// Any of the input sequences is null.
- ///
- /// Any of the input sequences are shorter than the others.
- ///
- /// The type of the elements of .
- /// The first sequence of elements.
- /// The type of the elements of .
- /// The second sequence of elements.
- /// The type of the elements of .
- /// The third sequence of elements.
- /// The type of the elements of .
- /// The fourth sequence of elements.
- public static global::System.Collections.Generic.IAsyncEnumerable<(TFirst, TSecond, TThird, TFourth)> EquiZip(this global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Collections.Generic.IAsyncEnumerable third, global::System.Collections.Generic.IAsyncEnumerable fourth) => EquiZip(first, second, third, fourth, global::System.ValueTuple.Create);
-}
\ No newline at end of file
+ ///
+ ///
+ /// Applies a specified function to the corresponding elements of second sequences,
+ /// producing a sequence of the results.
+ ///
+ /// The resulting sequence has the same length as the input sequences.
+ /// If the input sequences are of different lengths, an exception is thrown.
+ ///
+ ///
+ /// The type of the elements of the result sequence.
+ /// A projection function that combines
+ /// elements from all of the sequences.
+ /// A sequence of elements returned by .
+ ///
+ /// This method uses deferred execution and stream its results.
+ ///
+ /// or any of the input sequences is null.
+ ///
+ /// Any of the input sequences are shorter than the others.
+ ///
+ /// The type of the elements of .
+ /// The first sequence of elements.
+ /// The type of the elements of .
+ /// The second sequence of elements.
+ public static global::System.Collections.Generic.IAsyncEnumerable EquiZip(this
+ global::System.Collections.Generic.IAsyncEnumerable first,
+ global::System.Collections.Generic.IAsyncEnumerable second,
+ global::System.Func resultSelector
+ )
+ {
+ ArgumentNullException.ThrowIfNull(first);
+ ArgumentNullException.ThrowIfNull(second);
+
+ ArgumentNullException.ThrowIfNull(resultSelector);
+
+ return Core(
+ first,
+ second,
+ resultSelector
+ );
+
+ static async global::System.Collections.Generic.IAsyncEnumerable Core(
+ global::System.Collections.Generic.IAsyncEnumerable first,
+ global::System.Collections.Generic.IAsyncEnumerable second,
+ global::System.Func resultSelector,
+ [EnumeratorCancellation] CancellationToken cancellationToken = default
+ )
+ {
+ await using var e1 = first.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator();
+ await using var e2 = second.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator();
+
+ while (true)
+ {
+ if (!await e1.MoveNextAsync())
+ {
+ if (await e2.MoveNextAsync()
+ )
+ {
+ ThrowHelper.ThrowInvalidOperationException("First sequence too short.");
+ }
+
+ yield break;
+ }
+
+ if (!await e2.MoveNextAsync())
+ ThrowHelper.ThrowInvalidOperationException(
+ "Second sequence too short.");
+
+ yield return resultSelector(
+ e1.Current,
+ e2.Current
+ );
+ }
+ }
+ }
+
+ ///
+ /// Joins the corresponding elements of second sequences,
+ /// producing a sequence of tuples containing them.
+ ///
+ /// A sequence of
+ ///
+ /// containing corresponding elements from each of the sequences.
+ ///
+ /// This method uses deferred execution and stream its results.
+ ///
+ /// Any of the input sequences is null.
+ ///
+ /// Any of the input sequences are shorter than the others.
+ ///
+ /// The type of the elements of .
+ /// The first sequence of elements.
+ /// The type of the elements of .
+ /// The second sequence of elements.
+ public static global::System.Collections.Generic.IAsyncEnumerable<(TFirst,TSecond)>
+ EquiZip(this
+ global::System.Collections.Generic.IAsyncEnumerable first,
+ global::System.Collections.Generic.IAsyncEnumerable second
+ ) => EquiZip(first, second, global::System.ValueTuple.Create);
+
+ ///
+ ///
+ /// Applies a specified function to the corresponding elements of third sequences,
+ /// producing a sequence of the results.
+ ///
+ /// The resulting sequence has the same length as the input sequences.
+ /// If the input sequences are of different lengths, an exception is thrown.
+ ///
+ ///
+ /// The type of the elements of the result sequence.
+ /// A projection function that combines
+ /// elements from all of the sequences.
+ /// A sequence of elements returned by .
+ ///
+ /// This method uses deferred execution and stream its results.
+ ///
+ /// or any of the input sequences is null.
+ ///
+ /// Any of the input sequences are shorter than the others.
+ ///
+ /// The type of the elements of .
+ /// The first sequence of elements.
+ /// The type of the elements of .
+ /// The second sequence of elements.
+ /// The type of the elements of .
+ /// The third sequence of elements.
+ public static global::System.Collections.Generic.IAsyncEnumerable EquiZip(this
+ global::System.Collections.Generic.IAsyncEnumerable first,
+ global::System.Collections.Generic.IAsyncEnumerable second,
+ global::System.Collections.Generic.IAsyncEnumerable third,
+ global::System.Func resultSelector
+ )
+ {
+ ArgumentNullException.ThrowIfNull(first);
+ ArgumentNullException.ThrowIfNull(second);
+ ArgumentNullException.ThrowIfNull(third);
+
+ ArgumentNullException.ThrowIfNull(resultSelector);
+
+ return Core(
+ first,
+ second,
+ third,
+ resultSelector
+ );
+
+ static async global::System.Collections.Generic.IAsyncEnumerable Core(
+ global::System.Collections.Generic.IAsyncEnumerable first,
+ global::System.Collections.Generic.IAsyncEnumerable second,
+ global::System.Collections.Generic.IAsyncEnumerable third,
+ global::System.Func resultSelector,
+ [EnumeratorCancellation] CancellationToken cancellationToken = default
+ )
+ {
+ await using var e1 = first.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator();
+ await using var e2 = second.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator();
+ await using var e3 = third.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator();
+
+ while (true)
+ {
+ if (!await e1.MoveNextAsync())
+ {
+ if (await e2.MoveNextAsync()
+ || await e3.MoveNextAsync()
+ )
+ {
+ ThrowHelper.ThrowInvalidOperationException("First sequence too short.");
+ }
+
+ yield break;
+ }
+
+ if (!await e2.MoveNextAsync())
+ ThrowHelper.ThrowInvalidOperationException(
+ "Second sequence too short.");
+ if (!await e3.MoveNextAsync())
+ ThrowHelper.ThrowInvalidOperationException(
+ "Third sequence too short.");
+
+ yield return resultSelector(
+ e1.Current,
+ e2.Current,
+ e3.Current
+ );
+ }
+ }
+ }
+
+ ///
+ /// Joins the corresponding elements of third sequences,
+ /// producing a sequence of tuples containing them.
+ ///
+ /// A sequence of
+ ///
+ /// containing corresponding elements from each of the sequences.
+ ///
+ /// This method uses deferred execution and stream its results.
+ ///
+ /// Any of the input sequences is null.
+ ///
+ /// Any of the input sequences are shorter than the others.
+ ///
+ /// The type of the elements of .
+ /// The first sequence of elements.
+ /// The type of the elements of .
+ /// The second sequence of elements.
+ /// The type of the elements of .
+ /// The third sequence of elements.
+ public static global::System.Collections.Generic.IAsyncEnumerable<(TFirst,TSecond,TThird)>
+ EquiZip(this
+ global::System.Collections.Generic.IAsyncEnumerable first,
+ global::System.Collections.Generic.IAsyncEnumerable second,
+ global::System.Collections.Generic.IAsyncEnumerable third
+ ) => EquiZip(first, second, third, global::System.ValueTuple.Create);
+
+ ///
+ ///
+ /// Applies a specified function to the corresponding elements of fourth sequences,
+ /// producing a sequence of the results.
+ ///
+ /// The resulting sequence has the same length as the input sequences.
+ /// If the input sequences are of different lengths, an exception is thrown.
+ ///
+ ///
+ /// The type of the elements of the result sequence.
+ /// A projection function that combines
+ /// elements from all of the sequences.
+ /// A sequence of elements returned by .
+ ///
+ /// This method uses deferred execution and stream its results.
+ ///
+ /// or any of the input sequences is null.
+ ///
+ /// Any of the input sequences are shorter than the others.
+ ///
+ /// The type of the elements of .
+ /// The first sequence of elements.
+ /// The type of the elements of .
+ /// The second sequence of elements.
+ /// The type of the elements of .
+ /// The third sequence of elements.
+ /// The type of the elements of .
+ /// The fourth sequence of elements.
+ public static global::System.Collections.Generic.IAsyncEnumerable EquiZip(this
+ global::System.Collections.Generic.IAsyncEnumerable first,
+ global::System.Collections.Generic.IAsyncEnumerable second,
+ global::System.Collections.Generic.IAsyncEnumerable third,
+ global::System.Collections.Generic.IAsyncEnumerable fourth,
+ global::System.Func resultSelector
+ )
+ {
+ ArgumentNullException.ThrowIfNull(first);
+ ArgumentNullException.ThrowIfNull(second);
+ ArgumentNullException.ThrowIfNull(third);
+ ArgumentNullException.ThrowIfNull(fourth);
+
+ ArgumentNullException.ThrowIfNull(resultSelector);
+
+ return Core(
+ first,
+ second,
+ third,
+ fourth,
+ resultSelector
+ );
+
+ static async global::System.Collections.Generic.IAsyncEnumerable Core(
+ global::System.Collections.Generic.IAsyncEnumerable first,
+ global::System.Collections.Generic.IAsyncEnumerable second,
+ global::System.Collections.Generic.IAsyncEnumerable third,
+ global::System.Collections.Generic.IAsyncEnumerable fourth,
+ global::System.Func resultSelector,
+ [EnumeratorCancellation] CancellationToken cancellationToken = default
+ )
+ {
+ await using var e1 = first.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator();
+ await using var e2 = second.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator();
+ await using var e3 = third.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator();
+ await using var e4 = fourth.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator();
+
+ while (true)
+ {
+ if (!await e1.MoveNextAsync())
+ {
+ if (await e2.MoveNextAsync()
+ || await e3.MoveNextAsync()
+ || await e4.MoveNextAsync()
+ )
+ {
+ ThrowHelper.ThrowInvalidOperationException("First sequence too short.");
+ }
+
+ yield break;
+ }
+
+ if (!await e2.MoveNextAsync())
+ ThrowHelper.ThrowInvalidOperationException(
+ "Second sequence too short.");
+ if (!await e3.MoveNextAsync())
+ ThrowHelper.ThrowInvalidOperationException(
+ "Third sequence too short.");
+ if (!await e4.MoveNextAsync())
+ ThrowHelper.ThrowInvalidOperationException(
+ "Fourth sequence too short.");
+
+ yield return resultSelector(
+ e1.Current,
+ e2.Current,
+ e3.Current,
+ e4.Current
+ );
+ }
+ }
+ }
+
+ ///
+ /// Joins the corresponding elements of fourth sequences,
+ /// producing a sequence of tuples containing them.
+ ///
+ /// A sequence of
+ ///
+ /// containing corresponding elements from each of the sequences.
+ ///
+ /// This method uses deferred execution and stream its results.
+ ///
+ /// Any of the input sequences is null.
+ ///
+ /// Any of the input sequences are shorter than the others.
+ ///
+ /// The type of the elements of .
+ /// The first sequence of elements.
+ /// The type of the elements of .
+ /// The second sequence of elements.
+ /// The type of the elements of .
+ /// The third sequence of elements.
+ /// The type of the elements of .
+ /// The fourth sequence of elements.
+ public static global::System.Collections.Generic.IAsyncEnumerable<(TFirst,TSecond,TThird,TFourth)>
+ EquiZip(this
+ global::System.Collections.Generic.IAsyncEnumerable first,
+ global::System.Collections.Generic.IAsyncEnumerable second,
+ global::System.Collections.Generic.IAsyncEnumerable third,
+ global::System.Collections.Generic.IAsyncEnumerable fourth
+ ) => EquiZip(first, second, third, fourth, global::System.ValueTuple.Create);
+
+}
diff --git a/Source/SuperLinq.Async/Generated/SuperLinq.Async.Generator/SuperLinq.Async.Generator.Generator/Fold.g.cs b/Source/SuperLinq.Async/Generated/SuperLinq.Async.Generator/SuperLinq.Async.Generator.Generator/Fold.g.cs
index 085a95d1..76381788 100644
--- a/Source/SuperLinq.Async/Generated/SuperLinq.Async.Generator/SuperLinq.Async.Generator.Generator/Fold.g.cs
+++ b/Source/SuperLinq.Async/Generated/SuperLinq.Async.Generator/SuperLinq.Async.Generator.Generator/Fold.g.cs
@@ -1,436 +1,735 @@
namespace SuperLinq.Async;
+
#nullable enable
+
public static partial class AsyncSuperEnumerable
{
- ///
- /// Returns the result of applying a function to a sequence of 1 element.
- ///
- ///
- /// This operator uses immediate execution and buffers as many items of the source sequence as necessary.
- ///
- /// Type of element in the source sequence
- /// Type of the result
- /// The sequence of items to fold.
- /// Function to apply to the elements in the sequence.
- /// The folded value returned by .
- /// or is null.
- ///
- /// does not contain exactly 1 element.
- ///
- public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder)
- {
- ArgumentNullException.ThrowIfNull(source);
- ArgumentNullException.ThrowIfNull(folder);
- return Core(source, folder);
- static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder)
- {
- var elements = await source.AssertCount(1).ToListAsync().ConfigureAwait(false);
- return folder(elements[0]);
- }
- }
-
- ///
- /// Returns the result of applying a function to a sequence of 2 elements.
- ///
- ///
- /// This operator uses immediate execution and buffers as many items of the source sequence as necessary.
- ///
- /// Type of element in the source sequence
- /// Type of the result
- /// The sequence of items to fold.
- /// Function to apply to the elements in the sequence.
- /// The folded value returned by .
- /// or is null.
- ///
- /// does not contain exactly 2 elements.
- ///
- public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder)
- {
- ArgumentNullException.ThrowIfNull(source);
- ArgumentNullException.ThrowIfNull(folder);
- return Core(source, folder);
- static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder)
- {
- var elements = await source.AssertCount(2).ToListAsync().ConfigureAwait(false);
- return folder(elements[0], elements[1]);
- }
- }
-
- ///
- /// Returns the result of applying a function to a sequence of 3 elements.
- ///
- ///
- /// This operator uses immediate execution and buffers as many items of the source sequence as necessary.
- ///
- /// Type of element in the source sequence
- /// Type of the result
- /// The sequence of items to fold.
- /// Function to apply to the elements in the sequence.
- /// The folded value returned by .
- /// or is null.
- ///
- /// does not contain exactly 3 elements.
- ///
- public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder)
- {
- ArgumentNullException.ThrowIfNull(source);
- ArgumentNullException.ThrowIfNull(folder);
- return Core(source, folder);
- static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder)
- {
- var elements = await source.AssertCount(3).ToListAsync().ConfigureAwait(false);
- return folder(elements[0], elements[1], elements[2]);
- }
- }
-
- ///
- /// Returns the result of applying a function to a sequence of 4 elements.
- ///
- ///
- /// This operator uses immediate execution and buffers as many items of the source sequence as necessary.
- ///
- /// Type of element in the source sequence
- /// Type of the result
- /// The sequence of items to fold.
- /// Function to apply to the elements in the sequence.
- /// The folded value returned by .
- /// or is null.
- ///
- /// does not contain exactly 4 elements.
- ///
- public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder)
- {
- ArgumentNullException.ThrowIfNull(source);
- ArgumentNullException.ThrowIfNull(folder);
- return Core(source, folder);
- static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder)
- {
- var elements = await source.AssertCount(4).ToListAsync().ConfigureAwait(false);
- return folder(elements[0], elements[1], elements[2], elements[3]);
- }
- }
-
- ///
- /// Returns the result of applying a function to a sequence of 5 elements.
- ///
- ///
- /// This operator uses immediate execution and buffers as many items of the source sequence as necessary.
- ///
- /// Type of element in the source sequence
- /// Type of the result
- /// The sequence of items to fold.
- /// Function to apply to the elements in the sequence.
- /// The folded value returned by .
- /// or is null.
- ///
- /// does not contain exactly 5 elements.
- ///
- public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder)
- {
- ArgumentNullException.ThrowIfNull(source);
- ArgumentNullException.ThrowIfNull(folder);
- return Core(source, folder);
- static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder)
- {
- var elements = await source.AssertCount(5).ToListAsync().ConfigureAwait(false);
- return folder(elements[0], elements[1], elements[2], elements[3], elements[4]);
- }
- }
-
- ///
- /// Returns the result of applying a function to a sequence of 6 elements.
- ///
- ///
- /// This operator uses immediate execution and buffers as many items of the source sequence as necessary.
- ///
- /// Type of element in the source sequence
- /// Type of the result
- /// The sequence of items to fold.
- /// Function to apply to the elements in the sequence.
- /// The folded value returned by .
- /// or is null.
- ///
- /// does not contain exactly 6 elements.
- ///
- public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder)
- {
- ArgumentNullException.ThrowIfNull(source);
- ArgumentNullException.ThrowIfNull(folder);
- return Core(source, folder);
- static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder)
- {
- var elements = await source.AssertCount(6).ToListAsync().ConfigureAwait(false);
- return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5]);
- }
- }
-
- ///
- /// Returns the result of applying a function to a sequence of 7 elements.
- ///
- ///
- /// This operator uses immediate execution and buffers as many items of the source sequence as necessary.
- ///
- /// Type of element in the source sequence
- /// Type of the result
- /// The sequence of items to fold.
- /// Function to apply to the elements in the sequence.
- /// The folded value returned by .
- /// or is null.
- ///
- /// does not contain exactly 7 elements.
- ///
- public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder)
- {
- ArgumentNullException.ThrowIfNull(source);
- ArgumentNullException.ThrowIfNull(folder);
- return Core(source, folder);
- static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder)
- {
- var elements = await source.AssertCount(7).ToListAsync().ConfigureAwait(false);
- return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5], elements[6]);
- }
- }
-
- ///
- /// Returns the result of applying a function to a sequence of 8 elements.
- ///
- ///
- /// This operator uses immediate execution and buffers as many items of the source sequence as necessary.
- ///
- /// Type of element in the source sequence
- /// Type of the result
- /// The sequence of items to fold.
- /// Function to apply to the elements in the sequence.
- /// The folded value returned by .
- /// or is null.
- ///
- /// does not contain exactly 8 elements.
- ///
- public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder)
- {
- ArgumentNullException.ThrowIfNull(source);
- ArgumentNullException.ThrowIfNull(folder);
- return Core(source, folder);
- static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder)
- {
- var elements = await source.AssertCount(8).ToListAsync().ConfigureAwait(false);
- return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5], elements[6], elements[7]);
- }
- }
-
- ///
- /// Returns the result of applying a function to a sequence of 9 elements.
- ///
- ///
- /// This operator uses immediate execution and buffers as many items of the source sequence as necessary.
- ///
- /// Type of element in the source sequence
- /// Type of the result
- /// The sequence of items to fold.
- /// Function to apply to the elements in the sequence.
- /// The folded value returned by .
- /// or is null.
- ///
- /// does not contain exactly 9 elements.
- ///
- public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder)
- {
- ArgumentNullException.ThrowIfNull(source);
- ArgumentNullException.ThrowIfNull(folder);
- return Core(source, folder);
- static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder)
- {
- var elements = await source.AssertCount(9).ToListAsync().ConfigureAwait(false);
- return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5], elements[6], elements[7], elements[8]);
- }
- }
-
- ///
- /// Returns the result of applying a function to a sequence of 10 elements.
- ///
- ///
- /// This operator uses immediate execution and buffers as many items of the source sequence as necessary.
- ///
- /// Type of element in the source sequence
- /// Type of the result
- /// The sequence of items to fold.
- /// Function to apply to the elements in the sequence.
- /// The folded value returned by .
- /// or is null.
- ///
- /// does not contain exactly 10 elements.
- ///
- public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder)
- {
- ArgumentNullException.ThrowIfNull(source);
- ArgumentNullException.ThrowIfNull(folder);
- return Core(source, folder);
- static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder)
- {
- var elements = await source.AssertCount(10).ToListAsync().ConfigureAwait(false);
- return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5], elements[6], elements[7], elements[8], elements[9]);
- }
- }
-
- ///
- /// Returns the result of applying a function to a sequence of 11 elements.
- ///
- ///
- /// This operator uses immediate execution and buffers as many items of the source sequence as necessary.
- ///
- /// Type of element in the source sequence
- /// Type of the result
- /// The sequence of items to fold.
- /// Function to apply to the elements in the sequence.
- /// The folded value returned by .
- /// or is null.
- ///
- /// does not contain exactly 11 elements.
- ///
- public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder)
- {
- ArgumentNullException.ThrowIfNull(source);
- ArgumentNullException.ThrowIfNull(folder);
- return Core(source, folder);
- static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder)
- {
- var elements = await source.AssertCount(11).ToListAsync().ConfigureAwait(false);
- return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5], elements[6], elements[7], elements[8], elements[9], elements[10]);
- }
- }
-
- ///
- /// Returns the result of applying a function to a sequence of 12 elements.
- ///
- ///
- /// This operator uses immediate execution and buffers as many items of the source sequence as necessary.
- ///
- /// Type of element in the source sequence
- /// Type of the result
- /// The sequence of items to fold.
- /// Function to apply to the elements in the sequence.
- /// The folded value returned by .
- /// or is null.
- ///
- /// does not contain exactly 12 elements.
- ///
- public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func