Skip to content
Draft
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
36 changes: 10 additions & 26 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<PackageVersion Include="FSharp.Core" Version="8.0.200" />
<PackageVersion Include="GitHubActionsTestLogger" Version="3.0.5" />
<PackageVersion Include="IcedTasks" Version="0.11.4" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="10.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="5.6.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="5.6.0" />
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="10.0.8" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="10.0.13" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.13" />
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="10.11.0" />
Expand All @@ -35,34 +35,18 @@
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
<PackageVersion Include="System.ComponentModel.Annotations" Version="4.5.0" />
<PackageVersion Include="System.Memory" Version="4.6.3" />
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
<PackageVersion Include="System.ValueTuple" Version="4.5.0" />
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.6.3" />
<PackageVersion Include="System.ValueTuple" Version="4.6.1" />
<PackageVersion Include="xunit.v3.assert" Version="4.0.2" />
<PackageVersion Include="xunit.v3.mtp-v2" Version="4.0.2" />
</ItemGroup>
<!-- Dependencies below are pinned for the libraries we ship to NuGet.org -->
<ItemGroup>
<PackageVersion Include="Microsoft.Bcl.TimeProvider" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="8.0.0" />
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="8.0.0" />
<PackageVersion Include="System.Threading.RateLimiting" Version="8.0.0" />
</ItemGroup>
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible($(TargetFramework), 'net9.0'))">
<PackageVersion Update="Microsoft.Bcl.TimeProvider" Version="9.0.0" />
<PackageVersion Update="Microsoft.Extensions.Logging" Version="9.0.0" />
<PackageVersion Update="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />
<PackageVersion Update="Microsoft.Extensions.Options" Version="9.0.0" />
<PackageVersion Update="System.Diagnostics.DiagnosticSource" Version="9.0.0" />
<PackageVersion Update="System.Threading.RateLimiting" Version="9.0.0" />
</ItemGroup>
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible($(TargetFramework), 'net10.0'))">
<PackageVersion Update="Microsoft.Bcl.TimeProvider" Version="10.0.0" />
<PackageVersion Update="Microsoft.Extensions.Logging" Version="10.0.0" />
<PackageVersion Update="Microsoft.Extensions.Logging.Abstractions" Version="10.0.0" />
<PackageVersion Update="Microsoft.Extensions.Options" Version="10.0.0" />
<PackageVersion Update="System.Diagnostics.DiagnosticSource" Version="10.0.0" />
<PackageVersion Update="System.Threading.RateLimiting" Version="10.0.0" />
<PackageVersion Include="Microsoft.Bcl.TimeProvider" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="10.0.0" />
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="10.0.0" />
<PackageVersion Include="System.Threading.RateLimiting" Version="10.0.0" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion bench/Polly.Benchmarks/Polly.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<IsPackable>false</IsPackable>
<OutputType>Exe</OutputType>
<TargetFrameworks>net10.0;net9.0;net8.0</TargetFrameworks>
<TargetFrameworks>net10.0</TargetFrameworks>
<Nullable>enable</Nullable>
<ProjectType>Benchmark</ProjectType>
<NoWarn>$(NoWarn);CA1822;IDE0060</NoWarn>
Expand Down
2 changes: 1 addition & 1 deletion bench/Polly.Core.Benchmarks/Polly.Core.Benchmarks.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net10.0;net9.0;net8.0</TargetFrameworks>
<TargetFrameworks>net10.0</TargetFrameworks>
<RootNamespace>Polly</RootNamespace>
<ImplicitUsings>true</ImplicitUsings>
<ProjectType>Benchmark</ProjectType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ private static bool IsDateTimeOverflow(DateTimeOffset utcNow, TimeSpan breakDura
return breakDuration > maxDifference;
}

#if NET8_0_OR_GREATER
#if NET
private void EnsureNotDisposed()
=> ObjectDisposedException.ThrowIf(_disposed, this);
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public ScheduledTaskExecutor()

