diff --git a/Ix.NET/Source/Ix.NET.sln b/Ix.NET/Source/Ix.NET.sln index f44406c677..b06fded1ad 100644 --- a/Ix.NET/Source/Ix.NET.sln +++ b/Ix.NET/Source/Ix.NET.sln @@ -62,6 +62,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Benchmarks.System.Interacti EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Async.Ref", "refs\System.Linq.Async.Ref\System.Linq.Async.Ref.csproj", "{1754B36C-D0DB-4E5D-8C30-1F116046DC0F}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Linq.Async.SourceGenerator", "System.Linq.Async.SourceGenerator\System.Linq.Async.SourceGenerator.csproj", "{5C26D649-5ED4-49EE-AFBD-8FA8F12C4AE4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -136,6 +138,10 @@ Global {1754B36C-D0DB-4E5D-8C30-1F116046DC0F}.Debug|Any CPU.Build.0 = Debug|Any CPU {1754B36C-D0DB-4E5D-8C30-1F116046DC0F}.Release|Any CPU.ActiveCfg = Release|Any CPU {1754B36C-D0DB-4E5D-8C30-1F116046DC0F}.Release|Any CPU.Build.0 = Release|Any CPU + {5C26D649-5ED4-49EE-AFBD-8FA8F12C4AE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5C26D649-5ED4-49EE-AFBD-8FA8F12C4AE4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5C26D649-5ED4-49EE-AFBD-8FA8F12C4AE4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5C26D649-5ED4-49EE-AFBD-8FA8F12C4AE4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -158,6 +164,7 @@ Global {2EC0C302-B029-4DDB-AC91-000BF11006AD} = {A3D72E6E-4ADA-42E0-8B2A-055B1F244281} {5DF341BE-B369-4250-AFD4-604DE8C95E45} = {A3D72E6E-4ADA-42E0-8B2A-055B1F244281} {1754B36C-D0DB-4E5D-8C30-1F116046DC0F} = {A3D72E6E-4ADA-42E0-8B2A-055B1F244281} + {5C26D649-5ED4-49EE-AFBD-8FA8F12C4AE4} = {80EFE3A1-1414-42EA-949B-1B5370A1B2EA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {AF70B0C6-C9D9-43B1-9BE4-08720EC1B7B7} diff --git a/Ix.NET/Source/System.Linq.Async.SourceGenerator/AsyncMethod.cs b/Ix.NET/Source/System.Linq.Async.SourceGenerator/AsyncMethod.cs new file mode 100644 index 0000000000..cb896055ff --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.SourceGenerator/AsyncMethod.cs @@ -0,0 +1,7 @@ +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +namespace System.Linq.Async.SourceGenerator +{ + internal sealed record AsyncMethod(IMethodSymbol Symbol, MethodDeclarationSyntax Syntax); +} diff --git a/Ix.NET/Source/System.Linq.Async.SourceGenerator/AsyncMethodGrouping.cs b/Ix.NET/Source/System.Linq.Async.SourceGenerator/AsyncMethodGrouping.cs new file mode 100644 index 0000000000..9fe541acbb --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.SourceGenerator/AsyncMethodGrouping.cs @@ -0,0 +1,8 @@ +using System.Collections.Generic; + +using Microsoft.CodeAnalysis; + +namespace System.Linq.Async.SourceGenerator +{ + internal sealed record AsyncMethodGrouping(SyntaxTree SyntaxTree, IEnumerable Methods); +} diff --git a/Ix.NET/Source/System.Linq.Async.SourceGenerator/AsyncOverloadsGenerator.cs b/Ix.NET/Source/System.Linq.Async.SourceGenerator/AsyncOverloadsGenerator.cs new file mode 100644 index 0000000000..b0c27ecfee --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.SourceGenerator/AsyncOverloadsGenerator.cs @@ -0,0 +1,116 @@ +using System.Collections.Generic; +using System.IO; +using System.Text; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +namespace System.Linq.Async.SourceGenerator +{ + [Generator] + public sealed class AsyncOverloadsGenerator : ISourceGenerator + { + private const string AttributeSource = + "using System;\n" + + "using System.Diagnostics;\n" + + "namespace System.Linq\n" + + "{\n" + + " [AttributeUsage(AttributeTargets.Method)]\n" + + " [Conditional(\"COMPILE_TIME_ONLY\")]\n" + + " internal sealed class GenerateAsyncOverloadAttribute : Attribute { }\n" + + "}\n"; + + public void Initialize(GeneratorInitializationContext context) + { + context.RegisterForSyntaxNotifications(() => new SyntaxReceiver()); + context.RegisterForPostInitialization(c => c.AddSource("GenerateAsyncOverloadAttribute", AttributeSource)); + } + + public void Execute(GeneratorExecutionContext context) + { + if (context.SyntaxReceiver is not SyntaxReceiver syntaxReceiver) return; + + var options = GetGenerationOptions(context); + var methodsBySyntaxTree = GetMethodsGroupedBySyntaxTree(context, syntaxReceiver); + + foreach (var grouping in methodsBySyntaxTree) + context.AddSource( + $"{Path.GetFileNameWithoutExtension(grouping.SyntaxTree.FilePath)}.AsyncOverloads", + GenerateOverloads(grouping, options)); + } + + private static GenerationOptions GetGenerationOptions(GeneratorExecutionContext context) + => new(SupportFlatAsyncApi: context.ParseOptions.PreprocessorSymbolNames.Contains("SUPPORT_FLAT_ASYNC_API")); + + private static IEnumerable GetMethodsGroupedBySyntaxTree(GeneratorExecutionContext context, SyntaxReceiver syntaxReceiver) + => GetMethodsGroupedBySyntaxTree( + context, + syntaxReceiver, + GetAsyncOverloadAttributeSymbol(context)); + + private static string GenerateOverloads(AsyncMethodGrouping grouping, GenerationOptions options) + { + var usings = grouping.SyntaxTree.GetRoot() is CompilationUnitSyntax compilationUnit + ? compilationUnit.Usings.ToString() + : string.Empty; + + var overloads = new StringBuilder(); + overloads.AppendLine("#nullable enable"); + overloads.AppendLine(usings); + overloads.AppendLine("namespace System.Linq"); + overloads.AppendLine("{"); + overloads.AppendLine(" partial class AsyncEnumerable"); + overloads.AppendLine(" {"); + + foreach (var method in grouping.Methods) + overloads.AppendLine(GenerateOverload(method, options)); + + overloads.AppendLine(" }"); + overloads.AppendLine("}"); + + return overloads.ToString(); + } + + private static string GenerateOverload(AsyncMethod method, GenerationOptions options) + => MethodDeclaration(method.Syntax.ReturnType, GetMethodName(method.Symbol, options)) + .WithModifiers(TokenList(Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.StaticKeyword))) + .WithTypeParameterList(method.Syntax.TypeParameterList) + .WithParameterList(method.Syntax.ParameterList) + .WithConstraintClauses(method.Syntax.ConstraintClauses) + .WithExpressionBody(ArrowExpressionClause( + InvocationExpression( + IdentifierName(method.Symbol.Name), + ArgumentList( + SeparatedList( + method.Syntax.ParameterList.Parameters + .Select(p => Argument(IdentifierName(p.Identifier)))))))) + .WithSemicolonToken(Token(SyntaxKind.SemicolonToken)) + .WithLeadingTrivia(method.Syntax.GetLeadingTrivia().Where(t => t.GetStructure() is not DirectiveTriviaSyntax)) + .NormalizeWhitespace() + .ToFullString(); + + private static INamedTypeSymbol GetAsyncOverloadAttributeSymbol(GeneratorExecutionContext context) + => context.Compilation.GetTypeByMetadataName("System.Linq.GenerateAsyncOverloadAttribute") ?? throw new InvalidOperationException(); + + private static IEnumerable GetMethodsGroupedBySyntaxTree(GeneratorExecutionContext context, SyntaxReceiver syntaxReceiver, INamedTypeSymbol attributeSymbol) + => from candidate in syntaxReceiver.Candidates + group candidate by candidate.SyntaxTree into grouping + let model = context.Compilation.GetSemanticModel(grouping.Key) + select new AsyncMethodGrouping( + grouping.Key, + from methodSyntax in grouping + let methodSymbol = model.GetDeclaredSymbol(methodSyntax) ?? throw new InvalidOperationException() + where methodSymbol.GetAttributes().Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass!, attributeSymbol)) + select new AsyncMethod(methodSymbol, methodSyntax)); + + private static string GetMethodName(IMethodSymbol methodSymbol, GenerationOptions options) + { + var methodName = methodSymbol.Name.Replace("Core", ""); + return options.SupportFlatAsyncApi + ? methodName.Replace("Await", "").Replace("WithCancellation", "") + : methodName; + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.SourceGenerator/GenerationOptions.cs b/Ix.NET/Source/System.Linq.Async.SourceGenerator/GenerationOptions.cs new file mode 100644 index 0000000000..8733c5bae1 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.SourceGenerator/GenerationOptions.cs @@ -0,0 +1,4 @@ +namespace System.Linq.Async.SourceGenerator +{ + internal sealed record GenerationOptions(bool SupportFlatAsyncApi); +} diff --git a/Ix.NET/Source/System.Linq.Async.SourceGenerator/SyntaxReceiver.cs b/Ix.NET/Source/System.Linq.Async.SourceGenerator/SyntaxReceiver.cs new file mode 100644 index 0000000000..5bd54f9c03 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.SourceGenerator/SyntaxReceiver.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +namespace System.Linq.Async.SourceGenerator +{ + internal sealed class SyntaxReceiver : ISyntaxReceiver + { + public IList Candidates { get; } = new List(); + + public void OnVisitSyntaxNode(SyntaxNode syntaxNode) + { + if (syntaxNode is MethodDeclarationSyntax { AttributeLists: { Count: >0 } } methodDeclarationSyntax) + { + Candidates.Add(methodDeclarationSyntax); + } + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.SourceGenerator/System.Linq.Async.SourceGenerator.csproj b/Ix.NET/Source/System.Linq.Async.SourceGenerator/System.Linq.Async.SourceGenerator.csproj new file mode 100644 index 0000000000..cdcc8150b7 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.SourceGenerator/System.Linq.Async.SourceGenerator.csproj @@ -0,0 +1,10 @@ + + + netstandard2.0 + 9.0 + + + + + + diff --git a/Ix.NET/Source/System.Linq.Async.slnf b/Ix.NET/Source/System.Linq.Async.slnf new file mode 100644 index 0000000000..e3f05146b0 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.slnf @@ -0,0 +1,11 @@ +{ + "solution": { + "path": "Ix.NET.sln", + "projects": [ + "System.Linq.Async\\System.Linq.Async.csproj", + "System.Linq.Async.Tests\\System.Linq.Async.Tests.csproj", + "System.Linq.Async.SourceGenerator\\System.Linq.Async.SourceGenerator.csproj", + "refs\\System.Linq.Async.Ref\\System.Linq.Async.Ref.csproj" + ] + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj index 4d1c37cd65..1bfe13cbef 100644 --- a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj +++ b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj @@ -28,6 +28,7 @@ + diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.cs deleted file mode 100644 index 7c3888ba93..0000000000 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.cs +++ /dev/null @@ -1,1465 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT License. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace System.Linq -{ - partial class AsyncEnumerable - { -#if SUPPORT_FLAT_ASYNC_API - public static ValueTask AggregateAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) => AggregateAwaitAsyncCore(source, accumulator, cancellationToken); - public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) => AggregateAwaitAsyncCore(source, seed, accumulator, cancellationToken); - public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) => AggregateAwaitAsyncCore(source, seed, accumulator, resultSelector, cancellationToken); - public static ValueTask AllAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => AllAwaitAsyncCore(source, predicate, cancellationToken); - public static ValueTask AnyAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => AnyAwaitAsyncCore(source, predicate, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => CountAwaitAsyncCore(source, predicate, cancellationToken); - public static ValueTask FirstAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => FirstAwaitAsyncCore(source, predicate, cancellationToken); - public static ValueTask FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => FirstOrDefaultAwaitAsyncCore(source, predicate, cancellationToken); - public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken = default) => ForEachAwaitAsyncCore(source, action, cancellationToken); - public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken = default) => ForEachAwaitAsyncCore(source, action, cancellationToken); - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector) => GroupByAwaitCore(source, keySelector); - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => GroupByAwaitCore(source, keySelector, comparer); - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => GroupByAwaitCore(source, keySelector, elementSelector); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector) => GroupByAwaitCore(source, keySelector, resultSelector); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector) => GroupByAwaitCore(source, keySelector, elementSelector, resultSelector); - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => GroupByAwaitCore(source, keySelector, elementSelector, comparer); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitCore(source, keySelector, resultSelector, comparer); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitCore(source, keySelector, elementSelector, resultSelector, comparer); - public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector) => GroupJoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector); - public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => GroupJoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); - public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => JoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector); - public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) => JoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); - public static ValueTask LastAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => LastAwaitAsyncCore(source, predicate, cancellationToken); - public static ValueTask LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => LastOrDefaultAwaitAsyncCore(source, predicate, cancellationToken); - public static ValueTask LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => LongCountAwaitAsyncCore(source, predicate, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector) => OrderByAwaitCore(source, keySelector); - public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByAwaitCore(source, keySelector, comparer); - public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector) => OrderByDescendingAwaitCore(source, keySelector); - public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByDescendingAwaitCore(source, keySelector, comparer); - public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) => SelectAwaitCore(source, selector); - public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) => SelectAwaitCore(source, selector); - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) => SelectManyAwaitCore(source, selector); - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) => SelectManyAwaitCore(source, selector); - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitCore(source, collectionSelector, resultSelector); - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitCore(source, collectionSelector, resultSelector); - public static ValueTask SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => SingleAwaitAsyncCore(source, predicate, cancellationToken); - public static ValueTask SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => SingleOrDefaultAwaitAsyncCore(source, predicate, cancellationToken); - public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitCore(source, predicate); - public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitCore(source, predicate); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitCore(source, predicate); - public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitCore(source, predicate); - public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByAwaitCore(source, keySelector); - public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByAwaitCore(source, keySelector, comparer); - public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByDescendingAwaitCore(source, keySelector); - public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByDescendingAwaitCore(source, keySelector, comparer); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) where TKey : notnull => ToDictionaryAwaitAsyncCore(source, keySelector, cancellationToken); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) where TKey : notnull => ToDictionaryAwaitAsyncCore(source, keySelector, comparer, cancellationToken); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) where TKey : notnull => ToDictionaryAwaitAsyncCore(source, keySelector, elementSelector, cancellationToken); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) where TKey : notnull => ToDictionaryAwaitAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => ToLookupAwaitAsyncCore(source, keySelector, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => ToLookupAwaitAsyncCore(source, keySelector, elementSelector, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) => ToLookupAwaitAsyncCore(source, keySelector, comparer, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) => ToLookupAwaitAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); - public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) => WhereAwaitCore(source, predicate); - public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) => WhereAwaitCore(source, predicate); - public static IAsyncEnumerable Zip(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) => ZipAwaitCore(first, second, selector); - -#if !NO_DEEP_CANCELLATION - public static ValueTask AggregateAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) => AggregateAwaitWithCancellationAsyncCore(source, accumulator, cancellationToken); - public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) => AggregateAwaitWithCancellationAsyncCore(source, seed, accumulator, cancellationToken); - public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) => AggregateAwaitWithCancellationAsyncCore(source, seed, accumulator, resultSelector, cancellationToken); - public static ValueTask AllAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => AllAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask AnyAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => AnyAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => CountAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask FirstAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => FirstAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => FirstOrDefaultAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitWithCancellationAsyncCore(source, action, cancellationToken); - public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitWithCancellationAsyncCore(source, action, cancellationToken); - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector) => GroupByAwaitWithCancellationCore(source, keySelector); - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => GroupByAwaitWithCancellationCore(source, keySelector, comparer); - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => GroupByAwaitWithCancellationCore(source, keySelector, elementSelector); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector) => GroupByAwaitWithCancellationCore(source, keySelector, resultSelector); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector) => GroupByAwaitWithCancellationCore(source, keySelector, elementSelector, resultSelector); - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => GroupByAwaitWithCancellationCore(source, keySelector, elementSelector, comparer); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitWithCancellationCore(source, keySelector, resultSelector, comparer); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitWithCancellationCore(source, keySelector, elementSelector, resultSelector, comparer); - public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector) => GroupJoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector); - public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => GroupJoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); - public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => JoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector); - public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) => JoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); - public static ValueTask LastAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => LastAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => LastOrDefaultAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => LongCountAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector) => OrderByAwaitWithCancellationCore(source, keySelector); - public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByAwaitWithCancellationCore(source, keySelector, comparer); - public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector) => OrderByDescendingAwaitWithCancellationCore(source, keySelector); - public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByDescendingAwaitWithCancellationCore(source, keySelector, comparer); - public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) => SelectAwaitWithCancellationCore(source, selector); - public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) => SelectAwaitWithCancellationCore(source, selector); - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) => SelectManyAwaitWithCancellationCore(source, selector); - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) => SelectManyAwaitWithCancellationCore(source, selector); - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitWithCancellationCore(source, collectionSelector, resultSelector); - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitWithCancellationCore(source, collectionSelector, resultSelector); - public static ValueTask SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => SingleAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => SingleOrDefaultAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitWithCancellationCore(source, predicate); - public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitWithCancellationCore(source, predicate); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitWithCancellationCore(source, predicate); - public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitWithCancellationCore(source, predicate); - public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByAwaitWithCancellationCore(source, keySelector); - public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByAwaitWithCancellationCore(source, keySelector, comparer); - public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByDescendingAwaitWithCancellationCore(source, keySelector); - public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByDescendingAwaitWithCancellationCore(source, keySelector, comparer); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) where TKey : notnull => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, cancellationToken); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) where TKey : notnull => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, comparer, cancellationToken); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) where TKey : notnull => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, cancellationToken); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) where TKey : notnull => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, comparer, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); - public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) => WhereAwaitWithCancellationCore(source, predicate); - public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) => WhereAwaitWithCancellationCore(source, predicate); - public static IAsyncEnumerable Zip(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) => ZipAwaitWithCancellationCore(first, second, selector); -#endif -#else - /// - /// Applies an accumulator function over an async-enumerable sequence, returning the result of the aggregation as a single element in the result sequence. - /// - /// The type of elements in the source sequence. - /// An async-enumerable sequence to aggregate over. - /// An asynchronous accumulator function to be invoked and awaited on each element. - /// An optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask containing the final accumulator value. - /// or is . - /// The source sequence is empty. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask AggregateAwaitAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) => AggregateAwaitAsyncCore(source, accumulator, cancellationToken); - - /// - /// Applies an accumulator function over an async-enumerable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value. - /// - /// The type of elements in the source sequence. - /// The type of the result of aggregation. - /// An async-enumerable sequence to aggregate over. - /// The initial accumulator value. - /// An asynchronous accumulator function to be invoked and awaited on each element. - /// An optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask containing the final accumulator value. - /// or is . - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask AggregateAwaitAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) => AggregateAwaitAsyncCore(source, seed, accumulator, cancellationToken); - - /// - /// Applies an accumulator function over an async-enumerable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value, - /// and the specified result selector is used to select the result value. - /// - /// The type of elements in the source sequence. - /// The type of the accumulator value. - /// The type of the resulting value. - /// An async-enumerable sequence to aggregate over. - /// The initial accumulator value. - /// An asynchronous accumulator function to be invoked and awaited on each element. - /// An asynchronous transform function to transform the final accumulator value into the result value. - /// An optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask containing the value obtained by applying the result selector to the final accumulator value. - /// or or is . - public static ValueTask AggregateAwaitAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) => AggregateAwaitAsyncCore(source, seed, accumulator, resultSelector, cancellationToken); - - /// - /// Determines whether all elements in an async-enumerable sequence satisfy a condition. - /// - /// The type of element in the sequence. - /// An async-enumerable sequence whose elements to apply the predicate to. - /// An asynchronous predicate to apply to each element of the source sequence. - /// An optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask containing a value indicating whether all elements in the sequence pass the test in the specified predicate. - /// or is . - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask AllAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => AllAwaitAsyncCore(source, predicate, cancellationToken); - - /// - /// Determines whether any element in an async-enumerable sequence satisfies a condition. - /// - /// The type of element in the sequence. - /// An async-enumerable sequence whose elements to apply the predicate to. - /// An asynchronous predicate to apply to each element of the source sequence. - /// An optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask containing a value indicating whether any elements in the source sequence pass the test in the specified predicate. - /// or is . - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask AnyAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => AnyAwaitAsyncCore(source, predicate, cancellationToken); - - /// - /// Computes the average of an async-enumerable sequence of values that are obtained by invoking an asynchronous transform function on each element of the source sequence and awaiting the result. - /// - /// The type of elements in the source sequence. - /// An async-enumerable sequence of values to compute the average of. - /// A transform function to invoke and await on each element of the source sequence. - /// An optional cancellation token for cancelling the sequence at any time. - /// A ValueTask containing the average of the sequence of values. - /// or is . - /// The source sequence is empty. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Computes the average of an async-enumerable sequence of values that are obtained by invoking an asynchronous transform function on each element of the source sequence and awaiting the result. - /// - /// The type of elements in the source sequence. - /// An async-enumerable sequence of values to compute the average of. - /// A transform function to invoke and await on each element of the source sequence. - /// An optional cancellation token for cancelling the sequence at any time. - /// A ValueTask containing the average of the sequence of values. - /// or is . - /// The source sequence is empty. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Computes the average of an async-enumerable sequence of values that are obtained by invoking an asynchronous transform function on each element of the source sequence and awaiting the result. - /// - /// The type of elements in the source sequence. - /// An async-enumerable sequence of values to compute the average of. - /// A transform function to invoke and await on each element of the source sequence. - /// An optional cancellation token for cancelling the sequence at any time. - /// A ValueTask containing the average of the sequence of values. - /// or is . - /// The source sequence is empty. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Computes the average of an async-enumerable sequence of values that are obtained by invoking an asynchronous transform function on each element of the source sequence and awaiting the result. - /// - /// The type of elements in the source sequence. - /// An async-enumerable sequence of values to compute the average of. - /// A transform function to invoke and await on each element of the source sequence. - /// An optional cancellation token for cancelling the sequence at any time. - /// A ValueTask containing the average of the sequence of values. - /// or is . - /// The source sequence is empty. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Computes the average of an async-enumerable sequence of values that are obtained by invoking an asynchronous transform function on each element of the source sequence and awaiting the result. - /// - /// The type of elements in the source sequence. - /// An async-enumerable sequence of values to compute the average of. - /// A transform function to invoke and await on each element of the source sequence. - /// An optional cancellation token for cancelling the sequence at any time. - /// A ValueTask containing the average of the sequence of values. - /// or is . - /// The source sequence is empty. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Computes the average of an async-enumerable sequence of values that are obtained by invoking an asynchronous transform function on each element of the source sequence and awaiting the result. - /// - /// The type of elements in the source sequence. - /// An async-enumerable sequence of values to compute the average of. - /// A transform function to invoke and await on each element of the source sequence. - /// An optional cancellation token for cancelling the sequence at any time. - /// A ValueTask containing the average of the sequence of values, or if the source sequence is empty. - /// or is . - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Computes the average of an async-enumerable sequence of values that are obtained by invoking an asynchronous transform function on each element of the source sequence and awaiting the result. - /// - /// The type of elements in the source sequence. - /// An async-enumerable sequence of values to compute the average of. - /// A transform function to invoke and await on each element of the source sequence. - /// An optional cancellation token for cancelling the sequence at any time. - /// A ValueTask containing the average of the sequence of values, or if the source sequence is empty. - /// or is . - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Computes the average of an async-enumerable sequence of values that are obtained by invoking an asynchronous transform function on each element of the source sequence and awaiting the result. - /// - /// The type of elements in the source sequence. - /// An async-enumerable sequence of values to compute the average of. - /// A transform function to invoke and await on each element of the source sequence. - /// An optional cancellation token for cancelling the sequence at any time. - /// A ValueTask containing the average of the sequence of values, or if the source sequence is empty. - /// or is . - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Computes the average of an async-enumerable sequence of values that are obtained by invoking an asynchronous transform function on each element of the source sequence and awaiting the result. - /// - /// The type of elements in the source sequence. - /// An async-enumerable sequence of values to compute the average of. - /// A transform function to invoke and await on each element of the source sequence. - /// An optional cancellation token for cancelling the sequence at any time. - /// A ValueTask containing the average of the sequence of values, or if the source sequence is empty. - /// or is . - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Computes the average of an async-enumerable sequence of values that are obtained by invoking an asynchronous transform function on each element of the source sequence and awaiting the result. - /// - /// The type of elements in the source sequence. - /// An async-enumerable sequence of values to compute the average of. - /// A transform function to invoke and await on each element of the source sequence. - /// An optional cancellation token for cancelling the sequence at any time. - /// A ValueTask containing the average of the sequence of values, or if the source sequence is empty. - /// or is . - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Counts the elements in an async-enumerable sequence that satisfy a condition. - /// - /// Type of elements in the source sequence. - /// A sequence of elements to count. - /// An asynchronous predicate to apply to each element in the source sequence. - /// An optional cancellation token for cancelling the sequence at any time. - /// A ValueTask containing the number of elements in the sequence that satisfy the predicate. - /// or is . - public static ValueTask CountAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => CountAwaitAsyncCore(source, predicate, cancellationToken); - - /// - /// Returns the first element of an async-enumerable sequence that satisfies the condition in the predicate. - /// - /// The type of elements in the sequence. - /// Source async-enumerable sequence. - /// An asynchronous predicate that will be invoked and awaited for each element in the sequence. - /// An optional cancellation token for cancelling the sequence at any time. - /// A ValueTask containing the first element in the sequence that satisfies the predicate. - /// or is . - /// No element satisfies the condition in the predicate. -or- The source sequence is empty. - public static ValueTask FirstAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => FirstAwaitAsyncCore(source, predicate, cancellationToken); - - /// - /// Returns the first element of an async-enumerable sequence that satisfies the condition in the predicate, or a default value if no element satisfies the condition in the predicate. - /// - /// The type of element in the sequence. - /// Source async-enumerable sequence. - /// An asynchronous predicate to invoke and await on each element of the sequence. - /// An optional cancellation token for cancelling the sequence at any time. - /// A ValueTask containing the first element in the sequence that satisfies the predicate, or a default value if no element satisfies the predicate. - /// or is . - public static ValueTask FirstOrDefaultAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => FirstOrDefaultAwaitAsyncCore(source, predicate, cancellationToken); - - /// - /// Invokes and awaits an asynchronous action on each element in the source sequence, and returns a task that is signaled when the sequence terminates. - /// - /// Type of elements in the sequence. - /// Source sequence. - /// Asynchronous action to invoke and await for each element in the source sequence. - /// Optional cancellation token for cancelling the sequence at any time. - /// Task that signals the termination of the sequence. - /// or is . - public static Task ForEachAwaitAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken = default) => ForEachAwaitAsyncCore(source, action, cancellationToken); - - /// - /// Invokes and awaits an asynchronous action on each element in the source sequence, incorporating the element's index, and returns a task that is signaled when the sequence terminates. - /// - /// Type of elements in the sequence. - /// Source sequence. - /// Asynchronous action to invoke and await for each element in the source sequence; the second parameter represents the index of the element. - /// Optional cancellation token for cancelling the sequence at any time. - /// Task that signals the termination of the sequence. - /// or is . - public static Task ForEachAwaitAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken = default) => ForEachAwaitAsyncCore(source, action, cancellationToken); - - /// - /// Groups the elements of an async-enumerable sequence according to a specified key selector function. - /// - /// The type of the elements in the source sequence. - /// The type of the grouping key computed for each element in the source sequence. - /// An async-enumerable sequence whose elements to group. - /// An asynchronous function to extract the key for each element. - /// A sequence of async-enumerable groups, each of which corresponds to a unique key value, containing all elements that share that same key value. - /// or is . - public static IAsyncEnumerable> GroupByAwait(this IAsyncEnumerable source, Func> keySelector) => GroupByAwaitCore(source, keySelector); - - /// - /// Groups the elements of an async-enumerable sequence according to a specified key selector function and comparer. - /// - /// The type of the elements in the source sequence. - /// The type of the grouping key computed for each element in the source sequence. - /// An async-enumerable sequence whose elements to group. - /// An asynchronous function to extract the key for each element. - /// An equality comparer to compare keys with. - /// A sequence of async-enumerable groups, each of which corresponds to a unique key value, containing all elements that share that same key value. - /// or or is . - public static IAsyncEnumerable> GroupByAwait(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => GroupByAwaitCore(source, keySelector, comparer); - - /// - /// Groups the elements of an async-enumerable sequence and selects the resulting elements by using a specified function. - /// - /// The type of the elements in the source sequence. - /// The type of the grouping key computed for each element in the source sequence. - /// The type of the elements within the groups computed for each element in the source sequence. - /// An async-enumerable sequence whose elements to group. - /// An asynchronous function to extract the key for each element. - /// An asynchronous function to map each source element to an element in an async-enumerable group. - /// A sequence of async-enumerable groups, each of which corresponds to a unique key value, containing all elements that share that same key value. - /// or or is . - public static IAsyncEnumerable> GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => GroupByAwaitCore(source, keySelector, elementSelector); - - /// - /// Groups the elements of an async-enumerable sequence according to a specified key selector function, and then applies a result selector function to each group. - /// - /// Type of element in the source sequence. - /// Type of the grouping key computed for each element in the source sequence. - /// The result type returned by the result selector function. - /// An async-enumerable sequence whose elements to group. - /// An asynchronous function to extract the key for each element. - /// An asynchronous function to transform each group into the result type. - /// An async-enumerable sequence of results obtained by invoking and awaiting the result-selector function on each group. - /// or or is . - public static IAsyncEnumerable GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector) => GroupByAwaitCore(source, keySelector, resultSelector); - - /// - /// Groups the elements of an async-enumerable sequence according to a specified key-selector function, applies an element selector to each element of each group, then applies a result selector to each transformed group. - /// - /// The type of element in the source sequence. - /// The type of the grouping key computed for each element in the source sequence. - /// The type of element computed by the element selector. - /// The type of the final result, computed by applying the result selector to each transformed group of elements. - /// An async-enumerable sequence whose elements to group. - /// An asynchronous function to extract the key for each element. - /// An asynchronous function to apply to each element of each group. - /// An asynchronous function to transform each group into the result type. - /// An async-enumerable sequence of results obtained by invoking the result selector function on each group and awaiting the result. - /// or or or is . - public static IAsyncEnumerable GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector) => GroupByAwaitCore(source, keySelector, elementSelector, resultSelector); - - /// - /// Groups the elements of an async-enumerable sequence and selects the resulting elements by using a specified function. - /// - /// The type of the elements in the source sequence. - /// The type of the grouping key computed for each element in the source sequence. - /// The type of the elements within the groups computed for each element in the source sequence. - /// An async-enumerable sequence whose elements to group. - /// An asynchronous function to extract the key for each element. - /// An asynchronous function to map each source element to an element in an async-enumerable group. - /// An equality comparer to use to compare keys. - /// A sequence of async-enumerable groups, each of which corresponds to a unique key value, containing all elements that share that same key value. - /// or or or is . - public static IAsyncEnumerable> GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => GroupByAwaitCore(source, keySelector, elementSelector, comparer); - - /// - /// Groups the elements of an async-enumerable sequence according to a specified key selector function, and then applies a result selector function to each group. - /// - /// Type of element in the source sequence. - /// Type of the grouping key computed for each element in the source sequence. - /// The result type returned by the result selector function. - /// An async-enumerable sequence whose elements to group. - /// An asynchronous function to extract the key for each element. - /// An asynchronous function to transform each group into the result type. - /// An equality comparer to use to compare keys. - /// An async-enumerable sequence of results obtained by invoking and awaiting the result-selector function on each group. - /// or or or is . - public static IAsyncEnumerable GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitCore(source, keySelector, resultSelector, comparer); - - /// - /// Groups the elements of an async-enumerable sequence according to a specified key-selector function, applies an element selector to each element of each group, then applies a result selector to each transformed group. - /// - /// The type of element in the source sequence. - /// The type of the grouping key computed for each element in the source sequence. - /// The type of element computed by the element selector. - /// The type of the final result, computed by applying the result selector to each transformed group of elements. - /// An async-enumerable sequence whose elements to group. - /// An asynchronous function to extract the key for each element. - /// An asynchronous function to apply to each element of each group. - /// An asynchronous function to transform each group into the result type. - /// An equality comparer to use to compare keys. - /// An async-enumerable sequence of results obtained by invoking the result selector function on each group and awaiting the result. - /// or or or or is . - public static IAsyncEnumerable GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitCore(source, keySelector, elementSelector, resultSelector, comparer); - public static IAsyncEnumerable GroupJoinAwait(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector) => GroupJoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector); - public static IAsyncEnumerable GroupJoinAwait(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => GroupJoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); - public static IAsyncEnumerable JoinAwait(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => JoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector); - public static IAsyncEnumerable JoinAwait(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) => JoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); - - /// - /// Returns the last element of an async-enumerable sequence that satisfies the condition in the predicate. - /// - /// The type of the elements in the source sequence. - /// Source async-enumerable sequence. - /// An asynchronous predicate function to evaluate for elements in the source sequence. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// ValueTask containing the last element in the async-enumerable sequence that satisfies the condition in the predicate. - /// or is null. - /// (Asynchronous) No element satisfies the condition in the predicate. -or- The source sequence is empty. - public static ValueTask LastAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => LastAwaitAsyncCore(source, predicate, cancellationToken); - - /// - /// Returns the last element of an async-enumerable sequence that satisfies the condition in the predicate, or a default value if no such element exists. - /// - /// The type of the elements in the source sequence. - /// Source async-enumerable sequence. - /// An asynchronous predicate function to evaluate for elements in the source sequence. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// ValueTask containing the last element in the async-enumerable sequence that satisfies the condition in the predicate, or a default value if no such element exists. - /// or is null. - public static ValueTask LastOrDefaultAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => LastOrDefaultAwaitAsyncCore(source, predicate, cancellationToken); - - /// - /// Returns an async-enumerable sequence containing a that represents the number of elements in the specified async-enumerable sequence that satisfy a condition. - /// - /// The type of the elements in the source sequence. - /// An async-enumerable sequence that contains elements to be counted. - /// An asynchronous predicate to test each element for a condition. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// An async-enumerable sequence containing a single element with a number that represents how many elements in the input sequence satisfy the condition in the predicate function. - /// or is null. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask LongCountAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => LongCountAwaitAsyncCore(source, predicate, cancellationToken); - - /// - /// Invokes and awaits a transform function on each element of a sequence and returns the maximum value. - /// - /// Type of elements in the source sequence. - /// The source sequence. - /// An asynchronous transform function to invoke and await on each element of the source. - /// The optional cancellation token to be usef for cancelling the sequence at any time. - /// A ValueTask containing the maximum value in the sequence. - /// or is . - public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Invokes and awaits a transform function on each element of a sequence and returns the maximum value. - /// - /// Type of elements in the source sequence. - /// The source sequence. - /// An asynchronous transform function to invoke and await on each element of the source. - /// The optional cancellation token to be usef for cancelling the sequence at any time. - /// A ValueTask containing the maximum value in the sequence. - /// or is . - public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Invokes and awaits a transform function on each element of a sequence and returns the maximum value. - /// - /// Type of elements in the source sequence. - /// The source sequence. - /// An asynchronous transform function to invoke and await on each element of the source. - /// The optional cancellation token to be usef for cancelling the sequence at any time. - /// A ValueTask containing the maximum value in the sequence. - /// or is . - public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Invokes and awaits a transform function on each element of a sequence and returns the maximum value. - /// - /// Type of elements in the source sequence. - /// The source sequence. - /// An asynchronous transform function to invoke and await on each element of the source. - /// The optional cancellation token to be usef for cancelling the sequence at any time. - /// A ValueTask containing the maximum value in the sequence. - /// or is . - public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Invokes and awaits a transform function on each element of a sequence and returns the maximum value. - /// - /// Type of elements in the source sequence. - /// The source sequence. - /// An asynchronous transform function to invoke and await on each element of the source. - /// The optional cancellation token to be usef for cancelling the sequence at any time. - /// A ValueTask containing the maximum value in the sequence. - /// or is . - public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Invokes and awaits a transform function on each element of a sequence and returns the maximum value. - /// - /// Type of elements in the source sequence. - /// The source sequence. - /// An asynchronous transform function to invoke and await on each element of the source. - /// The optional cancellation token to be usef for cancelling the sequence at any time. - /// A ValueTask containing the maximum value in the sequence. - /// or is . - public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Invokes and awaits a transform function on each element of a sequence and returns the maximum value. - /// - /// Type of elements in the source sequence. - /// The source sequence. - /// An asynchronous transform function to invoke and await on each element of the source. - /// The optional cancellation token to be usef for cancelling the sequence at any time. - /// A ValueTask containing the maximum value in the sequence. - /// or is . - public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Invokes and awaits a transform function on each element of a sequence and returns the maximum value. - /// - /// Type of elements in the source sequence. - /// The source sequence. - /// An asynchronous transform function to invoke and await on each element of the source. - /// The optional cancellation token to be usef for cancelling the sequence at any time. - /// A ValueTask containing the maximum value in the sequence. - /// or is . - public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Invokes and awaits a transform function on each element of a sequence and returns the maximum value. - /// - /// The type of the elements in the source sequence. - /// The type of the objects derived from the elements in the source sequence to determine the maximum of. - /// An async-enumerable sequence to determine the minimum element of. - /// An asynchronous transform function to invoke and await on each element. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask containing a single element with the value that corresponds to the maximum element in the source sequence. - /// or is null. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Returns the maximum value in an async-enumerable sequence. - /// - /// Type of elements in the source sequence. - /// The source sequence. - /// An asynchronous transform function to invoke and await on each element of the source. - /// The optional cancellation token to be usef for cancelling the sequence at any time. - /// A ValueTask containing the maximum value in the sequence. - /// or is . - public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Returns the maximum value in an async-enumerable sequence. - /// - /// Type of elements in the source sequence. - /// The source sequence. - /// An asynchronous transform function to invoke and await on each element of the source. - /// The optional cancellation token to be usef for cancelling the sequence at any time. - /// A ValueTask containing the maximum value in the sequence. - /// or is . - public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Invokes and awaits a transform function on each element of a sequence and returns the minimum value. - /// - /// The type of the elements in the source sequence. - /// An async-enumerable sequence to determine the minimum element of. - /// An asynchronous transform function to invoke and await on each element. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask sequence containing a single element with the value that corresponds to the minimum element in the source sequence. - /// or is null. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Invokes and awaits a transform function on each element of a sequence and returns the minimum value. - /// - /// The type of the elements in the source sequence. - /// An async-enumerable sequence to determine the minimum element of. - /// An asynchronous transform function to invoke and await on each element. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask sequence containing a single element with the value that corresponds to the minimum element in the source sequence. - /// or is null. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Invokes and awaits a transform function on each element of a sequence and returns the minimum value. - /// - /// The type of the elements in the source sequence. - /// An async-enumerable sequence to determine the minimum element of. - /// An asynchronous transform function to invoke and await on each element. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask sequence containing a single element with the value that corresponds to the minimum element in the source sequence. - /// or is null. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Invokes and awaits a transform function on each element of a sequence and returns the minimum value. - /// - /// The type of the elements in the source sequence. - /// An async-enumerable sequence to determine the minimum element of. - /// An asynchronous transform function to invoke and await on each element. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask sequence containing a single element with the value that corresponds to the minimum element in the source sequence. - /// or is null. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Invokes and awaits a transform function on each element of a sequence and returns the minimum value. - /// - /// The type of the elements in the source sequence. - /// An async-enumerable sequence to determine the minimum element of. - /// An asynchronous transform function to invoke and await on each element. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask sequence containing a single element with the value that corresponds to the minimum element in the source sequence. - /// or is null. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Invokes and awaits a transform function on each element of a sequence and returns the minimum value. - /// - /// The type of the elements in the source sequence. - /// An async-enumerable sequence to determine the minimum element of. - /// An asynchronous transform function to invoke and await on each element. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask sequence containing a single element with the value that corresponds to the minimum element in the source sequence. - /// or is null. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Invokes and awaits a transform function on each element of a sequence and returns the minimum value. - /// - /// The type of the elements in the source sequence. - /// An async-enumerable sequence to determine the minimum element of. - /// An asynchronous transform function to invoke and await on each element. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask sequence containing a single element with the value that corresponds to the minimum element in the source sequence. - /// or is null. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Invokes and awaits a transform function on each element of a sequence and returns the minimum value. - /// - /// The type of the elements in the source sequence. - /// An async-enumerable sequence to determine the minimum element of. - /// An asynchronous transform function to invoke and await on each element. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask sequence containing a single element with the value that corresponds to the minimum element in the source sequence. - /// or is null. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Invokes and awaits a transform function on each element of a sequence and returns the minimum value. - /// - /// The type of the elements in the source sequence. - /// An async-enumerable sequence to determine the minimum element of. - /// An asynchronous transform function to invoke and await on each element. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask sequence containing a single element with the value that corresponds to the minimum element in the source sequence. - /// or is null. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Invokes and awaits a transform function on each element of a sequence and returns the minimum value. - /// - /// The type of the elements in the source sequence. - /// An async-enumerable sequence to determine the minimum element of. - /// An asynchronous transform function to invoke and await on each element. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask sequence containing a single element with the value that corresponds to the minimum element in the source sequence. - /// or is null. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Invokes and awaits a transform function on each element of a sequence and returns the minimum value. - /// - /// The type of the elements in the source sequence. - /// The type of the objects derived from the elements in the source sequence to determine the minimum of. - /// An async-enumerable sequence to determine the minimum element of. - /// An asynchronous transform function to invoke and await on each element. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask sequence containing a single element with the value that corresponds to the minimum element in the source sequence. - /// or is null. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Sorts the elements of a sequence in ascending order according to a key obtained by invoking a transform function on each element and awaiting the result. - /// - /// The type of the elements of source. - /// The type of the key returned by keySelector. - /// An async-enumerable sequence of values to order. - /// An asynchronous function to extract a key from an element. - /// An ordered async-enumerable sequence whose elements are sorted according to a key. - /// or is null. - public static IOrderedAsyncEnumerable OrderByAwait(this IAsyncEnumerable source, Func> keySelector) => OrderByAwaitCore(source, keySelector); - - /// - /// Sorts the elements of a sequence in ascending order by using a specified comparer. The keys are obtained by invoking the transform function on each element and awaiting the result. - /// - /// The type of the elements of source. - /// The type of the key returned by keySelector. - /// An async-enumerable sequence of values to order. - /// An asynchronous function to extract a key from an element. - /// A comparer to compare keys. - /// An ordered async-enumerable sequence whose elements are sorted according to a key. - /// or is null. - public static IOrderedAsyncEnumerable OrderByAwait(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByAwaitCore(source, keySelector, comparer); - - /// - /// Sorts the elements of a sequence in descending order according to a key obtained by invoking a transform function on each element and awaiting the result. - /// - /// The type of the elements of source. - /// The type of the key returned by keySelector. - /// An async-enumerable sequence of values to order. - /// An asynchronous function to extract a key from an element. - /// An ordered async-enumerable sequence whose elements are sorted in descending order according to a key. - /// or is null. - public static IOrderedAsyncEnumerable OrderByDescendingAwait(this IAsyncEnumerable source, Func> keySelector) => OrderByDescendingAwaitCore(source, keySelector); - - /// - /// Sorts the elements of a sequence in descending order by using a specified comparer. The keys are obtained by invoking the transform function on each element and awaiting the result. - /// - /// The type of the elements of source. - /// The type of the key returned by keySelector. - /// An async-enumerable sequence of values to order. - /// An asynchronous function to extract a key from an element. - /// A comparer to compare keys. - /// An ordered async-enumerable sequence whose elements are sorted in descending order according to a key. - /// or is null. - public static IOrderedAsyncEnumerable OrderByDescendingAwait(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByDescendingAwaitCore(source, keySelector, comparer); - - /// - /// Projects each element of an async-enumerable sequence into a new form by applying an asynchronous selector function to each member of the source sequence and awaiting the result. - /// - /// The type of the elements in the source sequence. - /// The type of the elements in the result sequence, obtained by running the selector function for each element in the source sequence and awaiting the result. - /// A sequence of elements to invoke a transform function on. - /// An asynchronous transform function to apply to each source element. - /// An async-enumerable sequence whose elements are the result of invoking the transform function on each element of the source sequence and awaiting the result. - /// or is null. - public static IAsyncEnumerable SelectAwait(this IAsyncEnumerable source, Func> selector) => SelectAwaitCore(source, selector); - - /// - /// Projects each element of an async-enumerable sequence into a new form by applying an asynchronous selector function that incorporates each element's index to each element of the source sequence and awaiting the result. - /// - /// The type of elements in the source sequence. - /// The type of elements in the result sequence, obtained by running the selector function for each element and its index, and awaiting the result. - /// A sequence of elements to invoke a transform function on. - /// An asynchronous transform function to apply to each source element; the second parameter represents the index of the element. - /// An async-enumerable sequence whose elements are the result of invoking the transform function on each element and its index of the source sequence and awaiting the result. - /// or is null. - public static IAsyncEnumerable SelectAwait(this IAsyncEnumerable source, Func> selector) => SelectAwaitCore(source, selector); - - /// - /// Projects each element of an async-enumerable sequence into an async-enumerable sequence and merges the resulting async-enumerable sequences into one async-enumerable sequence. - /// - /// The type of elements in the source sequence. - /// The type of elements in the projected inner sequences and the merged result sequence. - /// An async-enumerable sequence of elements to project. - /// An asynchronous selector function to apply to each element of the source sequence. - /// An async-enumerable sequence whose elements are the result of invoking the one-to-many transform function on each element of the source sequence and awaiting the result. - /// or is null. - public static IAsyncEnumerable SelectManyAwait(this IAsyncEnumerable source, Func>> selector) => SelectManyAwaitCore(source, selector); - - /// - /// Projects each element of an async-enumerable sequence into an async-enumerable sequence by incorporating the element's index and merges the resulting async-enumerable sequences into an async-enumerable sequence. - /// - /// The type of elements in the source sequence. - /// The type of elements in the projected inner sequences and the merged result sequence. - /// An async-enumerable sequence of elements to project. - /// An asynchronous selector function to apply to each element; the second parameter represents the index of the element. - /// An async-enumerable sequence who's elements are the result of invoking the one-to-many transform function on each element of the source sequence and awaiting the result. - /// or is null. - public static IAsyncEnumerable SelectManyAwait(this IAsyncEnumerable source, Func>> selector) => SelectManyAwaitCore(source, selector); - - /// - /// Projects each element of an async-enumerable sequence to an async-enumerable sequence by awaiting the result of a transform function, invokes the result selector for each of the source elements and each of the corrasponding inner-sequence's elements and awaits the result, and merges the results into one async-enumerable sequence. - /// - /// The type of elements in the source sequence. - /// The type of elements in the projected intermediate sequences. - /// The type of elements in the result sequence. - /// An async-enumerable sequence of elements to project. - /// An asynchronous transform function to apply to each source element. - /// An asynchronous transform function to apply to each element of the intermediate sequence. - /// An async-enumerable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence, awaiting the result, applying to each element of the intermediate sequences along with their corrasponding source element and awaiting the result. - /// , , or is . - public static IAsyncEnumerable SelectManyAwait(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitCore(source, collectionSelector, resultSelector); - - /// - /// Projects each element of an async-enumerable sequence to an async-enumerable sequence by awaiting the result of a transform function that incorporates each element's index, - /// invokes the result selector for the source element and each of the corrasponding inner-sequence's elements and awaits the result, and merges the results into one async-enumerable sequence. - /// - /// The type of elements in the source sequence. - /// The type of elements in the projected intermediate sequences. - /// The type of elements in the result sequence. - /// An async-enumerable sequence of elements to project. - /// An asynchronous transform function to apply to each source element; the second parameter represents the index of the element. - /// An asynchronous transform function to apply to each element of the intermediate sequence. - /// An async-enumerable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence, awaiting the result, applying to each element of the intermediate sequences olong with their corrasponding source element and awaiting the result. - /// , , or is . - public static IAsyncEnumerable SelectManyAwait(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitCore(source, collectionSelector, resultSelector); - - /// - /// Returns the only element of an async-enumerable sequence that satisfies the condition in the asynchronous predicate, and reports an exception if there is not exactly one element in the async-enumerable sequence that matches the predicate. - /// - /// The type of elements in the source sequence. - /// Source async-enumerable sequence. - /// An asynchronous predicate that will be applied to each element of the source sequence. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// ValueTask containing the only element in the async-enumerable sequence that satisfies the condition in the asynchronous predicate. - /// or is null. - /// (Asynchronous) No element satisfies the condition in the predicate. -or- More than one element satisfies the condition in the predicate. -or- The source sequence is empty. - public static ValueTask SingleAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => SingleAwaitAsyncCore(source, predicate, cancellationToken); - - /// - /// Returns the only element of an async-enumerable sequence that satisfies the condition in the asynchronous predicate, or a default value if no such element exists, and reports an exception if there is more than one element in the async-enumerable sequence that matches the predicate. - /// - /// The type of elements in the source sequence. - /// Source async-enumerable sequence. - /// An asynchronous predicate that will be applied to each element of the source sequence. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// ValueTask containing the only element in the async-enumerable sequence that satisfies the condition in the asynchronous predicate, or a default value if no such element exists. - /// or is null. - /// (Asynchronous) More than one element satisfies the condition in the predicate. - public static ValueTask SingleOrDefaultAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => SingleOrDefaultAwaitAsyncCore(source, predicate, cancellationToken); - - /// - /// Bypasses elements in an async-enumerable sequence as long as a condition is true, and then returns the remaining elements. - /// - /// The type of elements in the source sequence. - /// An async-enumerable sequence to return elements from. - /// An asynchronous function to test each element for a condition. - /// An async-enumerable sequence containing the elements in the source sequence starting at the first element that does not pass the test specified by the predicate. - /// or is . - public static IAsyncEnumerable SkipWhileAwait(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitCore(source, predicate); - - /// - /// Bypasses elements in an async-enumerable sequence as long as a condition is true, and then returns the remaining elements. - /// The index of the element is used by the predicate. - /// - /// The type of elements in the source sequence. - /// An async-enumerable sequence to return elements from. - /// An asynchronous function to test each element for a condition; the second parameter of the function represents the index of the element. - /// An async-enumerable sequence containing the elements in the source sequence starting at the first element that does not pass the test specified by the predicate. - /// or is . - public static IAsyncEnumerable SkipWhileAwait(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitCore(source, predicate); - - /// - /// Computes the sum of a sequence of values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result. - /// - /// The type of elements in the source sequence. - /// A sequence of values that are used to calculate a sum. - /// An asynchronous transform function to apply to each element. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask containing the sum of the values in the source sequence. - /// or is . - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Computes the sum of a sequence of values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result. - /// - /// The type of elements in the source sequence. - /// A sequence of values that are used to calculate a sum. - /// An asynchronous transform function to apply to each element. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask containing the sum of the values in the source sequence. - /// or is . - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Computes the sum of a sequence of values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result. - /// - /// The type of elements in the source sequence. - /// A sequence of values that are used to calculate a sum. - /// An asynchronous transform function to apply to each element. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask containing the sum of the values in the source sequence. - /// or is . - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Computes the sum of a sequence of values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result. - /// - /// The type of elements in the source sequence. - /// A sequence of values that are used to calculate a sum. - /// An asynchronous transform function to apply to each element. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask containing the sum of the values in the source sequence. - /// or is . - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Computes the sum of a sequence of values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result. - /// - /// The type of elements in the source sequence. - /// A sequence of values that are used to calculate a sum. - /// An asynchronous transform function to apply to each element. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask containing the sum of the values in the source sequence. - /// or is . - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Computes the sum of a sequence of values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result. - /// - /// The type of elements in the source sequence. - /// A sequence of values that are used to calculate a sum. - /// An asynchronous transform function to apply to each element. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask containing the sum of the values in the source sequence. - /// or is . - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Computes the sum of a sequence of values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result. - /// - /// The type of elements in the source sequence. - /// A sequence of values that are used to calculate a sum. - /// An asynchronous transform function to apply to each element. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask containing the sum of the values in the source sequence. - /// or is . - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Computes the sum of a sequence of values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result. - /// - /// The type of elements in the source sequence. - /// A sequence of values that are used to calculate a sum. - /// An asynchronous transform function to apply to each element. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask containing the sum of the values in the source sequence. - /// or is . - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Computes the sum of a sequence of values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result. - /// - /// The type of elements in the source sequence. - /// A sequence of values that are used to calculate a sum. - /// An asynchronous transform function to apply to each element. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask containing the sum of the values in the source sequence. - /// or is . - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Computes the sum of a sequence of values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result. - /// - /// The type of elements in the source sequence. - /// A sequence of values that are used to calculate a sum. - /// An asynchronous transform function to apply to each element. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask containing the sum of the values in the source sequence. - /// or is . - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); - - /// - /// Returns elements from an async-enumerable sequence as long as a specified condition is true. - /// - /// The type of the elements in the source sequence. - /// A sequence to return elements from. - /// An asynchronous predicate to test each element for a condition. - /// An async-enumerable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes. - /// or is null. - public static IAsyncEnumerable TakeWhileAwait(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitCore(source, predicate); - - /// - /// Returns elements from an async-enumerable sequence as long as a specified condition is true. - /// The element's index is used in the logic of the predicate function. - /// - /// The type of the elements in the source sequence. - /// A sequence to return elements from. - /// An asynchronous function to test each element for a condition; the second parameter of the function represents the index of the source element. - /// An async-enumerable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes. - /// or is null. - public static IAsyncEnumerable TakeWhileAwait(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitCore(source, predicate); - - /// - /// Performs a subsequent ordering of the elements in a sequence in ascending order according to a key obtained by invoking a transform function on each element and awaiting the result. - /// - /// The type of the elements of source. - /// The type of the key returned by keySelector. - /// An ordered async-enumerable sequence that contains elements to sort. - /// An asynchronous function to extract a key from each element. - /// An ordered async-enumerable whose elements are sorted according to a key. - /// or is null. - public static IOrderedAsyncEnumerable ThenByAwait(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByAwaitCore(source, keySelector); - - /// - /// Performs a subsequent ordering of the elements in a sequence in ascending order by using a specified comparer. The keys are obtained by invoking a transform function on each element and awaiting the result. - /// - /// The type of the elements of source. - /// The type of the key returned by keySelector. - /// An ordered async-enumerable sequence that contains elements to sort. - /// An asynchronous function to extract a key from each element. - /// A comparer to compare keys. - /// An ordered async-enumerable whose elements are sorted according to a key. - /// or is null. - public static IOrderedAsyncEnumerable ThenByAwait(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByAwaitCore(source, keySelector, comparer); - - /// - /// Performs a subsequent ordering of the elements in a sequence in descending order, according to a key obtained by invoking a transform function on each element and awaiting the result. - /// - /// The type of the elements of source. - /// The type of the key returned by keySelector. - /// An ordered async-enumerable sequence that contains elements to sort. - /// An asynchronous function to extract a key from each element. - /// An ordered async-enumerable sequence whose elements are sorted in descending order according to a key. - /// or is null. - public static IOrderedAsyncEnumerable ThenByDescendingAwait(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByDescendingAwaitCore(source, keySelector); - - /// - /// Performs a subsequent ordering of the elements in a sequence in descending order by using a specified comparer. The keys are obtained by invoking a transform function on each element and awaiting the result. - /// - /// The type of the elements of source. - /// The type of the key returned by keySelector. - /// An ordered async-enumerable sequence that contains elements to sort. - /// An asynchronous function to extract a key from each element. - /// A comparer to compare keys. - /// An ordered async-enumerable sequence whose elements are sorted in descending order according to a key. - /// or is null. - public static IOrderedAsyncEnumerable ThenByDescendingAwait(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByDescendingAwaitCore(source, keySelector, comparer); - - /// - /// Creates a dictionary from an async-enumerable sequence by invoking a key-selector function on each element and awaiting the result. - /// - /// The type of the elements in the source sequence. - /// The type of the dictionary key computed for each element in the source sequence. - /// An async-enumerable sequence to create a dictionary for. - /// An asynchronous function to extract a key from each element. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask containing a dictionary mapping unique key values onto the corresponding source sequence's element. - /// or is null. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask> ToDictionaryAwaitAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) where TKey : notnull => ToDictionaryAwaitAsyncCore(source, keySelector, cancellationToken); - - /// - /// Creates a dictionary from an async-enumerable sequence by invoking a key-selector function on each element and awaiting the result. - /// - /// The type of the elements in the source sequence. - /// The type of the dictionary key computed for each element in the source sequence. - /// An async-enumerable sequence to create a dictionary for. - /// An asynchronous function to extract a key from each element. - /// An equality comparer to compare keys. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask containing a dictionary mapping unique key values onto the corresponding source sequence's element. - /// or or is null. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask> ToDictionaryAwaitAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) where TKey : notnull => ToDictionaryAwaitAsyncCore(source, keySelector, comparer, cancellationToken); - - /// - /// Creates a dictionary from an async-enumerable sequence using the specified asynchronous key and element selector functions. - /// - /// The type of the elements in the source sequence. - /// The type of the dictionary key computed for each element in the source sequence. - /// The type of the dictionary value computed for each element in the source sequence. - /// An async-enumerable sequence to create a dictionary for. - /// An asynchronous function to extract a key from each element. - /// An asynchronous transform function to produce a result element value from each element. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask containing a dictionary mapping unique key values onto the corresponding source sequence's element. - /// or or is null. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask> ToDictionaryAwaitAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) where TKey : notnull => ToDictionaryAwaitAsyncCore(source, keySelector, elementSelector, cancellationToken); - - /// - /// Creates a dictionary from an async-enumerable sequence using the specified asynchronous key and element selector functions. - /// - /// The type of the elements in the source sequence. - /// The type of the dictionary key computed for each element in the source sequence. - /// The type of the dictionary value computed for each element in the source sequence. - /// An async-enumerable sequence to create a dictionary for. - /// An asynchronous function to extract a key from each element. - /// An asynchronous transform function to produce a result element value from each element. - /// An equality comparer to compare keys. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask containing a dictionary mapping unique key values onto the corresponding source sequence's element. - /// or or or is null. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask> ToDictionaryAwaitAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) where TKey : notnull => ToDictionaryAwaitAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); - - /// - /// Creates a lookup from an async-enumerable sequence by invoking a key-selector function on each element and awaiting the result. - /// - /// The type of the elements in the source sequence. - /// The type of the lookup key computed for each element in the source sequence. - /// An async-enumerable sequence to create a lookup for. - /// An asynchronous function to extract a key from each element. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask containing a lookup mapping unique key values onto the corresponding source sequence's elements. - /// or is null. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask> ToLookupAwaitAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => ToLookupAwaitAsyncCore(source, keySelector, cancellationToken); - - /// - /// Creates a lookup from an async-enumerable sequence by invoking key and element selector functions on each source element and awaiting the results. - /// - /// The type of the elements in the source sequence. - /// The type of the lookup key computed for each element in the source sequence. - /// The type of the lookup value computed for each element in the source sequence. - /// An async-enumerable sequence to create a lookup for. - /// An asynchronous function to extract a key from each element. - /// An asynchronous transform function to produce a result element value from each element. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// An async-enumerable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements. - /// or or is null. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask> ToLookupAwaitAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => ToLookupAwaitAsyncCore(source, keySelector, elementSelector, cancellationToken); - - /// - /// Creates a lookup from an async-enumerable sequence by invoking a key-selector function on each element and awaiting the result. - /// - /// The type of the elements in the source sequence. - /// The type of the lookup key computed for each element in the source sequence. - /// An async-enumerable sequence to create a lookup for. - /// An asynchronous function to extract a key from each element. - /// An equality comparer to compare keys. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask containing a lookup mapping unique key values onto the corresponding source sequence's elements. - /// or or is null. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask> ToLookupAwaitAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) => ToLookupAwaitAsyncCore(source, keySelector, comparer, cancellationToken); - - /// - /// Creates a lookup from an async-enumerable sequence by invoking key and element selector functions on each source element and awaiting the results. - /// - /// The type of the elements in the source sequence. - /// The type of the lookup key computed for each element in the source sequence. - /// The type of the lookup value computed for each element in the source sequence. - /// An async-enumerable sequence to create a lookup for. - /// An asynchronous function to extract a key from each element. - /// An asynchronous transform function to produce a result element value from each source element. - /// An equality comparer to compare keys. - /// The optional cancellation token to be used for cancelling the sequence at any time. - /// A ValueTask containing a lookup mapping unique key values onto the corresponding source sequence's elements. - /// or or or is null. - /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. - public static ValueTask> ToLookupAwaitAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) => ToLookupAwaitAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); - - /// - /// Filters the elements of an async-enumerable sequence based on an asynchronous predicate. - /// - /// The type of the elements in the source sequence. - /// An async-enumerable sequence whose elements to filter. - /// An asynchronous predicate to test each source element for a condition. - /// An async-enumerable sequence that contains elements from the input sequence that satisfy the condition. - /// or is null. - public static IAsyncEnumerable WhereAwait(this IAsyncEnumerable source, Func> predicate) => WhereAwaitCore(source, predicate); - - /// - /// Filters the elements of an async-enumerable sequence based on an asynchronous predicate that incorporates the element's index. - /// - /// The type of the elements in the source sequence. - /// An async-enumerable sequence whose elements to filter. - /// An asynchronous predicate to test each source element for a condition; the second parameter of the function represents the index of the source element. - /// An async-enumerable sequence that contains elements from the input sequence that satisfy the condition. - /// or is null. - public static IAsyncEnumerable WhereAwait(this IAsyncEnumerable source, Func> predicate) => WhereAwaitCore(source, predicate); - - /// - /// Merges two async-enumerable sequences into one async-enumerable sequence by combining their elements in a pairwise fashion. - /// - /// The type of the elements in the first source sequence. - /// The type of the elements in the second source sequence. - /// The type of the elements in the result sequence, returned by the selector function. - /// First async-enumerable source. - /// Second async-enumerable source. - /// An asynchronous function to invoke and await for each consecutive pair of elements from the first and second source. - /// An async-enumerable sequence containing the result of pairwise combining the elements of the first and second source using the specified result selector function. - /// or or is null. - public static IAsyncEnumerable ZipAwait(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) => ZipAwaitCore(first, second, selector); - -#if !NO_DEEP_CANCELLATION - public static ValueTask AggregateAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) => AggregateAwaitWithCancellationAsyncCore(source, accumulator, cancellationToken); - public static ValueTask AggregateAwaitWithCancellationAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) => AggregateAwaitWithCancellationAsyncCore(source, seed, accumulator, cancellationToken); - public static ValueTask AggregateAwaitWithCancellationAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) => AggregateAwaitWithCancellationAsyncCore(source, seed, accumulator, resultSelector, cancellationToken); - public static ValueTask AllAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => AllAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask AnyAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => AnyAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask CountAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => CountAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask FirstAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => FirstAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask FirstOrDefaultAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => FirstOrDefaultAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static Task ForEachAwaitWithCancellationAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitWithCancellationAsyncCore(source, action, cancellationToken); - public static Task ForEachAwaitWithCancellationAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitWithCancellationAsyncCore(source, action, cancellationToken); - public static IAsyncEnumerable> GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector) => GroupByAwaitWithCancellationCore(source, keySelector); - public static IAsyncEnumerable> GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => GroupByAwaitWithCancellationCore(source, keySelector, comparer); - public static IAsyncEnumerable> GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => GroupByAwaitWithCancellationCore(source, keySelector, elementSelector); - public static IAsyncEnumerable GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector) => GroupByAwaitWithCancellationCore(source, keySelector, resultSelector); - public static IAsyncEnumerable GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector) => GroupByAwaitWithCancellationCore(source, keySelector, elementSelector, resultSelector); - public static IAsyncEnumerable> GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => GroupByAwaitWithCancellationCore(source, keySelector, elementSelector, comparer); - public static IAsyncEnumerable GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitWithCancellationCore(source, keySelector, resultSelector, comparer); - public static IAsyncEnumerable GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitWithCancellationCore(source, keySelector, elementSelector, resultSelector, comparer); - public static IAsyncEnumerable GroupJoinAwaitWithCancellation(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector) => GroupJoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector); - public static IAsyncEnumerable GroupJoinAwaitWithCancellation(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => GroupJoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); - public static IAsyncEnumerable JoinAwaitWithCancellation(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => JoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector); - public static IAsyncEnumerable JoinAwaitWithCancellation(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) => JoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); - public static ValueTask LastAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => LastAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask LastOrDefaultAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => LastOrDefaultAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask LongCountAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => LongCountAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static IOrderedAsyncEnumerable OrderByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector) => OrderByAwaitWithCancellationCore(source, keySelector); - public static IOrderedAsyncEnumerable OrderByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByAwaitWithCancellationCore(source, keySelector, comparer); - public static IOrderedAsyncEnumerable OrderByDescendingAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector) => OrderByDescendingAwaitWithCancellationCore(source, keySelector); - public static IOrderedAsyncEnumerable OrderByDescendingAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByDescendingAwaitWithCancellationCore(source, keySelector, comparer); - public static IAsyncEnumerable SelectAwaitWithCancellation(this IAsyncEnumerable source, Func> selector) => SelectAwaitWithCancellationCore(source, selector); - public static IAsyncEnumerable SelectAwaitWithCancellation(this IAsyncEnumerable source, Func> selector) => SelectAwaitWithCancellationCore(source, selector); - public static IAsyncEnumerable SelectManyAwaitWithCancellation(this IAsyncEnumerable source, Func>> selector) => SelectManyAwaitWithCancellationCore(source, selector); - public static IAsyncEnumerable SelectManyAwaitWithCancellation(this IAsyncEnumerable source, Func>> selector) => SelectManyAwaitWithCancellationCore(source, selector); - public static IAsyncEnumerable SelectManyAwaitWithCancellation(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitWithCancellationCore(source, collectionSelector, resultSelector); - public static IAsyncEnumerable SelectManyAwaitWithCancellation(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitWithCancellationCore(source, collectionSelector, resultSelector); - public static ValueTask SingleAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => SingleAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask SingleOrDefaultAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => SingleOrDefaultAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static IAsyncEnumerable SkipWhileAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitWithCancellationCore(source, predicate); - public static IAsyncEnumerable SkipWhileAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitWithCancellationCore(source, predicate); - public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static IAsyncEnumerable TakeWhileAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitWithCancellationCore(source, predicate); - public static IAsyncEnumerable TakeWhileAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitWithCancellationCore(source, predicate); - public static IOrderedAsyncEnumerable ThenByAwaitWithCancellation(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByAwaitWithCancellationCore(source, keySelector); - public static IOrderedAsyncEnumerable ThenByAwaitWithCancellation(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByAwaitWithCancellationCore(source, keySelector, comparer); - public static IOrderedAsyncEnumerable ThenByDescendingAwaitWithCancellation(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByDescendingAwaitWithCancellationCore(source, keySelector); - public static IOrderedAsyncEnumerable ThenByDescendingAwaitWithCancellation(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByDescendingAwaitWithCancellationCore(source, keySelector, comparer); - public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) where TKey : notnull => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, cancellationToken); - public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) where TKey : notnull => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, comparer, cancellationToken); - public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) where TKey : notnull => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, cancellationToken); - public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) where TKey : notnull => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); - public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, cancellationToken); - public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, cancellationToken); - public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, comparer, cancellationToken); - public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); - public static IAsyncEnumerable WhereAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) => WhereAwaitWithCancellationCore(source, predicate); - public static IAsyncEnumerable WhereAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) => WhereAwaitWithCancellationCore(source, predicate); - public static IAsyncEnumerable ZipAwaitWithCancellation(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) => ZipAwaitWithCancellationCore(first, second, selector); -#endif -#endif - } -} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.tt deleted file mode 100644 index 1bf1f2bba1..0000000000 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.tt +++ /dev/null @@ -1,163 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT License. -// See the LICENSE file in the project root for more information. - -<#@ template debug="false" hostspecific="false" language="C#" #> -<#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net46\System.Threading.Tasks.Extensions.dll" #> -<#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net46\System.Linq.Async.dll" #> -<#@ assembly name="System.Core" #> -<#@ assembly name="System.Runtime" #> -<#@ import namespace="System.Collections.Generic" #> -<#@ import namespace="System.Linq" #> -<#@ import namespace="System.Reflection" #> -<#@ output extension=".cs" #> -<# -Func toCSharp = null; -toCSharp = t => -{ - if (t.IsGenericType) - { - var def = t.GetGenericTypeDefinition(); - if (def == typeof(Nullable<>)) - { - return toCSharp(t.GetGenericArguments()[0]) + "?"; - } - else - { - return def.Name.Substring(0, def.Name.IndexOf('`')) + "<" + string.Join(", ", t.GetGenericArguments().Select(toCSharp)) + ">"; - } - } - else if (t.IsArray) - { - return toCSharp(t.GetElementType()) + "[]"; - } - else - { - if (t == typeof(int)) - { - return "int"; - } - else if (t == typeof(long)) - { - return "long"; - } - else if (t == typeof(float)) - { - return "float"; - } - else if (t == typeof(double)) - { - return "double"; - } - else if (t == typeof(decimal)) - { - return "decimal"; - } - else if (t == typeof(bool)) - { - return "bool"; - } - else if (t == typeof(object)) - { - return "object"; - } - - return t.Name; - } -}; - -Func getOptionalSuffix = p => -{ - if (p.IsOptional) - { - return " = default"; - } - - return ""; -}; -#> -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace System.Linq -{ - partial class AsyncEnumerable - { -<# -var methods = typeof(AsyncEnumerable).GetMethods(BindingFlags.NonPublic | BindingFlags.Static); -var asyncMethods = methods.Where(m => m.Name.Contains("Await") && m.Name.EndsWith("Core")).OrderBy(m => m.Name).ThenBy(m => m.GetParameters().Length); -#> -#if SUPPORT_FLAT_ASYNC_API -<# -foreach (var g in asyncMethods.GroupBy(m => m.Name.Contains("WithCancellation"))) -{ - if (g.Key) - { -#> - -#if !NO_DEEP_CANCELLATION -<# - } - - foreach (var m in g) - { - var longName = m.Name; - var shortName = m.Name.Replace("WithCancellation", "").Replace("Await", "").Replace("Core", ""); - var genArgs = m.IsGenericMethod ? "<" + string.Join(", ", m.GetGenericArguments().Select(t => t.Name)) + ">" : ""; - var returnType = toCSharp(m.ReturnType); - var isExtension = m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true); - var pars = (isExtension ? "this " : "") + string.Join(", ", m.GetParameters().Select(p => toCSharp(p.ParameterType) + " " + p.Name + getOptionalSuffix(p))); - var args = string.Join(", ", m.GetParameters().Select(p => p.Name)); - var cons = m.Name.StartsWith("ToDictionary") ? " where TKey : notnull" : ""; -#> - public static <#=returnType#> <#=shortName#><#=genArgs#>(<#=pars#>)<#=cons#> => <#=longName#><#=genArgs#>(<#=args#>); -<# - } - - if (g.Key) - { -#> -#endif -<# - } -} -#> -#else -<# -foreach (var g in asyncMethods.GroupBy(m => m.Name.Contains("WithCancellation"))) -{ - if (g.Key) - { -#> - -#if !NO_DEEP_CANCELLATION -<# - } - - foreach (var m in g) - { - var longName = m.Name; - var shortName = m.Name.Replace("Core", ""); - var genArgs = m.IsGenericMethod ? "<" + string.Join(", ", m.GetGenericArguments().Select(t => t.Name)) + ">" : ""; - var returnType = toCSharp(m.ReturnType); - var isExtension = m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true); - var pars = (isExtension ? "this " : "") + string.Join(", ", m.GetParameters().Select(p => toCSharp(p.ParameterType) + " " + p.Name + getOptionalSuffix(p))); - var args = string.Join(", ", m.GetParameters().Select(p => p.Name)); - var cons = m.Name.StartsWith("ToDictionary") ? " where TKey : notnull" : ""; -#> - public static <#=returnType#> <#=shortName#><#=genArgs#>(<#=pars#>)<#=cons#> => <#=longName#><#=genArgs#>(<#=args#>); -<# - } - - if (g.Key) - { -#> -#endif -<# - } -} -#> -#endif - } -} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index b5580dbbb4..2559212255 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -51,7 +51,19 @@ static async ValueTask Core(IAsyncEnumerable source, Func AggregateAwaitAsyncCore(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) + /// + /// Applies an accumulator function over an async-enumerable sequence, returning the result of the aggregation as a single element in the result sequence. + /// + /// The type of elements in the source sequence. + /// An async-enumerable sequence to aggregate over. + /// An asynchronous accumulator function to be invoked and awaited on each element. + /// An optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask containing the final accumulator value. + /// or is . + /// The source sequence is empty. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask AggregateAwaitAsyncCore(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -81,7 +93,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func AggregateAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask AggregateAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -146,7 +159,20 @@ static async ValueTask Core(IAsyncEnumerable source, TAccu } } - internal static ValueTask AggregateAwaitAsyncCore(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) + /// + /// Applies an accumulator function over an async-enumerable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value. + /// + /// The type of elements in the source sequence. + /// The type of the result of aggregation. + /// An async-enumerable sequence to aggregate over. + /// The initial accumulator value. + /// An asynchronous accumulator function to be invoked and awaited on each element. + /// An optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask containing the final accumulator value. + /// or is . + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask AggregateAwaitAsyncCore(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -169,7 +195,8 @@ static async ValueTask Core(IAsyncEnumerable source, TAccu } #if !NO_DEEP_CANCELLATION - internal static ValueTask AggregateAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask AggregateAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -231,7 +258,22 @@ static async ValueTask Core(IAsyncEnumerable source, TAccumula } } - internal static ValueTask AggregateAwaitAsyncCore(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) + /// + /// Applies an accumulator function over an async-enumerable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value, + /// and the specified result selector is used to select the result value. + /// + /// The type of elements in the source sequence. + /// The type of the accumulator value. + /// The type of the resulting value. + /// An async-enumerable sequence to aggregate over. + /// The initial accumulator value. + /// An asynchronous accumulator function to be invoked and awaited on each element. + /// An asynchronous transform function to transform the final accumulator value into the result value. + /// An optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask containing the value obtained by applying the result selector to the final accumulator value. + /// or or is . + [GenerateAsyncOverload] + private static ValueTask AggregateAwaitAsyncCore(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -256,7 +298,8 @@ static async ValueTask Core(IAsyncEnumerable source, TAccumula } #if !NO_DEEP_CANCELLATION - internal static ValueTask AggregateAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask AggregateAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs index b3c8360cc6..f1b40e7b75 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs @@ -43,7 +43,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func AllAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + /// + /// Determines whether all elements in an async-enumerable sequence satisfy a condition. + /// + /// The type of element in the sequence. + /// An async-enumerable sequence whose elements to apply the predicate to. + /// An asynchronous predicate to apply to each element of the source sequence. + /// An optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask containing a value indicating whether all elements in the sequence pass the test in the specified predicate. + /// or is . + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask AllAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -67,6 +78,7 @@ static async ValueTask Core(IAsyncEnumerable source, Func AllAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs index 33bd5947f4..68138f4ca3 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs @@ -67,7 +67,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func AnyAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + /// + /// Determines whether any element in an async-enumerable sequence satisfies a condition. + /// + /// The type of element in the sequence. + /// An async-enumerable sequence whose elements to apply the predicate to. + /// An asynchronous predicate to apply to each element of the source sequence. + /// An optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask containing a value indicating whether any elements in the source sequence pass the test in the specified predicate. + /// or is . + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask AnyAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -91,6 +102,7 @@ static async ValueTask Core(IAsyncEnumerable source, Func AnyAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs index 7aff63e03d..abc41a5428 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs @@ -95,7 +95,19 @@ static async ValueTask Core(IAsyncEnumerable source, Func AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Computes the average of an async-enumerable sequence of values that are obtained by invoking an asynchronous transform function on each element of the source sequence and awaiting the result. + /// + /// The type of elements in the source sequence. + /// An async-enumerable sequence of values to compute the average of. + /// A transform function to invoke and await on each element of the source sequence. + /// An optional cancellation token for cancelling the sequence at any time. + /// A ValueTask containing the average of the sequence of values. + /// or is . + /// The source sequence is empty. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -130,7 +142,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -250,7 +263,19 @@ static async ValueTask Core(IAsyncEnumerable source, Func AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Computes the average of an async-enumerable sequence of values that are obtained by invoking an asynchronous transform function on each element of the source sequence and awaiting the result. + /// + /// The type of elements in the source sequence. + /// An async-enumerable sequence of values to compute the average of. + /// A transform function to invoke and await on each element of the source sequence. + /// An optional cancellation token for cancelling the sequence at any time. + /// A ValueTask containing the average of the sequence of values. + /// or is . + /// The source sequence is empty. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -285,7 +310,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -405,7 +431,19 @@ static async ValueTask Core(IAsyncEnumerable source, Func AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Computes the average of an async-enumerable sequence of values that are obtained by invoking an asynchronous transform function on each element of the source sequence and awaiting the result. + /// + /// The type of elements in the source sequence. + /// An async-enumerable sequence of values to compute the average of. + /// A transform function to invoke and await on each element of the source sequence. + /// An optional cancellation token for cancelling the sequence at any time. + /// A ValueTask containing the average of the sequence of values. + /// or is . + /// The source sequence is empty. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -440,7 +478,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -560,7 +599,19 @@ static async ValueTask Core(IAsyncEnumerable source, Func AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Computes the average of an async-enumerable sequence of values that are obtained by invoking an asynchronous transform function on each element of the source sequence and awaiting the result. + /// + /// The type of elements in the source sequence. + /// An async-enumerable sequence of values to compute the average of. + /// A transform function to invoke and await on each element of the source sequence. + /// An optional cancellation token for cancelling the sequence at any time. + /// A ValueTask containing the average of the sequence of values. + /// or is . + /// The source sequence is empty. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -595,7 +646,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -715,7 +767,19 @@ static async ValueTask Core(IAsyncEnumerable source, Func AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Computes the average of an async-enumerable sequence of values that are obtained by invoking an asynchronous transform function on each element of the source sequence and awaiting the result. + /// + /// The type of elements in the source sequence. + /// An async-enumerable sequence of values to compute the average of. + /// A transform function to invoke and await on each element of the source sequence. + /// An optional cancellation token for cancelling the sequence at any time. + /// A ValueTask containing the average of the sequence of values. + /// or is . + /// The source sequence is empty. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -750,7 +814,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -886,7 +951,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Computes the average of an async-enumerable sequence of values that are obtained by invoking an asynchronous transform function on each element of the source sequence and awaiting the result. + /// + /// The type of elements in the source sequence. + /// An async-enumerable sequence of values to compute the average of. + /// A transform function to invoke and await on each element of the source sequence. + /// An optional cancellation token for cancelling the sequence at any time. + /// A ValueTask containing the average of the sequence of values, or if the source sequence is empty. + /// or is . + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -929,7 +1005,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1073,7 +1150,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Computes the average of an async-enumerable sequence of values that are obtained by invoking an asynchronous transform function on each element of the source sequence and awaiting the result. + /// + /// The type of elements in the source sequence. + /// An async-enumerable sequence of values to compute the average of. + /// A transform function to invoke and await on each element of the source sequence. + /// An optional cancellation token for cancelling the sequence at any time. + /// A ValueTask containing the average of the sequence of values, or if the source sequence is empty. + /// or is . + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1116,7 +1204,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1260,7 +1349,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Computes the average of an async-enumerable sequence of values that are obtained by invoking an asynchronous transform function on each element of the source sequence and awaiting the result. + /// + /// The type of elements in the source sequence. + /// An async-enumerable sequence of values to compute the average of. + /// A transform function to invoke and await on each element of the source sequence. + /// An optional cancellation token for cancelling the sequence at any time. + /// A ValueTask containing the average of the sequence of values, or if the source sequence is empty. + /// or is . + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1303,7 +1403,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1447,7 +1548,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Computes the average of an async-enumerable sequence of values that are obtained by invoking an asynchronous transform function on each element of the source sequence and awaiting the result. + /// + /// The type of elements in the source sequence. + /// An async-enumerable sequence of values to compute the average of. + /// A transform function to invoke and await on each element of the source sequence. + /// An optional cancellation token for cancelling the sequence at any time. + /// A ValueTask containing the average of the sequence of values, or if the source sequence is empty. + /// or is . + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1490,7 +1602,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1634,7 +1747,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Computes the average of an async-enumerable sequence of values that are obtained by invoking an asynchronous transform function on each element of the source sequence and awaiting the result. + /// + /// The type of elements in the source sequence. + /// An async-enumerable sequence of values to compute the average of. + /// A transform function to invoke and await on each element of the source sequence. + /// An optional cancellation token for cancelling the sequence at any time. + /// A ValueTask containing the average of the sequence of values, or if the source sequence is empty. + /// or is . + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1677,7 +1801,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs index 668b35c056..ba839a4a40 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs @@ -88,7 +88,17 @@ static async ValueTask Core(IAsyncEnumerable source, Func CountAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + /// + /// Counts the elements in an async-enumerable sequence that satisfy a condition. + /// + /// Type of elements in the source sequence. + /// A sequence of elements to count. + /// An asynchronous predicate to apply to each element in the source sequence. + /// An optional cancellation token for cancelling the sequence at any time. + /// A ValueTask containing the number of elements in the sequence that satisfy the predicate. + /// or is . + [GenerateAsyncOverload] + private static ValueTask CountAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -117,7 +127,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func CountAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask CountAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs index 35739c7e27..2bcfbb862c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs @@ -61,7 +61,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func FirstAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + /// + /// Returns the first element of an async-enumerable sequence that satisfies the condition in the predicate. + /// + /// The type of elements in the sequence. + /// Source async-enumerable sequence. + /// An asynchronous predicate that will be invoked and awaited for each element in the sequence. + /// An optional cancellation token for cancelling the sequence at any time. + /// A ValueTask containing the first element in the sequence that satisfies the predicate. + /// or is . + /// No element satisfies the condition in the predicate. -or- The source sequence is empty. + [GenerateAsyncOverload] + private static ValueTask FirstAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -79,6 +90,7 @@ static async ValueTask Core(IAsyncEnumerable source, Func FirstAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index 11b7d720c2..d67b50ada8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -59,7 +59,17 @@ public static partial class AsyncEnumerable } } - internal static ValueTask FirstOrDefaultAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + /// + /// Returns the first element of an async-enumerable sequence that satisfies the condition in the predicate, or a default value if no element satisfies the condition in the predicate. + /// + /// The type of element in the sequence. + /// Source async-enumerable sequence. + /// An asynchronous predicate to invoke and await on each element of the sequence. + /// An optional cancellation token for cancelling the sequence at any time. + /// A ValueTask containing the first element in the sequence that satisfies the predicate, or a default value if no element satisfies the predicate. + /// or is . + [GenerateAsyncOverload] + private static ValueTask FirstOrDefaultAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -77,7 +87,8 @@ public static partial class AsyncEnumerable } #if !NO_DEEP_CANCELLATION - internal static ValueTask FirstOrDefaultAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask FirstOrDefaultAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs index f46f07e3aa..6e0302febf 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs @@ -75,7 +75,17 @@ static async Task Core(IAsyncEnumerable source, Action ac } } - internal static Task ForEachAwaitAsyncCore(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken = default) + /// + /// Invokes and awaits an asynchronous action on each element in the source sequence, and returns a task that is signaled when the sequence terminates. + /// + /// Type of elements in the sequence. + /// Source sequence. + /// Asynchronous action to invoke and await for each element in the source sequence. + /// Optional cancellation token for cancelling the sequence at any time. + /// Task that signals the termination of the sequence. + /// or is . + [GenerateAsyncOverload] + private static Task ForEachAwaitAsyncCore(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -93,6 +103,8 @@ static async Task Core(IAsyncEnumerable source, Func act } } + #if !NO_DEEP_CANCELLATION + [GenerateAsyncOverload] internal static Task ForEachAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) { if (source == null) @@ -110,8 +122,19 @@ static async Task Core(IAsyncEnumerable source, Func(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken = default) + /// + /// Invokes and awaits an asynchronous action on each element in the source sequence, incorporating the element's index, and returns a task that is signaled when the sequence terminates. + /// + /// Type of elements in the sequence. + /// Source sequence. + /// Asynchronous action to invoke and await for each element in the source sequence; the second parameter represents the index of the element. + /// Optional cancellation token for cancelling the sequence at any time. + /// Task that signals the termination of the sequence. + /// or is . + [GenerateAsyncOverload] + private static Task ForEachAwaitAsyncCore(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -131,6 +154,8 @@ static async Task Core(IAsyncEnumerable source, Func(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) { if (source == null) @@ -150,6 +175,7 @@ static async Task Core(IAsyncEnumerable source, Func> GroupBy> GroupBy(this IAsyncEnumerable source, Func keySelector, IEqualityComparer? comparer) => new GroupedAsyncEnumerable(source, keySelector, comparer); - internal static IAsyncEnumerable> GroupByAwaitCore(this IAsyncEnumerable source, Func> keySelector) => + /// + /// Groups the elements of an async-enumerable sequence according to a specified key selector function. + /// + /// The type of the elements in the source sequence. + /// The type of the grouping key computed for each element in the source sequence. + /// An async-enumerable sequence whose elements to group. + /// An asynchronous function to extract the key for each element. + /// A sequence of async-enumerable groups, each of which corresponds to a unique key value, containing all elements that share that same key value. + /// or is . + [GenerateAsyncOverload] + private static IAsyncEnumerable> GroupByAwaitCore(this IAsyncEnumerable source, Func> keySelector) => new GroupedAsyncEnumerableWithTask(source, keySelector, comparer: null); - internal static IAsyncEnumerable> GroupByAwaitCore(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer? comparer) => + /// + /// Groups the elements of an async-enumerable sequence according to a specified key selector function and comparer. + /// + /// The type of the elements in the source sequence. + /// The type of the grouping key computed for each element in the source sequence. + /// An async-enumerable sequence whose elements to group. + /// An asynchronous function to extract the key for each element. + /// An equality comparer to compare keys with. + /// A sequence of async-enumerable groups, each of which corresponds to a unique key value, containing all elements that share that same key value. + /// or or is . + [GenerateAsyncOverload] + private static IAsyncEnumerable> GroupByAwaitCore(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer? comparer) => new GroupedAsyncEnumerableWithTask(source, keySelector, comparer); #if !NO_DEEP_CANCELLATION - internal static IAsyncEnumerable> GroupByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector) => + [GenerateAsyncOverload] + private static IAsyncEnumerable> GroupByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector) => new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer: null); - internal static IAsyncEnumerable> GroupByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer? comparer) => + [GenerateAsyncOverload] + private static IAsyncEnumerable> GroupByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer? comparer) => new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer); #endif @@ -78,17 +101,44 @@ public static IAsyncEnumerable> GroupBy> GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer? comparer) => new GroupedAsyncEnumerable(source, keySelector, elementSelector, comparer); - internal static IAsyncEnumerable> GroupByAwaitCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => + /// + /// Groups the elements of an async-enumerable sequence and selects the resulting elements by using a specified function. + /// + /// The type of the elements in the source sequence. + /// The type of the grouping key computed for each element in the source sequence. + /// The type of the elements within the groups computed for each element in the source sequence. + /// An async-enumerable sequence whose elements to group. + /// An asynchronous function to extract the key for each element. + /// An asynchronous function to map each source element to an element in an async-enumerable group. + /// A sequence of async-enumerable groups, each of which corresponds to a unique key value, containing all elements that share that same key value. + /// or or is . + [GenerateAsyncOverload] + private static IAsyncEnumerable> GroupByAwaitCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => new GroupedAsyncEnumerableWithTask(source, keySelector, elementSelector, comparer: null); - internal static IAsyncEnumerable> GroupByAwaitCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer? comparer) => + /// + /// Groups the elements of an async-enumerable sequence and selects the resulting elements by using a specified function. + /// + /// The type of the elements in the source sequence. + /// The type of the grouping key computed for each element in the source sequence. + /// The type of the elements within the groups computed for each element in the source sequence. + /// An async-enumerable sequence whose elements to group. + /// An asynchronous function to extract the key for each element. + /// An asynchronous function to map each source element to an element in an async-enumerable group. + /// An equality comparer to use to compare keys. + /// A sequence of async-enumerable groups, each of which corresponds to a unique key value, containing all elements that share that same key value. + /// or or or is . + [GenerateAsyncOverload] + private static IAsyncEnumerable> GroupByAwaitCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer? comparer) => new GroupedAsyncEnumerableWithTask(source, keySelector, elementSelector, comparer); #if !NO_DEEP_CANCELLATION - internal static IAsyncEnumerable> GroupByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => + [GenerateAsyncOverload] + private static IAsyncEnumerable> GroupByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, elementSelector, comparer: null); - internal static IAsyncEnumerable> GroupByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer? comparer) => + [GenerateAsyncOverload] + private static IAsyncEnumerable> GroupByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer? comparer) => new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, elementSelector, comparer); #endif @@ -98,17 +148,44 @@ public static IAsyncEnumerable GroupBy(this IAs public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func, TResult> resultSelector, IEqualityComparer? comparer) => new GroupedResultAsyncEnumerable(source, keySelector, resultSelector, comparer); - internal static IAsyncEnumerable GroupByAwaitCore(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector) => + /// + /// Groups the elements of an async-enumerable sequence according to a specified key selector function, and then applies a result selector function to each group. + /// + /// Type of element in the source sequence. + /// Type of the grouping key computed for each element in the source sequence. + /// The result type returned by the result selector function. + /// An async-enumerable sequence whose elements to group. + /// An asynchronous function to extract the key for each element. + /// An asynchronous function to transform each group into the result type. + /// An async-enumerable sequence of results obtained by invoking and awaiting the result-selector function on each group. + /// or or is . + [GenerateAsyncOverload] + private static IAsyncEnumerable GroupByAwaitCore(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector) => new GroupedResultAsyncEnumerableWithTask(source, keySelector, resultSelector, comparer: null); - internal static IAsyncEnumerable GroupByAwaitCore(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector, IEqualityComparer? comparer) => + /// + /// Groups the elements of an async-enumerable sequence according to a specified key selector function, and then applies a result selector function to each group. + /// + /// Type of element in the source sequence. + /// Type of the grouping key computed for each element in the source sequence. + /// The result type returned by the result selector function. + /// An async-enumerable sequence whose elements to group. + /// An asynchronous function to extract the key for each element. + /// An asynchronous function to transform each group into the result type. + /// An equality comparer to use to compare keys. + /// An async-enumerable sequence of results obtained by invoking and awaiting the result-selector function on each group. + /// or or or is . + [GenerateAsyncOverload] + private static IAsyncEnumerable GroupByAwaitCore(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector, IEqualityComparer? comparer) => new GroupedResultAsyncEnumerableWithTask(source, keySelector, resultSelector, comparer); #if !NO_DEEP_CANCELLATION - internal static IAsyncEnumerable GroupByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector) => + [GenerateAsyncOverload] + private static IAsyncEnumerable GroupByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector) => new GroupedResultAsyncEnumerableWithTaskAndCancellation(source, keySelector, resultSelector, comparer: null); - internal static IAsyncEnumerable GroupByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer? comparer) => + [GenerateAsyncOverload] + private static IAsyncEnumerable GroupByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer? comparer) => new GroupedResultAsyncEnumerableWithTaskAndCancellation(source, keySelector, resultSelector, comparer); #endif @@ -118,17 +195,48 @@ public static IAsyncEnumerable GroupBy GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, Func, TResult> resultSelector, IEqualityComparer? comparer) => new GroupedResultAsyncEnumerable(source, keySelector, elementSelector, resultSelector, comparer); - internal static IAsyncEnumerable GroupByAwaitCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector) => + /// + /// Groups the elements of an async-enumerable sequence according to a specified key-selector function, applies an element selector to each element of each group, then applies a result selector to each transformed group. + /// + /// The type of element in the source sequence. + /// The type of the grouping key computed for each element in the source sequence. + /// The type of element computed by the element selector. + /// The type of the final result, computed by applying the result selector to each transformed group of elements. + /// An async-enumerable sequence whose elements to group. + /// An asynchronous function to extract the key for each element. + /// An asynchronous function to apply to each element of each group. + /// An asynchronous function to transform each group into the result type. + /// An async-enumerable sequence of results obtained by invoking the result selector function on each group and awaiting the result. + /// or or or is . + [GenerateAsyncOverload] + private static IAsyncEnumerable GroupByAwaitCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector) => new GroupedResultAsyncEnumerableWithTask(source, keySelector, elementSelector, resultSelector, comparer: null); - internal static IAsyncEnumerable GroupByAwaitCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector, IEqualityComparer? comparer) => + /// + /// Groups the elements of an async-enumerable sequence according to a specified key-selector function, applies an element selector to each element of each group, then applies a result selector to each transformed group. + /// + /// The type of element in the source sequence. + /// The type of the grouping key computed for each element in the source sequence. + /// The type of element computed by the element selector. + /// The type of the final result, computed by applying the result selector to each transformed group of elements. + /// An async-enumerable sequence whose elements to group. + /// An asynchronous function to extract the key for each element. + /// An asynchronous function to apply to each element of each group. + /// An asynchronous function to transform each group into the result type. + /// An equality comparer to use to compare keys. + /// An async-enumerable sequence of results obtained by invoking the result selector function on each group and awaiting the result. + /// or or or or is . + [GenerateAsyncOverload] + private static IAsyncEnumerable GroupByAwaitCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector, IEqualityComparer? comparer) => new GroupedResultAsyncEnumerableWithTask(source, keySelector, elementSelector, resultSelector, comparer); #if !NO_DEEP_CANCELLATION - internal static IAsyncEnumerable GroupByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector) => + [GenerateAsyncOverload] + private static IAsyncEnumerable GroupByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector) => new GroupedResultAsyncEnumerableWithTaskAndCancellation(source, keySelector, elementSelector, resultSelector, comparer: null); - internal static IAsyncEnumerable GroupByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer? comparer) => + [GenerateAsyncOverload] + private static IAsyncEnumerable GroupByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer? comparer) => new GroupedResultAsyncEnumerableWithTaskAndCancellation(source, keySelector, elementSelector, resultSelector, comparer); #endif diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs index 322ab7a040..e1182bc950 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs @@ -76,10 +76,12 @@ static async IAsyncEnumerable Core(IAsyncEnumerable outer, IAsy } } - internal static IAsyncEnumerable GroupJoinAwaitCore(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector) => + [GenerateAsyncOverload] + private static IAsyncEnumerable GroupJoinAwaitCore(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector) => GroupJoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); - internal static IAsyncEnumerable GroupJoinAwaitCore(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector, IEqualityComparer? comparer) + [GenerateAsyncOverload] + private static IAsyncEnumerable GroupJoinAwaitCore(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector, IEqualityComparer? comparer) { if (outer == null) throw Error.ArgumentNull(nameof(outer)); @@ -114,10 +116,12 @@ static async IAsyncEnumerable Core(IAsyncEnumerable outer, IAsy } #if !NO_DEEP_CANCELLATION - internal static IAsyncEnumerable GroupJoinAwaitWithCancellationCore(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector) => + [GenerateAsyncOverload] + private static IAsyncEnumerable GroupJoinAwaitWithCancellationCore(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector) => GroupJoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); - internal static IAsyncEnumerable GroupJoinAwaitWithCancellationCore(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer? comparer) + [GenerateAsyncOverload] + private static IAsyncEnumerable GroupJoinAwaitWithCancellationCore(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer? comparer) { if (outer == null) throw Error.ArgumentNull(nameof(outer)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs index eebaf2fed3..e27723c9f5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs @@ -92,10 +92,12 @@ static async IAsyncEnumerable Core(IAsyncEnumerable outer, IAsy } } - internal static IAsyncEnumerable JoinAwaitCore(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => + [GenerateAsyncOverload] + private static IAsyncEnumerable JoinAwaitCore(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => JoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); - internal static IAsyncEnumerable JoinAwaitCore(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer? comparer) + [GenerateAsyncOverload] + private static IAsyncEnumerable JoinAwaitCore(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer? comparer) { if (outer == null) throw Error.ArgumentNull(nameof(outer)); @@ -146,10 +148,12 @@ static async IAsyncEnumerable Core(IAsyncEnumerable outer, IAsy } #if !NO_DEEP_CANCELLATION - internal static IAsyncEnumerable JoinAwaitWithCancellationCore(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => + [GenerateAsyncOverload] + private static IAsyncEnumerable JoinAwaitWithCancellationCore(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => JoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); - internal static IAsyncEnumerable JoinAwaitWithCancellationCore(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer? comparer) + [GenerateAsyncOverload] + private static IAsyncEnumerable JoinAwaitWithCancellationCore(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer? comparer) { if (outer == null) throw Error.ArgumentNull(nameof(outer)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs index 66c3d8250b..0e77b193cb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs @@ -61,7 +61,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func LastAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + /// + /// Returns the last element of an async-enumerable sequence that satisfies the condition in the predicate. + /// + /// The type of the elements in the source sequence. + /// Source async-enumerable sequence. + /// An asynchronous predicate function to evaluate for elements in the source sequence. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// ValueTask containing the last element in the async-enumerable sequence that satisfies the condition in the predicate. + /// or is null. + /// (Asynchronous) No element satisfies the condition in the predicate. -or- The source sequence is empty. + [GenerateAsyncOverload] + private static ValueTask LastAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -79,7 +90,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func LastAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask LastAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs index c5335ecd2a..9dae828c10 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -59,7 +59,17 @@ public static partial class AsyncEnumerable } } - internal static ValueTask LastOrDefaultAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + /// + /// Returns the last element of an async-enumerable sequence that satisfies the condition in the predicate, or a default value if no such element exists. + /// + /// The type of the elements in the source sequence. + /// Source async-enumerable sequence. + /// An asynchronous predicate function to evaluate for elements in the source sequence. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// ValueTask containing the last element in the async-enumerable sequence that satisfies the condition in the predicate, or a default value if no such element exists. + /// or is null. + [GenerateAsyncOverload] + private static ValueTask LastOrDefaultAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -77,7 +87,8 @@ public static partial class AsyncEnumerable } #if !NO_DEEP_CANCELLATION - internal static ValueTask LastOrDefaultAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask LastOrDefaultAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs index 764c0dad59..463ce0ec03 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs @@ -81,7 +81,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func LongCountAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + /// + /// Returns an async-enumerable sequence containing a that represents the number of elements in the specified async-enumerable sequence that satisfy a condition. + /// + /// The type of the elements in the source sequence. + /// An async-enumerable sequence that contains elements to be counted. + /// An asynchronous predicate to test each element for a condition. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// An async-enumerable sequence containing a single element with a number that represents how many elements in the input sequence satisfy the condition in the predicate function. + /// or is null. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask LongCountAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -110,7 +121,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func LongCountAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask LongCountAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs index d3317fe113..6190d70437 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs @@ -184,7 +184,19 @@ static async ValueTask Core(IAsyncEnumerable source, Func MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Invokes and awaits a transform function on each element of a sequence and returns the maximum value. + /// + /// The type of the elements in the source sequence. + /// The type of the objects derived from the elements in the source sequence to determine the maximum of. + /// An async-enumerable sequence to determine the minimum element of. + /// An asynchronous transform function to invoke and await on each element. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask containing a single element with the value that corresponds to the maximum element in the source sequence. + /// or is null. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -264,7 +276,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs index 4ec44e260d..5075c5e48a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs @@ -186,7 +186,19 @@ static async ValueTask Core(IAsyncEnumerable source, Func MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Invokes and awaits a transform function on each element of a sequence and returns the minimum value. + /// + /// The type of the elements in the source sequence. + /// The type of the objects derived from the elements in the source sequence to determine the minimum of. + /// An async-enumerable sequence to determine the minimum element of. + /// An asynchronous transform function to invoke and await on each element. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask sequence containing a single element with the value that corresponds to the minimum element in the source sequence. + /// or is null. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -266,7 +278,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs index c0e8b53147..47d0052d75 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs @@ -87,7 +87,17 @@ static async ValueTask Core(IAsyncEnumerable source, Func MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Returns the maximum value in an async-enumerable sequence. + /// + /// Type of elements in the source sequence. + /// The source sequence. + /// An asynchronous transform function to invoke and await on each element of the source. + /// The optional cancellation token to be usef for cancelling the sequence at any time. + /// A ValueTask containing the maximum value in the sequence. + /// or is . + [GenerateAsyncOverload] + private static ValueTask MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -124,7 +134,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -316,7 +327,17 @@ static async ValueTask Core(IAsyncEnumerable source, Func MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Returns the maximum value in an async-enumerable sequence. + /// + /// Type of elements in the source sequence. + /// The source sequence. + /// An asynchronous transform function to invoke and await on each element of the source. + /// The optional cancellation token to be usef for cancelling the sequence at any time. + /// A ValueTask containing the maximum value in the sequence. + /// or is . + [GenerateAsyncOverload] + private static ValueTask MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -392,7 +413,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -545,7 +567,17 @@ static async ValueTask Core(IAsyncEnumerable source, Func MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Invokes and awaits a transform function on each element of a sequence and returns the maximum value. + /// + /// Type of elements in the source sequence. + /// The source sequence. + /// An asynchronous transform function to invoke and await on each element of the source. + /// The optional cancellation token to be usef for cancelling the sequence at any time. + /// A ValueTask containing the maximum value in the sequence. + /// or is . + [GenerateAsyncOverload] + private static ValueTask MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -582,7 +614,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -774,7 +807,17 @@ static async ValueTask Core(IAsyncEnumerable source, Func MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Invokes and awaits a transform function on each element of a sequence and returns the maximum value. + /// + /// Type of elements in the source sequence. + /// The source sequence. + /// An asynchronous transform function to invoke and await on each element of the source. + /// The optional cancellation token to be usef for cancelling the sequence at any time. + /// A ValueTask containing the maximum value in the sequence. + /// or is . + [GenerateAsyncOverload] + private static ValueTask MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -850,7 +893,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1033,7 +1077,17 @@ static async ValueTask Core(IAsyncEnumerable source, Func MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Invokes and awaits a transform function on each element of a sequence and returns the maximum value. + /// + /// Type of elements in the source sequence. + /// The source sequence. + /// An asynchronous transform function to invoke and await on each element of the source. + /// The optional cancellation token to be usef for cancelling the sequence at any time. + /// A ValueTask containing the maximum value in the sequence. + /// or is . + [GenerateAsyncOverload] + private static ValueTask MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1085,7 +1139,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1284,7 +1339,17 @@ static async ValueTask Core(IAsyncEnumerable source, Func MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Invokes and awaits a transform function on each element of a sequence and returns the maximum value. + /// + /// Type of elements in the source sequence. + /// The source sequence. + /// An asynchronous transform function to invoke and await on each element of the source. + /// The optional cancellation token to be usef for cancelling the sequence at any time. + /// A ValueTask containing the maximum value in the sequence. + /// or is . + [GenerateAsyncOverload] + private static ValueTask MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1356,7 +1421,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1535,7 +1601,17 @@ static async ValueTask Core(IAsyncEnumerable source, Func MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Invokes and awaits a transform function on each element of a sequence and returns the maximum value. + /// + /// Type of elements in the source sequence. + /// The source sequence. + /// An asynchronous transform function to invoke and await on each element of the source. + /// The optional cancellation token to be usef for cancelling the sequence at any time. + /// A ValueTask containing the maximum value in the sequence. + /// or is . + [GenerateAsyncOverload] + private static ValueTask MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1587,7 +1663,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1786,7 +1863,17 @@ static async ValueTask Core(IAsyncEnumerable source, Func MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Invokes and awaits a transform function on each element of a sequence and returns the maximum value. + /// + /// Type of elements in the source sequence. + /// The source sequence. + /// An asynchronous transform function to invoke and await on each element of the source. + /// The optional cancellation token to be usef for cancelling the sequence at any time. + /// A ValueTask containing the maximum value in the sequence. + /// or is . + [GenerateAsyncOverload] + private static ValueTask MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1858,7 +1945,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2007,7 +2095,17 @@ static async ValueTask Core(IAsyncEnumerable source, Func MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Invokes and awaits a transform function on each element of a sequence and returns the maximum value. + /// + /// Type of elements in the source sequence. + /// The source sequence. + /// An asynchronous transform function to invoke and await on each element of the source. + /// The optional cancellation token to be usef for cancelling the sequence at any time. + /// A ValueTask containing the maximum value in the sequence. + /// or is . + [GenerateAsyncOverload] + private static ValueTask MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2044,7 +2142,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2184,7 +2283,17 @@ static async ValueTask Core(IAsyncEnumerable source, Func MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Invokes and awaits a transform function on each element of a sequence and returns the maximum value. + /// + /// Type of elements in the source sequence. + /// The source sequence. + /// An asynchronous transform function to invoke and await on each element of the source. + /// The optional cancellation token to be usef for cancelling the sequence at any time. + /// A ValueTask containing the maximum value in the sequence. + /// or is . + [GenerateAsyncOverload] + private static ValueTask MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2234,7 +2343,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2361,7 +2471,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Invokes and awaits a transform function on each element of a sequence and returns the minimum value. + /// + /// The type of the elements in the source sequence. + /// An async-enumerable sequence to determine the minimum element of. + /// An asynchronous transform function to invoke and await on each element. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask sequence containing a single element with the value that corresponds to the minimum element in the source sequence. + /// or is null. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2398,7 +2519,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2542,7 +2664,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Invokes and awaits a transform function on each element of a sequence and returns the minimum value. + /// + /// The type of the elements in the source sequence. + /// An async-enumerable sequence to determine the minimum element of. + /// An asynchronous transform function to invoke and await on each element. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask sequence containing a single element with the value that corresponds to the minimum element in the source sequence. + /// or is null. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2594,7 +2727,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2723,7 +2857,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Invokes and awaits a transform function on each element of a sequence and returns the minimum value. + /// + /// The type of the elements in the source sequence. + /// An async-enumerable sequence to determine the minimum element of. + /// An asynchronous transform function to invoke and await on each element. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask sequence containing a single element with the value that corresponds to the minimum element in the source sequence. + /// or is null. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2760,7 +2905,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2904,7 +3050,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Invokes and awaits a transform function on each element of a sequence and returns the minimum value. + /// + /// The type of the elements in the source sequence. + /// An async-enumerable sequence to determine the minimum element of. + /// An asynchronous transform function to invoke and await on each element. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask sequence containing a single element with the value that corresponds to the minimum element in the source sequence. + /// or is null. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2956,7 +3113,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3117,7 +3275,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Invokes and awaits a transform function on each element of a sequence and returns the minimum value. + /// + /// The type of the elements in the source sequence. + /// An async-enumerable sequence to determine the minimum element of. + /// An asynchronous transform function to invoke and await on each element. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask sequence containing a single element with the value that corresponds to the minimum element in the source sequence. + /// or is null. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3170,7 +3339,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3362,7 +3532,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Invokes and awaits a transform function on each element of a sequence and returns the minimum value. + /// + /// The type of the elements in the source sequence. + /// An async-enumerable sequence to determine the minimum element of. + /// An asynchronous transform function to invoke and await on each element. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask sequence containing a single element with the value that corresponds to the minimum element in the source sequence. + /// or is null. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3430,7 +3611,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3607,7 +3789,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Invokes and awaits a transform function on each element of a sequence and returns the minimum value. + /// + /// The type of the elements in the source sequence. + /// An async-enumerable sequence to determine the minimum element of. + /// An asynchronous transform function to invoke and await on each element. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask sequence containing a single element with the value that corresponds to the minimum element in the source sequence. + /// or is null. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3660,7 +3853,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3852,7 +4046,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Invokes and awaits a transform function on each element of a sequence and returns the minimum value. + /// + /// The type of the elements in the source sequence. + /// An async-enumerable sequence to determine the minimum element of. + /// An asynchronous transform function to invoke and await on each element. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask sequence containing a single element with the value that corresponds to the minimum element in the source sequence. + /// or is null. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3920,7 +4125,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -4065,7 +4271,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Invokes and awaits a transform function on each element of a sequence and returns the minimum value. + /// + /// The type of the elements in the source sequence. + /// An async-enumerable sequence to determine the minimum element of. + /// An asynchronous transform function to invoke and await on each element. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask sequence containing a single element with the value that corresponds to the minimum element in the source sequence. + /// or is null. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -4102,7 +4319,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) +[GenerateAsyncOverload] + private static ValueTask MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -4242,7 +4460,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Invokes and awaits a transform function on each element of a sequence and returns the minimum value. + /// + /// The type of the elements in the source sequence. + /// An async-enumerable sequence to determine the minimum element of. + /// An asynchronous transform function to invoke and await on each element. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask sequence containing a single element with the value that corresponds to the minimum element in the source sequence. + /// or is null. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -4292,7 +4521,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs index c04045e9de..ecb1b1207e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs @@ -22,11 +22,22 @@ public static partial class AsyncEnumerable public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func keySelector) => new OrderedAsyncEnumerable(source, keySelector, comparer: null, descending: false, parent: null); - internal static IOrderedAsyncEnumerable OrderByAwaitCore(this IAsyncEnumerable source, Func> keySelector) => + /// + /// Sorts the elements of a sequence in ascending order according to a key obtained by invoking a transform function on each element and awaiting the result. + /// + /// The type of the elements of source. + /// The type of the key returned by keySelector. + /// An async-enumerable sequence of values to order. + /// An asynchronous function to extract a key from an element. + /// An ordered async-enumerable sequence whose elements are sorted according to a key. + /// or is null. + [GenerateAsyncOverload] + private static IOrderedAsyncEnumerable OrderByAwaitCore(this IAsyncEnumerable source, Func> keySelector) => new OrderedAsyncEnumerableWithTask(source, keySelector, comparer: null, descending: false, parent: null); #if !NO_DEEP_CANCELLATION - internal static IOrderedAsyncEnumerable OrderByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector) => + [GenerateAsyncOverload] + private static IOrderedAsyncEnumerable OrderByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector) => new OrderedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer: null, descending: false, parent: null); #endif @@ -43,11 +54,23 @@ internal static IOrderedAsyncEnumerable OrderByAwaitWithCancellationCor public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) => new OrderedAsyncEnumerable(source, keySelector, comparer, descending: false, parent: null); - internal static IOrderedAsyncEnumerable OrderByAwaitCore(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => + /// + /// Sorts the elements of a sequence in ascending order by using a specified comparer. The keys are obtained by invoking the transform function on each element and awaiting the result. + /// + /// The type of the elements of source. + /// The type of the key returned by keySelector. + /// An async-enumerable sequence of values to order. + /// An asynchronous function to extract a key from an element. + /// A comparer to compare keys. + /// An ordered async-enumerable sequence whose elements are sorted according to a key. + /// or is null. + [GenerateAsyncOverload] + private static IOrderedAsyncEnumerable OrderByAwaitCore(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => new OrderedAsyncEnumerableWithTask(source, keySelector, comparer, descending: false, parent: null); #if !NO_DEEP_CANCELLATION - internal static IOrderedAsyncEnumerable OrderByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => + [GenerateAsyncOverload] + private static IOrderedAsyncEnumerable OrderByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => new OrderedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer, descending: false, parent: null); #endif @@ -63,11 +86,22 @@ internal static IOrderedAsyncEnumerable OrderByAwaitWithCancellationCor public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func keySelector) => new OrderedAsyncEnumerable(source, keySelector, comparer: null, descending: true, parent: null); - internal static IOrderedAsyncEnumerable OrderByDescendingAwaitCore(this IAsyncEnumerable source, Func> keySelector) => + /// + /// Sorts the elements of a sequence in descending order according to a key obtained by invoking a transform function on each element and awaiting the result. + /// + /// The type of the elements of source. + /// The type of the key returned by keySelector. + /// An async-enumerable sequence of values to order. + /// An asynchronous function to extract a key from an element. + /// An ordered async-enumerable sequence whose elements are sorted in descending order according to a key. + /// or is null. + [GenerateAsyncOverload] + private static IOrderedAsyncEnumerable OrderByDescendingAwaitCore(this IAsyncEnumerable source, Func> keySelector) => new OrderedAsyncEnumerableWithTask(source, keySelector, comparer: null, descending: true, parent: null); #if !NO_DEEP_CANCELLATION - internal static IOrderedAsyncEnumerable OrderByDescendingAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector) => + [GenerateAsyncOverload] + private static IOrderedAsyncEnumerable OrderByDescendingAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector) => new OrderedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer: null, descending: true, parent: null); #endif @@ -84,11 +118,23 @@ internal static IOrderedAsyncEnumerable OrderByDescendingAwaitWithCance public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func keySelector, IComparer comparer) => new OrderedAsyncEnumerable(source, keySelector, comparer, descending: true, parent: null); - internal static IOrderedAsyncEnumerable OrderByDescendingAwaitCore(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => + /// + /// Sorts the elements of a sequence in descending order by using a specified comparer. The keys are obtained by invoking the transform function on each element and awaiting the result. + /// + /// The type of the elements of source. + /// The type of the key returned by keySelector. + /// An async-enumerable sequence of values to order. + /// An asynchronous function to extract a key from an element. + /// A comparer to compare keys. + /// An ordered async-enumerable sequence whose elements are sorted in descending order according to a key. + /// or is null. + [GenerateAsyncOverload] + private static IOrderedAsyncEnumerable OrderByDescendingAwaitCore(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => new OrderedAsyncEnumerableWithTask(source, keySelector, comparer, descending: true, parent: null); #if !NO_DEEP_CANCELLATION - internal static IOrderedAsyncEnumerable OrderByDescendingAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => + [GenerateAsyncOverload] + private static IOrderedAsyncEnumerable OrderByDescendingAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => new OrderedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer, descending: true, parent: null); #endif @@ -109,7 +155,17 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder return source.CreateOrderedEnumerable(keySelector, comparer: null, descending: false); } - internal static IOrderedAsyncEnumerable ThenByAwaitCore(this IOrderedAsyncEnumerable source, Func> keySelector) + /// + /// Performs a subsequent ordering of the elements in a sequence in ascending order according to a key obtained by invoking a transform function on each element and awaiting the result. + /// + /// The type of the elements of source. + /// The type of the key returned by keySelector. + /// An ordered async-enumerable sequence that contains elements to sort. + /// An asynchronous function to extract a key from each element. + /// An ordered async-enumerable whose elements are sorted according to a key. + /// or is null. + [GenerateAsyncOverload] + private static IOrderedAsyncEnumerable ThenByAwaitCore(this IOrderedAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -118,7 +174,8 @@ internal static IOrderedAsyncEnumerable ThenByAwaitCore( } #if !NO_DEEP_CANCELLATION - internal static IOrderedAsyncEnumerable ThenByAwaitWithCancellationCore(this IOrderedAsyncEnumerable source, Func> keySelector) + [GenerateAsyncOverload] + private static IOrderedAsyncEnumerable ThenByAwaitWithCancellationCore(this IOrderedAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -145,7 +202,18 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder return source.CreateOrderedEnumerable(keySelector, comparer, descending: false); } - internal static IOrderedAsyncEnumerable ThenByAwaitCore(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) + /// + /// Performs a subsequent ordering of the elements in a sequence in ascending order by using a specified comparer. The keys are obtained by invoking a transform function on each element and awaiting the result. + /// + /// The type of the elements of source. + /// The type of the key returned by keySelector. + /// An ordered async-enumerable sequence that contains elements to sort. + /// An asynchronous function to extract a key from each element. + /// A comparer to compare keys. + /// An ordered async-enumerable whose elements are sorted according to a key. + /// or is null. + [GenerateAsyncOverload] + private static IOrderedAsyncEnumerable ThenByAwaitCore(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -154,7 +222,8 @@ internal static IOrderedAsyncEnumerable ThenByAwaitCore( } #if !NO_DEEP_CANCELLATION - internal static IOrderedAsyncEnumerable ThenByAwaitWithCancellationCore(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) + [GenerateAsyncOverload] + private static IOrderedAsyncEnumerable ThenByAwaitWithCancellationCore(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -180,7 +249,17 @@ public static IOrderedAsyncEnumerable ThenByDescending(t return source.CreateOrderedEnumerable(keySelector, comparer: null, descending: true); } - internal static IOrderedAsyncEnumerable ThenByDescendingAwaitCore(this IOrderedAsyncEnumerable source, Func> keySelector) + /// + /// Performs a subsequent ordering of the elements in a sequence in descending order, according to a key obtained by invoking a transform function on each element and awaiting the result. + /// + /// The type of the elements of source. + /// The type of the key returned by keySelector. + /// An ordered async-enumerable sequence that contains elements to sort. + /// An asynchronous function to extract a key from each element. + /// An ordered async-enumerable sequence whose elements are sorted in descending order according to a key. + /// or is null. + [GenerateAsyncOverload] + private static IOrderedAsyncEnumerable ThenByDescendingAwaitCore(this IOrderedAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -189,7 +268,8 @@ internal static IOrderedAsyncEnumerable ThenByDescendingAwaitCore ThenByDescendingAwaitWithCancellationCore(this IOrderedAsyncEnumerable source, Func> keySelector) + [GenerateAsyncOverload] + private static IOrderedAsyncEnumerable ThenByDescendingAwaitWithCancellationCore(this IOrderedAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -216,7 +296,18 @@ public static IOrderedAsyncEnumerable ThenByDescending(t return source.CreateOrderedEnumerable(keySelector, comparer, descending: true); } - internal static IOrderedAsyncEnumerable ThenByDescendingAwaitCore(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) + /// + /// Performs a subsequent ordering of the elements in a sequence in descending order by using a specified comparer. The keys are obtained by invoking a transform function on each element and awaiting the result. + /// + /// The type of the elements of source. + /// The type of the key returned by keySelector. + /// An ordered async-enumerable sequence that contains elements to sort. + /// An asynchronous function to extract a key from each element. + /// A comparer to compare keys. + /// An ordered async-enumerable sequence whose elements are sorted in descending order according to a key. + /// or is null. + [GenerateAsyncOverload] + private static IOrderedAsyncEnumerable ThenByDescendingAwaitCore(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -225,7 +316,8 @@ internal static IOrderedAsyncEnumerable ThenByDescendingAwaitCore ThenByDescendingAwaitWithCancellationCore(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) + [GenerateAsyncOverload] + private static IOrderedAsyncEnumerable ThenByDescendingAwaitWithCancellationCore(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index defb886eb3..bcd1b9ffce 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -68,7 +68,17 @@ static async IAsyncEnumerable Core(IAsyncEnumerable source, Fu } } - internal static IAsyncEnumerable SelectAwaitCore(this IAsyncEnumerable source, Func> selector) + /// + /// Projects each element of an async-enumerable sequence into a new form by applying an asynchronous selector function to each member of the source sequence and awaiting the result. + /// + /// The type of the elements in the source sequence. + /// The type of the elements in the result sequence, obtained by running the selector function for each element in the source sequence and awaiting the result. + /// A sequence of elements to invoke a transform function on. + /// An asynchronous transform function to apply to each source element. + /// An async-enumerable sequence whose elements are the result of invoking the transform function on each element of the source sequence and awaiting the result. + /// or is null. + [GenerateAsyncOverload] + private static IAsyncEnumerable SelectAwaitCore(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -84,7 +94,8 @@ internal static IAsyncEnumerable SelectAwaitCore(this } #if !NO_DEEP_CANCELLATION - internal static IAsyncEnumerable SelectAwaitWithCancellationCore(this IAsyncEnumerable source, Func> selector) + [GenerateAsyncOverload] + private static IAsyncEnumerable SelectAwaitWithCancellationCore(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -100,7 +111,17 @@ internal static IAsyncEnumerable SelectAwaitWithCancellationCore SelectAwaitCore(this IAsyncEnumerable source, Func> selector) + /// + /// Projects each element of an async-enumerable sequence into a new form by applying an asynchronous selector function that incorporates each element's index to each element of the source sequence and awaiting the result. + /// + /// The type of elements in the source sequence. + /// The type of elements in the result sequence, obtained by running the selector function for each element and its index, and awaiting the result. + /// A sequence of elements to invoke a transform function on. + /// An asynchronous transform function to apply to each source element; the second parameter represents the index of the element. + /// An async-enumerable sequence whose elements are the result of invoking the transform function on each element and its index of the source sequence and awaiting the result. + /// or is null. + [GenerateAsyncOverload] + private static IAsyncEnumerable SelectAwaitCore(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -126,7 +147,8 @@ static async IAsyncEnumerable Core(IAsyncEnumerable source, Fu } #if !NO_DEEP_CANCELLATION - internal static IAsyncEnumerable SelectAwaitWithCancellationCore(this IAsyncEnumerable source, Func> selector) + [GenerateAsyncOverload] + private static IAsyncEnumerable SelectAwaitWithCancellationCore(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs index 6df637bf99..e70b194cf9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs @@ -31,7 +31,17 @@ public static IAsyncEnumerable SelectMany(this IAsync // REVIEW: Should we keep these overloads that return ValueTask>? One could argue the selector is async twice. - internal static IAsyncEnumerable SelectManyAwaitCore(this IAsyncEnumerable source, Func>> selector) + /// + /// Projects each element of an async-enumerable sequence into an async-enumerable sequence and merges the resulting async-enumerable sequences into one async-enumerable sequence. + /// + /// The type of elements in the source sequence. + /// The type of elements in the projected inner sequences and the merged result sequence. + /// An async-enumerable sequence of elements to project. + /// An asynchronous selector function to apply to each element of the source sequence. + /// An async-enumerable sequence whose elements are the result of invoking the one-to-many transform function on each element of the source sequence and awaiting the result. + /// or is null. + [GenerateAsyncOverload] + private static IAsyncEnumerable SelectManyAwaitCore(this IAsyncEnumerable source, Func>> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -42,7 +52,8 @@ internal static IAsyncEnumerable SelectManyAwaitCore( } #if !NO_DEEP_CANCELLATION - internal static IAsyncEnumerable SelectManyAwaitWithCancellationCore(this IAsyncEnumerable source, Func>> selector) + [GenerateAsyncOverload] + private static IAsyncEnumerable SelectManyAwaitWithCancellationCore(this IAsyncEnumerable source, Func>> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -92,7 +103,17 @@ static async IAsyncEnumerable Core(IAsyncEnumerable source, Fu } } - internal static IAsyncEnumerable SelectManyAwaitCore(this IAsyncEnumerable source, Func>> selector) + /// + /// Projects each element of an async-enumerable sequence into an async-enumerable sequence by incorporating the element's index and merges the resulting async-enumerable sequences into an async-enumerable sequence. + /// + /// The type of elements in the source sequence. + /// The type of elements in the projected inner sequences and the merged result sequence. + /// An async-enumerable sequence of elements to project. + /// An asynchronous selector function to apply to each element; the second parameter represents the index of the element. + /// An async-enumerable sequence who's elements are the result of invoking the one-to-many transform function on each element of the source sequence and awaiting the result. + /// or is null. + [GenerateAsyncOverload] + private static IAsyncEnumerable SelectManyAwaitCore(this IAsyncEnumerable source, Func>> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -123,7 +144,8 @@ static async IAsyncEnumerable Core(IAsyncEnumerable source, Fu } #if !NO_DEEP_CANCELLATION - internal static IAsyncEnumerable SelectManyAwaitWithCancellationCore(this IAsyncEnumerable source, Func>> selector) + [GenerateAsyncOverload] + private static IAsyncEnumerable SelectManyAwaitWithCancellationCore(this IAsyncEnumerable source, Func>> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -190,7 +212,19 @@ static async IAsyncEnumerable Core(IAsyncEnumerable source, Fu } } - internal static IAsyncEnumerable SelectManyAwaitCore(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) + /// + /// Projects each element of an async-enumerable sequence to an async-enumerable sequence by awaiting the result of a transform function, invokes the result selector for each of the source elements and each of the corrasponding inner-sequence's elements and awaits the result, and merges the results into one async-enumerable sequence. + /// + /// The type of elements in the source sequence. + /// The type of elements in the projected intermediate sequences. + /// The type of elements in the result sequence. + /// An async-enumerable sequence of elements to project. + /// An asynchronous transform function to apply to each source element. + /// An asynchronous transform function to apply to each element of the intermediate sequence. + /// An async-enumerable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence, awaiting the result, applying to each element of the intermediate sequences along with their corrasponding source element and awaiting the result. + /// , , or is . + [GenerateAsyncOverload] + private static IAsyncEnumerable SelectManyAwaitCore(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -216,7 +250,8 @@ static async IAsyncEnumerable Core(IAsyncEnumerable source, Fu } #if !NO_DEEP_CANCELLATION - internal static IAsyncEnumerable SelectManyAwaitWithCancellationCore(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) + [GenerateAsyncOverload] + private static IAsyncEnumerable SelectManyAwaitWithCancellationCore(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -285,7 +320,20 @@ static async IAsyncEnumerable Core(IAsyncEnumerable source, Fu } } - internal static IAsyncEnumerable SelectManyAwaitCore(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) + /// + /// Projects each element of an async-enumerable sequence to an async-enumerable sequence by awaiting the result of a transform function that incorporates each element's index, + /// invokes the result selector for the source element and each of the corrasponding inner-sequence's elements and awaits the result, and merges the results into one async-enumerable sequence. + /// + /// The type of elements in the source sequence. + /// The type of elements in the projected intermediate sequences. + /// The type of elements in the result sequence. + /// An async-enumerable sequence of elements to project. + /// An asynchronous transform function to apply to each source element; the second parameter represents the index of the element. + /// An asynchronous transform function to apply to each element of the intermediate sequence. + /// An async-enumerable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence, awaiting the result, applying to each element of the intermediate sequences olong with their corrasponding source element and awaiting the result. + /// , , or is . + [GenerateAsyncOverload] + private static IAsyncEnumerable SelectManyAwaitCore(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -318,7 +366,8 @@ static async IAsyncEnumerable Core(IAsyncEnumerable source, Fu } #if !NO_DEEP_CANCELLATION - internal static IAsyncEnumerable SelectManyAwaitWithCancellationCore(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) + [GenerateAsyncOverload] + private static IAsyncEnumerable SelectManyAwaitWithCancellationCore(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs index 1e46708205..8f2aef284b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs @@ -102,7 +102,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func SingleAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + /// + /// Returns the only element of an async-enumerable sequence that satisfies the condition in the asynchronous predicate, and reports an exception if there is not exactly one element in the async-enumerable sequence that matches the predicate. + /// + /// The type of elements in the source sequence. + /// Source async-enumerable sequence. + /// An asynchronous predicate that will be applied to each element of the source sequence. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// ValueTask containing the only element in the async-enumerable sequence that satisfies the condition in the asynchronous predicate. + /// or is null. + /// (Asynchronous) No element satisfies the condition in the predicate. -or- More than one element satisfies the condition in the predicate. -or- The source sequence is empty. + [GenerateAsyncOverload] + private static ValueTask SingleAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -139,7 +150,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func SingleAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask SingleAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs index 20c171d126..08e0c7e9ed 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs @@ -103,7 +103,18 @@ public static partial class AsyncEnumerable } } - internal static ValueTask SingleOrDefaultAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + /// + /// Returns the only element of an async-enumerable sequence that satisfies the condition in the asynchronous predicate, or a default value if no such element exists, and reports an exception if there is more than one element in the async-enumerable sequence that matches the predicate. + /// + /// The type of elements in the source sequence. + /// Source async-enumerable sequence. + /// An asynchronous predicate that will be applied to each element of the source sequence. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// ValueTask containing the only element in the async-enumerable sequence that satisfies the condition in the asynchronous predicate, or a default value if no such element exists. + /// or is null. + /// (Asynchronous) More than one element satisfies the condition in the predicate. + [GenerateAsyncOverload] + private static ValueTask SingleOrDefaultAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -140,7 +151,8 @@ public static partial class AsyncEnumerable } #if !NO_DEEP_CANCELLATION - internal static ValueTask SingleOrDefaultAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask SingleOrDefaultAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs index 32358fb8d3..a30e7bcfaf 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs @@ -97,7 +97,16 @@ static async IAsyncEnumerable Core(IAsyncEnumerable source, Fu } } - internal static IAsyncEnumerable SkipWhileAwaitCore(this IAsyncEnumerable source, Func> predicate) + /// + /// Bypasses elements in an async-enumerable sequence as long as a condition is true, and then returns the remaining elements. + /// + /// The type of elements in the source sequence. + /// An async-enumerable sequence to return elements from. + /// An asynchronous function to test each element for a condition. + /// An async-enumerable sequence containing the elements in the source sequence starting at the first element that does not pass the test specified by the predicate. + /// or is . + [GenerateAsyncOverload] + private static IAsyncEnumerable SkipWhileAwaitCore(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -130,7 +139,8 @@ static async IAsyncEnumerable Core(IAsyncEnumerable source, Fu } #if !NO_DEEP_CANCELLATION - internal static IAsyncEnumerable SkipWhileAwaitWithCancellationCore(this IAsyncEnumerable source, Func> predicate) + [GenerateAsyncOverload] + private static IAsyncEnumerable SkipWhileAwaitWithCancellationCore(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -163,7 +173,17 @@ static async IAsyncEnumerable Core(IAsyncEnumerable source, Fu } #endif - internal static IAsyncEnumerable SkipWhileAwaitCore(this IAsyncEnumerable source, Func> predicate) + /// + /// Bypasses elements in an async-enumerable sequence as long as a condition is true, and then returns the remaining elements. + /// The index of the element is used by the predicate. + /// + /// The type of elements in the source sequence. + /// An async-enumerable sequence to return elements from. + /// An asynchronous function to test each element for a condition; the second parameter of the function represents the index of the element. + /// An async-enumerable sequence containing the elements in the source sequence starting at the first element that does not pass the test specified by the predicate. + /// or is . + [GenerateAsyncOverload] + private static IAsyncEnumerable SkipWhileAwaitCore(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -202,7 +222,8 @@ static async IAsyncEnumerable Core(IAsyncEnumerable source, Fu } #if !NO_DEEP_CANCELLATION - internal static IAsyncEnumerable SkipWhileAwaitWithCancellationCore(this IAsyncEnumerable source, Func> predicate) + [GenerateAsyncOverload] + private static IAsyncEnumerable SkipWhileAwaitWithCancellationCore(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs index f851dbf20e..cd9be75fa7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs @@ -78,7 +78,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Computes the sum of a sequence of values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result. + /// + /// The type of elements in the source sequence. + /// A sequence of values that are used to calculate a sum. + /// An asynchronous transform function to apply to each element. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask containing the sum of the values in the source sequence. + /// or is . + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -106,7 +117,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -202,7 +214,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Computes the sum of a sequence of values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result. + /// + /// The type of elements in the source sequence. + /// A sequence of values that are used to calculate a sum. + /// An asynchronous transform function to apply to each element. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask containing the sum of the values in the source sequence. + /// or is . + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -230,7 +253,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -320,7 +344,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Computes the sum of a sequence of values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result. + /// + /// The type of elements in the source sequence. + /// A sequence of values that are used to calculate a sum. + /// An asynchronous transform function to apply to each element. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask containing the sum of the values in the source sequence. + /// or is . + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -345,7 +380,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -432,7 +468,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Computes the sum of a sequence of values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result. + /// + /// The type of elements in the source sequence. + /// A sequence of values that are used to calculate a sum. + /// An asynchronous transform function to apply to each element. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask containing the sum of the values in the source sequence. + /// or is . + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -457,7 +504,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -544,7 +592,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Computes the sum of a sequence of values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result. + /// + /// The type of elements in the source sequence. + /// A sequence of values that are used to calculate a sum. + /// An asynchronous transform function to apply to each element. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask containing the sum of the values in the source sequence. + /// or is . + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -569,7 +628,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -662,7 +722,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Computes the sum of a sequence of values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result. + /// + /// The type of elements in the source sequence. + /// A sequence of values that are used to calculate a sum. + /// An asynchronous transform function to apply to each element. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask containing the sum of the values in the source sequence. + /// or is . + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -690,7 +761,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -786,7 +858,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Computes the sum of a sequence of values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result. + /// + /// The type of elements in the source sequence. + /// A sequence of values that are used to calculate a sum. + /// An asynchronous transform function to apply to each element. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask containing the sum of the values in the source sequence. + /// or is . + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -814,7 +897,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -904,7 +988,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Computes the sum of a sequence of values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result. + /// + /// The type of elements in the source sequence. + /// A sequence of values that are used to calculate a sum. + /// An asynchronous transform function to apply to each element. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask containing the sum of the values in the source sequence. + /// or is . + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -929,7 +1024,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1016,7 +1112,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Computes the sum of a sequence of values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result. + /// + /// The type of elements in the source sequence. + /// A sequence of values that are used to calculate a sum. + /// An asynchronous transform function to apply to each element. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask containing the sum of the values in the source sequence. + /// or is . + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1041,7 +1148,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1128,7 +1236,18 @@ static async ValueTask Core(IAsyncEnumerable source, Func SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + /// + /// Computes the sum of a sequence of values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result. + /// + /// The type of elements in the source sequence. + /// A sequence of values that are used to calculate a sum. + /// An asynchronous transform function to apply to each element. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask containing the sum of the values in the source sequence. + /// or is . + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1153,7 +1272,8 @@ static async ValueTask Core(IAsyncEnumerable source, Func SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs index 123900b0d9..d214e48c2d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs @@ -80,7 +80,16 @@ static async IAsyncEnumerable Core(IAsyncEnumerable source, Fu } } - internal static IAsyncEnumerable TakeWhileAwaitCore(this IAsyncEnumerable source, Func> predicate) + /// + /// Returns elements from an async-enumerable sequence as long as a specified condition is true. + /// + /// The type of the elements in the source sequence. + /// A sequence to return elements from. + /// An asynchronous predicate to test each element for a condition. + /// An async-enumerable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes. + /// or is null. + [GenerateAsyncOverload] + private static IAsyncEnumerable TakeWhileAwaitCore(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -104,7 +113,8 @@ static async IAsyncEnumerable Core(IAsyncEnumerable source, Fu } #if !NO_DEEP_CANCELLATION - internal static IAsyncEnumerable TakeWhileAwaitWithCancellationCore(this IAsyncEnumerable source, Func> predicate) + [GenerateAsyncOverload] + private static IAsyncEnumerable TakeWhileAwaitWithCancellationCore(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -128,7 +138,17 @@ static async IAsyncEnumerable Core(IAsyncEnumerable source, Fu } #endif - internal static IAsyncEnumerable TakeWhileAwaitCore(this IAsyncEnumerable source, Func> predicate) + /// + /// Returns elements from an async-enumerable sequence as long as a specified condition is true. + /// The element's index is used in the logic of the predicate function. + /// + /// The type of the elements in the source sequence. + /// A sequence to return elements from. + /// An asynchronous function to test each element for a condition; the second parameter of the function represents the index of the source element. + /// An async-enumerable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes. + /// or is null. + [GenerateAsyncOverload] + private static IAsyncEnumerable TakeWhileAwaitCore(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -159,7 +179,8 @@ static async IAsyncEnumerable Core(IAsyncEnumerable source, Fu } #if !NO_DEEP_CANCELLATION - internal static IAsyncEnumerable TakeWhileAwaitWithCancellationCore(this IAsyncEnumerable source, Func> predicate) + [GenerateAsyncOverload] + private static IAsyncEnumerable TakeWhileAwaitWithCancellationCore(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs index 029b342fbb..97cfedf874 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs @@ -60,10 +60,35 @@ static async ValueTask> Core(IAsyncEnumerable } } - internal static ValueTask> ToDictionaryAwaitAsyncCore(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) where TKey : notnull => + /// + /// Creates a dictionary from an async-enumerable sequence by invoking a key-selector function on each element and awaiting the result. + /// + /// The type of the elements in the source sequence. + /// The type of the dictionary key computed for each element in the source sequence. + /// An async-enumerable sequence to create a dictionary for. + /// An asynchronous function to extract a key from each element. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask containing a dictionary mapping unique key values onto the corresponding source sequence's element. + /// or is null. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask> ToDictionaryAwaitAsyncCore(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) where TKey : notnull => ToDictionaryAwaitAsyncCore(source, keySelector, comparer: null, cancellationToken); - internal static ValueTask> ToDictionaryAwaitAsyncCore(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer? comparer, CancellationToken cancellationToken = default) where TKey : notnull + /// + /// Creates a dictionary from an async-enumerable sequence by invoking a key-selector function on each element and awaiting the result. + /// + /// The type of the elements in the source sequence. + /// The type of the dictionary key computed for each element in the source sequence. + /// An async-enumerable sequence to create a dictionary for. + /// An asynchronous function to extract a key from each element. + /// An equality comparer to compare keys. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask containing a dictionary mapping unique key values onto the corresponding source sequence's element. + /// or or is null. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask> ToDictionaryAwaitAsyncCore(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer? comparer, CancellationToken cancellationToken = default) where TKey : notnull { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -88,10 +113,12 @@ static async ValueTask> Core(IAsyncEnumerable } #if !NO_DEEP_CANCELLATION - internal static ValueTask> ToDictionaryAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) where TKey : notnull => + [GenerateAsyncOverload] + private static ValueTask> ToDictionaryAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) where TKey : notnull => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, comparer: null, cancellationToken); - internal static ValueTask> ToDictionaryAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer? comparer, CancellationToken cancellationToken = default) where TKey : notnull + [GenerateAsyncOverload] + private static ValueTask> ToDictionaryAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer? comparer, CancellationToken cancellationToken = default) where TKey : notnull { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -173,10 +200,39 @@ static async ValueTask> Core(IAsyncEnumerable> ToDictionaryAwaitAsyncCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) where TKey : notnull => + /// + /// Creates a dictionary from an async-enumerable sequence using the specified asynchronous key and element selector functions. + /// + /// The type of the elements in the source sequence. + /// The type of the dictionary key computed for each element in the source sequence. + /// The type of the dictionary value computed for each element in the source sequence. + /// An async-enumerable sequence to create a dictionary for. + /// An asynchronous function to extract a key from each element. + /// An asynchronous transform function to produce a result element value from each element. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask containing a dictionary mapping unique key values onto the corresponding source sequence's element. + /// or or is null. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask> ToDictionaryAwaitAsyncCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) where TKey : notnull => ToDictionaryAwaitAsyncCore(source, keySelector, elementSelector, comparer: null, cancellationToken); - internal static ValueTask> ToDictionaryAwaitAsyncCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer? comparer, CancellationToken cancellationToken = default) where TKey : notnull + /// + /// Creates a dictionary from an async-enumerable sequence using the specified asynchronous key and element selector functions. + /// + /// The type of the elements in the source sequence. + /// The type of the dictionary key computed for each element in the source sequence. + /// The type of the dictionary value computed for each element in the source sequence. + /// An async-enumerable sequence to create a dictionary for. + /// An asynchronous function to extract a key from each element. + /// An asynchronous transform function to produce a result element value from each element. + /// An equality comparer to compare keys. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask containing a dictionary mapping unique key values onto the corresponding source sequence's element. + /// or or or is null. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask> ToDictionaryAwaitAsyncCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer? comparer, CancellationToken cancellationToken = default) where TKey : notnull { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -204,10 +260,12 @@ static async ValueTask> Core(IAsyncEnumerable> ToDictionaryAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) where TKey : notnull => + [GenerateAsyncOverload] + private static ValueTask> ToDictionaryAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) where TKey : notnull => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, comparer: null, cancellationToken); - internal static ValueTask> ToDictionaryAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer? comparer, CancellationToken cancellationToken = default) where TKey : notnull + [GenerateAsyncOverload] + private static ValueTask> ToDictionaryAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer? comparer, CancellationToken cancellationToken = default) where TKey : notnull { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs index df0724b51c..4ad7f7e04c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs @@ -51,10 +51,35 @@ static async ValueTask> Core(IAsyncEnumerable so } } - internal static ValueTask> ToLookupAwaitAsyncCore(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => + /// + /// Creates a lookup from an async-enumerable sequence by invoking a key-selector function on each element and awaiting the result. + /// + /// The type of the elements in the source sequence. + /// The type of the lookup key computed for each element in the source sequence. + /// An async-enumerable sequence to create a lookup for. + /// An asynchronous function to extract a key from each element. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask containing a lookup mapping unique key values onto the corresponding source sequence's elements. + /// or is null. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask> ToLookupAwaitAsyncCore(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => ToLookupAwaitAsyncCore(source, keySelector, comparer:null, cancellationToken); - internal static ValueTask> ToLookupAwaitAsyncCore(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer? comparer, CancellationToken cancellationToken = default) + /// + /// Creates a lookup from an async-enumerable sequence by invoking a key-selector function on each element and awaiting the result. + /// + /// The type of the elements in the source sequence. + /// The type of the lookup key computed for each element in the source sequence. + /// An async-enumerable sequence to create a lookup for. + /// An asynchronous function to extract a key from each element. + /// An equality comparer to compare keys. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask containing a lookup mapping unique key values onto the corresponding source sequence's elements. + /// or or is null. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask> ToLookupAwaitAsyncCore(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer? comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -70,10 +95,12 @@ static async ValueTask> Core(IAsyncEnumerable so } #if !NO_DEEP_CANCELLATION - internal static ValueTask> ToLookupAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => + [GenerateAsyncOverload] + private static ValueTask> ToLookupAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, comparer: null, cancellationToken); - internal static ValueTask> ToLookupAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer? comparer, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask> ToLookupAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer? comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -136,10 +163,39 @@ static async ValueTask> Core(IAsyncEnumerable s } } - internal static ValueTask> ToLookupAwaitAsyncCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => + /// + /// Creates a lookup from an async-enumerable sequence by invoking key and element selector functions on each source element and awaiting the results. + /// + /// The type of the elements in the source sequence. + /// The type of the lookup key computed for each element in the source sequence. + /// The type of the lookup value computed for each element in the source sequence. + /// An async-enumerable sequence to create a lookup for. + /// An asynchronous function to extract a key from each element. + /// An asynchronous transform function to produce a result element value from each element. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// An async-enumerable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements. + /// or or is null. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask> ToLookupAwaitAsyncCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => ToLookupAwaitAsyncCore(source, keySelector, elementSelector, comparer: null, cancellationToken); - internal static ValueTask> ToLookupAwaitAsyncCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer? comparer, CancellationToken cancellationToken = default) + /// + /// Creates a lookup from an async-enumerable sequence by invoking key and element selector functions on each source element and awaiting the results. + /// + /// The type of the elements in the source sequence. + /// The type of the lookup key computed for each element in the source sequence. + /// The type of the lookup value computed for each element in the source sequence. + /// An async-enumerable sequence to create a lookup for. + /// An asynchronous function to extract a key from each element. + /// An asynchronous transform function to produce a result element value from each source element. + /// An equality comparer to compare keys. + /// The optional cancellation token to be used for cancelling the sequence at any time. + /// A ValueTask containing a lookup mapping unique key values onto the corresponding source sequence's elements. + /// or or or is null. + /// The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior. + [GenerateAsyncOverload] + private static ValueTask> ToLookupAwaitAsyncCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer? comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -157,10 +213,12 @@ static async ValueTask> Core(IAsyncEnumerable s } #if !NO_DEEP_CANCELLATION - internal static ValueTask> ToLookupAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => + [GenerateAsyncOverload] + private static ValueTask> ToLookupAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, comparer: null, cancellationToken); - internal static ValueTask> ToLookupAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer? comparer, CancellationToken cancellationToken = default) + [GenerateAsyncOverload] + private static ValueTask> ToLookupAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer? comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs index 156e588f17..705b07ac6f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs @@ -70,7 +70,16 @@ static async IAsyncEnumerable Core(IAsyncEnumerable source, Fu } } - internal static IAsyncEnumerable WhereAwaitCore(this IAsyncEnumerable source, Func> predicate) + /// + /// Filters the elements of an async-enumerable sequence based on an asynchronous predicate. + /// + /// The type of the elements in the source sequence. + /// An async-enumerable sequence whose elements to filter. + /// An asynchronous predicate to test each source element for a condition. + /// An async-enumerable sequence that contains elements from the input sequence that satisfy the condition. + /// or is null. + [GenerateAsyncOverload] + private static IAsyncEnumerable WhereAwaitCore(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -87,7 +96,8 @@ internal static IAsyncEnumerable WhereAwaitCore(this IAsyncEnu } #if !NO_DEEP_CANCELLATION - internal static IAsyncEnumerable WhereAwaitWithCancellationCore(this IAsyncEnumerable source, Func> predicate) + [GenerateAsyncOverload] + private static IAsyncEnumerable WhereAwaitWithCancellationCore(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -104,7 +114,16 @@ internal static IAsyncEnumerable WhereAwaitWithCancellationCore WhereAwaitCore(this IAsyncEnumerable source, Func> predicate) + /// + /// Filters the elements of an async-enumerable sequence based on an asynchronous predicate that incorporates the element's index. + /// + /// The type of the elements in the source sequence. + /// An async-enumerable sequence whose elements to filter. + /// An asynchronous predicate to test each source element for a condition; the second parameter of the function represents the index of the source element. + /// An async-enumerable sequence that contains elements from the input sequence that satisfy the condition. + /// or is null. + [GenerateAsyncOverload] + private static IAsyncEnumerable WhereAwaitCore(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -133,7 +152,8 @@ static async IAsyncEnumerable Core(IAsyncEnumerable source, Fu } #if !NO_DEEP_CANCELLATION - internal static IAsyncEnumerable WhereAwaitWithCancellationCore(this IAsyncEnumerable source, Func> predicate) + [GenerateAsyncOverload] + private static IAsyncEnumerable WhereAwaitWithCancellationCore(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs index adaef2981d..c783ddd17d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs @@ -67,7 +67,19 @@ static async IAsyncEnumerable Core(IAsyncEnumerable first, IAsy } } - internal static IAsyncEnumerable ZipAwaitCore(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) + /// + /// Merges two async-enumerable sequences into one async-enumerable sequence by combining their elements in a pairwise fashion. + /// + /// The type of the elements in the first source sequence. + /// The type of the elements in the second source sequence. + /// The type of the elements in the result sequence, returned by the selector function. + /// First async-enumerable source. + /// Second async-enumerable source. + /// An asynchronous function to invoke and await for each consecutive pair of elements from the first and second source. + /// An async-enumerable sequence containing the result of pairwise combining the elements of the first and second source using the specified result selector function. + /// or or is null. + [GenerateAsyncOverload] + private static IAsyncEnumerable ZipAwaitCore(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) { if (first == null) throw Error.ArgumentNull(nameof(first)); @@ -91,7 +103,8 @@ static async IAsyncEnumerable Core(IAsyncEnumerable first, IAsy } #if !NO_DEEP_CANCELLATION - internal static IAsyncEnumerable ZipAwaitWithCancellationCore(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) + [GenerateAsyncOverload] + private static IAsyncEnumerable ZipAwaitWithCancellationCore(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) { if (first == null) throw Error.ArgumentNull(nameof(first)); diff --git a/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj b/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj index a18025f6f1..ead9cd3018 100644 --- a/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj +++ b/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj @@ -11,6 +11,11 @@ + + + ExtrasIsReferenceAssembly;AssemblyName;Version;AssemblyTitle +