-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove dependency on System.Linq.Async
Added ToListAsync implementation to eliminate dependency on System.Linq.Async, which provided System.Linq.AsyncEnumerable.ToListAsync. System.Linq.Async introduces extension methods to a default (or even mandatory) namespace which conflict with other implementations, see: dotnet/reactive#1057
- Loading branch information
1 parent
3f13132
commit c394f37
Showing
2 changed files
with
22 additions
and
2 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
21 changes: 21 additions & 0 deletions
21
src/Novell.Directory.Ldap.NETStandard/Utilclass/AsyncEnumerableExtensions.cs
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,21 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
public static class AsyncEnumerableExtensions | ||
{ | ||
/// <summary> | ||
/// Asynchronously materializes the subject <see cref="IAsyncEnumerable{T}"/> into a list. | ||
/// </summary> | ||
public static async Task<List<T>> ToListAsync<T>(this IAsyncEnumerable<T> enumerable, CancellationToken cancellationToken = default) | ||
{ | ||
var list = new List<T>(); | ||
await foreach (var element in enumerable.WithCancellation(cancellationToken)) | ||
{ | ||
list.Add(element); | ||
} | ||
|
||
return list; | ||
} | ||
} |