Skip to content

Commit c1e7400

Browse files
thomhurstclaude
andcommitted
refactor: Remove NET6.0+ conditionals for IAsyncEnumerable support
- Add Microsoft.Bcl.AsyncInterfaces 6.0.0 package for netstandard2.0 - Remove all #if NET6_0_OR_GREATER conditionals from IAsyncEnumerable code - Make ProcessInParallel and other async enumerable extensions available for all target frameworks - This enables IAsyncEnumerable support across all framework targets 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent af0f064 commit c1e7400

13 files changed

+14
-36
lines changed

EnumerableAsyncProcessor.Example/ProcessInParallelExample.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ public static async Task RunExample()
1717
Console.WriteLine("====================================\n");
1818

1919
// Example 1: Simple parallel processing without transformation
20-
Console.WriteLine("Example 1: Simple parallel processing");
20+
Console.WriteLine("Example 1: Simple parallel processing (no transformation needed!)");
2121
var asyncEnumerable1 = GenerateAsyncEnumerable(5);
22-
var results1 = await asyncEnumerable1.ProcessInParallel();
22+
IEnumerable<int> results1 = await asyncEnumerable1.ProcessInParallel(); // <-- This is the simple extension!
2323
Console.WriteLine($"Results: {string.Join(", ", results1)}");
2424

2525
// Example 2: Parallel processing with transformation

EnumerableAsyncProcessor/Builders/AsyncEnumerableActionAsyncProcessorBuilder_1.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#if NET6_0_OR_GREATER
21
using EnumerableAsyncProcessor.Extensions;
32
using EnumerableAsyncProcessor.RunnableProcessors.AsyncEnumerable;
43

@@ -92,5 +91,4 @@ public IAsyncEnumerableProcessor ProcessInBatches(int batchSize)
9291
_items, _taskSelector, batchSize, _cancellationTokenSource);
9392
}
9493

95-
}
96-
#endif
94+
}

EnumerableAsyncProcessor/Builders/AsyncEnumerableActionAsyncProcessorBuilder_2.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#if NET6_0_OR_GREATER
21
using EnumerableAsyncProcessor.Extensions;
32
using EnumerableAsyncProcessor.RunnableProcessors.AsyncEnumerable.ResultProcessors;
43

@@ -92,5 +91,4 @@ public IAsyncEnumerableProcessor<TOutput> ProcessInBatches(int batchSize)
9291
_items, _taskSelector, batchSize, _cancellationTokenSource);
9392
}
9493

95-
}
96-
#endif
94+
}

EnumerableAsyncProcessor/Builders/AsyncEnumerableAsyncProcessorBuilder.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#if NET6_0_OR_GREATER
21
namespace EnumerableAsyncProcessor.Builders;
32

43
public class AsyncEnumerableAsyncProcessorBuilder<TInput>
@@ -35,5 +34,4 @@ public AsyncEnumerableActionAsyncProcessorBuilder<TInput> ForEachAsync(
3534
{
3635
return new AsyncEnumerableActionAsyncProcessorBuilder<TInput>(_items, taskSelector, cancellationToken);
3736
}
38-
}
39-
#endif
37+
}

EnumerableAsyncProcessor/EnumerableAsyncProcessor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
2222
</PropertyGroup>
2323

24-
<ItemGroup Condition="'$(TargetFrameworkIdentifier)'!='.NETCoreApp'">
24+
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
2525
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
2626
</ItemGroup>
2727

EnumerableAsyncProcessor/Extensions/AsyncEnumerableExtensions.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#if NET6_0_OR_GREATER
21
using EnumerableAsyncProcessor.Builders;
32

43
namespace EnumerableAsyncProcessor.Extensions;
@@ -222,5 +221,4 @@ public static async Task<IEnumerable<TOutput>> ProcessInParallel<T, TOutput>(
222221

223222
return results;
224223
}
225-
}
226-
#endif
224+
}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#if NET6_0_OR_GREATER
21
namespace EnumerableAsyncProcessor.Extensions;
32

43
public interface IAsyncEnumerableProcessor
@@ -9,5 +8,4 @@ public interface IAsyncEnumerableProcessor
98
public interface IAsyncEnumerableProcessor<TOutput>
109
{
1110
IAsyncEnumerable<TOutput> ExecuteAsync();
12-
}
13-
#endif
11+
}

EnumerableAsyncProcessor/RunnableProcessors/AsyncEnumerable/AsyncEnumerableBatchProcessor.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#if NET6_0_OR_GREATER
21
using EnumerableAsyncProcessor.Extensions;
32

43
namespace EnumerableAsyncProcessor.RunnableProcessors.AsyncEnumerable;
@@ -50,5 +49,4 @@ private async Task ProcessBatch(List<TInput> batch, CancellationToken cancellati
5049
var tasks = batch.Select(item => _taskSelector(item)).ToArray();
5150
await Task.WhenAll(tasks).ConfigureAwait(false);
5251
}
53-
}
54-
#endif
52+
}

EnumerableAsyncProcessor/RunnableProcessors/AsyncEnumerable/AsyncEnumerableOneAtATimeProcessor.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#if NET6_0_OR_GREATER
21
using EnumerableAsyncProcessor.Extensions;
32

43
namespace EnumerableAsyncProcessor.RunnableProcessors.AsyncEnumerable;
@@ -31,5 +30,4 @@ public async Task ExecuteAsync()
3130
await _taskSelector(item).ConfigureAwait(false);
3231
}
3332
}
34-
}
35-
#endif
33+
}

EnumerableAsyncProcessor/RunnableProcessors/AsyncEnumerable/AsyncEnumerableParallelProcessor.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#if NET6_0_OR_GREATER
21
using EnumerableAsyncProcessor.Extensions;
32

43
namespace EnumerableAsyncProcessor.RunnableProcessors.AsyncEnumerable;
@@ -94,5 +93,4 @@ public async Task ExecuteAsync()
9493
}
9594
}
9695
}
97-
}
98-
#endif
96+
}

0 commit comments

Comments
 (0)