Skip to content

Commit 0e5d91f

Browse files
[WIP] Fixing Task.WhenEach not polyfilled on .NET Standard 2.0 when Microsoft.Bcl.AsyncInterfaces is present or .NET Standard 2.1 (#482)
* allow FeatureAsyncInterfaces to work where supported * enable testing Task.WhenEach polyfill with FeatureAsyncInterface
1 parent 98d6234 commit 0e5d91f

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

src/Polyfill/TaskWhenEachPolyfill.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#if !NET9_0_OR_GREATER && (NET5_0_OR_GREATER || NETCOREAPP3_0_OR_GREATER) && FeatureAsyncInterfaces
2-
1+
#if !NET9_0_OR_GREATER && FeatureAsyncInterfaces
32
namespace Polyfills;
43

54
using System;

src/Tests/PolyfillTests_Task.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -610,8 +610,7 @@ public async Task WaitAsync_InfiniteTimeoutAndNoCancellation_ReturnsOriginalTask
610610

611611
#endregion
612612

613-
#if NET5_0_OR_GREATER || NETCOREAPP3_0_OR_GREATER
614-
613+
#if FeatureAsyncInterfaces
615614
#region WhenEach Tests
616615

617616
[Test]
@@ -882,4 +881,4 @@ async Task<T> ThrowExceptionAsync<T>()
882881

883882
#endregion
884883
}
885-
#endif
884+
#endif

src/Tests/Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<PackageReference Include="ProjectDefaults" PrivateAssets="all" />
1212
<PackageReference Include="ProjectFiles" />
1313
<PackageReference Include="System.Memory" Condition="$(TargetFrameworkIdentifier) == '.NETStandard' or $(TargetFrameworkIdentifier) == '.NETFramework' or $(TargetFramework.StartsWith('netcoreapp'))" />
14+
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Condition="$(TargetFramework.StartsWith('net4')) OR $(TargetFramework) == 'netstandard2.0'"/>
1415
<PackageReference Include="System.ValueTuple" Condition="$(TargetFramework.StartsWith('net46'))" />
1516
<PackageReference Include="System.Net.Http" Condition="$(TargetFramework.StartsWith('net4'))" />
1617
<PackageReference Include="System.Threading.Tasks.Extensions" Condition="$(TargetFramework) == 'netstandard2.0' or $(TargetFramework) == 'netcoreapp2.0' or $(TargetFrameworkIdentifier) == '.NETFramework'" />

0 commit comments

Comments
 (0)