|
@@ -10,6 +10,7 @@ namespace System.Linq
|
|
|
{
|
|
|
public static partial class AsyncEnumerable
|
|
|
{
|
|
|
+#if INCLUDE_SYSTEM_LINQ_ASYNCENUMERABLE_DUPLICATES
|
|
|
/// <summary>
|
|
|
/// Computes the sum of a sequence of <see cref="int" /> values.
|
|
|
/// </summary>
|
|
@@ -40,6 +41,7 @@ namespace System.Linq
|
|
|
return sum;
|
|
|
}
|
|
|
}
|
|
|
+#endif // INCLUDE_SYSTEM_LINQ_ASYNCENUMERABLE_DUPLICATES
|
|
|
|
|
|
/// <summary>
|
|
|
/// Computes the sum of a sequence of <see cref="int" /> values that are obtained by invoking a transform function on each element of the input sequence.
|
|
@@ -51,6 +53,7 @@ namespace System.Linq
|
|
|
/// <returns>An async-enumerable sequence containing a single element with the sum of the values in the source sequence.</returns>
|
|
|
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
|
|
|
/// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
public static ValueTask<int> SumAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -78,16 +81,7 @@ namespace System.Linq
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// Computes the sum of a sequence of <see cref="int"/> values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result.
|
|
|
- /// </summary>
|
|
|
- /// <typeparam name="TSource">The type of elements in the source sequence.</typeparam>
|
|
|
- /// <param name="source">A sequence of values that are used to calculate a sum.</param>
|
|
|
- /// <param name="selector">An asynchronous transform function to apply to each element.</param>
|
|
|
- /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
- /// <returns>A ValueTask containing the sum of the values in the source sequence.</returns>
|
|
|
- /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is <see langword="null"/>.</exception>
|
|
|
- /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
[GenerateAsyncOverload]
|
|
|
private static ValueTask<int> SumAwaitAsyncCore<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, ValueTask<int>> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
@@ -117,6 +111,7 @@ namespace System.Linq
|
|
|
}
|
|
|
|
|
|
#if !NO_DEEP_CANCELLATION
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
[GenerateAsyncOverload]
|
|
|
private static ValueTask<int> SumAwaitWithCancellationAsyncCore<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, ValueTask<int>> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
@@ -146,6 +141,7 @@ namespace System.Linq
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+#if INCLUDE_SYSTEM_LINQ_ASYNCENUMERABLE_DUPLICATES
|
|
|
/// <summary>
|
|
|
/// Computes the sum of a sequence of <see cref="long" /> values.
|
|
|
/// </summary>
|
|
@@ -176,6 +172,7 @@ namespace System.Linq
|
|
|
return sum;
|
|
|
}
|
|
|
}
|
|
|
+#endif // INCLUDE_SYSTEM_LINQ_ASYNCENUMERABLE_DUPLICATES
|
|
|
|
|
|
/// <summary>
|
|
|
/// Computes the sum of a sequence of <see cref="long" /> values that are obtained by invoking a transform function on each element of the input sequence.
|
|
@@ -187,6 +184,7 @@ namespace System.Linq
|
|
|
/// <returns>An async-enumerable sequence containing a single element with the sum of the values in the source sequence.</returns>
|
|
|
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
|
|
|
/// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
public static ValueTask<long> SumAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -214,16 +212,7 @@ namespace System.Linq
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// Computes the sum of a sequence of <see cref="long"/> values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result.
|
|
|
- /// </summary>
|
|
|
- /// <typeparam name="TSource">The type of elements in the source sequence.</typeparam>
|
|
|
- /// <param name="source">A sequence of values that are used to calculate a sum.</param>
|
|
|
- /// <param name="selector">An asynchronous transform function to apply to each element.</param>
|
|
|
- /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
- /// <returns>A ValueTask containing the sum of the values in the source sequence.</returns>
|
|
|
- /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is <see langword="null"/>.</exception>
|
|
|
- /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
[GenerateAsyncOverload]
|
|
|
private static ValueTask<long> SumAwaitAsyncCore<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, ValueTask<long>> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
@@ -253,6 +242,7 @@ namespace System.Linq
|
|
|
}
|
|
|
|
|
|
#if !NO_DEEP_CANCELLATION
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
[GenerateAsyncOverload]
|
|
|
private static ValueTask<long> SumAwaitWithCancellationAsyncCore<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, ValueTask<long>> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
@@ -282,6 +272,7 @@ namespace System.Linq
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+#if INCLUDE_SYSTEM_LINQ_ASYNCENUMERABLE_DUPLICATES
|
|
|
/// <summary>
|
|
|
/// Computes the sum of a sequence of <see cref="float" /> values.
|
|
|
/// </summary>
|
|
@@ -309,6 +300,7 @@ namespace System.Linq
|
|
|
return sum;
|
|
|
}
|
|
|
}
|
|
|
+#endif // INCLUDE_SYSTEM_LINQ_ASYNCENUMERABLE_DUPLICATES
|
|
|
|
|
|
/// <summary>
|
|
|
/// Computes the sum of a sequence of <see cref="float" /> values that are obtained by invoking a transform function on each element of the input sequence.
|
|
@@ -320,6 +312,7 @@ namespace System.Linq
|
|
|
/// <returns>An async-enumerable sequence containing a single element with the sum of the values in the source sequence.</returns>
|
|
|
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
|
|
|
/// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
public static ValueTask<float> SumAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -344,16 +337,7 @@ namespace System.Linq
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// Computes the sum of a sequence of <see cref="float"/> values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result.
|
|
|
- /// </summary>
|
|
|
- /// <typeparam name="TSource">The type of elements in the source sequence.</typeparam>
|
|
|
- /// <param name="source">A sequence of values that are used to calculate a sum.</param>
|
|
|
- /// <param name="selector">An asynchronous transform function to apply to each element.</param>
|
|
|
- /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
- /// <returns>A ValueTask containing the sum of the values in the source sequence.</returns>
|
|
|
- /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is <see langword="null"/>.</exception>
|
|
|
- /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
[GenerateAsyncOverload]
|
|
|
private static ValueTask<float> SumAwaitAsyncCore<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, ValueTask<float>> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
@@ -380,6 +364,7 @@ namespace System.Linq
|
|
|
}
|
|
|
|
|
|
#if !NO_DEEP_CANCELLATION
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
[GenerateAsyncOverload]
|
|
|
private static ValueTask<float> SumAwaitWithCancellationAsyncCore<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, ValueTask<float>> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
@@ -406,6 +391,7 @@ namespace System.Linq
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+#if INCLUDE_SYSTEM_LINQ_ASYNCENUMERABLE_DUPLICATES
|
|
|
/// <summary>
|
|
|
/// Computes the sum of a sequence of <see cref="double" /> values.
|
|
|
/// </summary>
|
|
@@ -433,6 +419,7 @@ namespace System.Linq
|
|
|
return sum;
|
|
|
}
|
|
|
}
|
|
|
+#endif // INCLUDE_SYSTEM_LINQ_ASYNCENUMERABLE_DUPLICATES
|
|
|
|
|
|
/// <summary>
|
|
|
/// Computes the sum of a sequence of <see cref="double" /> values that are obtained by invoking a transform function on each element of the input sequence.
|
|
@@ -444,6 +431,7 @@ namespace System.Linq
|
|
|
/// <returns>An async-enumerable sequence containing a single element with the sum of the values in the source sequence.</returns>
|
|
|
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
|
|
|
/// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
public static ValueTask<double> SumAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -468,16 +456,7 @@ namespace System.Linq
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// Computes the sum of a sequence of <see cref="double"/> values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result.
|
|
|
- /// </summary>
|
|
|
- /// <typeparam name="TSource">The type of elements in the source sequence.</typeparam>
|
|
|
- /// <param name="source">A sequence of values that are used to calculate a sum.</param>
|
|
|
- /// <param name="selector">An asynchronous transform function to apply to each element.</param>
|
|
|
- /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
- /// <returns>A ValueTask containing the sum of the values in the source sequence.</returns>
|
|
|
- /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is <see langword="null"/>.</exception>
|
|
|
- /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
[GenerateAsyncOverload]
|
|
|
private static ValueTask<double> SumAwaitAsyncCore<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, ValueTask<double>> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
@@ -504,6 +483,7 @@ namespace System.Linq
|
|
|
}
|
|
|
|
|
|
#if !NO_DEEP_CANCELLATION
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
[GenerateAsyncOverload]
|
|
|
private static ValueTask<double> SumAwaitWithCancellationAsyncCore<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, ValueTask<double>> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
@@ -530,6 +510,7 @@ namespace System.Linq
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+#if INCLUDE_SYSTEM_LINQ_ASYNCENUMERABLE_DUPLICATES
|
|
|
/// <summary>
|
|
|
/// Computes the sum of a sequence of <see cref="decimal" /> values.
|
|
|
/// </summary>
|
|
@@ -557,6 +538,7 @@ namespace System.Linq
|
|
|
return sum;
|
|
|
}
|
|
|
}
|
|
|
+#endif // INCLUDE_SYSTEM_LINQ_ASYNCENUMERABLE_DUPLICATES
|
|
|
|
|
|
/// <summary>
|
|
|
/// Computes the sum of a sequence of <see cref="decimal" /> values that are obtained by invoking a transform function on each element of the input sequence.
|
|
@@ -568,6 +550,7 @@ namespace System.Linq
|
|
|
/// <returns>An async-enumerable sequence containing a single element with the sum of the values in the source sequence.</returns>
|
|
|
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
|
|
|
/// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
public static ValueTask<decimal> SumAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -592,16 +575,7 @@ namespace System.Linq
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// Computes the sum of a sequence of <see cref="decimal"/> values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result.
|
|
|
- /// </summary>
|
|
|
- /// <typeparam name="TSource">The type of elements in the source sequence.</typeparam>
|
|
|
- /// <param name="source">A sequence of values that are used to calculate a sum.</param>
|
|
|
- /// <param name="selector">An asynchronous transform function to apply to each element.</param>
|
|
|
- /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
- /// <returns>A ValueTask containing the sum of the values in the source sequence.</returns>
|
|
|
- /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is <see langword="null"/>.</exception>
|
|
|
- /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
[GenerateAsyncOverload]
|
|
|
private static ValueTask<decimal> SumAwaitAsyncCore<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, ValueTask<decimal>> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
@@ -628,6 +602,7 @@ namespace System.Linq
|
|
|
}
|
|
|
|
|
|
#if !NO_DEEP_CANCELLATION
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
[GenerateAsyncOverload]
|
|
|
private static ValueTask<decimal> SumAwaitWithCancellationAsyncCore<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, ValueTask<decimal>> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
@@ -654,6 +629,7 @@ namespace System.Linq
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+#if INCLUDE_SYSTEM_LINQ_ASYNCENUMERABLE_DUPLICATES
|
|
|
/// <summary>
|
|
|
/// Computes the sum of a sequence of <see cref="Nullable{Int}" /> values.
|
|
|
/// </summary>
|
|
@@ -684,6 +660,7 @@ namespace System.Linq
|
|
|
return sum;
|
|
|
}
|
|
|
}
|
|
|
+#endif // INCLUDE_SYSTEM_LINQ_ASYNCENUMERABLE_DUPLICATES
|
|
|
|
|
|
/// <summary>
|
|
|
/// Computes the sum of a sequence of <see cref="Nullable{Int}" /> values that are obtained by invoking a transform function on each element of the input sequence.
|
|
@@ -695,6 +672,7 @@ namespace System.Linq
|
|
|
/// <returns>An async-enumerable sequence containing a single element with the sum of the values in the source sequence.</returns>
|
|
|
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
|
|
|
/// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
public static ValueTask<int?> SumAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int?> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -722,16 +700,7 @@ namespace System.Linq
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// Computes the sum of a sequence of <see cref="Nullable{Int}"/> values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result.
|
|
|
- /// </summary>
|
|
|
- /// <typeparam name="TSource">The type of elements in the source sequence.</typeparam>
|
|
|
- /// <param name="source">A sequence of values that are used to calculate a sum.</param>
|
|
|
- /// <param name="selector">An asynchronous transform function to apply to each element.</param>
|
|
|
- /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
- /// <returns>A ValueTask containing the sum of the values in the source sequence.</returns>
|
|
|
- /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is <see langword="null"/>.</exception>
|
|
|
- /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
[GenerateAsyncOverload]
|
|
|
private static ValueTask<int?> SumAwaitAsyncCore<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, ValueTask<int?>> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
@@ -761,6 +730,7 @@ namespace System.Linq
|
|
|
}
|
|
|
|
|
|
#if !NO_DEEP_CANCELLATION
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
[GenerateAsyncOverload]
|
|
|
private static ValueTask<int?> SumAwaitWithCancellationAsyncCore<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, ValueTask<int?>> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
@@ -790,6 +760,7 @@ namespace System.Linq
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+#if INCLUDE_SYSTEM_LINQ_ASYNCENUMERABLE_DUPLICATES
|
|
|
/// <summary>
|
|
|
/// Computes the sum of a sequence of <see cref="Nullable{Long}" /> values.
|
|
|
/// </summary>
|
|
@@ -820,6 +791,7 @@ namespace System.Linq
|
|
|
return sum;
|
|
|
}
|
|
|
}
|
|
|
+#endif // INCLUDE_SYSTEM_LINQ_ASYNCENUMERABLE_DUPLICATES
|
|
|
|
|
|
/// <summary>
|
|
|
/// Computes the sum of a sequence of <see cref="Nullable{Long}" /> values that are obtained by invoking a transform function on each element of the input sequence.
|
|
@@ -831,6 +803,7 @@ namespace System.Linq
|
|
|
/// <returns>An async-enumerable sequence containing a single element with the sum of the values in the source sequence.</returns>
|
|
|
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
|
|
|
/// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
public static ValueTask<long?> SumAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long?> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -858,16 +831,7 @@ namespace System.Linq
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// Computes the sum of a sequence of <see cref="Nullable{Long}"/> values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result.
|
|
|
- /// </summary>
|
|
|
- /// <typeparam name="TSource">The type of elements in the source sequence.</typeparam>
|
|
|
- /// <param name="source">A sequence of values that are used to calculate a sum.</param>
|
|
|
- /// <param name="selector">An asynchronous transform function to apply to each element.</param>
|
|
|
- /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
- /// <returns>A ValueTask containing the sum of the values in the source sequence.</returns>
|
|
|
- /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is <see langword="null"/>.</exception>
|
|
|
- /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
[GenerateAsyncOverload]
|
|
|
private static ValueTask<long?> SumAwaitAsyncCore<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, ValueTask<long?>> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
@@ -897,6 +861,7 @@ namespace System.Linq
|
|
|
}
|
|
|
|
|
|
#if !NO_DEEP_CANCELLATION
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
[GenerateAsyncOverload]
|
|
|
private static ValueTask<long?> SumAwaitWithCancellationAsyncCore<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, ValueTask<long?>> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
@@ -926,6 +891,7 @@ namespace System.Linq
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+#if INCLUDE_SYSTEM_LINQ_ASYNCENUMERABLE_DUPLICATES
|
|
|
/// <summary>
|
|
|
/// Computes the sum of a sequence of <see cref="Nullable{Float}" /> values.
|
|
|
/// </summary>
|
|
@@ -953,6 +919,7 @@ namespace System.Linq
|
|
|
return sum;
|
|
|
}
|
|
|
}
|
|
|
+#endif // INCLUDE_SYSTEM_LINQ_ASYNCENUMERABLE_DUPLICATES
|
|
|
|
|
|
/// <summary>
|
|
|
/// Computes the sum of a sequence of <see cref="Nullable{Float}" /> values that are obtained by invoking a transform function on each element of the input sequence.
|
|
@@ -964,6 +931,7 @@ namespace System.Linq
|
|
|
/// <returns>An async-enumerable sequence containing a single element with the sum of the values in the source sequence.</returns>
|
|
|
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
|
|
|
/// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
public static ValueTask<float?> SumAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float?> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -988,16 +956,7 @@ namespace System.Linq
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// Computes the sum of a sequence of <see cref="Nullable{Float}"/> values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result.
|
|
|
- /// </summary>
|
|
|
- /// <typeparam name="TSource">The type of elements in the source sequence.</typeparam>
|
|
|
- /// <param name="source">A sequence of values that are used to calculate a sum.</param>
|
|
|
- /// <param name="selector">An asynchronous transform function to apply to each element.</param>
|
|
|
- /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
- /// <returns>A ValueTask containing the sum of the values in the source sequence.</returns>
|
|
|
- /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is <see langword="null"/>.</exception>
|
|
|
- /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
[GenerateAsyncOverload]
|
|
|
private static ValueTask<float?> SumAwaitAsyncCore<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, ValueTask<float?>> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
@@ -1024,6 +983,7 @@ namespace System.Linq
|
|
|
}
|
|
|
|
|
|
#if !NO_DEEP_CANCELLATION
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
[GenerateAsyncOverload]
|
|
|
private static ValueTask<float?> SumAwaitWithCancellationAsyncCore<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, ValueTask<float?>> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
@@ -1050,6 +1010,7 @@ namespace System.Linq
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+#if INCLUDE_SYSTEM_LINQ_ASYNCENUMERABLE_DUPLICATES
|
|
|
/// <summary>
|
|
|
/// Computes the sum of a sequence of <see cref="Nullable{Double}" /> values.
|
|
|
/// </summary>
|
|
@@ -1077,6 +1038,7 @@ namespace System.Linq
|
|
|
return sum;
|
|
|
}
|
|
|
}
|
|
|
+#endif // INCLUDE_SYSTEM_LINQ_ASYNCENUMERABLE_DUPLICATES
|
|
|
|
|
|
/// <summary>
|
|
|
/// Computes the sum of a sequence of <see cref="Nullable{Double}" /> values that are obtained by invoking a transform function on each element of the input sequence.
|
|
@@ -1088,6 +1050,7 @@ namespace System.Linq
|
|
|
/// <returns>An async-enumerable sequence containing a single element with the sum of the values in the source sequence.</returns>
|
|
|
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
|
|
|
/// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
public static ValueTask<double?> SumAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double?> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -1112,16 +1075,7 @@ namespace System.Linq
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// Computes the sum of a sequence of <see cref="Nullable{Double}"/> values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result.
|
|
|
- /// </summary>
|
|
|
- /// <typeparam name="TSource">The type of elements in the source sequence.</typeparam>
|
|
|
- /// <param name="source">A sequence of values that are used to calculate a sum.</param>
|
|
|
- /// <param name="selector">An asynchronous transform function to apply to each element.</param>
|
|
|
- /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
- /// <returns>A ValueTask containing the sum of the values in the source sequence.</returns>
|
|
|
- /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is <see langword="null"/>.</exception>
|
|
|
- /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
[GenerateAsyncOverload]
|
|
|
private static ValueTask<double?> SumAwaitAsyncCore<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, ValueTask<double?>> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
@@ -1148,6 +1102,7 @@ namespace System.Linq
|
|
|
}
|
|
|
|
|
|
#if !NO_DEEP_CANCELLATION
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
[GenerateAsyncOverload]
|
|
|
private static ValueTask<double?> SumAwaitWithCancellationAsyncCore<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, ValueTask<double?>> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
@@ -1174,6 +1129,7 @@ namespace System.Linq
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+#if INCLUDE_SYSTEM_LINQ_ASYNCENUMERABLE_DUPLICATES
|
|
|
/// <summary>
|
|
|
/// Computes the sum of a sequence of <see cref="Nullable{Decimal}" /> values.
|
|
|
/// </summary>
|
|
@@ -1201,6 +1157,7 @@ namespace System.Linq
|
|
|
return sum;
|
|
|
}
|
|
|
}
|
|
|
+#endif // INCLUDE_SYSTEM_LINQ_ASYNCENUMERABLE_DUPLICATES
|
|
|
|
|
|
/// <summary>
|
|
|
/// Computes the sum of a sequence of <see cref="Nullable{Decimal}" /> values that are obtained by invoking a transform function on each element of the input sequence.
|
|
@@ -1212,6 +1169,7 @@ namespace System.Linq
|
|
|
/// <returns>An async-enumerable sequence containing a single element with the sum of the values in the source sequence.</returns>
|
|
|
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
|
|
|
/// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
public static ValueTask<decimal?> SumAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal?> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -1236,16 +1194,7 @@ namespace System.Linq
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// Computes the sum of a sequence of <see cref="Nullable{Decimal}"/> values that are obtained by invoking a transform function on each element of the source sequence and awaiting the result.
|
|
|
- /// </summary>
|
|
|
- /// <typeparam name="TSource">The type of elements in the source sequence.</typeparam>
|
|
|
- /// <param name="source">A sequence of values that are used to calculate a sum.</param>
|
|
|
- /// <param name="selector">An asynchronous transform function to apply to each element.</param>
|
|
|
- /// <param name="cancellationToken">The optional cancellation token to be used for cancelling the sequence at any time.</param>
|
|
|
- /// <returns>A ValueTask containing the sum of the values in the source sequence.</returns>
|
|
|
- /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is <see langword="null"/>.</exception>
|
|
|
- /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
[GenerateAsyncOverload]
|
|
|
private static ValueTask<decimal?> SumAwaitAsyncCore<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, ValueTask<decimal?>> selector, CancellationToken cancellationToken = default)
|
|
|
{
|
|
@@ -1272,6 +1221,7 @@ namespace System.Linq
|
|
|
}
|
|
|
|
|
|
#if !NO_DEEP_CANCELLATION
|
|
|
+ [Obsolete("Use Select then SumAsync. System.Linq.Async (a community-supported library) has been replaced by the (Microsoft supported) IAsyncEnumerable LINQ in System.Linq.AsyncEnumerable, and its SumAsync method does not include the overloads that take a selector. So you should use Select to perform the projection and then use SumAsync on the resulting sequence.")]
|
|
|
[GenerateAsyncOverload]
|
|
|
private static ValueTask<decimal?> SumAwaitWithCancellationAsyncCore<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, ValueTask<decimal?>> selector, CancellationToken cancellationToken = default)
|
|
|
{
|