Skip to content

Commit

Permalink
Remove USE_AWAIT_FOREACH (always on now).
Browse files Browse the repository at this point in the history
  • Loading branch information
bartdesmet committed Feb 13, 2019
1 parent e7fa52d commit d5aa7e2
Show file tree
Hide file tree
Showing 23 changed files with 0 additions and 2,102 deletions.
4 changes: 0 additions & 4 deletions Ix.NET/Source/Directory.build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
<DefineConstants>$(DefineConstants);USE_ASYNC_ITERATOR;HAS_ASYNCENUMERABLE;HAS_ASYNCDISPOSABLE;BCL_HAS_CONFIGUREAWAIT</DefineConstants>
</PropertyGroup>

<PropertyGroup>
<DefineConstants>$(DefineConstants);USE_AWAIT_FOREACH</DefineConstants>
</PropertyGroup>

<PropertyGroup>
<Product>$(AssemblyName) ($(TargetFramework))</Product>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,26 +112,10 @@ internal static async Task<Set<T>> ToSet<T>(IAsyncEnumerable<T> source, IEqualit
{
var set = new Set<T>(comparer);

#if USE_AWAIT_FOREACH
await foreach (T item in source.WithCancellation(cancellationToken).ConfigureAwait(false))
{
set.Add(item);
}
#else
var e = source.GetAsyncEnumerator(cancellationToken);

try
{
while (await e.MoveNextAsync().ConfigureAwait(false))
{
set.Add(e.Current);
}
}
finally
{
await e.DisposeAsync().ConfigureAwait(false);
}
#endif

return set;
}
Expand Down
96 changes: 0 additions & 96 deletions Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,26 +133,10 @@ static async Task<TAccumulate> Core(IAsyncEnumerable<TSource> _source, TAccumula
{
var acc = _seed;

#if USE_AWAIT_FOREACH
await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
{
acc = _accumulator(acc, item);
}
#else
var e = _source.GetAsyncEnumerator(_cancellationToken);

try
{
while (await e.MoveNextAsync().ConfigureAwait(false))
{
acc = _accumulator(acc, e.Current);
}
}
finally
{
await e.DisposeAsync().ConfigureAwait(false);
}
#endif

return acc;
}
Expand All @@ -171,26 +155,10 @@ static async Task<TAccumulate> Core(IAsyncEnumerable<TSource> _source, TAccumula
{
var acc = _seed;

#if USE_AWAIT_FOREACH
await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
{
acc = await _accumulator(acc, item).ConfigureAwait(false);
}
#else
var e = _source.GetAsyncEnumerator(_cancellationToken);

try
{
while (await e.MoveNextAsync().ConfigureAwait(false))
{
acc = await _accumulator(acc, e.Current).ConfigureAwait(false);
}
}
finally
{
await e.DisposeAsync().ConfigureAwait(false);
}
#endif

return acc;
}
Expand All @@ -210,26 +178,10 @@ static async Task<TAccumulate> Core(IAsyncEnumerable<TSource> _source, TAccumula
{
var acc = _seed;

#if USE_AWAIT_FOREACH
await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
{
acc = await _accumulator(acc, item, _cancellationToken).ConfigureAwait(false);
}
#else
var e = _source.GetAsyncEnumerator(_cancellationToken);

try
{
while (await e.MoveNextAsync().ConfigureAwait(false))
{
acc = await _accumulator(acc, e.Current, _cancellationToken).ConfigureAwait(false);
}
}
finally
{
await e.DisposeAsync().ConfigureAwait(false);
}
#endif

return acc;
}
Expand All @@ -251,26 +203,10 @@ static async Task<TResult> Core(IAsyncEnumerable<TSource> _source, TAccumulate _
{
var acc = _seed;

#if USE_AWAIT_FOREACH
await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
{
acc = _accumulator(acc, item);
}
#else
var e = _source.GetAsyncEnumerator(_cancellationToken);

try
{
while (await e.MoveNextAsync().ConfigureAwait(false))
{
acc = _accumulator(acc, e.Current);
}
}
finally
{
await e.DisposeAsync().ConfigureAwait(false);
}
#endif

return _resultSelector(acc);
}
Expand All @@ -291,26 +227,10 @@ static async Task<TResult> Core(IAsyncEnumerable<TSource> _source, TAccumulate _
{
var acc = _seed;

#if USE_AWAIT_FOREACH
await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
{
acc = await _accumulator(acc, item).ConfigureAwait(false);
}
#else
var e = _source.GetAsyncEnumerator(_cancellationToken);

try
{
while (await e.MoveNextAsync().ConfigureAwait(false))
{
acc = await _accumulator(acc, e.Current).ConfigureAwait(false);
}
}
finally
{
await e.DisposeAsync().ConfigureAwait(false);
}
#endif

return await _resultSelector(acc).ConfigureAwait(false);
}
Expand All @@ -332,26 +252,10 @@ static async Task<TResult> Core(IAsyncEnumerable<TSource> _source, TAccumulate _
{
var acc = _seed;

#if USE_AWAIT_FOREACH
await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
{
acc = await _accumulator(acc, item, _cancellationToken).ConfigureAwait(false);
}
#else
var e = _source.GetAsyncEnumerator(_cancellationToken);

try
{
while (await e.MoveNextAsync().ConfigureAwait(false))
{
acc = await _accumulator(acc, e.Current, _cancellationToken).ConfigureAwait(false);
}
}
finally
{
await e.DisposeAsync().ConfigureAwait(false);
}
#endif

return await _resultSelector(acc, _cancellationToken).ConfigureAwait(false);
}
Expand Down
51 changes: 0 additions & 51 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,30 +21,13 @@ public static Task<bool> AllAsync<TSource>(this IAsyncEnumerable<TSource> source

static async Task<bool> Core(IAsyncEnumerable<TSource> _source, Func<TSource, bool> _predicate, CancellationToken _cancellationToken)
{
#if USE_AWAIT_FOREACH
await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
{
if (!_predicate(item))
{
return false;
}
}
#else
var e = _source.GetAsyncEnumerator(_cancellationToken);

try
{
while (await e.MoveNextAsync().ConfigureAwait(false))
{
if (!_predicate(e.Current))
return false;
}
}
finally
{
await e.DisposeAsync().ConfigureAwait(false);
}
#endif

return true;
}
Expand All @@ -61,30 +44,13 @@ public static Task<bool> AllAsync<TSource>(this IAsyncEnumerable<TSource> source

static async Task<bool> Core(IAsyncEnumerable<TSource> _source, Func<TSource, ValueTask<bool>> _predicate, CancellationToken _cancellationToken)
{
#if USE_AWAIT_FOREACH
await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
{
if (!await _predicate(item).ConfigureAwait(false))
{
return false;
}
}
#else
var e = _source.GetAsyncEnumerator(_cancellationToken);

try
{
while (await e.MoveNextAsync().ConfigureAwait(false))
{
if (!await _predicate(e.Current).ConfigureAwait(false))
return false;
}
}
finally
{
await e.DisposeAsync().ConfigureAwait(false);
}
#endif

return true;
}
Expand All @@ -102,30 +68,13 @@ public static Task<bool> AllAsync<TSource>(this IAsyncEnumerable<TSource> source

static async Task<bool> Core(IAsyncEnumerable<TSource> _source, Func<TSource, CancellationToken, ValueTask<bool>> _predicate, CancellationToken _cancellationToken)
{
#if USE_AWAIT_FOREACH
await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
{
if (!await _predicate(item, _cancellationToken).ConfigureAwait(false))
{
return false;
}
}
#else
var e = _source.GetAsyncEnumerator(_cancellationToken);

try
{
while (await e.MoveNextAsync().ConfigureAwait(false))
{
if (!await _predicate(e.Current, _cancellationToken).ConfigureAwait(false))
return false;
}
}
finally
{
await e.DisposeAsync().ConfigureAwait(false);
}
#endif

return true;
}
Expand Down
51 changes: 0 additions & 51 deletions Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,13 @@ public static Task<bool> AnyAsync<TSource>(this IAsyncEnumerable<TSource> source

static async Task<bool> Core(IAsyncEnumerable<TSource> _source, Func<TSource, bool> _predicate, CancellationToken _cancellationToken)
{
#if USE_AWAIT_FOREACH
await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
{
if (_predicate(item))
{
return true;
}
}
#else
var e = _source.GetAsyncEnumerator(_cancellationToken);

try
{
while (await e.MoveNextAsync().ConfigureAwait(false))
{
if (_predicate(e.Current))
return true;
}
}
finally
{
await e.DisposeAsync().ConfigureAwait(false);
}
#endif

return false;
}
Expand All @@ -83,30 +66,13 @@ public static Task<bool> AnyAsync<TSource>(this IAsyncEnumerable<TSource> source

static async Task<bool> Core(IAsyncEnumerable<TSource> _source, Func<TSource, ValueTask<bool>> _predicate, CancellationToken _cancellationToken)
{
#if USE_AWAIT_FOREACH
await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
{
if (await _predicate(item).ConfigureAwait(false))
{
return true;
}
}
#else
var e = _source.GetAsyncEnumerator(_cancellationToken);

try
{
while (await e.MoveNextAsync().ConfigureAwait(false))
{
if (await _predicate(e.Current).ConfigureAwait(false))
return true;
}
}
finally
{
await e.DisposeAsync().ConfigureAwait(false);
}
#endif

return false;
}
Expand All @@ -124,30 +90,13 @@ public static Task<bool> AnyAsync<TSource>(this IAsyncEnumerable<TSource> source

static async Task<bool> Core(IAsyncEnumerable<TSource> _source, Func<TSource, CancellationToken, ValueTask<bool>> _predicate, CancellationToken _cancellationToken)
{
#if USE_AWAIT_FOREACH
await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
{
if (await _predicate(item, _cancellationToken).ConfigureAwait(false))
{
return true;
}
}
#else
var e = _source.GetAsyncEnumerator(_cancellationToken);

try
{
while (await e.MoveNextAsync().ConfigureAwait(false))
{
if (await _predicate(e.Current, _cancellationToken).ConfigureAwait(false))
return true;
}
}
finally
{
await e.DisposeAsync().ConfigureAwait(false);
}
#endif

return false;
}
Expand Down
Loading

0 comments on commit d5aa7e2

Please sign in to comment.