-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added
IAsyncEnumerable<T>.ToAsyncEnumerable()
extension method.
Added `AsyncEnumerable<T>.Create` functions. Fixed `AsyncEnumerable<T>.ConfigureAwait(false)` to match behavior of `IAsyncEnumerable<T>ConfigureAwait(false)`. Enabled C#8 for `await foreach` support.
- Loading branch information
1 parent
e69588d
commit d28ec09
Showing
6 changed files
with
605 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
|
||
namespace Proto.Promises.Linq | ||
{ | ||
#if NET47_OR_GREATER || NETSTANDARD2_1_OR_GREATER || NETCOREAPP || UNITY_2021_2_OR_NEWER | ||
/// <summary> | ||
/// Provides extension methods for <see cref="AsyncEnumerable{T}"/>. | ||
/// </summary> | ||
#if !PROTO_PROMISE_DEVELOPER_MODE | ||
[DebuggerNonUserCode, StackTraceHidden] | ||
#endif | ||
public static class AsyncEnumerableExtensions | ||
{ | ||
/// <summary> | ||
/// Convert the <see cref="IAsyncEnumerable{T}"/> <paramref name="source"/> to an <see cref="AsyncEnumerable{T}"/>. | ||
/// </summary> | ||
public static AsyncEnumerable<T> ToAsyncEnumerable<T>(this IAsyncEnumerable<T> source) | ||
{ | ||
return AsyncEnumerable<T>.Create(source, async (_source, writer, cancelationToken) => | ||
{ | ||
await foreach (T item in System.Threading.Tasks.TaskAsyncEnumerableExtensions.WithCancellation(source, cancelationToken.ToCancellationToken()).ConfigureAwait(false)) | ||
{ | ||
await writer.YieldAsync(item); | ||
} | ||
}); | ||
} | ||
} | ||
#endif // NET47_OR_GREATER || NETSTANDARD2_1_OR_GREATER || NETCOREAPP || UNITY_2021_2_OR_NEWER | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.