public Task ScheduleTask(Func<Task> taskFactory)
{
#if NET8_0_OR_GREATER
#if NET
ObjectDisposedException.ThrowIf(_disposed, this);
#else
if (_disposed)
Expand Down
78 changes: 74 additions & 4 deletions src/Polly.Core/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,92 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/diagnostic-ids -->
<!-- https://learn.microsoft.com/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Polly.CircuitBreaker.BrokenCircuitException.#ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)</Target>
<Left>lib/netstandard2.0/Polly.Core.dll</Left>
<Right>lib/net6.0/Polly.Core.dll</Right>
<Right>lib/net10.0/Polly.Core.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Polly.CircuitBreaker.IsolatedCircuitException.#ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)</Target>
<Left>lib/netstandard2.0/Polly.Core.dll</Left>
<Right>lib/net6.0/Polly.Core.dll</Right>
<Right>lib/net10.0/Polly.Core.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Polly.ExecutionRejectedException.#ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)</Target>
<Left>lib/netstandard2.0/Polly.Core.dll</Left>
<Right>lib/net6.0/Polly.Core.dll</Right>
<Right>lib/net10.0/Polly.Core.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0008</DiagnosticId>
<Target>T:Polly.CircuitBreaker.BrokenCircuitException</Target>
<Left>lib/net462/Polly.Core.dll</Left>
<Right>lib/netstandard2.0/Polly.Core.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0008</DiagnosticId>
<Target>T:Polly.CircuitBreaker.IsolatedCircuitException</Target>
<Left>lib/net462/Polly.Core.dll</Left>
<Right>lib/netstandard2.0/Polly.Core.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0008</DiagnosticId>
<Target>T:Polly.ExecutionRejectedException</Target>
<Left>lib/net462/Polly.Core.dll</Left>
<Right>lib/netstandard2.0/Polly.Core.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0008</DiagnosticId>
<Target>T:Polly.Timeout.TimeoutRejectedException</Target>
<Left>lib/net462/Polly.Core.dll</Left>
<Right>lib/netstandard2.0/Polly.Core.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0008</DiagnosticId>
<Target>T:Polly.CircuitBreaker.CircuitState</Target>
<Left>lib/net6.0/Polly.Core.dll</Left>
<Right>lib/netstandard2.0/Polly.Core.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0008</DiagnosticId>
<Target>T:Polly.DelayBackoffType</Target>
<Left>lib/net6.0/Polly.Core.dll</Left>
<Right>lib/netstandard2.0/Polly.Core.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0008</DiagnosticId>
<Target>T:Polly.Telemetry.ResilienceEventSeverity</Target>
<Left>lib/net6.0/Polly.Core.dll</Left>
<Right>lib/netstandard2.0/Polly.Core.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0008</DiagnosticId>
<Target>T:Polly.CircuitBreaker.CircuitState</Target>
<Left>lib/net8.0/Polly.Core.dll</Left>
<Right>lib/netstandard2.0/Polly.Core.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0008</DiagnosticId>
<Target>T:Polly.DelayBackoffType</Target>
<Left>lib/net8.0/Polly.Core.dll</Left>
<Right>lib/netstandard2.0/Polly.Core.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0008</DiagnosticId>
<Target>T:Polly.Telemetry.ResilienceEventSeverity</Target>
<Left>lib/net8.0/Polly.Core.dll</Left>
<Right>lib/netstandard2.0/Polly.Core.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
</Suppressions>
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public async ValueTask DisposeAsync()
return task;
}

#if NET8_0_OR_GREATER
#if NET
var whenAnyHedgedTask = WaitForTaskCompetitionAsync();
await whenAnyHedgedTask.WaitAsync(hedgingDelay, _timeProvider, PrimaryContext!.CancellationToken)
.ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing | (ContinueOnCapturedContext ? ConfigureAwaitOptions.ContinueOnCapturedContext : 0));
Expand Down
8 changes: 4 additions & 4 deletions src/Polly.Core/Polly.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net10.0;net8.0;net6.0;netstandard2.0;net472;net462</TargetFrameworks>
<TargetFrameworks>net10.0;netstandard2.0;net472</TargetFrameworks>
<AssemblyTitle>Polly.Core</AssemblyTitle>
<RootNamespace>Polly</RootNamespace>
<Nullable>enable</Nullable>
Expand All @@ -11,7 +11,7 @@
<LegacySupport>true</LegacySupport>
<InjectSharedSources>true</InjectSharedSources>
</PropertyGroup>
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net10.0'))">
<IsAotCompatible>true</IsAotCompatible>
</PropertyGroup>

