|
@@ -12,6 +12,15 @@ namespace System.Linq
|
|
|
{
|
|
|
// REVIEW: Should we convert Task-based overloads to ValueTask?
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Invokes an action for each element in the observable sequence, and propagates all observer messages through the result sequence.
|
|
|
+ /// This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
|
|
|
+ /// <param name="source">Source sequence.</param>
|
|
|
+ /// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
|
|
|
+ /// <returns>The source sequence with the side-effecting behavior applied.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="onNext"/> is null.</exception>
|
|
|
public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource> onNext)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -22,6 +31,16 @@ namespace System.Linq
|
|
|
return DoCore(source, onNext: onNext, onError: null, onCompleted: null);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Invokes an action for each element in the observable sequence and invokes an action upon graceful termination of the observable sequence.
|
|
|
+ /// This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
|
|
|
+ /// <param name="source">Source sequence.</param>
|
|
|
+ /// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
|
|
|
+ /// <param name="onCompleted">Action to invoke upon graceful termination of the observable sequence.</param>
|
|
|
+ /// <returns>The source sequence with the side-effecting behavior applied.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="onNext"/> or <paramref name="onCompleted"/> is null.</exception>
|
|
|
public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource> onNext, Action onCompleted)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -34,6 +53,16 @@ namespace System.Linq
|
|
|
return DoCore(source, onNext: onNext, onError: null, onCompleted: onCompleted);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Invokes an action for each element in the observable sequence and invokes an action upon exceptional termination of the observable sequence.
|
|
|
+ /// This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
|
|
|
+ /// <param name="source">Source sequence.</param>
|
|
|
+ /// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
|
|
|
+ /// <param name="onError">Action to invoke upon exceptional termination of the observable sequence.</param>
|
|
|
+ /// <returns>The source sequence with the side-effecting behavior applied.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="onNext"/> or <paramref name="onError"/> is null.</exception>
|
|
|
public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource> onNext, Action<Exception> onError)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -46,6 +75,17 @@ namespace System.Linq
|
|
|
return DoCore(source, onNext: onNext, onError: onError, onCompleted: null);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence.
|
|
|
+ /// This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
|
|
|
+ /// <param name="source">Source sequence.</param>
|
|
|
+ /// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
|
|
|
+ /// <param name="onError">Action to invoke upon exceptional termination of the observable sequence.</param>
|
|
|
+ /// <param name="onCompleted">Action to invoke upon graceful termination of the observable sequence.</param>
|
|
|
+ /// <returns>The source sequence with the side-effecting behavior applied.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="onNext"/> or <paramref name="onError"/> or <paramref name="onCompleted"/> is null.</exception>
|
|
|
public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource> onNext, Action<Exception> onError, Action onCompleted)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -60,6 +100,15 @@ namespace System.Linq
|
|
|
return DoCore(source, onNext, onError, onCompleted);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Invokes and awaits an asynchronous action for each element in the observable sequence, and propagates all observer messages through the result sequence.
|
|
|
+ /// This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
|
|
|
+ /// <param name="source">Source sequence.</param>
|
|
|
+ /// <param name="onNext">Action to invoke and await for each element in the observable sequence.</param>
|
|
|
+ /// <returns>The source sequence with the side-effecting behavior applied.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="onNext"/> is null.</exception>
|
|
|
public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task> onNext)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -70,6 +119,16 @@ namespace System.Linq
|
|
|
return DoCore(source, onNext: onNext, onError: null, onCompleted: null);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Invokes and awaits an asynchronous action for each element in the observable sequence, then invokes and awaits an asynchronous an action upon graceful termination of the observable sequence.
|
|
|
+ /// This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
|
|
|
+ /// <param name="source">Source sequence.</param>
|
|
|
+ /// <param name="onNext">Action to invoke and await for each element in the observable sequence.</param>
|
|
|
+ /// <param name="onCompleted">Action to invoke and await upon graceful termination of the observable sequence.</param>
|
|
|
+ /// <returns>The source sequence with the side-effecting behavior applied.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="onNext"/> or <paramref name="onCompleted"/> is null.</exception>
|
|
|
public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task> onNext, Func<Task> onCompleted)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -82,6 +141,16 @@ namespace System.Linq
|
|
|
return DoCore(source, onNext: onNext, onError: null, onCompleted: onCompleted);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Invokes and awaits an asynchronous action for each element in the observable sequence, then invokes and awaits an asynchronous action upon exceptional termination of the observable sequence.
|
|
|
+ /// This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
|
|
|
+ /// <param name="source">Source sequence.</param>
|
|
|
+ /// <param name="onNext">Action to invoke and await for each element in the observable sequence.</param>
|
|
|
+ /// <param name="onError">Action to invoke and await upon exceptional termination of the observable sequence.</param>
|
|
|
+ /// <returns>The source sequence with the side-effecting behavior applied.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="onNext"/> or <paramref name="onError"/> is null.</exception>
|
|
|
public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task> onNext, Func<Exception, Task> onError)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -94,6 +163,17 @@ namespace System.Linq
|
|
|
return DoCore(source, onNext: onNext, onError: onError, onCompleted: null);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Invokes and awaits an asynchronous action for each element in the observable sequence, then invokes and awaits an asynchronous action upon graceful or exceptional termination of the observable sequence.
|
|
|
+ /// This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
|
|
|
+ /// <param name="source">Source sequence.</param>
|
|
|
+ /// <param name="onNext">Action to invoke and await for each element in the observable sequence.</param>
|
|
|
+ /// <param name="onError">Action to invoke and await upon exceptional termination of the observable sequence.</param>
|
|
|
+ /// <param name="onCompleted">Action to invoke and await upon graceful termination of the observable sequence.</param>
|
|
|
+ /// <returns>The source sequence with the side-effecting behavior applied.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="onNext"/> or <paramref name="onError"/> or <paramref name="onCompleted"/> is null.</exception>
|
|
|
public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task> onNext, Func<Exception, Task> onError, Func<Task> onCompleted)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -109,6 +189,15 @@ namespace System.Linq
|
|
|
}
|
|
|
|
|
|
#if !NO_DEEP_CANCELLATION
|
|
|
+ /// <summary>
|
|
|
+ /// Invokes and awaits an asynchronous (cancellable) action for each element in the observable sequence, and propagates all observer messages through the result sequence.
|
|
|
+ /// This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
|
|
|
+ /// <param name="source">Source sequence.</param>
|
|
|
+ /// <param name="onNext">Action to invoke and await for each element in the observable sequence while supporting cancellation.</param>
|
|
|
+ /// <returns>The source sequence with the side-effecting behavior applied.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="onNext"/> is null.</exception>
|
|
|
public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, Task> onNext)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -119,6 +208,16 @@ namespace System.Linq
|
|
|
return DoCore(source, onNext: onNext, onError: null, onCompleted: null);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Invokes and awaits an asynchronous (cancellable) action for each element in the observable sequence, then invokes and awaits an asynchronous (cancellable) an action upon graceful termination of the observable sequence.
|
|
|
+ /// This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
|
|
|
+ /// <param name="source">Source sequence.</param>
|
|
|
+ /// <param name="onNext">Action to invoke and await for each element in the observable sequence while supporting cancellation.</param>
|
|
|
+ /// <param name="onCompleted">Action to invoke and await upon graceful termination of the observable sequence while supporting cancellation.</param>
|
|
|
+ /// <returns>The source sequence with the side-effecting behavior applied.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="onNext"/> or <paramref name="onCompleted"/> is null.</exception>
|
|
|
public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, Task> onNext, Func<CancellationToken, Task> onCompleted)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -131,6 +230,16 @@ namespace System.Linq
|
|
|
return DoCore(source, onNext: onNext, onError: null, onCompleted: onCompleted);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Invokes and awaits an asynchronous (cancellable) action for each element in the observable sequence, then invokes and awaits an asynchronous (cancellable) action upon exceptional termination of the observable sequence.
|
|
|
+ /// This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
|
|
|
+ /// <param name="source">Source sequence.</param>
|
|
|
+ /// <param name="onNext">Action to invoke and await for each element in the observable sequence while supporting cancellation.</param>
|
|
|
+ /// <param name="onError">Action to invoke and await upon exceptional termination of the observable sequence while supporting cancellation.</param>
|
|
|
+ /// <returns>The source sequence with the side-effecting behavior applied.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="onNext"/> or <paramref name="onError"/> is null.</exception>
|
|
|
public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, Task> onNext, Func<Exception, CancellationToken, Task> onError)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -143,6 +252,17 @@ namespace System.Linq
|
|
|
return DoCore(source, onNext: onNext, onError: onError, onCompleted: null);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Invokes and awaits an asynchronous (cancellable) action for each element in the observable sequence, then invokes and awaits an asynchronous (cancellable) action upon graceful or exceptional termination of the observable sequence.
|
|
|
+ /// This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
|
|
|
+ /// <param name="source">Source sequence.</param>
|
|
|
+ /// <param name="onNext">Action to invoke and await for each element in the observable sequence while supporting cancellation.</param>
|
|
|
+ /// <param name="onError">Action to invoke and await upon exceptional termination of the observable sequence while supporting cancellation.</param>
|
|
|
+ /// <param name="onCompleted">Action to invoke and await upon graceful termination of the observable sequence while supporting cancellation.</param>
|
|
|
+ /// <returns>The source sequence with the side-effecting behavior applied.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="onNext"/> or <paramref name="onError"/> or <paramref name="onCompleted"/> is null.</exception>
|
|
|
public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, Task> onNext, Func<Exception, CancellationToken, Task> onError, Func<CancellationToken, Task> onCompleted)
|
|
|
{
|
|
|
if (source == null)
|
|
@@ -158,6 +278,15 @@ namespace System.Linq
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Invokes the observer's methods for each message in the source async-enumerable sequence.
|
|
|
+ /// This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
|
|
|
+ /// <param name="source">Source sequence.</param>
|
|
|
+ /// <param name="observer">Observer whose methods to invoke as part of the source sequence's observation.</param>
|
|
|
+ /// <returns>The source sequence with the side-effecting behavior applied.</returns>
|
|
|
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="observer"/> is null.</exception>
|
|
|
public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, IObserver<TSource> observer)
|
|
|
{
|
|
|
if (source == null)
|