Skip to content

Commit d5aa7e2

Browse files
committed
Remove USE_AWAIT_FOREACH (always on now).
1 parent e7fa52d commit d5aa7e2

23 files changed

+0
-2102
lines changed

Ix.NET/Source/Directory.build.targets

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
<DefineConstants>$(DefineConstants);USE_ASYNC_ITERATOR;HAS_ASYNCENUMERABLE;HAS_ASYNCDISPOSABLE;BCL_HAS_CONFIGUREAWAIT</DefineConstants>
2020
</PropertyGroup>
2121

22-
<PropertyGroup>
23-
<DefineConstants>$(DefineConstants);USE_AWAIT_FOREACH</DefineConstants>
24-
</PropertyGroup>
25-
2622
<PropertyGroup>
2723
<Product>$(AssemblyName) ($(TargetFramework))</Product>
2824
</PropertyGroup>

Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -112,26 +112,10 @@ internal static async Task<Set<T>> ToSet<T>(IAsyncEnumerable<T> source, IEqualit
112112
{
113113
var set = new Set<T>(comparer);
114114

115-
#if USE_AWAIT_FOREACH
116115
await foreach (T item in source.WithCancellation(cancellationToken).ConfigureAwait(false))
117116
{
118117
set.Add(item);
119118
}
120-
#else
121-
var e = source.GetAsyncEnumerator(cancellationToken);
122-
123-
try
124-
{
125-
while (await e.MoveNextAsync().ConfigureAwait(false))
126-
{
127-
set.Add(e.Current);
128-
}
129-
}
130-
finally
131-
{
132-
await e.DisposeAsync().ConfigureAwait(false);
133-
}
134-
#endif
135119

136120
return set;
137121
}

Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -133,26 +133,10 @@ static async Task<TAccumulate> Core(IAsyncEnumerable<TSource> _source, TAccumula
133133
{
134134
var acc = _seed;
135135

136-
#if USE_AWAIT_FOREACH
137136
await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
138137
{
139138
acc = _accumulator(acc, item);
140139
}
141-
#else
142-
var e = _source.GetAsyncEnumerator(_cancellationToken);
143-
144-
try
145-
{
146-
while (await e.MoveNextAsync().ConfigureAwait(false))
147-
{
148-
acc = _accumulator(acc, e.Current);
149-
}
150-
}
151-
finally
152-
{
153-
await e.DisposeAsync().ConfigureAwait(false);
154-
}
155-
#endif
156140

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

174-
#if USE_AWAIT_FOREACH
175158
await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
176159
{
177160
acc = await _accumulator(acc, item).ConfigureAwait(false);
178161
}
179-
#else
180-
var e = _source.GetAsyncEnumerator(_cancellationToken);
181-
182-
try
183-
{
184-
while (await e.MoveNextAsync().ConfigureAwait(false))
185-
{
186-
acc = await _accumulator(acc, e.Current).ConfigureAwait(false);
187-
}
188-
}
189-
finally
190-
{
191-
await e.DisposeAsync().ConfigureAwait(false);
192-
}
193-
#endif
194162

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

213-
#if USE_AWAIT_FOREACH
214181
await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
215182
{
216183
acc = await _accumulator(acc, item, _cancellationToken).ConfigureAwait(false);
217184
}
218-
#else
219-
var e = _source.GetAsyncEnumerator(_cancellationToken);
220-
221-
try
222-
{
223-
while (await e.MoveNextAsync().ConfigureAwait(false))
224-
{
225-
acc = await _accumulator(acc, e.Current, _cancellationToken).ConfigureAwait(false);
226-
}
227-
}
228-
finally
229-
{
230-
await e.DisposeAsync().ConfigureAwait(false);
231-
}
232-
#endif
233185

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

254-
#if USE_AWAIT_FOREACH
255206
await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
256207
{
257208
acc = _accumulator(acc, item);
258209
}
259-
#else
260-
var e = _source.GetAsyncEnumerator(_cancellationToken);
261-
262-
try
263-
{
264-
while (await e.MoveNextAsync().ConfigureAwait(false))
265-
{
266-
acc = _accumulator(acc, e.Current);
267-
}
268-
}
269-
finally
270-
{
271-
await e.DisposeAsync().ConfigureAwait(false);
272-
}
273-
#endif
274210

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

294-
#if USE_AWAIT_FOREACH
295230
await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
296231
{
297232
acc = await _accumulator(acc, item).ConfigureAwait(false);
298233
}
299-
#else
300-
var e = _source.GetAsyncEnumerator(_cancellationToken);
301-
302-
try
303-
{
304-
while (await e.MoveNextAsync().ConfigureAwait(false))
305-
{
306-
acc = await _accumulator(acc, e.Current).ConfigureAwait(false);
307-
}
308-
}
309-
finally
310-
{
311-
await e.DisposeAsync().ConfigureAwait(false);
312-
}
313-
#endif
314234

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

335-
#if USE_AWAIT_FOREACH
336255
await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
337256
{
338257
acc = await _accumulator(acc, item, _cancellationToken).ConfigureAwait(false);
339258
}
340-
#else
341-
var e = _source.GetAsyncEnumerator(_cancellationToken);
342-
343-
try
344-
{
345-
while (await e.MoveNextAsync().ConfigureAwait(false))
346-
{
347-
acc = await _accumulator(acc, e.Current, _cancellationToken).ConfigureAwait(false);
348-
}
349-
}
350-
finally
351-
{
352-
await e.DisposeAsync().ConfigureAwait(false);
353-
}
354-
#endif
355259

356260
return await _resultSelector(acc, _cancellationToken).ConfigureAwait(false);
357261
}

Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,13 @@ public static Task<bool> AllAsync<TSource>(this IAsyncEnumerable<TSource> source
2121

2222
static async Task<bool> Core(IAsyncEnumerable<TSource> _source, Func<TSource, bool> _predicate, CancellationToken _cancellationToken)
2323
{
24-
#if USE_AWAIT_FOREACH
2524
await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
2625
{
2726
if (!_predicate(item))
2827
{
2928
return false;
3029
}
3130
}
32-
#else
33-
var e = _source.GetAsyncEnumerator(_cancellationToken);
34-
35-
try
36-
{
37-
while (await e.MoveNextAsync().ConfigureAwait(false))
38-
{
39-
if (!_predicate(e.Current))
40-
return false;
41-
}
42-
}
43-
finally
44-
{
45-
await e.DisposeAsync().ConfigureAwait(false);
46-
}
47-
#endif
4831

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

6245
static async Task<bool> Core(IAsyncEnumerable<TSource> _source, Func<TSource, ValueTask<bool>> _predicate, CancellationToken _cancellationToken)
6346
{
64-
#if USE_AWAIT_FOREACH
6547
await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
6648
{
6749
if (!await _predicate(item).ConfigureAwait(false))
6850
{
6951
return false;
7052
}
7153
}
72-
#else
73-
var e = _source.GetAsyncEnumerator(_cancellationToken);
74-
75-
try
76-
{
77-
while (await e.MoveNextAsync().ConfigureAwait(false))
78-
{
79-
if (!await _predicate(e.Current).ConfigureAwait(false))
80-
return false;
81-
}
82-
}
83-
finally
84-
{
85-
await e.DisposeAsync().ConfigureAwait(false);
86-
}
87-
#endif
8854

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

10369
static async Task<bool> Core(IAsyncEnumerable<TSource> _source, Func<TSource, CancellationToken, ValueTask<bool>> _predicate, CancellationToken _cancellationToken)
10470
{
105-
#if USE_AWAIT_FOREACH
10671
await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
10772
{
10873
if (!await _predicate(item, _cancellationToken).ConfigureAwait(false))
10974
{
11075
return false;
11176
}
11277
}
113-
#else
114-
var e = _source.GetAsyncEnumerator(_cancellationToken);
115-
116-
try
117-
{
118-
while (await e.MoveNextAsync().ConfigureAwait(false))
119-
{
120-
if (!await _predicate(e.Current, _cancellationToken).ConfigureAwait(false))
121-
return false;
122-
}
123-
}
124-
finally
125-
{
126-
await e.DisposeAsync().ConfigureAwait(false);
127-
}
128-
#endif
12978

13079
return true;
13180
}

Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -43,30 +43,13 @@ public static Task<bool> AnyAsync<TSource>(this IAsyncEnumerable<TSource> source
4343

4444
static async Task<bool> Core(IAsyncEnumerable<TSource> _source, Func<TSource, bool> _predicate, CancellationToken _cancellationToken)
4545
{
46-
#if USE_AWAIT_FOREACH
4746
await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
4847
{
4948
if (_predicate(item))
5049
{
5150
return true;
5251
}
5352
}
54-
#else
55-
var e = _source.GetAsyncEnumerator(_cancellationToken);
56-
57-
try
58-
{
59-
while (await e.MoveNextAsync().ConfigureAwait(false))
60-
{
61-
if (_predicate(e.Current))
62-
return true;
63-
}
64-
}
65-
finally
66-
{
67-
await e.DisposeAsync().ConfigureAwait(false);
68-
}
69-
#endif
7053

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

8467
static async Task<bool> Core(IAsyncEnumerable<TSource> _source, Func<TSource, ValueTask<bool>> _predicate, CancellationToken _cancellationToken)
8568
{
86-
#if USE_AWAIT_FOREACH
8769
await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
8870
{
8971
if (await _predicate(item).ConfigureAwait(false))
9072
{
9173
return true;
9274
}
9375
}
94-
#else
95-
var e = _source.GetAsyncEnumerator(_cancellationToken);
96-
97-
try
98-
{
99-
while (await e.MoveNextAsync().ConfigureAwait(false))
100-
{
101-
if (await _predicate(e.Current).ConfigureAwait(false))
102-
return true;
103-
}
104-
}
105-
finally
106-
{
107-
await e.DisposeAsync().ConfigureAwait(false);
108-
}
109-
#endif
11076

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

12591
static async Task<bool> Core(IAsyncEnumerable<TSource> _source, Func<TSource, CancellationToken, ValueTask<bool>> _predicate, CancellationToken _cancellationToken)
12692
{
127-
#if USE_AWAIT_FOREACH
12893
await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false))
12994
{
13095
if (await _predicate(item, _cancellationToken).ConfigureAwait(false))
13196
{
13297
return true;
13398
}
13499
}
135-
#else
136-
var e = _source.GetAsyncEnumerator(_cancellationToken);
137-
138-
try
139-
{
140-
while (await e.MoveNextAsync().ConfigureAwait(false))
141-
{
142-
if (await _predicate(e.Current, _cancellationToken).ConfigureAwait(false))
143-
return true;
144-
}
145-
}
146-
finally
147-
{
148-
await e.DisposeAsync().ConfigureAwait(false);
149-
}
150-
#endif
151100

152101
return false;
153102
}

0 commit comments

Comments
 (0)