Expand All @@ -30,13 +30,13 @@

<ItemGroup>
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Condition="!$([MSBuild]::IsTargetFrameworkCompatible($(TargetFramework), 'netcoreapp3.1'))" />
<PackageReference Include="Microsoft.Bcl.TimeProvider" Condition="!$([MSBuild]::IsTargetFrameworkCompatible($(TargetFramework), 'net8.0'))" />
<PackageReference Include="Microsoft.Bcl.TimeProvider" Condition="!$([MSBuild]::IsTargetFrameworkCompatible($(TargetFramework), 'net10.0'))" />
<PackageReference Include="System.Threading.Tasks.Extensions" Condition="!$([MSBuild]::IsTargetFrameworkCompatible($(TargetFramework), 'netcoreapp3.1'))" />
<PackageReference Include="System.ValueTuple" Condition="$([MSBuild]::GetTargetFrameworkIdentifier('$(TargetFramework)')) == '.NETFramework'" />
<PackageReference Include="System.ComponentModel.Annotations" Condition="!$([MSBuild]::IsTargetFrameworkCompatible($(TargetFramework), 'netcoreapp3.1'))" />
</ItemGroup>

<ItemGroup Condition="!$([MSBuild]::IsTargetFrameworkCompatible($(TargetFramework), 'net9.0'))">
<ItemGroup Condition="!$([MSBuild]::IsTargetFrameworkCompatible($(TargetFramework), 'net10.0'))">
<Compile Include="$(MSBuildThisFileDirectory)..\Shared\DebuggerDisableUserUnhandledExceptionsAttribute.cs" Link="DebuggerDisableUserUnhandledExceptionsAttribute.cs" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace Polly.Utils;

