Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions EnumerableAsyncProcessor.Example/DisposalExample.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#if NET6_0_OR_GREATER
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
Expand Down Expand Up @@ -169,4 +168,3 @@ private static async IAsyncEnumerable<int> GenerateAsyncEnumerable(
}
}
}
#endif
2 changes: 0 additions & 2 deletions EnumerableAsyncProcessor.Example/ProcessInParallelExample.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#if NET6_0_OR_GREATER
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -111,4 +110,3 @@ private static async IAsyncEnumerable<int> GenerateAsyncEnumerable(
}
}
}
#endif
2 changes: 0 additions & 2 deletions EnumerableAsyncProcessor.Example/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ Task<HttpResponseMessage> PingAsync()
}
}

#if NET6_0_OR_GREATER
// Run IAsyncEnumerable examples
Console.WriteLine("\n\n=== Running IAsyncEnumerable Examples ===\n");
await AsyncEnumerableExample.RunExamples();
Expand All @@ -78,4 +77,3 @@ Task<HttpResponseMessage> PingAsync()
// Run disposal pattern examples
Console.WriteLine("\n\n=== Running Disposal Pattern Examples ===\n");
await DisposalExample.RunExamples();
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#if NET6_0_OR_GREATER
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand Down Expand Up @@ -219,4 +218,3 @@ public async Task ProcessInParallel_PreservesExceptionFromTransformation()
await Assert.That(exception.Message).IsEqualTo("Test exception");
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#if NET6_0_OR_GREATER
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -142,7 +141,6 @@ public async Task SelectAsync_ProcessInParallel_WithHighConcurrency_HandlesCorre
await Assert.That(results.OrderBy(x => x)).IsEquivalentTo(Enumerable.Range(1, 50).Select(x => x * 3));
}


[Test]
public async Task ForEachAsync_WithCancellation_StopsProcessing()
{
Expand Down Expand Up @@ -368,4 +366,3 @@ public static async Task<List<T>> ToListAsync<T>(this IAsyncEnumerable<T> source
return list;
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<!-- net8.0 also exercises the pre-net9 completion-order streaming path in ToIAsyncEnumerable -->
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<!-- Do not warn about non-strong named dependencies, as we target .NET (not .NET Framework).
Expand Down
11 changes: 1 addition & 10 deletions EnumerableAsyncProcessor/EnumerableAsyncProcessor.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net8.0;net9.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
Expand All @@ -21,10 +21,6 @@
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>$(MSBuildProjectName).UnitTests, PublicKey=$(PublicKey)</_Parameter1>
Expand All @@ -34,11 +30,6 @@

<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.301" PrivateAssets="All"/>

<PackageReference Include="Polyfill" Version="11.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

</ItemGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@ public async ValueTask DisposeAsync()

protected virtual ValueTask DisposeAsyncCore()
{
#if NET6_0_OR_GREATER
return ValueTask.CompletedTask;
#else
return new ValueTask(Task.CompletedTask);
#endif
}

public void Dispose()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,7 @@ public async ValueTask DisposeAsync()

protected virtual ValueTask DisposeAsyncCore()
{
#if NET6_0_OR_GREATER
return ValueTask.CompletedTask;
#else
return new ValueTask(Task.CompletedTask);
#endif
}

public void Dispose()
Expand Down
34 changes: 0 additions & 34 deletions EnumerableAsyncProcessor/TaskCompletionSource.cs

This file was deleted.

23 changes: 1 addition & 22 deletions EnumerableAsyncProcessor/Validation/ValidationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,15 @@ namespace EnumerableAsyncProcessor.Validation;
internal static class ValidationHelper
{
/// <summary>
/// Validates that an object is not null using modern or fallback methods.
/// Validates that an object is not null.
/// </summary>
/// <typeparam name="T">The type of the object to validate.</typeparam>
/// <param name="value">The value to validate.</param>
/// <param name="paramName">The parameter name for the exception.</param>
/// <exception cref="ArgumentNullException">Thrown when the value is null.</exception>
public static void ThrowIfNull<T>([NotNull] T? value, [CallerArgumentExpression(nameof(value))] string? paramName = null)
{
#if NET6_0_OR_GREATER
ArgumentNullException.ThrowIfNull(value, paramName);
#else
if (value is null)
{
throw new ArgumentNullException(paramName);
}
#endif
}

/// <summary>
Expand All @@ -35,14 +28,7 @@ public static void ThrowIfNull<T>([NotNull] T? value, [CallerArgumentExpression(
/// <exception cref="ArgumentOutOfRangeException">Thrown when the value is negative.</exception>
public static void ThrowIfNegative(int value, [CallerArgumentExpression(nameof(value))] string? paramName = null)
{
#if NET8_0_OR_GREATER
ArgumentOutOfRangeException.ThrowIfNegative(value, paramName);
#else
if (value < 0)
{
throw new ArgumentOutOfRangeException(paramName, value, $"'{paramName}' must be a non-negative value.");
}
#endif
}

/// <summary>
Expand All @@ -53,14 +39,7 @@ public static void ThrowIfNegative(int value, [CallerArgumentExpression(nameof(v
/// <exception cref="ArgumentOutOfRangeException">Thrown when the value is negative or zero.</exception>
public static void ThrowIfNegativeOrZero(int value, [CallerArgumentExpression(nameof(value))] string? paramName = null)
{
#if NET8_0_OR_GREATER
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(value, paramName);
#else
if (value <= 0)
{
throw new ArgumentOutOfRangeException(paramName, value, $"'{paramName}' must be a positive value.");
}
#endif
}

/// <summary>
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Process Multiple Asynchronous Tasks in Various Ways - One at a time / Batched /
Install via Nuget
`Install-Package EnumerableAsyncProcessor`

### Supported frameworks

Version 4 requires .NET 8 or later. The package targets and tests `net8.0`, `net9.0`, and `net10.0`.

## Why I built this

Because I've come across situations where you need to fine tune the rate at which you do things.
Expand Down
Loading