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: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: packages-${{ matrix.os_name }}
path: ./artifacts/nuget-packages
path: ./artifacts/package/release
if-no-files-found: error

- name: Upload signing file list
Expand Down
5 changes: 5 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>
<PropertyGroup>
<UseArtifactsOutput>true</UseArtifactsOutput>
</PropertyGroup>
</Project>
10 changes: 3 additions & 7 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var artifactsDir = Directory("./artifacts");
var testResultsDir = System.IO.Path.Combine(artifactsDir, Directory("test-results"));

// NuGet
var nupkgDestDir = System.IO.Path.Combine(artifactsDir, Directory("nuget-packages"));
var nupkgDestDir = System.IO.Path.Combine(artifactsDir, Directory("package"), Directory("release"));

// Stryker / Mutation Testing
var strykerConfig = MakeAbsolute(File("./eng/stryker-config.json"));
Expand Down Expand Up @@ -65,17 +65,13 @@ Teardown(_ =>
Task("__Clean")
.Does(() =>
{
DirectoryPath[] cleanDirectories = new DirectoryPath[]
CleanDirectories(new[]
{
testResultsDir,
nupkgDestDir,
artifactsDir,
strykerOutput
};

CleanDirectories(cleanDirectories);

foreach (var path in cleanDirectories) { EnsureDirectoryExists(path); }
});

foreach (var path in solutionPaths)
{
Expand Down
3 changes: 2 additions & 1 deletion eng/stryker-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"block",
"statement"
],
"target-framework": "net7.0",
"language-version": "Preview",
"target-framework": "net8.0",
"thresholds": {
"high": 100,
"low": 100
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.403",
"version": "8.0.100",
"allowPrerelease": false,
"rollForward": "latestMajor"
}
Expand Down
4 changes: 2 additions & 2 deletions src/Polly.Core/CircuitBreaker/CircuitBreakerManualControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ namespace Polly.CircuitBreaker;
public sealed class CircuitBreakerManualControl
{
private readonly object _lock = new();
private readonly HashSet<Func<ResilienceContext, Task>> _onIsolate = new();
private readonly HashSet<Func<ResilienceContext, Task>> _onReset = new();
private readonly HashSet<Func<ResilienceContext, Task>> _onIsolate = [];
private readonly HashSet<Func<ResilienceContext, Task>> _onReset = [];
private bool _isolated;

/// <summary>
Expand Down
12 changes: 0 additions & 12 deletions src/Polly.Core/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
<Left>lib/netstandard2.0/Polly.Core.dll</Left>
<Right>lib/net6.0/Polly.Core.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Polly.CircuitBreaker.BrokenCircuitException`1.#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>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Polly.CircuitBreaker.IsolatedCircuitException.#ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)</Target>
Expand All @@ -25,10 +19,4 @@
<Left>lib/netstandard2.0/Polly.Core.dll</Left>
<Right>lib/net6.0/Polly.Core.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Polly.Timeout.TimeoutRejectedException.#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>
</Suppression>
</Suppressions>
4 changes: 2 additions & 2 deletions src/Polly.Core/Hedging/Controller/HedgingExecutionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ internal sealed class HedgingExecutionContext<T> : IAsyncDisposable
{
public readonly record struct ExecutionInfo<TResult>(TaskExecution<T>? Execution, bool Loaded, Outcome<TResult>? Outcome);

private readonly List<TaskExecution<T>> _tasks = new();
private readonly List<TaskExecution<T>> _executingTasks = new();
private readonly List<TaskExecution<T>> _tasks = [];
private readonly List<TaskExecution<T>> _executingTasks = [];
private readonly ObjectPool<TaskExecution<T>> _executionPool;
private readonly TimeProvider _timeProvider;
private readonly int _maxAttempts;
Expand Down
2 changes: 1 addition & 1 deletion src/Polly.Core/PredicateBuilder.TResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Polly;
/// <typeparam name="TResult">The type of the result.</typeparam>
public partial class PredicateBuilder<TResult>
{
private readonly List<Predicate<Outcome<TResult>>> _predicates = new();
private readonly List<Predicate<Outcome<TResult>>> _predicates = [];

/// <summary>
/// Adds a predicate for handling exceptions of the specified type.
Expand Down
4 changes: 2 additions & 2 deletions src/Polly.Core/Registry/ConfigureBuilderContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ internal ConfigureBuilderContext(TKey strategyKey, string builderName, string? b
/// </summary>
internal string? BuilderInstanceName { get; }

internal List<CancellationToken> ReloadTokens { get; } = new();
internal List<CancellationToken> ReloadTokens { get; } = [];

internal List<Action> DisposeCallbacks { get; } = new();
internal List<Action> DisposeCallbacks { get; } = [];

/// <summary>
/// Reloads the pipeline when <paramref name="cancellationToken"/> is canceled.
Expand Down
3 changes: 1 addition & 2 deletions src/Polly.Core/ResiliencePipelineBuilderBase.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.ComponentModel;

using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;
using Polly.Telemetry;
Expand All @@ -19,7 +18,7 @@ namespace Polly;
public abstract class ResiliencePipelineBuilderBase
#pragma warning restore S1694 // An abstract class should have both abstract and concrete methods
{
private readonly List<Entry> _entries = new();
private readonly List<Entry> _entries = [];
private bool _used;

private protected ResiliencePipelineBuilderBase()
Expand Down
4 changes: 2 additions & 2 deletions src/Polly.Core/Utils/Pipeline/ReloadableComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private void TryRegisterOnReload()
return;
}

_tokenSource = CancellationTokenSource.CreateLinkedTokenSource(_reloadTokens.ToArray());
_tokenSource = CancellationTokenSource.CreateLinkedTokenSource([.. _reloadTokens]);
_registration = _tokenSource.Token.Register(() =>
{
var context = ResilienceContextPool.Shared.Get().Initialize<VoidResult>(isSynchronous: true);
Expand All @@ -65,7 +65,7 @@ private void TryRegisterOnReload()
}
catch (Exception e)
{
_reloadTokens = new List<CancellationToken>();
_reloadTokens = [];
_telemetry.Report(new(ResilienceEventSeverity.Error, ReloadFailedEvent), context, Outcome.FromException(e), new ReloadFailedArguments(e));
ResilienceContextPool.Shared.Return(context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ namespace Polly.DependencyInjection;
internal sealed class ConfigureResiliencePipelineRegistryOptions<TKey>
where TKey : notnull
{
public List<Action<ResiliencePipelineRegistry<TKey>>> Actions { get; } = new();
public List<Action<ResiliencePipelineRegistry<TKey>>> Actions { get; } = [];
}
24 changes: 12 additions & 12 deletions src/Polly/AsyncPolicy.ExecuteOverloads.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public abstract partial class AsyncPolicy : PolicyBase, IAsyncPolicy
/// <param name="action">The action to perform.</param>
[DebuggerStepThrough]
public Task ExecuteAsync(Func<Task> action) =>
ExecuteAsync((_, _) => action(), new Context(), DefaultCancellationToken, DefaultContinueOnCapturedContext);
ExecuteAsync((_, _) => action(), [], DefaultCancellationToken, DefaultContinueOnCapturedContext);

/// <summary>
/// Executes the specified asynchronous action within the policy.
Expand All @@ -37,7 +37,7 @@ public Task ExecuteAsync(Func<Context, Task> action, Context context) =>
/// <param name="cancellationToken">A cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.</param>
[DebuggerStepThrough]
public Task ExecuteAsync(Func<CancellationToken, Task> action, CancellationToken cancellationToken) =>
ExecuteAsync((_, ct) => action(ct), new Context(), cancellationToken, DefaultContinueOnCapturedContext);
ExecuteAsync((_, ct) => action(ct), [], cancellationToken, DefaultContinueOnCapturedContext);

/// <summary>
/// Executes the specified asynchronous action within the policy.
Expand Down Expand Up @@ -68,7 +68,7 @@ public Task ExecuteAsync(Func<Context, CancellationToken, Task> action, Context
/// <exception cref="InvalidOperationException">Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.</exception>
[DebuggerStepThrough]
public Task ExecuteAsync(Func<CancellationToken, Task> action, CancellationToken cancellationToken, bool continueOnCapturedContext) =>
ExecuteAsync((_, ct) => action(ct), new Context(), cancellationToken, continueOnCapturedContext);
ExecuteAsync((_, ct) => action(ct), [], cancellationToken, continueOnCapturedContext);

/// <summary>
/// Executes the specified asynchronous action within the policy.
Expand Down Expand Up @@ -117,7 +117,7 @@ public async Task ExecuteAsync(Func<Context, CancellationToken, Task> action, Co
/// <returns>The value returned by the action</returns>
[DebuggerStepThrough]
public Task<TResult> ExecuteAsync<TResult>(Func<Task<TResult>> action) =>
ExecuteAsync((_, _) => action(), new Context(), DefaultCancellationToken, DefaultContinueOnCapturedContext);
ExecuteAsync((_, _) => action(), [], DefaultCancellationToken, DefaultContinueOnCapturedContext);

/// <summary>
/// Executes the specified asynchronous action within the policy and returns the result.
Expand Down Expand Up @@ -149,7 +149,7 @@ public Task<TResult> ExecuteAsync<TResult>(Func<Context, Task<TResult>> action,
/// <returns>The value returned by the action</returns>
[DebuggerStepThrough]
public Task<TResult> ExecuteAsync<TResult>(Func<CancellationToken, Task<TResult>> action, CancellationToken cancellationToken) =>
ExecuteAsync((_, ct) => action(ct), new Context(), cancellationToken, DefaultContinueOnCapturedContext);
ExecuteAsync((_, ct) => action(ct), [], cancellationToken, DefaultContinueOnCapturedContext);

/// <summary>
/// Executes the specified asynchronous action within the policy and returns the result.
Expand Down Expand Up @@ -185,7 +185,7 @@ public Task<TResult> ExecuteAsync<TResult>(Func<Context, CancellationToken, Task
/// <exception cref="InvalidOperationException">Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.</exception>
[DebuggerStepThrough]
public Task<TResult> ExecuteAsync<TResult>(Func<CancellationToken, Task<TResult>> action, CancellationToken cancellationToken, bool continueOnCapturedContext) =>
ExecuteAsync((_, ct) => action(ct), new Context(), cancellationToken, continueOnCapturedContext);
ExecuteAsync((_, ct) => action(ct), [], cancellationToken, continueOnCapturedContext);

/// <summary>
/// Executes the specified asynchronous action within the policy and returns the result.
Expand Down Expand Up @@ -240,7 +240,7 @@ public async Task<TResult> ExecuteAsync<TResult>(Func<Context, CancellationToken
/// <returns>The captured result</returns>
[DebuggerStepThrough]
public Task<PolicyResult> ExecuteAndCaptureAsync(Func<Task> action) =>
ExecuteAndCaptureAsync((_, _) => action(), new Context(), DefaultCancellationToken, DefaultContinueOnCapturedContext);
ExecuteAndCaptureAsync((_, _) => action(), [], DefaultCancellationToken, DefaultContinueOnCapturedContext);

/// <summary>
/// Executes the specified asynchronous action within the policy and returns the captured result.
Expand Down Expand Up @@ -270,7 +270,7 @@ public Task<PolicyResult> ExecuteAndCaptureAsync(Func<Context, Task> action, Con
/// <param name="cancellationToken">A cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.</param>
[DebuggerStepThrough]
public Task<PolicyResult> ExecuteAndCaptureAsync(Func<CancellationToken, Task> action, CancellationToken cancellationToken) =>
ExecuteAndCaptureAsync((_, ct) => action(ct), new Context(), cancellationToken, DefaultContinueOnCapturedContext);
ExecuteAndCaptureAsync((_, ct) => action(ct), [], cancellationToken, DefaultContinueOnCapturedContext);

/// <summary>
/// Executes the specified asynchronous action within the policy and returns the captured result.
Expand Down Expand Up @@ -303,7 +303,7 @@ public Task<PolicyResult> ExecuteAndCaptureAsync(Func<Context, CancellationToken
/// <exception cref="InvalidOperationException">Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.</exception>
[DebuggerStepThrough]
public Task<PolicyResult> ExecuteAndCaptureAsync(Func<CancellationToken, Task> action, CancellationToken cancellationToken, bool continueOnCapturedContext) =>
ExecuteAndCaptureAsync((_, ct) => action(ct), new Context(), cancellationToken, continueOnCapturedContext);
ExecuteAndCaptureAsync((_, ct) => action(ct), [], cancellationToken, continueOnCapturedContext);

/// <summary>
/// Executes the specified asynchronous action within the policy and returns the captured result.
Expand Down Expand Up @@ -352,7 +352,7 @@ public async Task<PolicyResult> ExecuteAndCaptureAsync(Func<Context, Cancellatio
/// <returns>The captured result</returns>
[DebuggerStepThrough]
public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<Task<TResult>> action) =>
ExecuteAndCaptureAsync((_, _) => action(), new Context(), DefaultCancellationToken, DefaultContinueOnCapturedContext);
ExecuteAndCaptureAsync((_, _) => action(), [], DefaultCancellationToken, DefaultContinueOnCapturedContext);

/// <summary>
/// Executes the specified asynchronous action within the policy and returns the result.
Expand Down Expand Up @@ -386,7 +386,7 @@ public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<Context,
/// <returns>The captured result</returns>
[DebuggerStepThrough]
public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<CancellationToken, Task<TResult>> action, CancellationToken cancellationToken) =>
ExecuteAndCaptureAsync((_, ct) => action(ct), new Context(), cancellationToken, DefaultContinueOnCapturedContext);
ExecuteAndCaptureAsync((_, ct) => action(ct), [], cancellationToken, DefaultContinueOnCapturedContext);

/// <summary>
/// Executes the specified asynchronous action within the policy and returns the result.
Expand Down Expand Up @@ -424,7 +424,7 @@ public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<Context,
/// <exception cref="InvalidOperationException">Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.</exception>
[DebuggerStepThrough]
public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<CancellationToken, Task<TResult>> action, CancellationToken cancellationToken, bool continueOnCapturedContext) =>
ExecuteAndCaptureAsync((_, ct) => action(ct), new Context(), cancellationToken, continueOnCapturedContext);
ExecuteAndCaptureAsync((_, ct) => action(ct), [], cancellationToken, continueOnCapturedContext);

/// <summary>
/// Executes the specified asynchronous action within the policy and returns the result.
Expand Down
12 changes: 6 additions & 6 deletions src/Polly/AsyncPolicy.TResult.ExecuteOverloads.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public abstract partial class AsyncPolicy<TResult> : IAsyncPolicy<TResult>
/// <returns>The value returned by the action</returns>
[DebuggerStepThrough]
public Task<TResult> ExecuteAsync(Func<Task<TResult>> action) =>
ExecuteAsync((_, _) => action(), new Context(), CancellationToken.None, DefaultContinueOnCapturedContext);
ExecuteAsync((_, _) => action(), [], CancellationToken.None, DefaultContinueOnCapturedContext);

/// <summary>
/// Executes the specified asynchronous action within the policy and returns the result.
Expand Down Expand Up @@ -41,7 +41,7 @@ public Task<TResult> ExecuteAsync(Func<Context, Task<TResult>> action, Context c
/// <returns>The value returned by the action</returns>
[DebuggerStepThrough]
public Task<TResult> ExecuteAsync(Func<CancellationToken, Task<TResult>> action, CancellationToken cancellationToken) =>
ExecuteAsync((_, ct) => action(ct), new Context(), cancellationToken, DefaultContinueOnCapturedContext);
ExecuteAsync((_, ct) => action(ct), [], cancellationToken, DefaultContinueOnCapturedContext);

/// <summary>
/// Executes the specified asynchronous action within the policy and returns the result.
Expand All @@ -53,7 +53,7 @@ public Task<TResult> ExecuteAsync(Func<CancellationToken, Task<TResult>> action,
/// <exception cref="InvalidOperationException">Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.</exception>
[DebuggerStepThrough]
public Task<TResult> ExecuteAsync(Func<CancellationToken, Task<TResult>> action, CancellationToken cancellationToken, bool continueOnCapturedContext) =>
ExecuteAsync((_, ct) => action(ct), new Context(), cancellationToken, continueOnCapturedContext);
ExecuteAsync((_, ct) => action(ct), [], cancellationToken, continueOnCapturedContext);

/// <summary>
/// Executes the specified asynchronous action within the policy and returns the result.
Expand Down Expand Up @@ -127,7 +127,7 @@ public async Task<TResult> ExecuteAsync(Func<Context, CancellationToken, Task<TR
/// <returns>The captured result</returns>
[DebuggerStepThrough]
public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync(Func<Task<TResult>> action) =>
ExecuteAndCaptureAsync((_, _) => action(), new Context(), CancellationToken.None, DefaultContinueOnCapturedContext);
ExecuteAndCaptureAsync((_, _) => action(), [], CancellationToken.None, DefaultContinueOnCapturedContext);

/// <summary>
/// Executes the specified asynchronous action within the policy and returns the result.
Expand Down Expand Up @@ -158,7 +158,7 @@ public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync(Func<Context, Task<TRe
/// <returns>The captured result</returns>
[DebuggerStepThrough]
public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync(Func<CancellationToken, Task<TResult>> action, CancellationToken cancellationToken) =>
ExecuteAndCaptureAsync((_, ct) => action(ct), new Context(), cancellationToken, DefaultContinueOnCapturedContext);
ExecuteAndCaptureAsync((_, ct) => action(ct), [], cancellationToken, DefaultContinueOnCapturedContext);

/// <summary>
/// Executes the specified asynchronous action within the policy and returns the result.
Expand All @@ -170,7 +170,7 @@ public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync(Func<CancellationToken
/// <exception cref="InvalidOperationException">Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.</exception>
[DebuggerStepThrough]
public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync(Func<CancellationToken, Task<TResult>> action, CancellationToken cancellationToken, bool continueOnCapturedContext) =>
ExecuteAndCaptureAsync((_, ct) => action(ct), new Context(), cancellationToken, continueOnCapturedContext);
ExecuteAndCaptureAsync((_, ct) => action(ct), [], cancellationToken, continueOnCapturedContext);

/// <summary>
/// Executes the specified asynchronous action within the policy and returns the result.
Expand Down
Loading