internal abstract partial class CancellationTokenSourcePool
{
#if !NET8_0_OR_GREATER
#if !NET
private sealed class DisposableCancellationTokenSourcePool : CancellationTokenSourcePool
{
private readonly TimeProvider _timeProvider;
Expand Down
4 changes: 0 additions & 4 deletions src/Polly.Core/Utils/CancellationTokenSourcePool.Pooled.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ internal sealed class PooledCancellationTokenSourcePool : CancellationTokenSourc
public PooledCancellationTokenSourcePool(TimeProvider timeProvider) => _pool = new(
() =>
{
#if NET8_0_OR_GREATER
return new CancellationTokenSource(System.Threading.Timeout.InfiniteTimeSpan, timeProvider);
#else
return new CancellationTokenSource();
#endif
},
static cts => true);

Expand Down
9 changes: 1 addition & 8 deletions src/Polly.Core/Utils/CancellationTokenSourcePool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,13 @@ internal abstract partial class CancellationTokenSourcePool
{
public static CancellationTokenSourcePool Create(TimeProvider timeProvider)
{
#if NET8_0_OR_GREATER
#if NET
if (timeProvider == TimeProvider.System)
{
return PooledCancellationTokenSourcePool.SystemInstance;
}

return new PooledCancellationTokenSourcePool(timeProvider);
#elif NET6_0_OR_GREATER
if (timeProvider == TimeProvider.System)
{
return PooledCancellationTokenSourcePool.SystemInstance;
}

return new DisposableCancellationTokenSourcePool(timeProvider);
#else
return new DisposableCancellationTokenSourcePool(timeProvider);
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/Polly.Core/Utils/Guard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal static class Guard
public static T NotNull<T>(T value, [CallerArgumentExpression("value")] string argumentName = "")
where T : class
{
#if NET8_0_OR_GREATER
#if NET
ArgumentNullException.ThrowIfNull(value, argumentName);
#else
if (value is null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public override async ValueTask DisposeAsync()
// so we will do "dummy" retries until there are no more executions.
while (HasPendingExecutions)
{
#if NET8_0_OR_GREATER
#if NET
await Task.Delay(SleepDelay, _timeProvider).ConfigureAwait(false);
#else
await _timeProvider.Delay(SleepDelay).ConfigureAwait(false);
Expand Down
4 changes: 2 additions & 2 deletions src/Polly.Core/Utils/TimeProviderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static Task DelayAsync(this TimeProvider timeProvider, TimeSpan delay, Re
// the use of Thread.Sleep() here because it is not cancellable and to
// simplify the code. Sync-over-async is not a concern here because it
// only applies in the case of a resilience event and not on the hot path.
#if NET8_0_OR_GREATER
#if NET
Task.Delay(delay, timeProvider, context.CancellationToken).GetAwaiter().GetResult();
#else
timeProvider.Delay(delay, context.CancellationToken).GetAwaiter().GetResult();
Expand All @@ -45,7 +45,7 @@ public static Task DelayAsync(this TimeProvider timeProvider, TimeSpan delay, Re
return Task.CompletedTask;
}

#if NET8_0_OR_GREATER
#if NET
return Task.Delay(delay, timeProvider, context.CancellationToken);
#else
return timeProvider.Delay(delay, context.CancellationToken);
Expand Down
6 changes: 3 additions & 3 deletions src/Polly.Extensions/Polly.Extensions.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net10.0;net8.0;net6.0;netstandard2.0;net472;net462</TargetFrameworks>
<TargetFrameworks>net10.0;netstandard2.0;net472</TargetFrameworks>
<AssemblyTitle>Polly.Extensions</AssemblyTitle>
<RootNamespace>Polly</RootNamespace>
<Nullable>enable</Nullable>
Expand All @@ -9,7 +9,7 @@
<MutationScore>100</MutationScore>
<LegacySupport>true</LegacySupport>
</PropertyGroup>
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net10.0'))">
<IsAotCompatible>true</IsAotCompatible>
</PropertyGroup>

Expand Down Expand Up @@ -37,7 +37,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Options" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Condition="!$([MSBuild]::IsTargetFrameworkCompatible($(TargetFramework), 'net6.0'))" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Condition="!$([MSBuild]::IsTargetFrameworkCompatible($(TargetFramework), 'net10.0'))" />
<Reference Include="System.Net.Http" Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'" />
</ItemGroup>
</Project>
11 changes: 11 additions & 0 deletions src/Polly.RateLimiting/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
<DiagnosticId>CP0008</DiagnosticId>
<Target>T:Polly.RateLimiting.RateLimiterRejectedException</Target>
<Left>lib/net462/Polly.RateLimiting.dll</Left>
<Right>lib/netstandard2.0/Polly.RateLimiting.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
</Suppressions>
4 changes: 2 additions & 2 deletions src/Polly.RateLimiting/Polly.RateLimiting.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net10.0;net8.0;net6.0;netstandard2.0;net472;net462</TargetFrameworks>
<TargetFrameworks>net10.0;netstandard2.0;net472</TargetFrameworks>
<AssemblyTitle>Polly.RateLimiting</AssemblyTitle>
<RootNamespace>Polly.RateLimiting</RootNamespace>
<Nullable>enable</Nullable>
Expand All @@ -9,7 +9,7 @@
<MutationScore>100</MutationScore>
<LegacySupport>true</LegacySupport>
</PropertyGroup>
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net10.0'))">
<IsAotCompatible>true</IsAotCompatible>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Polly.Testing/Polly.Testing.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net10.0;net8.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net10.0;netstandard2.0</TargetFrameworks>
<AssemblyTitle>Polly.Testing</AssemblyTitle>
<RootNamespace>Polly.Testing</RootNamespace>
<Nullable>enable</Nullable>
Expand Down
Loading
Loading