diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 30e988ae560..e5bfa20acd4 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -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
diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644
index 00000000000..c3398254fd3
--- /dev/null
+++ b/Directory.Build.props
@@ -0,0 +1,5 @@
+
+
+ true
+
+
diff --git a/build.cake b/build.cake
index 013c4260812..e535c0ba225 100644
--- a/build.cake
+++ b/build.cake
@@ -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"));
@@ -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)
{
diff --git a/eng/stryker-config.json b/eng/stryker-config.json
index ba638442829..bba70bf11b9 100644
--- a/eng/stryker-config.json
+++ b/eng/stryker-config.json
@@ -18,7 +18,8 @@
"block",
"statement"
],
- "target-framework": "net7.0",
+ "language-version": "Preview",
+ "target-framework": "net8.0",
"thresholds": {
"high": 100,
"low": 100
diff --git a/global.json b/global.json
index 0115ef0494c..33d26e563fb 100644
--- a/global.json
+++ b/global.json
@@ -1,6 +1,6 @@
{
"sdk": {
- "version": "7.0.403",
+ "version": "8.0.100",
"allowPrerelease": false,
"rollForward": "latestMajor"
}
diff --git a/src/Polly.Core/CircuitBreaker/CircuitBreakerManualControl.cs b/src/Polly.Core/CircuitBreaker/CircuitBreakerManualControl.cs
index bb4adb10a3f..1258c4f5ae4 100644
--- a/src/Polly.Core/CircuitBreaker/CircuitBreakerManualControl.cs
+++ b/src/Polly.Core/CircuitBreaker/CircuitBreakerManualControl.cs
@@ -9,8 +9,8 @@ namespace Polly.CircuitBreaker;
public sealed class CircuitBreakerManualControl
{
private readonly object _lock = new();
- private readonly HashSet> _onIsolate = new();
- private readonly HashSet> _onReset = new();
+ private readonly HashSet> _onIsolate = [];
+ private readonly HashSet> _onReset = [];
private bool _isolated;
///
diff --git a/src/Polly.Core/CompatibilitySuppressions.xml b/src/Polly.Core/CompatibilitySuppressions.xml
index a5bb6e45765..ac7575c1ecd 100644
--- a/src/Polly.Core/CompatibilitySuppressions.xml
+++ b/src/Polly.Core/CompatibilitySuppressions.xml
@@ -7,12 +7,6 @@
lib/netstandard2.0/Polly.Core.dll
lib/net6.0/Polly.Core.dll
-
- CP0002
- M:Polly.CircuitBreaker.BrokenCircuitException`1.#ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)
- lib/netstandard2.0/Polly.Core.dll
- lib/net6.0/Polly.Core.dll
-
CP0002
M:Polly.CircuitBreaker.IsolatedCircuitException.#ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)
@@ -25,10 +19,4 @@
lib/netstandard2.0/Polly.Core.dll
lib/net6.0/Polly.Core.dll
-
- CP0002
- M:Polly.Timeout.TimeoutRejectedException.#ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)
- lib/netstandard2.0/Polly.Core.dll
- lib/net6.0/Polly.Core.dll
-
\ No newline at end of file
diff --git a/src/Polly.Core/Hedging/Controller/HedgingExecutionContext.cs b/src/Polly.Core/Hedging/Controller/HedgingExecutionContext.cs
index 157ec750c9c..58772f45b95 100644
--- a/src/Polly.Core/Hedging/Controller/HedgingExecutionContext.cs
+++ b/src/Polly.Core/Hedging/Controller/HedgingExecutionContext.cs
@@ -10,8 +10,8 @@ internal sealed class HedgingExecutionContext : IAsyncDisposable
{
public readonly record struct ExecutionInfo(TaskExecution? Execution, bool Loaded, Outcome? Outcome);
- private readonly List> _tasks = new();
- private readonly List> _executingTasks = new();
+ private readonly List> _tasks = [];
+ private readonly List> _executingTasks = [];
private readonly ObjectPool> _executionPool;
private readonly TimeProvider _timeProvider;
private readonly int _maxAttempts;
diff --git a/src/Polly.Core/PredicateBuilder.TResult.cs b/src/Polly.Core/PredicateBuilder.TResult.cs
index e8f94007911..a0f05e486a3 100644
--- a/src/Polly.Core/PredicateBuilder.TResult.cs
+++ b/src/Polly.Core/PredicateBuilder.TResult.cs
@@ -6,7 +6,7 @@ namespace Polly;
/// The type of the result.
public partial class PredicateBuilder
{
- private readonly List>> _predicates = new();
+ private readonly List>> _predicates = [];
///
/// Adds a predicate for handling exceptions of the specified type.
diff --git a/src/Polly.Core/Registry/ConfigureBuilderContext.cs b/src/Polly.Core/Registry/ConfigureBuilderContext.cs
index 1cf19ca6f56..56c8c483679 100644
--- a/src/Polly.Core/Registry/ConfigureBuilderContext.cs
+++ b/src/Polly.Core/Registry/ConfigureBuilderContext.cs
@@ -29,9 +29,9 @@ internal ConfigureBuilderContext(TKey strategyKey, string builderName, string? b
///
internal string? BuilderInstanceName { get; }
- internal List ReloadTokens { get; } = new();
+ internal List ReloadTokens { get; } = [];
- internal List DisposeCallbacks { get; } = new();
+ internal List DisposeCallbacks { get; } = [];
///
/// Reloads the pipeline when is canceled.
diff --git a/src/Polly.Core/ResiliencePipelineBuilderBase.cs b/src/Polly.Core/ResiliencePipelineBuilderBase.cs
index 2484ac72ac0..d7b49610d24 100644
--- a/src/Polly.Core/ResiliencePipelineBuilderBase.cs
+++ b/src/Polly.Core/ResiliencePipelineBuilderBase.cs
@@ -1,5 +1,4 @@
using System.ComponentModel;
-
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;
using Polly.Telemetry;
@@ -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 _entries = new();
+ private readonly List _entries = [];
private bool _used;
private protected ResiliencePipelineBuilderBase()
diff --git a/src/Polly.Core/Utils/Pipeline/ReloadableComponent.cs b/src/Polly.Core/Utils/Pipeline/ReloadableComponent.cs
index f8a216e37dc..82b3caac674 100644
--- a/src/Polly.Core/Utils/Pipeline/ReloadableComponent.cs
+++ b/src/Polly.Core/Utils/Pipeline/ReloadableComponent.cs
@@ -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(isSynchronous: true);
@@ -65,7 +65,7 @@ private void TryRegisterOnReload()
}
catch (Exception e)
{
- _reloadTokens = new List();
+ _reloadTokens = [];
_telemetry.Report(new(ResilienceEventSeverity.Error, ReloadFailedEvent), context, Outcome.FromException(e), new ReloadFailedArguments(e));
ResilienceContextPool.Shared.Return(context);
}
diff --git a/src/Polly.Extensions/DependencyInjection/ConfigureResiliencePipelineRegistryOptions.cs b/src/Polly.Extensions/DependencyInjection/ConfigureResiliencePipelineRegistryOptions.cs
index 83ecd3ffd0e..639946a6063 100644
--- a/src/Polly.Extensions/DependencyInjection/ConfigureResiliencePipelineRegistryOptions.cs
+++ b/src/Polly.Extensions/DependencyInjection/ConfigureResiliencePipelineRegistryOptions.cs
@@ -5,5 +5,5 @@ namespace Polly.DependencyInjection;
internal sealed class ConfigureResiliencePipelineRegistryOptions
where TKey : notnull
{
- public List>> Actions { get; } = new();
+ public List>> Actions { get; } = [];
}
diff --git a/src/Polly/AsyncPolicy.ExecuteOverloads.cs b/src/Polly/AsyncPolicy.ExecuteOverloads.cs
index 667b1d4cb4b..0d35960c437 100644
--- a/src/Polly/AsyncPolicy.ExecuteOverloads.cs
+++ b/src/Polly/AsyncPolicy.ExecuteOverloads.cs
@@ -10,7 +10,7 @@ public abstract partial class AsyncPolicy : PolicyBase, IAsyncPolicy
/// The action to perform.
[DebuggerStepThrough]
public Task ExecuteAsync(Func action) =>
- ExecuteAsync((_, _) => action(), new Context(), DefaultCancellationToken, DefaultContinueOnCapturedContext);
+ ExecuteAsync((_, _) => action(), [], DefaultCancellationToken, DefaultContinueOnCapturedContext);
///
/// Executes the specified asynchronous action within the policy.
@@ -37,7 +37,7 @@ public Task ExecuteAsync(Func action, Context context) =>
/// A cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
[DebuggerStepThrough]
public Task ExecuteAsync(Func action, CancellationToken cancellationToken) =>
- ExecuteAsync((_, ct) => action(ct), new Context(), cancellationToken, DefaultContinueOnCapturedContext);
+ ExecuteAsync((_, ct) => action(ct), [], cancellationToken, DefaultContinueOnCapturedContext);
///
/// Executes the specified asynchronous action within the policy.
@@ -68,7 +68,7 @@ public Task ExecuteAsync(Func action, Context
/// Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.
[DebuggerStepThrough]
public Task ExecuteAsync(Func action, CancellationToken cancellationToken, bool continueOnCapturedContext) =>
- ExecuteAsync((_, ct) => action(ct), new Context(), cancellationToken, continueOnCapturedContext);
+ ExecuteAsync((_, ct) => action(ct), [], cancellationToken, continueOnCapturedContext);
///
/// Executes the specified asynchronous action within the policy.
@@ -117,7 +117,7 @@ public async Task ExecuteAsync(Func action, Co
/// The value returned by the action
[DebuggerStepThrough]
public Task ExecuteAsync(Func> action) =>
- ExecuteAsync((_, _) => action(), new Context(), DefaultCancellationToken, DefaultContinueOnCapturedContext);
+ ExecuteAsync((_, _) => action(), [], DefaultCancellationToken, DefaultContinueOnCapturedContext);
///
/// Executes the specified asynchronous action within the policy and returns the result.
@@ -149,7 +149,7 @@ public Task ExecuteAsync(Func> action,
/// The value returned by the action
[DebuggerStepThrough]
public Task ExecuteAsync(Func> action, CancellationToken cancellationToken) =>
- ExecuteAsync((_, ct) => action(ct), new Context(), cancellationToken, DefaultContinueOnCapturedContext);
+ ExecuteAsync((_, ct) => action(ct), [], cancellationToken, DefaultContinueOnCapturedContext);
///
/// Executes the specified asynchronous action within the policy and returns the result.
@@ -185,7 +185,7 @@ public Task ExecuteAsync(FuncPlease use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.
[DebuggerStepThrough]
public Task ExecuteAsync(Func> action, CancellationToken cancellationToken, bool continueOnCapturedContext) =>
- ExecuteAsync((_, ct) => action(ct), new Context(), cancellationToken, continueOnCapturedContext);
+ ExecuteAsync((_, ct) => action(ct), [], cancellationToken, continueOnCapturedContext);
///
/// Executes the specified asynchronous action within the policy and returns the result.
@@ -240,7 +240,7 @@ public async Task ExecuteAsync(FuncThe captured result
[DebuggerStepThrough]
public Task ExecuteAndCaptureAsync(Func action) =>
- ExecuteAndCaptureAsync((_, _) => action(), new Context(), DefaultCancellationToken, DefaultContinueOnCapturedContext);
+ ExecuteAndCaptureAsync((_, _) => action(), [], DefaultCancellationToken, DefaultContinueOnCapturedContext);
///
/// Executes the specified asynchronous action within the policy and returns the captured result.
@@ -270,7 +270,7 @@ public Task ExecuteAndCaptureAsync(Func action, Con
/// A cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
[DebuggerStepThrough]
public Task ExecuteAndCaptureAsync(Func action, CancellationToken cancellationToken) =>
- ExecuteAndCaptureAsync((_, ct) => action(ct), new Context(), cancellationToken, DefaultContinueOnCapturedContext);
+ ExecuteAndCaptureAsync((_, ct) => action(ct), [], cancellationToken, DefaultContinueOnCapturedContext);
///
/// Executes the specified asynchronous action within the policy and returns the captured result.
@@ -303,7 +303,7 @@ public Task ExecuteAndCaptureAsync(FuncPlease use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.
[DebuggerStepThrough]
public Task ExecuteAndCaptureAsync(Func action, CancellationToken cancellationToken, bool continueOnCapturedContext) =>
- ExecuteAndCaptureAsync((_, ct) => action(ct), new Context(), cancellationToken, continueOnCapturedContext);
+ ExecuteAndCaptureAsync((_, ct) => action(ct), [], cancellationToken, continueOnCapturedContext);
///
/// Executes the specified asynchronous action within the policy and returns the captured result.
@@ -352,7 +352,7 @@ public async Task ExecuteAndCaptureAsync(FuncThe captured result
[DebuggerStepThrough]
public Task> ExecuteAndCaptureAsync(Func> action) =>
- ExecuteAndCaptureAsync((_, _) => action(), new Context(), DefaultCancellationToken, DefaultContinueOnCapturedContext);
+ ExecuteAndCaptureAsync((_, _) => action(), [], DefaultCancellationToken, DefaultContinueOnCapturedContext);
///
/// Executes the specified asynchronous action within the policy and returns the result.
@@ -386,7 +386,7 @@ public Task> ExecuteAndCaptureAsync(FuncThe captured result
[DebuggerStepThrough]
public Task> ExecuteAndCaptureAsync(Func> action, CancellationToken cancellationToken) =>
- ExecuteAndCaptureAsync((_, ct) => action(ct), new Context(), cancellationToken, DefaultContinueOnCapturedContext);
+ ExecuteAndCaptureAsync((_, ct) => action(ct), [], cancellationToken, DefaultContinueOnCapturedContext);
///
/// Executes the specified asynchronous action within the policy and returns the result.
@@ -424,7 +424,7 @@ public Task> ExecuteAndCaptureAsync(FuncPlease use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.
[DebuggerStepThrough]
public Task> ExecuteAndCaptureAsync(Func> action, CancellationToken cancellationToken, bool continueOnCapturedContext) =>
- ExecuteAndCaptureAsync((_, ct) => action(ct), new Context(), cancellationToken, continueOnCapturedContext);
+ ExecuteAndCaptureAsync((_, ct) => action(ct), [], cancellationToken, continueOnCapturedContext);
///
/// Executes the specified asynchronous action within the policy and returns the result.
diff --git a/src/Polly/AsyncPolicy.TResult.ExecuteOverloads.cs b/src/Polly/AsyncPolicy.TResult.ExecuteOverloads.cs
index e74d818070a..1daa607943e 100644
--- a/src/Polly/AsyncPolicy.TResult.ExecuteOverloads.cs
+++ b/src/Polly/AsyncPolicy.TResult.ExecuteOverloads.cs
@@ -11,7 +11,7 @@ public abstract partial class AsyncPolicy : IAsyncPolicy
/// The value returned by the action
[DebuggerStepThrough]
public Task ExecuteAsync(Func> action) =>
- ExecuteAsync((_, _) => action(), new Context(), CancellationToken.None, DefaultContinueOnCapturedContext);
+ ExecuteAsync((_, _) => action(), [], CancellationToken.None, DefaultContinueOnCapturedContext);
///
/// Executes the specified asynchronous action within the policy and returns the result.
@@ -41,7 +41,7 @@ public Task ExecuteAsync(Func> action, Context c
/// The value returned by the action
[DebuggerStepThrough]
public Task ExecuteAsync(Func> action, CancellationToken cancellationToken) =>
- ExecuteAsync((_, ct) => action(ct), new Context(), cancellationToken, DefaultContinueOnCapturedContext);
+ ExecuteAsync((_, ct) => action(ct), [], cancellationToken, DefaultContinueOnCapturedContext);
///
/// Executes the specified asynchronous action within the policy and returns the result.
@@ -53,7 +53,7 @@ public Task ExecuteAsync(Func> action,
/// Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.
[DebuggerStepThrough]
public Task ExecuteAsync(Func> action, CancellationToken cancellationToken, bool continueOnCapturedContext) =>
- ExecuteAsync((_, ct) => action(ct), new Context(), cancellationToken, continueOnCapturedContext);
+ ExecuteAsync((_, ct) => action(ct), [], cancellationToken, continueOnCapturedContext);
///
/// Executes the specified asynchronous action within the policy and returns the result.
@@ -127,7 +127,7 @@ public async Task ExecuteAsync(FuncThe captured result
[DebuggerStepThrough]
public Task> ExecuteAndCaptureAsync(Func> action) =>
- ExecuteAndCaptureAsync((_, _) => action(), new Context(), CancellationToken.None, DefaultContinueOnCapturedContext);
+ ExecuteAndCaptureAsync((_, _) => action(), [], CancellationToken.None, DefaultContinueOnCapturedContext);
///
/// Executes the specified asynchronous action within the policy and returns the result.
@@ -158,7 +158,7 @@ public Task> ExecuteAndCaptureAsync(FuncThe captured result
[DebuggerStepThrough]
public Task> ExecuteAndCaptureAsync(Func> action, CancellationToken cancellationToken) =>
- ExecuteAndCaptureAsync((_, ct) => action(ct), new Context(), cancellationToken, DefaultContinueOnCapturedContext);
+ ExecuteAndCaptureAsync((_, ct) => action(ct), [], cancellationToken, DefaultContinueOnCapturedContext);
///
/// Executes the specified asynchronous action within the policy and returns the result.
@@ -170,7 +170,7 @@ public Task> ExecuteAndCaptureAsync(FuncPlease use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.
[DebuggerStepThrough]
public Task> ExecuteAndCaptureAsync(Func> action, CancellationToken cancellationToken, bool continueOnCapturedContext) =>
- ExecuteAndCaptureAsync((_, ct) => action(ct), new Context(), cancellationToken, continueOnCapturedContext);
+ ExecuteAndCaptureAsync((_, ct) => action(ct), [], cancellationToken, continueOnCapturedContext);
///
/// Executes the specified asynchronous action within the policy and returns the result.
diff --git a/src/Polly/CompatibilitySuppressions.xml b/src/Polly/CompatibilitySuppressions.xml
index e76772a16fc..ff409018bff 100644
--- a/src/Polly/CompatibilitySuppressions.xml
+++ b/src/Polly/CompatibilitySuppressions.xml
@@ -1,132 +1,6 @@
-
- CP0001
- T:Polly.CircuitBreaker.BrokenCircuitException
- lib/net461/Polly.dll
- lib/netstandard2.0/Polly.dll
- true
-
-
- CP0001
- T:Polly.CircuitBreaker.BrokenCircuitException`1
- lib/net461/Polly.dll
- lib/netstandard2.0/Polly.dll
- true
-
-
- CP0001
- T:Polly.CircuitBreaker.CircuitState
- lib/net461/Polly.dll
- lib/netstandard2.0/Polly.dll
- true
-
-
- CP0001
- T:Polly.CircuitBreaker.IsolatedCircuitException
- lib/net461/Polly.dll
- lib/netstandard2.0/Polly.dll
- true
-
-
- CP0001
- T:Polly.ExecutionRejectedException
- lib/net461/Polly.dll
- lib/netstandard2.0/Polly.dll
- true
-
-
- CP0001
- T:Polly.Timeout.TimeoutRejectedException
- lib/net461/Polly.dll
- lib/netstandard2.0/Polly.dll
- true
-
-
- CP0001
- T:Polly.CircuitBreaker.BrokenCircuitException
- lib/net472/Polly.dll
- lib/net472/Polly.dll
- true
-
-
- CP0001
- T:Polly.CircuitBreaker.BrokenCircuitException`1
- lib/net472/Polly.dll
- lib/net472/Polly.dll
- true
-
-
- CP0001
- T:Polly.CircuitBreaker.CircuitState
- lib/net472/Polly.dll
- lib/net472/Polly.dll
- true
-
-
- CP0001
- T:Polly.CircuitBreaker.IsolatedCircuitException
- lib/net472/Polly.dll
- lib/net472/Polly.dll
- true
-
-
- CP0001
- T:Polly.ExecutionRejectedException
- lib/net472/Polly.dll
- lib/net472/Polly.dll
- true
-
-
- CP0001
- T:Polly.Timeout.TimeoutRejectedException
- lib/net472/Polly.dll
- lib/net472/Polly.dll
- true
-
-
- CP0001
- T:Polly.CircuitBreaker.BrokenCircuitException
- lib/netstandard2.0/Polly.dll
- lib/netstandard2.0/Polly.dll
- true
-
-
- CP0001
- T:Polly.CircuitBreaker.BrokenCircuitException`1
- lib/netstandard2.0/Polly.dll
- lib/netstandard2.0/Polly.dll
- true
-
-
- CP0001
- T:Polly.CircuitBreaker.CircuitState
- lib/netstandard2.0/Polly.dll
- lib/netstandard2.0/Polly.dll
- true
-
-
- CP0001
- T:Polly.CircuitBreaker.IsolatedCircuitException
- lib/netstandard2.0/Polly.dll
- lib/netstandard2.0/Polly.dll
- true
-
-
- CP0001
- T:Polly.ExecutionRejectedException
- lib/netstandard2.0/Polly.dll
- lib/netstandard2.0/Polly.dll
- true
-
-
- CP0001
- T:Polly.Timeout.TimeoutRejectedException
- lib/netstandard2.0/Polly.dll
- lib/netstandard2.0/Polly.dll
- true
-
CP0002
M:Polly.Bulkhead.BulkheadRejectedException.#ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)
@@ -175,14 +49,4 @@
lib/netstandard2.0/Polly.dll
lib/net6.0/Polly.dll
-
- CP0002
- M:Polly.Timeout.TimeoutRejectedException.#ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)
- lib/netstandard2.0/Polly.dll
- lib/net6.0/Polly.dll
-
-
- PKV006
- .NETStandard,Version=v1.1
-
-
\ No newline at end of file
+
diff --git a/src/Polly/Context.Dictionary.cs b/src/Polly/Context.Dictionary.cs
index 8fd71070860..d0090ceba72 100644
--- a/src/Polly/Context.Dictionary.cs
+++ b/src/Polly/Context.Dictionary.cs
@@ -11,7 +11,7 @@ public partial class Context : IDictionary, IDictionary, IReadOn
private Dictionary wrappedDictionary;
- private Dictionary WrappedDictionary => wrappedDictionary ?? (wrappedDictionary = new Dictionary());
+ private Dictionary WrappedDictionary => wrappedDictionary ?? (wrappedDictionary = []);
///
/// Initializes a new instance of the class, with the specified and the supplied .
diff --git a/src/Polly/ExceptionPredicates.cs b/src/Polly/ExceptionPredicates.cs
index f8504e8e617..5bae4c9b15a 100644
--- a/src/Polly/ExceptionPredicates.cs
+++ b/src/Polly/ExceptionPredicates.cs
@@ -9,7 +9,7 @@ public class ExceptionPredicates
internal void Add(ExceptionPredicate predicate)
{
- _predicates ??= new List(); // The ?? pattern here is sufficient; only a deliberately contrived example would lead to the same PolicyBuilder instance being used in a multi-threaded way to define policies simultaneously on multiple threads.
+ _predicates ??= []; // The ?? pattern here is sufficient; only a deliberately contrived example would lead to the same PolicyBuilder instance being used in a multi-threaded way to define policies simultaneously on multiple threads.
_predicates.Add(predicate);
}
diff --git a/src/Polly/Policy.ExecuteOverloads.cs b/src/Polly/Policy.ExecuteOverloads.cs
index 4d7e2e666aa..edfa5f41d4f 100644
--- a/src/Polly/Policy.ExecuteOverloads.cs
+++ b/src/Polly/Policy.ExecuteOverloads.cs
@@ -10,7 +10,7 @@ public abstract partial class Policy : ISyncPolicy
/// The action to perform.
[DebuggerStepThrough]
public void Execute(Action action) =>
- Execute((_, _) => action(), new Context(), DefaultCancellationToken);
+ Execute((_, _) => action(), [], DefaultCancellationToken);
///
/// Executes the specified action within the policy.
@@ -37,7 +37,7 @@ public void Execute(Action action, Context context) =>
///
[DebuggerStepThrough]
public void Execute(Action action, CancellationToken cancellationToken) =>
- Execute((_, ct) => action(ct), new Context(), cancellationToken);
+ Execute((_, ct) => action(ct), [], cancellationToken);
///
/// Executes the specified action within the policy.
@@ -83,7 +83,7 @@ public void Execute(Action action, Context context,
/// The value returned by the action
[DebuggerStepThrough]
public TResult Execute(Func action) =>
- Execute((_, _) => action(), new Context(), DefaultCancellationToken);
+ Execute((_, _) => action(), [], DefaultCancellationToken);
///
/// Executes the specified action within the policy and returns the result.
@@ -124,7 +124,7 @@ public TResult Execute(Func action, Context context)
/// The value returned by the action
[DebuggerStepThrough]
public TResult Execute(Func action, CancellationToken cancellationToken) =>
- Execute((_, ct) => action(ct), new Context(), cancellationToken);
+ Execute((_, ct) => action(ct), [], cancellationToken);
///
/// Executes the specified action within the policy and returns the result.
@@ -177,7 +177,7 @@ public TResult Execute(Func action
/// The captured result
[DebuggerStepThrough]
public PolicyResult ExecuteAndCapture(Action action) =>
- ExecuteAndCapture((_, _) => action(), new Context(), DefaultCancellationToken);
+ ExecuteAndCapture((_, _) => action(), [], DefaultCancellationToken);
///
/// Executes the specified action within the policy and returns the captured result.
@@ -208,7 +208,7 @@ public PolicyResult ExecuteAndCapture(Action action, Context context) =
/// The captured result
[DebuggerStepThrough]
public PolicyResult ExecuteAndCapture(Action action, CancellationToken cancellationToken) =>
- ExecuteAndCapture((_, ct) => action(ct), new Context(), cancellationToken);
+ ExecuteAndCapture((_, ct) => action(ct), [], cancellationToken);
///
/// Executes the specified action within the policy and returns the captured result.
@@ -254,7 +254,7 @@ public PolicyResult ExecuteAndCapture(Action action,
/// The captured result
[DebuggerStepThrough]
public PolicyResult ExecuteAndCapture(Func action) =>
- ExecuteAndCapture((_, _) => action(), new Context(), DefaultCancellationToken);
+ ExecuteAndCapture((_, _) => action(), [], DefaultCancellationToken);
///
/// Executes the specified action within the policy and returns the captured result.
@@ -286,7 +286,7 @@ public PolicyResult ExecuteAndCapture(Func a
/// The cancellation token.
/// The captured result
public PolicyResult ExecuteAndCapture(Func action, CancellationToken cancellationToken) =>
- ExecuteAndCapture((_, ct) => action(ct), new Context(), cancellationToken);
+ ExecuteAndCapture((_, ct) => action(ct), [], cancellationToken);
///
/// Executes the specified action within the policy and returns the captured result.
diff --git a/src/Polly/Policy.TResult.ExecuteOverloads.cs b/src/Polly/Policy.TResult.ExecuteOverloads.cs
index a6f13261aa0..0ee2110329c 100644
--- a/src/Polly/Policy.TResult.ExecuteOverloads.cs
+++ b/src/Polly/Policy.TResult.ExecuteOverloads.cs
@@ -11,7 +11,7 @@ public abstract partial class Policy : ISyncPolicy
/// The value returned by the action
[DebuggerStepThrough]
public TResult Execute(Func action) =>
- Execute((_, _) => action(), new Context(), DefaultCancellationToken);
+ Execute((_, _) => action(), [], DefaultCancellationToken);
///
/// Executes the specified action within the policy and returns the result.
@@ -49,7 +49,7 @@ public TResult Execute(Func action, Context context) =>
/// The value returned by the action
[DebuggerStepThrough]
public TResult Execute(Func action, CancellationToken cancellationToken) =>
- Execute((_, ct) => action(ct), new Context(), cancellationToken);
+ Execute((_, ct) => action(ct), [], cancellationToken);
///
/// Executes the specified action within the policy and returns the result.
@@ -98,7 +98,7 @@ public TResult Execute(Func action, Context
/// The captured result
[DebuggerStepThrough]
public PolicyResult ExecuteAndCapture(Func action) =>
- ExecuteAndCapture((_, _) => action(), new Context(), DefaultCancellationToken);
+ ExecuteAndCapture((_, _) => action(), [], DefaultCancellationToken);
///
/// Executes the specified action within the policy and returns the captured result.
@@ -130,7 +130,7 @@ public PolicyResult ExecuteAndCapture(Func action, Co
/// The captured result
[DebuggerStepThrough]
public PolicyResult ExecuteAndCapture(Func action, CancellationToken cancellationToken) =>
- ExecuteAndCapture((_, ct) => action(ct), new Context(), cancellationToken);
+ ExecuteAndCapture((_, ct) => action(ct), [], cancellationToken);
///
/// Executes the specified action within the policy and returns the captured result.
diff --git a/src/Polly/ResultPredicates.cs b/src/Polly/ResultPredicates.cs
index 72b43db3a5c..6be1aa99fe9 100644
--- a/src/Polly/ResultPredicates.cs
+++ b/src/Polly/ResultPredicates.cs
@@ -9,7 +9,7 @@ public class ResultPredicates
internal void Add(ResultPredicate predicate)
{
- _predicates ??= new List>(); // The ?? pattern here is sufficient; only a deliberately contrived example would lead to the same PolicyBuilder instance being used in a multi-threaded way to define policies simultaneously on multiple threads.
+ _predicates ??= []; // The ?? pattern here is sufficient; only a deliberately contrived example would lead to the same PolicyBuilder instance being used in a multi-threaded way to define policies simultaneously on multiple threads.
_predicates.Add(predicate);
}
diff --git a/test/Polly.AotTest/Polly.AotTest.csproj b/test/Polly.AotTest/Polly.AotTest.csproj
index 0f8b6725774..9ede9228685 100644
--- a/test/Polly.AotTest/Polly.AotTest.csproj
+++ b/test/Polly.AotTest/Polly.AotTest.csproj
@@ -2,10 +2,13 @@
enable
Exe
- true
true
+ true
net7.0
+
+ true
+
diff --git a/test/Polly.Core.Tests/CircuitBreaker/CircuitBreakerResiliencePipelineBuilderTests.cs b/test/Polly.Core.Tests/CircuitBreaker/CircuitBreakerResiliencePipelineBuilderTests.cs
index a081a36655b..51c75f9e424 100644
--- a/test/Polly.Core.Tests/CircuitBreaker/CircuitBreakerResiliencePipelineBuilderTests.cs
+++ b/test/Polly.Core.Tests/CircuitBreaker/CircuitBreakerResiliencePipelineBuilderTests.cs
@@ -7,6 +7,7 @@ namespace Polly.Core.Tests.CircuitBreaker;
public class CircuitBreakerResiliencePipelineBuilderTests
{
+#pragma warning disable IDE0028
public static TheoryData> ConfigureData = new()
{
builder => builder.AddCircuitBreaker(new CircuitBreakerStrategyOptions
@@ -22,6 +23,7 @@ public class CircuitBreakerResiliencePipelineBuilderTests
ShouldHandle = _ => PredicateResult.True()
}),
};
+#pragma warning restore IDE0028
[MemberData(nameof(ConfigureData))]
[Theory]
diff --git a/test/Polly.Core.Tests/Fallback/FallbackResiliencePipelineBuilderExtensionsTests.cs b/test/Polly.Core.Tests/Fallback/FallbackResiliencePipelineBuilderExtensionsTests.cs
index 6dbe198712d..ccb10ef02b8 100644
--- a/test/Polly.Core.Tests/Fallback/FallbackResiliencePipelineBuilderExtensionsTests.cs
+++ b/test/Polly.Core.Tests/Fallback/FallbackResiliencePipelineBuilderExtensionsTests.cs
@@ -6,6 +6,7 @@ namespace Polly.Core.Tests.Fallback;
public class FallbackResiliencePipelineBuilderExtensionsTests
{
+#pragma warning disable IDE0028
public static readonly TheoryData>> FallbackOverloadsGeneric = new()
{
builder =>
@@ -17,6 +18,7 @@ public class FallbackResiliencePipelineBuilderExtensionsTests
});
}
};
+#pragma warning restore IDE0028
[MemberData(nameof(FallbackOverloadsGeneric))]
[Theory]
diff --git a/test/Polly.Core.Tests/Fallback/FallbackResilienceStrategyTests.cs b/test/Polly.Core.Tests/Fallback/FallbackResilienceStrategyTests.cs
index 8415d82e19d..131496df358 100644
--- a/test/Polly.Core.Tests/Fallback/FallbackResilienceStrategyTests.cs
+++ b/test/Polly.Core.Tests/Fallback/FallbackResilienceStrategyTests.cs
@@ -6,7 +6,7 @@ namespace Polly.Core.Tests.Fallback;
public class FallbackResilienceStrategyTests
{
private readonly FallbackStrategyOptions _options = new();
- private readonly List> _args = new();
+ private readonly List> _args = [];
private readonly ResilienceStrategyTelemetry _telemetry;
private FallbackHandler? _handler;
diff --git a/test/Polly.Core.Tests/Hedging/Controller/HedgingExecutionContextTests.cs b/test/Polly.Core.Tests/Hedging/Controller/HedgingExecutionContextTests.cs
index f00b23cc56c..e8081852ba9 100644
--- a/test/Polly.Core.Tests/Hedging/Controller/HedgingExecutionContextTests.cs
+++ b/test/Polly.Core.Tests/Hedging/Controller/HedgingExecutionContextTests.cs
@@ -14,9 +14,9 @@ public class HedgingExecutionContextTests : IDisposable
private readonly ResiliencePropertyKey _myKey = new("my-key");
private readonly CancellationTokenSource _cts;
private readonly HedgingTimeProvider _timeProvider;
- private readonly List> _createdExecutions = new();
- private readonly List> _returnedExecutions = new();
- private readonly List> _resets = new();
+ private readonly List> _createdExecutions = [];
+ private readonly List> _returnedExecutions = [];
+ private readonly List> _resets = [];
private readonly ResilienceContext _resilienceContext;
private readonly AutoResetEvent _onReset = new(false);
private int _maxAttempts = 2;
diff --git a/test/Polly.Core.Tests/Hedging/Controller/TaskExecutionTests.cs b/test/Polly.Core.Tests/Hedging/Controller/TaskExecutionTests.cs
index 51c549fdbee..5e3bb507607 100644
--- a/test/Polly.Core.Tests/Hedging/Controller/TaskExecutionTests.cs
+++ b/test/Polly.Core.Tests/Hedging/Controller/TaskExecutionTests.cs
@@ -14,7 +14,7 @@ public class TaskExecutionTests : IDisposable
private readonly CancellationTokenSource _cts;
private readonly HedgingTimeProvider _timeProvider;
private readonly ResilienceStrategyTelemetry _telemetry;
- private readonly List _args = new();
+ private readonly List _args = [];
private ResilienceContext _primaryContext = ResilienceContextPool.Shared.Get();
public TaskExecutionTests()
diff --git a/test/Polly.Core.Tests/Hedging/HedgingActions.cs b/test/Polly.Core.Tests/Hedging/HedgingActions.cs
index e2267d250ab..37911f2e9b2 100644
--- a/test/Polly.Core.Tests/Hedging/HedgingActions.cs
+++ b/test/Polly.Core.Tests/Hedging/HedgingActions.cs
@@ -10,12 +10,12 @@ public HedgingActions(TimeProvider timeProvider)
{
_timeProvider = timeProvider;
- Functions = new()
- {
+ Functions =
+ [
GetApples,
GetOranges,
GetPears
- };
+ ];
Generator = args =>
{
diff --git a/test/Polly.Core.Tests/Hedging/HedgingResilienceStrategyTests.cs b/test/Polly.Core.Tests/Hedging/HedgingResilienceStrategyTests.cs
index 37b13d8633a..e053cff5b79 100644
--- a/test/Polly.Core.Tests/Hedging/HedgingResilienceStrategyTests.cs
+++ b/test/Polly.Core.Tests/Hedging/HedgingResilienceStrategyTests.cs
@@ -620,7 +620,7 @@ public async Task ExecuteAsync_EnsureBackgroundWorkInSuccessfulCallNotCancelled(
{
// arrange
using var cts = new CancellationTokenSource();
- List backgroundTasks = new List();
+ List backgroundTasks = [];
ConfigureHedging(BackgroundWork);
var strategy = Create();
diff --git a/test/Polly.Core.Tests/ResiliencePipelineTTests.Async.cs b/test/Polly.Core.Tests/ResiliencePipelineTTests.Async.cs
index 125548504d6..c22471a427d 100644
--- a/test/Polly.Core.Tests/ResiliencePipelineTTests.Async.cs
+++ b/test/Polly.Core.Tests/ResiliencePipelineTTests.Async.cs
@@ -3,10 +3,9 @@
namespace Polly.Core.Tests;
-#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
-
public partial class ResiliencePipelineTests
{
+#pragma warning disable IDE0028
public static TheoryData, ValueTask>> ExecuteAsyncGenericStrategyData = new()
{
async strategy =>
@@ -59,8 +58,9 @@ public partial class ResiliencePipelineTests
return new ValueTask("res");
},
context)).Should().Be("res");
- }
+ },
};
+#pragma warning restore IDE0028
[MemberData(nameof(ExecuteAsyncGenericStrategyData))]
[Theory]
diff --git a/test/Polly.Core.Tests/ResiliencePipelineTTests.Sync.cs b/test/Polly.Core.Tests/ResiliencePipelineTTests.Sync.cs
index 60dc613c269..d242e3aa62a 100644
--- a/test/Polly.Core.Tests/ResiliencePipelineTTests.Sync.cs
+++ b/test/Polly.Core.Tests/ResiliencePipelineTTests.Sync.cs
@@ -5,6 +5,7 @@ namespace Polly.Core.Tests;
public partial class ResiliencePipelineTests
{
+#pragma warning disable IDE0028
public static TheoryData>> ExecuteGenericStrategyData = new()
{
strategy =>
@@ -73,8 +74,9 @@ public partial class ResiliencePipelineTests
return "res";
},
context).Should().Be("res");
- }
+ },
};
+#pragma warning restore IDE0028
[MemberData(nameof(ExecuteGenericStrategyData))]
[Theory]
diff --git a/test/Polly.Core.Tests/ResiliencePipelineTests.cs b/test/Polly.Core.Tests/ResiliencePipelineTests.cs
index 95d4cc939fe..f12ae724c32 100644
--- a/test/Polly.Core.Tests/ResiliencePipelineTests.cs
+++ b/test/Polly.Core.Tests/ResiliencePipelineTests.cs
@@ -4,12 +4,18 @@
namespace Polly.Core.Tests;
-#pragma warning disable S3966 // Objects should not be disposed more than once
-
public partial class ResiliencePipelineTests
{
public static readonly CancellationToken CancellationToken = new CancellationTokenSource().Token;
+#pragma warning disable IDE0028
+ public static TheoryData ResilienceContextPools = new()
+ {
+ null,
+ ResilienceContextPool.Shared,
+ };
+#pragma warning restore IDE0028
+
[Fact]
public async Task DisposeAsync_NullPipeline_OK()
{
diff --git a/test/Polly.Core.Tests/Retry/RetryResiliencePipelineBuilderExtensionsTests.cs b/test/Polly.Core.Tests/Retry/RetryResiliencePipelineBuilderExtensionsTests.cs
index f73886985ba..51801b11bf7 100644
--- a/test/Polly.Core.Tests/Retry/RetryResiliencePipelineBuilderExtensionsTests.cs
+++ b/test/Polly.Core.Tests/Retry/RetryResiliencePipelineBuilderExtensionsTests.cs
@@ -5,10 +5,9 @@
namespace Polly.Core.Tests.Retry;
-#pragma warning disable CA2012 // Use ValueTasks correctly
-
public class RetryResiliencePipelineBuilderExtensionsTests
{
+#pragma warning disable IDE0028
public static readonly TheoryData> OverloadsData = new()
{
builder =>
@@ -22,7 +21,7 @@ public class RetryResiliencePipelineBuilderExtensionsTests
});
AssertStrategy(builder, DelayBackoffType.Exponential, 3, TimeSpan.FromSeconds(2));
- }
+ },
};
public static readonly TheoryData>> OverloadsDataGeneric = new()
@@ -38,8 +37,9 @@ public class RetryResiliencePipelineBuilderExtensionsTests
});
AssertStrategy(builder, DelayBackoffType.Exponential, 3, TimeSpan.FromSeconds(2));
- }
+ },
};
+#pragma warning restore IDE0028
[MemberData(nameof(OverloadsData))]
[Theory]
diff --git a/test/Polly.Core.Tests/Retry/RetryResilienceStrategyTests.cs b/test/Polly.Core.Tests/Retry/RetryResilienceStrategyTests.cs
index d0727bda922..0a94d396896 100644
--- a/test/Polly.Core.Tests/Retry/RetryResilienceStrategyTests.cs
+++ b/test/Polly.Core.Tests/Retry/RetryResilienceStrategyTests.cs
@@ -10,7 +10,7 @@ public class RetryResilienceStrategyTests
{
private readonly RetryStrategyOptions _options = new();
private readonly FakeTimeProvider _timeProvider = new();
- private readonly List> _args = new();
+ private readonly List> _args = [];
private ResilienceStrategyTelemetry _telemetry;
public RetryResilienceStrategyTests()
diff --git a/test/Polly.Core.Tests/Simmy/Behavior/BehaviorChaosStrategyTests.cs b/test/Polly.Core.Tests/Simmy/Behavior/BehaviorChaosStrategyTests.cs
index 64947e22a85..aa58aaa7d0f 100644
--- a/test/Polly.Core.Tests/Simmy/Behavior/BehaviorChaosStrategyTests.cs
+++ b/test/Polly.Core.Tests/Simmy/Behavior/BehaviorChaosStrategyTests.cs
@@ -2,11 +2,12 @@
using Polly.Telemetry;
namespace Polly.Core.Tests.Simmy.Behavior;
+
public class BehaviorChaosStrategyTests
{
private readonly ResilienceStrategyTelemetry _telemetry;
private readonly BehaviorStrategyOptions _options;
- private readonly List> _args = new();
+ private readonly List> _args = [];
public BehaviorChaosStrategyTests()
{
diff --git a/test/Polly.Core.Tests/Simmy/Fault/FaultChaosPipelineBuilderExtensionsTests.cs b/test/Polly.Core.Tests/Simmy/Fault/FaultChaosPipelineBuilderExtensionsTests.cs
index 17fab140a8c..34f4408b7e2 100644
--- a/test/Polly.Core.Tests/Simmy/Fault/FaultChaosPipelineBuilderExtensionsTests.cs
+++ b/test/Polly.Core.Tests/Simmy/Fault/FaultChaosPipelineBuilderExtensionsTests.cs
@@ -7,6 +7,7 @@ namespace Polly.Core.Tests.Simmy.Fault;
public class FaultChaosPipelineBuilderExtensionsTests
{
+#pragma warning disable IDE0028
public static readonly TheoryData> FaultStrategy = new()
{
builder =>
@@ -21,8 +22,9 @@ public class FaultChaosPipelineBuilderExtensionsTests
AssertFaultStrategy(builder, true, 0.6)
.Fault.Should().BeOfType(typeof(InvalidOperationException));
- }
+ },
};
+#pragma warning restore IDE0028
private static void AssertFaultStrategy(ResiliencePipelineBuilder builder, bool enabled, double injectionRate)
where TException : Exception
diff --git a/test/Polly.Core.Tests/Simmy/Fault/FaultChaosStrategyTests.cs b/test/Polly.Core.Tests/Simmy/Fault/FaultChaosStrategyTests.cs
index c7014e1a5ce..1a076c6791e 100644
--- a/test/Polly.Core.Tests/Simmy/Fault/FaultChaosStrategyTests.cs
+++ b/test/Polly.Core.Tests/Simmy/Fault/FaultChaosStrategyTests.cs
@@ -7,7 +7,7 @@ namespace Polly.Core.Tests.Simmy.Fault;
public class FaultChaosStrategyTests
{
private readonly ResilienceStrategyTelemetry _telemetry;
- private readonly List> _args = new();
+ private readonly List> _args = [];
public FaultChaosStrategyTests() => _telemetry = TestUtilities.CreateResilienceTelemetry(arg => _args.Add(arg));
diff --git a/test/Polly.Core.Tests/Simmy/Latency/LatencyChaosStrategyTests.cs b/test/Polly.Core.Tests/Simmy/Latency/LatencyChaosStrategyTests.cs
index 10b733b4f52..361ab2d75ba 100644
--- a/test/Polly.Core.Tests/Simmy/Latency/LatencyChaosStrategyTests.cs
+++ b/test/Polly.Core.Tests/Simmy/Latency/LatencyChaosStrategyTests.cs
@@ -11,7 +11,7 @@ public class LatencyChaosStrategyTests : IDisposable
private readonly LatencyStrategyOptions _options;
private readonly CancellationTokenSource _cancellationSource;
private readonly TimeSpan _delay = TimeSpan.FromMilliseconds(500);
- private readonly List> _args = new();
+ private readonly List> _args = [];
public LatencyChaosStrategyTests()
{
diff --git a/test/Polly.Core.Tests/Simmy/Outcomes/OutcomeChaosPipelineBuilderExtensionsTests.cs b/test/Polly.Core.Tests/Simmy/Outcomes/OutcomeChaosPipelineBuilderExtensionsTests.cs
index 946b2a442f8..bfc56cfb9e2 100644
--- a/test/Polly.Core.Tests/Simmy/Outcomes/OutcomeChaosPipelineBuilderExtensionsTests.cs
+++ b/test/Polly.Core.Tests/Simmy/Outcomes/OutcomeChaosPipelineBuilderExtensionsTests.cs
@@ -7,6 +7,7 @@ namespace Polly.Core.Tests.Simmy.Outcomes;
public class OutcomeChaosPipelineBuilderExtensionsTests
{
+#pragma warning disable IDE0028
public static readonly TheoryData>> ResultStrategy = new()
{
builder =>
@@ -20,8 +21,9 @@ public class OutcomeChaosPipelineBuilderExtensionsTests
});
AssertResultStrategy(builder, true, 0.6, new(100));
- }
+ },
};
+#pragma warning restore IDE0028
private static void AssertResultStrategy(ResiliencePipelineBuilder builder, bool enabled, double injectionRate, Outcome outcome)
{
diff --git a/test/Polly.Core.Tests/Simmy/Outcomes/OutcomeChaosStrategyTests.cs b/test/Polly.Core.Tests/Simmy/Outcomes/OutcomeChaosStrategyTests.cs
index 7a7e8fb631e..ada7f9e8a1a 100644
--- a/test/Polly.Core.Tests/Simmy/Outcomes/OutcomeChaosStrategyTests.cs
+++ b/test/Polly.Core.Tests/Simmy/Outcomes/OutcomeChaosStrategyTests.cs
@@ -6,7 +6,7 @@ namespace Polly.Core.Tests.Simmy.Outcomes;
public class OutcomeChaosStrategyTests
{
private readonly ResilienceStrategyTelemetry _telemetry;
- private readonly List> _args = new();
+ private readonly List> _args = [];
public OutcomeChaosStrategyTests() => _telemetry = TestUtilities.CreateResilienceTelemetry(arg => _args.Add(arg));
diff --git a/test/Polly.Core.Tests/Telemetry/ResilienceStrategyTelemetryTests.cs b/test/Polly.Core.Tests/Telemetry/ResilienceStrategyTelemetryTests.cs
index fb2d56f1154..90b58338be1 100644
--- a/test/Polly.Core.Tests/Telemetry/ResilienceStrategyTelemetryTests.cs
+++ b/test/Polly.Core.Tests/Telemetry/ResilienceStrategyTelemetryTests.cs
@@ -4,7 +4,7 @@ namespace Polly.Core.Tests.Telemetry;
public class ResilienceStrategyTelemetryTests
{
- private readonly List> _args = new();
+ private readonly List> _args = [];
private readonly ResilienceTelemetrySource _source;
private readonly ResilienceStrategyTelemetry _sut;
diff --git a/test/Polly.Core.Tests/Timeout/TimeoutResilienceStrategyTests.cs b/test/Polly.Core.Tests/Timeout/TimeoutResilienceStrategyTests.cs
index 7bebeb49bcd..c625d0958dc 100644
--- a/test/Polly.Core.Tests/Timeout/TimeoutResilienceStrategyTests.cs
+++ b/test/Polly.Core.Tests/Timeout/TimeoutResilienceStrategyTests.cs
@@ -12,7 +12,7 @@ public class TimeoutResilienceStrategyTests : IDisposable
private readonly TimeoutStrategyOptions _options;
private readonly CancellationTokenSource _cancellationSource;
private readonly TimeSpan _delay = TimeSpan.FromSeconds(12);
- private readonly List> _args = new();
+ private readonly List> _args = [];
public TimeoutResilienceStrategyTests()
{
diff --git a/test/Polly.Core.Tests/Timeout/TimeoutTestUtils.cs b/test/Polly.Core.Tests/Timeout/TimeoutTestUtils.cs
index 302cdc8be4a..ce037d8cf8c 100644
--- a/test/Polly.Core.Tests/Timeout/TimeoutTestUtils.cs
+++ b/test/Polly.Core.Tests/Timeout/TimeoutTestUtils.cs
@@ -8,6 +8,7 @@ public static class TimeoutTestUtils
public static TimeoutGeneratorArguments TimeoutGeneratorArguments() => new(ResilienceContextPool.Shared.Get());
+#pragma warning disable IDE0028
public static readonly TheoryData InvalidTimeouts = new()
{
TimeSpan.MinValue,
@@ -21,4 +22,5 @@ public static class TimeoutTestUtils
TimeSpan.FromSeconds(1),
TimeSpan.FromHours(1),
};
+#pragma warning restore IDE0028
}
diff --git a/test/Polly.Core.Tests/Utils/Pipeline/ReloadablePipelineComponentTests.cs b/test/Polly.Core.Tests/Utils/Pipeline/ReloadablePipelineComponentTests.cs
index 371e4d88219..b60d1e17110 100644
--- a/test/Polly.Core.Tests/Utils/Pipeline/ReloadablePipelineComponentTests.cs
+++ b/test/Polly.Core.Tests/Utils/Pipeline/ReloadablePipelineComponentTests.cs
@@ -8,7 +8,7 @@ public class ReloadablePipelineComponentTests : IDisposable
{
private readonly FakeTelemetryListener _listener;
private readonly ResilienceStrategyTelemetry _telemetry;
- private readonly List _synchronousFlags = new();
+ private readonly List _synchronousFlags = [];
private CancellationTokenSource _cancellationTokenSource;
public ReloadablePipelineComponentTests()
@@ -56,7 +56,7 @@ public async Task ChangeTriggered_EnsureOldStrategyDisposed()
{
var telemetry = TestUtilities.CreateResilienceTelemetry(_listener);
var component = Substitute.For();
- await using var sut = CreateSut(component, () => new(Substitute.For(), new List(), telemetry));
+ await using var sut = CreateSut(component, () => new(Substitute.For(), [], telemetry));
for (var i = 0; i < 10; i++)
{
@@ -131,10 +131,10 @@ public async Task DisposeError_EnsureReported()
private ReloadableComponent CreateSut(PipelineComponent? initial = null, Func? factory = null)
{
- factory ??= () => new ReloadableComponent.Entry(PipelineComponent.Empty, new List(), _telemetry);
+ factory ??= () => new ReloadableComponent.Entry(PipelineComponent.Empty, [], _telemetry);
return (ReloadableComponent)PipelineComponentFactory.CreateReloadable(
- new ReloadableComponent.Entry(initial ?? PipelineComponent.Empty, new List { _cancellationTokenSource.Token }, _telemetry),
+ new ReloadableComponent.Entry(initial ?? PipelineComponent.Empty, [_cancellationTokenSource.Token], _telemetry),
factory);
}
diff --git a/test/Polly.Extensions.Tests/Telemetry/TelemetryListenerImplTests.cs b/test/Polly.Extensions.Tests/Telemetry/TelemetryListenerImplTests.cs
index b6b5a387638..bc86c98e304 100644
--- a/test/Polly.Extensions.Tests/Telemetry/TelemetryListenerImplTests.cs
+++ b/test/Polly.Extensions.Tests/Telemetry/TelemetryListenerImplTests.cs
@@ -12,7 +12,7 @@ public class TelemetryListenerImplTests : IDisposable
{
private readonly FakeLogger _logger;
private readonly ILoggerFactory _loggerFactory;
- private readonly List _events = new();
+ private readonly List _events = [];
private Action>? _onEvent;
public TelemetryListenerImplTests() => _loggerFactory = TestUtilities.CreateLoggerFactory(out _logger);
diff --git a/test/Polly.RateLimiting.Tests/RateLimiterResiliencePipelineBuilderExtensionsTests.cs b/test/Polly.RateLimiting.Tests/RateLimiterResiliencePipelineBuilderExtensionsTests.cs
index 9cf0f4f404a..60326769100 100644
--- a/test/Polly.RateLimiting.Tests/RateLimiterResiliencePipelineBuilderExtensionsTests.cs
+++ b/test/Polly.RateLimiting.Tests/RateLimiterResiliencePipelineBuilderExtensionsTests.cs
@@ -9,6 +9,7 @@ namespace Polly.RateLimiting.Tests;
public class RateLimiterResiliencePipelineBuilderExtensionsTests
{
+#pragma warning disable IDE0028
public static readonly TheoryData> Data = new()
{
builder =>
@@ -41,6 +42,7 @@ public class RateLimiterResiliencePipelineBuilderExtensionsTests
AssertRateLimiterStrategy(builder, strategy => strategy.Wrapper.Should().BeNull());
}
};
+#pragma warning restore IDE0028
[MemberData(nameof(Data))]
[Theory(Skip = "https://github.com/stryker-mutator/stryker-net/issues/2144")]
diff --git a/test/Polly.Specs/CircuitBreaker/AdvancedCircuitBreakerAsyncSpecs.cs b/test/Polly.Specs/CircuitBreaker/AdvancedCircuitBreakerAsyncSpecs.cs
index 73c234a9493..42911a81b9f 100644
--- a/test/Polly.Specs/CircuitBreaker/AdvancedCircuitBreakerAsyncSpecs.cs
+++ b/test/Polly.Specs/CircuitBreaker/AdvancedCircuitBreakerAsyncSpecs.cs
@@ -2358,7 +2358,7 @@ await breaker.Awaiting(x => x.RaiseExceptionAsync())
[Fact]
public async Task Should_call_onbreak_with_a_state_of_half_open()
{
- List transitionedStates = new List();
+ List transitionedStates = [];
Action onBreak = (_, state, _, _) => { transitionedStates.Add(state); };
Action onReset = _ => { };
diff --git a/test/Polly.Specs/CircuitBreaker/AdvancedCircuitBreakerSpecs.cs b/test/Polly.Specs/CircuitBreaker/AdvancedCircuitBreakerSpecs.cs
index d65c1c59412..d2140938f8b 100644
--- a/test/Polly.Specs/CircuitBreaker/AdvancedCircuitBreakerSpecs.cs
+++ b/test/Polly.Specs/CircuitBreaker/AdvancedCircuitBreakerSpecs.cs
@@ -1601,7 +1601,7 @@ public void Should_only_allow_single_execution_on_first_entering_halfopen_state_
permitFirstExecutionEnd.Set();
#pragma warning disable xUnit1031 // Do not use blocking task operations in test method
- Task.WaitAll(new[] { firstExecution, secondExecution }, testTimeoutToExposeDeadlocks).Should().BeTrue();
+ Task.WaitAll([firstExecution, secondExecution], testTimeoutToExposeDeadlocks).Should().BeTrue();
#pragma warning restore xUnit1031 // Do not use blocking task operations in test method
if (firstExecution.IsFaulted)
@@ -1713,7 +1713,7 @@ public void Should_allow_single_execution_per_break_duration_in_halfopen_state__
permitFirstExecutionEnd.Set();
#pragma warning disable xUnit1031 // Do not use blocking task operations in test method
- Task.WaitAll(new[] { firstExecution, secondExecution }, testTimeoutToExposeDeadlocks).Should().BeTrue();
+ Task.WaitAll([firstExecution, secondExecution], testTimeoutToExposeDeadlocks).Should().BeTrue();
#pragma warning restore xUnit1031 // Do not use blocking task operations in test method
if (firstExecution.IsFaulted)
@@ -2032,8 +2032,12 @@ public void Should_call_onbreak_when_breaking_circuit_first_time_but_not_for_sub
#pragma warning disable xUnit1031 // Do not use blocking task operations in test method
longRunningExecution.Wait(testTimeoutToExposeDeadlocks).Should().BeTrue();
#pragma warning restore xUnit1031 // Do not use blocking task operations in test method
+
if (longRunningExecution.IsFaulted)
+ {
throw longRunningExecution!.Exception!;
+ }
+
longRunningExecution.Status.Should().Be(TaskStatus.RanToCompletion);
// onBreak() should still only have been called once.
@@ -2355,7 +2359,7 @@ public void Should_call_onbreak_with_a_state_of_closed()
[Fact]
public void Should_call_onbreak_with_a_state_of_half_open()
{
- List transitionedStates = new List();
+ List transitionedStates = [];
Action onBreak = (_, state, _, _) => { transitionedStates.Add(state); };
Action onReset = _ => { };
diff --git a/test/Polly.Specs/CircuitBreaker/CircuitBreakerAsyncSpecs.cs b/test/Polly.Specs/CircuitBreaker/CircuitBreakerAsyncSpecs.cs
index 571c66005ee..0a46d9ee986 100644
--- a/test/Polly.Specs/CircuitBreaker/CircuitBreakerAsyncSpecs.cs
+++ b/test/Polly.Specs/CircuitBreaker/CircuitBreakerAsyncSpecs.cs
@@ -1074,7 +1074,7 @@ await breaker.Awaiting(x => x.RaiseExceptionAsync())
[Fact]
public async Task Should_call_onbreak_with_a_state_of_half_open()
{
- List transitionedStates = new List();
+ List