Skip to content

Commit

Permalink
Add shim for code that's moved to TaskExtensions
Browse files Browse the repository at this point in the history
  • Loading branch information
Oren Novotny committed Feb 18, 2019
1 parent 4fd1c93 commit 176fd41
Show file tree
Hide file tree
Showing 38 changed files with 189 additions and 170 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async IAsyncEnumerator<IList<TSource>> Core(CancellationToken cancellationToken)
{
var buffer = new List<TSource>(count);

await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(source, cancellationToken).ConfigureAwait(false))
{
buffer.Add(item);

Expand Down Expand Up @@ -65,7 +65,7 @@ async IAsyncEnumerator<IList<TSource>> Core(CancellationToken cancellationToken)

var index = 0;

await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(source, cancellationToken).ConfigureAwait(false))
{
if (index++ % skip == 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async IAsyncEnumerator<TSource> Core(CancellationToken cancellationToken)

if (err != null)
{
await foreach (var item in err.WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(err, cancellationToken).ConfigureAwait(false))
{
yield return item;
}
Expand Down Expand Up @@ -122,7 +122,7 @@ async IAsyncEnumerator<TSource> Core(CancellationToken cancellationToken)

if (err != null)
{
await foreach (var item in err.WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(err, cancellationToken).ConfigureAwait(false))
{
yield return item;
}
Expand Down Expand Up @@ -181,7 +181,7 @@ async IAsyncEnumerator<TSource> Core(CancellationToken cancellationToken)

if (err != null)
{
await foreach (var item in err.WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(err, cancellationToken).ConfigureAwait(false))
{
yield return item;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public static IAsyncEnumerable<TSource> Concat<TSource>(this IAsyncEnumerable<IA

async IAsyncEnumerator<TSource> Core(CancellationToken cancellationToken)
{
await foreach (var source in sources.WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var source in AsyncEnumerableExtensions.WithCancellation(sources, cancellationToken).ConfigureAwait(false))
{
await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(source, cancellationToken).ConfigureAwait(false))
{
yield return item;
}
Expand All @@ -46,7 +46,7 @@ async IAsyncEnumerator<TSource> Core(CancellationToken cancellationToken)
{
foreach (var source in sources)
{
await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(source, cancellationToken).ConfigureAwait(false))
{
yield return item;
}
Expand All @@ -69,7 +69,7 @@ async IAsyncEnumerator<TSource> Core(CancellationToken cancellationToken)
{
foreach (var source in sources)
{
await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(source, cancellationToken).ConfigureAwait(false))
{
yield return item;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static IAsyncEnumerable<TSource> Defer<TSource>(Func<IAsyncEnumerable<TSo

async IAsyncEnumerator<TSource> Core(CancellationToken cancellationToken)
{
await foreach (var item in factory().WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(factory(), cancellationToken).ConfigureAwait(false))
{
yield return item;
}
Expand All @@ -41,7 +41,7 @@ public static IAsyncEnumerable<TSource> Defer<TSource>(Func<Task<IAsyncEnumerabl

async IAsyncEnumerator<TSource> Core(CancellationToken cancellationToken)
{
await foreach (var item in (await factory().ConfigureAwait(false)).WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation((await factory().ConfigureAwait(false)), cancellationToken).ConfigureAwait(false))
{
yield return item;
}
Expand All @@ -62,7 +62,7 @@ public static IAsyncEnumerable<TSource> Defer<TSource>(Func<CancellationToken, T

async IAsyncEnumerator<TSource> Core(CancellationToken cancellationToken)
{
await foreach (var item in (await factory(cancellationToken).ConfigureAwait(false)).WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation((await factory(cancellationToken).ConfigureAwait(false)), cancellationToken).ConfigureAwait(false))
{
yield return item;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async IAsyncEnumerator<TSource> Core(CancellationToken cancellationToken)

while (queue.Count > 0)
{
await foreach (var item in queue.Dequeue().WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(queue.Dequeue(), cancellationToken).ConfigureAwait(false))
{
queue.Enqueue(selector(item));

Expand Down Expand Up @@ -60,7 +60,7 @@ async IAsyncEnumerator<TSource> Core(CancellationToken cancellationToken)

while (queue.Count > 0)
{
await foreach (var item in queue.Dequeue().WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(queue.Dequeue(), cancellationToken).ConfigureAwait(false))
{
queue.Enqueue(await selector(item).ConfigureAwait(false));

Expand Down Expand Up @@ -92,7 +92,7 @@ async IAsyncEnumerator<TSource> Core(CancellationToken cancellationToken)

while (queue.Count > 0)
{
await foreach (var item in queue.Dequeue().WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(queue.Dequeue(), cancellationToken).ConfigureAwait(false))
{
queue.Enqueue(await selector(item, cancellationToken).ConfigureAwait(false));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async IAsyncEnumerator<TSource> Core(CancellationToken cancellationToken)
{
try
{
await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(source, cancellationToken).ConfigureAwait(false))
{
yield return item;
}
Expand Down Expand Up @@ -54,7 +54,7 @@ async IAsyncEnumerator<TSource> Core(CancellationToken cancellationToken)
{
try
{
await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(source, cancellationToken).ConfigureAwait(false))
{
yield return item;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static IAsyncEnumerable<TSource> IgnoreElements<TSource>(this IAsyncEnume

async IAsyncEnumerator<TSource> Core(CancellationToken cancellationToken)
{
await foreach (var _ in source.WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var _ in AsyncEnumerableExtensions.WithCancellation(source, cancellationToken).ConfigureAwait(false))
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async IAsyncEnumerator<TSource> Core(CancellationToken cancellationToken)
{
while (true)
{
await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(source, cancellationToken).ConfigureAwait(false))
{
yield return item;
}
Expand All @@ -69,7 +69,7 @@ async IAsyncEnumerator<TSource> Core(CancellationToken cancellationToken)
{
for (var i = 0; i < count; i++)
{
await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(source, cancellationToken).ConfigureAwait(false))
{
yield return item;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async IAsyncEnumerator<TAccumulate> Core(CancellationToken cancellationToken)
{
var res = seed;

await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(source, cancellationToken).ConfigureAwait(false))
{
res = accumulator(res, item);

Expand Down Expand Up @@ -159,7 +159,7 @@ async IAsyncEnumerator<TAccumulate> Core(CancellationToken cancellationToken)
{
var res = seed;

await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(source, cancellationToken).ConfigureAwait(false))
{
res = await accumulator(res, item).ConfigureAwait(false);

Expand All @@ -186,7 +186,7 @@ async IAsyncEnumerator<TAccumulate> Core(CancellationToken cancellationToken)
{
var res = seed;

await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(source, cancellationToken).ConfigureAwait(false))
{
res = await accumulator(res, item, cancellationToken).ConfigureAwait(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async IAsyncEnumerator<TSource> Core(CancellationToken cancellationToken)
{
using (var resource = resourceFactory())
{
await foreach (var item in enumerableFactory(resource).WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(enumerableFactory(resource), cancellationToken).ConfigureAwait(false))
{
yield return item;
}
Expand All @@ -52,7 +52,7 @@ async IAsyncEnumerator<TSource> Core(CancellationToken cancellationToken)
{
using (var resource = await resourceFactory().ConfigureAwait(false))
{
await foreach (var item in (await enumerableFactory(resource).ConfigureAwait(false)).WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation((await enumerableFactory(resource).ConfigureAwait(false)), cancellationToken).ConfigureAwait(false))
{
yield return item;
}
Expand All @@ -78,7 +78,7 @@ async IAsyncEnumerator<TSource> Core(CancellationToken cancellationToken)
{
using (var resource = await resourceFactory(cancellationToken).ConfigureAwait(false))
{
await foreach (var item in (await enumerableFactory(resource, cancellationToken).ConfigureAwait(false)).WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation((await enumerableFactory(resource, cancellationToken).ConfigureAwait(false)), cancellationToken).ConfigureAwait(false))
{
yield return item;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ internal static async Task<Set<T>> ToSet<T>(IAsyncEnumerable<T> source, IEqualit
{
var set = new Set<T>(comparer);

await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(source, cancellationToken).ConfigureAwait(false))
{
set.Add(item);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static async ValueTask<TAccumulate> Core(IAsyncEnumerable<TSource> _source, TAcc
{
var acc = _seed;

await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(_source, _cancellationToken).ConfigureAwait(false))
{
acc = _accumulator(acc, item);
}
Expand All @@ -137,7 +137,7 @@ static async ValueTask<TAccumulate> Core(IAsyncEnumerable<TSource> _source, TAcc
{
var acc = _seed;

await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(_source, _cancellationToken).ConfigureAwait(false))
{
acc = await _accumulator(acc, item).ConfigureAwait(false);
}
Expand All @@ -160,7 +160,7 @@ static async ValueTask<TAccumulate> Core(IAsyncEnumerable<TSource> _source, TAcc
{
var acc = _seed;

await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(_source, _cancellationToken).ConfigureAwait(false))
{
acc = await _accumulator(acc, item, _cancellationToken).ConfigureAwait(false);
}
Expand All @@ -185,7 +185,7 @@ static async ValueTask<TResult> Core(IAsyncEnumerable<TSource> _source, TAccumul
{
var acc = _seed;

await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(_source, _cancellationToken).ConfigureAwait(false))
{
acc = _accumulator(acc, item);
}
Expand All @@ -209,7 +209,7 @@ static async ValueTask<TResult> Core(IAsyncEnumerable<TSource> _source, TAccumul
{
var acc = _seed;

await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(_source, _cancellationToken).ConfigureAwait(false))
{
acc = await _accumulator(acc, item).ConfigureAwait(false);
}
Expand All @@ -234,7 +234,7 @@ static async ValueTask<TResult> Core(IAsyncEnumerable<TSource> _source, TAccumul
{
var acc = _seed;

await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(_source, _cancellationToken).ConfigureAwait(false))
{
acc = await _accumulator(acc, item, _cancellationToken).ConfigureAwait(false);
}
Expand Down
6 changes: 3 additions & 3 deletions Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static ValueTask<bool> AllAsync<TSource>(this IAsyncEnumerable<TSource> s

static async ValueTask<bool> Core(IAsyncEnumerable<TSource> _source, Func<TSource, bool> _predicate, CancellationToken _cancellationToken)
{
await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(_source, _cancellationToken).ConfigureAwait(false))
{
if (!_predicate(item))
{
Expand All @@ -44,7 +44,7 @@ public static ValueTask<bool> AllAsync<TSource>(this IAsyncEnumerable<TSource> s

static async ValueTask<bool> Core(IAsyncEnumerable<TSource> _source, Func<TSource, ValueTask<bool>> _predicate, CancellationToken _cancellationToken)
{
await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(_source, _cancellationToken).ConfigureAwait(false))
{
if (!await _predicate(item).ConfigureAwait(false))
{
Expand All @@ -68,7 +68,7 @@ public static ValueTask<bool> AllAsync<TSource>(this IAsyncEnumerable<TSource> s

static async ValueTask<bool> Core(IAsyncEnumerable<TSource> _source, Func<TSource, CancellationToken, ValueTask<bool>> _predicate, CancellationToken _cancellationToken)
{
await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
await foreach (var item in AsyncEnumerableExtensions.WithCancellation(_source, _cancellationToken).ConfigureAwait(false))
{
if (!await _predicate(item, _cancellationToken).ConfigureAwait(false))
{
Expand Down
Loading

0 comments on commit 176fd41

Please sign in to comment.