diff --git a/src/Polly.Core/Hedging/Controller/HedgingHandler.cs b/src/Polly.Core/Hedging/Controller/HedgingHandler.cs index 0d9a54262af..ec762a19f7a 100644 --- a/src/Polly.Core/Hedging/Controller/HedgingHandler.cs +++ b/src/Polly.Core/Hedging/Controller/HedgingHandler.cs @@ -12,7 +12,7 @@ internal sealed record class HedgingHandler( var copiedArgs = new HedgingActionGeneratorArguments( args.PrimaryContext, args.ActionContext, - args.Attempt, + args.AttemptNumber, (Func>>)(object)args.Callback); return (Func>>?)(object)ActionGenerator(copiedArgs)!; @@ -24,7 +24,7 @@ internal sealed record class HedgingHandler( private Func>>? CreateNonGenericAction(HedgingActionGeneratorArguments args) { var generator = (Func, Func>>?>)(object)ActionGenerator; - var action = generator(new HedgingActionGeneratorArguments(args.PrimaryContext, args.ActionContext, args.Attempt, async context => + var action = generator(new HedgingActionGeneratorArguments(args.PrimaryContext, args.ActionContext, args.AttemptNumber, async context => { var outcome = await args.Callback(context).ConfigureAwait(context.ContinueOnCapturedContext); return outcome.AsOutcome(); diff --git a/src/Polly.Core/Hedging/Controller/TaskExecution.cs b/src/Polly.Core/Hedging/Controller/TaskExecution.cs index d91f32c6060..7e6553ad324 100644 --- a/src/Polly.Core/Hedging/Controller/TaskExecution.cs +++ b/src/Polly.Core/Hedging/Controller/TaskExecution.cs @@ -65,7 +65,7 @@ public TaskExecution(HedgingHandler handler, CancellationTokenSourcePool canc public TimeSpan ExecutionTime => _timeProvider.GetElapsedTime(_startExecutionTimestamp, _stopExecutionTimestamp); - public int Attempt { get; private set; } + public int AttemptNumber { get; private set; } public void AcceptOutcome() { @@ -92,9 +92,9 @@ public async ValueTask InitializeAsync( ContextSnapshot snapshot, Func>> primaryCallback, TState state, - int attempt) + int attemptNumber) { - Attempt = attempt; + AttemptNumber = attemptNumber; Type = type; _cancellationSource = _cancellationTokenSourcePool.Get(System.Threading.Timeout.InfiniteTimeSpan); _startExecutionTimestamp = _timeProvider.GetTimestamp(); @@ -113,7 +113,7 @@ public async ValueTask InitializeAsync( try { - action = _handler.GenerateAction(CreateArguments(primaryCallback, snapshot.Context, state, attempt)); + action = _handler.GenerateAction(CreateArguments(primaryCallback, snapshot.Context, state, attemptNumber)); if (action == null) { await ResetAsync().ConfigureAwait(false); @@ -178,7 +178,7 @@ public async ValueTask ResetAsync() IsHandled = false; Properties.Clear(); OnReset = null; - Attempt = 0; + AttemptNumber = 0; _activeContext = null; _cachedContext.Reset(); _cancellationSource = null!; @@ -227,7 +227,7 @@ private async Task UpdateOutcomeAsync(Outcome outcome) var args = new OutcomeArguments(Context, outcome, default); Outcome = outcome.AsOutcome(); IsHandled = await _handler.ShouldHandle(args).ConfigureAwait(Context.ContinueOnCapturedContext); - TelemetryUtil.ReportExecutionAttempt(_telemetry, Context, outcome, Attempt, ExecutionTime, IsHandled); + TelemetryUtil.ReportExecutionAttempt(_telemetry, Context, outcome, AttemptNumber, ExecutionTime, IsHandled); } private void PrepareContext(ref ContextSnapshot snapshot) diff --git a/src/Polly.Core/Hedging/HedgingActionGeneratorArguments.cs b/src/Polly.Core/Hedging/HedgingActionGeneratorArguments.cs index 9de0b577210..20e50b650e9 100644 --- a/src/Polly.Core/Hedging/HedgingActionGeneratorArguments.cs +++ b/src/Polly.Core/Hedging/HedgingActionGeneratorArguments.cs @@ -18,17 +18,17 @@ public readonly struct HedgingActionGeneratorArguments /// /// The context that will be passed to action generated by . /// . - /// The zero-based hedging attempt number. + /// The zero-based hedging attempt number. /// The callback passed to hedging strategy. public HedgingActionGeneratorArguments( ResilienceContext primaryContext, ResilienceContext actionContext, - int attempt, + int attemptNumber, Func>> callback) { PrimaryContext = primaryContext; ActionContext = actionContext; - Attempt = attempt; + AttemptNumber = attemptNumber; Callback = callback; } @@ -48,7 +48,7 @@ public HedgingActionGeneratorArguments( /// /// Gets the zero-based hedging attempt number. /// - public int Attempt { get; } + public int AttemptNumber { get; } /// /// Gets the callback passed to hedging strategy. diff --git a/src/Polly.Core/Hedging/HedgingDelayArguments.cs b/src/Polly.Core/Hedging/HedgingDelayArguments.cs index 9f0fa9f201c..0792e0ddda6 100644 --- a/src/Polly.Core/Hedging/HedgingDelayArguments.cs +++ b/src/Polly.Core/Hedging/HedgingDelayArguments.cs @@ -14,11 +14,11 @@ public readonly struct HedgingDelayArguments /// Initializes a new instance of the struct. /// /// The context associated with the execution of a user-provided callback. - /// The zero-based hedging attempt number. - public HedgingDelayArguments(ResilienceContext context, int attempt) + /// The zero-based hedging attempt number. + public HedgingDelayArguments(ResilienceContext context, int attemptNumber) { Context = context; - Attempt = attempt; + AttemptNumber = attemptNumber; } /// @@ -29,5 +29,5 @@ public HedgingDelayArguments(ResilienceContext context, int attempt) /// /// Gets the zero-based hedging attempt number. /// - public int Attempt { get; } + public int AttemptNumber { get; } } diff --git a/src/Polly.Core/Hedging/OnHedgingArguments.cs b/src/Polly.Core/Hedging/OnHedgingArguments.cs index 1ea70e674e1..2b2db37b08e 100644 --- a/src/Polly.Core/Hedging/OnHedgingArguments.cs +++ b/src/Polly.Core/Hedging/OnHedgingArguments.cs @@ -8,12 +8,12 @@ public sealed class OnHedgingArguments /// /// Initializes a new instance of the class. /// - /// The zero-based hedging attempt number. + /// The zero-based hedging attempt number. /// Indicates whether outcome is available. /// The execution time of hedging attempt or the hedging delay in case the attempt was not finished in time. - public OnHedgingArguments(int attempt, bool hasOutcome, TimeSpan executionTime) + public OnHedgingArguments(int attemptNumber, bool hasOutcome, TimeSpan executionTime) { - Attempt = attempt; + AttemptNumber = attemptNumber; HasOutcome = hasOutcome; ExecutionTime = executionTime; } @@ -21,7 +21,7 @@ public OnHedgingArguments(int attempt, bool hasOutcome, TimeSpan executionTime) /// /// Gets the zero-based hedging attempt number. /// - public int Attempt { get; } + public int AttemptNumber { get; } /// /// Gets a value indicating whether the outcome is available before loading the next hedged task. diff --git a/src/Polly.Core/PublicAPI.Unshipped.txt b/src/Polly.Core/PublicAPI.Unshipped.txt index 28f4521fe64..e7aac574c76 100644 --- a/src/Polly.Core/PublicAPI.Unshipped.txt +++ b/src/Polly.Core/PublicAPI.Unshipped.txt @@ -1,5 +1,4 @@ -#nullable enable -abstract Polly.Registry.ResilienceStrategyProvider.TryGetStrategy(TKey key, out Polly.ResilienceStrategy? strategy) -> bool +abstract Polly.Registry.ResilienceStrategyProvider.TryGetStrategy(TKey key, out Polly.ResilienceStrategy? strategy) -> bool abstract Polly.Registry.ResilienceStrategyProvider.TryGetStrategy(TKey key, out Polly.ResilienceStrategy? strategy) -> bool abstract Polly.ResilienceContextPool.Get(string? operationKey, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Polly.ResilienceContext! abstract Polly.ResilienceContextPool.Return(Polly.ResilienceContext! context) -> void @@ -94,16 +93,16 @@ Polly.Fallback.OnFallbackArguments.OnFallbackArguments() -> void Polly.FallbackResilienceStrategyBuilderExtensions Polly.Hedging.HedgingActionGeneratorArguments Polly.Hedging.HedgingActionGeneratorArguments.ActionContext.get -> Polly.ResilienceContext! -Polly.Hedging.HedgingActionGeneratorArguments.Attempt.get -> int +Polly.Hedging.HedgingActionGeneratorArguments.AttemptNumber.get -> int Polly.Hedging.HedgingActionGeneratorArguments.Callback.get -> System.Func>>! Polly.Hedging.HedgingActionGeneratorArguments.HedgingActionGeneratorArguments() -> void -Polly.Hedging.HedgingActionGeneratorArguments.HedgingActionGeneratorArguments(Polly.ResilienceContext! primaryContext, Polly.ResilienceContext! actionContext, int attempt, System.Func>>! callback) -> void +Polly.Hedging.HedgingActionGeneratorArguments.HedgingActionGeneratorArguments(Polly.ResilienceContext! primaryContext, Polly.ResilienceContext! actionContext, int attemptNumber, System.Func>>! callback) -> void Polly.Hedging.HedgingActionGeneratorArguments.PrimaryContext.get -> Polly.ResilienceContext! Polly.Hedging.HedgingDelayArguments -Polly.Hedging.HedgingDelayArguments.Attempt.get -> int +Polly.Hedging.HedgingDelayArguments.AttemptNumber.get -> int Polly.Hedging.HedgingDelayArguments.Context.get -> Polly.ResilienceContext! Polly.Hedging.HedgingDelayArguments.HedgingDelayArguments() -> void -Polly.Hedging.HedgingDelayArguments.HedgingDelayArguments(Polly.ResilienceContext! context, int attempt) -> void +Polly.Hedging.HedgingDelayArguments.HedgingDelayArguments(Polly.ResilienceContext! context, int attemptNumber) -> void Polly.Hedging.HedgingPredicateArguments Polly.Hedging.HedgingPredicateArguments.HedgingPredicateArguments() -> void Polly.Hedging.HedgingStrategyOptions @@ -121,10 +120,10 @@ Polly.Hedging.HedgingStrategyOptions.OnHedging.set -> void Polly.Hedging.HedgingStrategyOptions.ShouldHandle.get -> System.Func, System.Threading.Tasks.ValueTask>! Polly.Hedging.HedgingStrategyOptions.ShouldHandle.set -> void Polly.Hedging.OnHedgingArguments -Polly.Hedging.OnHedgingArguments.Attempt.get -> int +Polly.Hedging.OnHedgingArguments.AttemptNumber.get -> int Polly.Hedging.OnHedgingArguments.ExecutionTime.get -> System.TimeSpan Polly.Hedging.OnHedgingArguments.HasOutcome.get -> bool -Polly.Hedging.OnHedgingArguments.OnHedgingArguments(int attempt, bool hasOutcome, System.TimeSpan executionTime) -> void +Polly.Hedging.OnHedgingArguments.OnHedgingArguments(int attemptNumber, bool hasOutcome, System.TimeSpan executionTime) -> void Polly.HedgingResilienceStrategyBuilderExtensions Polly.NullResilienceStrategy Polly.NullResilienceStrategy @@ -279,31 +278,31 @@ Polly.ResilienceStrategyBuilderContext.StrategyName.get -> string? Polly.ResilienceStrategyBuilderContext.Telemetry.get -> Polly.Telemetry.ResilienceStrategyTelemetry! Polly.ResilienceStrategyBuilderExtensions Polly.ResilienceStrategyOptions -Polly.ResilienceStrategyOptions.ResilienceStrategyOptions() -> void Polly.ResilienceStrategyOptions.Name.get -> string? Polly.ResilienceStrategyOptions.Name.set -> void +Polly.ResilienceStrategyOptions.ResilienceStrategyOptions() -> void Polly.ResilienceValidationContext Polly.ResilienceValidationContext.Instance.get -> object! Polly.ResilienceValidationContext.PrimaryMessage.get -> string! Polly.ResilienceValidationContext.ResilienceValidationContext(object! instance, string! primaryMessage) -> void Polly.Retry.OnRetryArguments -Polly.Retry.OnRetryArguments.Attempt.get -> int +Polly.Retry.OnRetryArguments.AttemptNumber.get -> int Polly.Retry.OnRetryArguments.ExecutionTime.get -> System.TimeSpan -Polly.Retry.OnRetryArguments.OnRetryArguments(int attempt, System.TimeSpan retryDelay, System.TimeSpan executionTime) -> void +Polly.Retry.OnRetryArguments.OnRetryArguments(int attemptNumber, System.TimeSpan retryDelay, System.TimeSpan executionTime) -> void Polly.Retry.OnRetryArguments.RetryDelay.get -> System.TimeSpan Polly.Retry.RetryBackoffType Polly.Retry.RetryBackoffType.Constant = 0 -> Polly.Retry.RetryBackoffType Polly.Retry.RetryBackoffType.Linear = 1 -> Polly.Retry.RetryBackoffType Polly.Retry.RetryBackoffType.Exponential = 2 -> Polly.Retry.RetryBackoffType Polly.Retry.RetryDelayArguments -Polly.Retry.RetryDelayArguments.Attempt.get -> int +Polly.Retry.RetryDelayArguments.AttemptNumber.get -> int Polly.Retry.RetryDelayArguments.DelayHint.get -> System.TimeSpan Polly.Retry.RetryDelayArguments.RetryDelayArguments() -> void -Polly.Retry.RetryDelayArguments.RetryDelayArguments(int attempt, System.TimeSpan delayHint) -> void +Polly.Retry.RetryDelayArguments.RetryDelayArguments(int attemptNumber, System.TimeSpan delayHint) -> void Polly.Retry.RetryPredicateArguments -Polly.Retry.RetryPredicateArguments.Attempt.get -> int +Polly.Retry.RetryPredicateArguments.AttemptNumber.get -> int Polly.Retry.RetryPredicateArguments.RetryPredicateArguments() -> void -Polly.Retry.RetryPredicateArguments.RetryPredicateArguments(int attempt) -> void +Polly.Retry.RetryPredicateArguments.RetryPredicateArguments(int attemptNumber) -> void Polly.Retry.RetryStrategyOptions Polly.Retry.RetryStrategyOptions.RetryStrategyOptions() -> void Polly.Retry.RetryStrategyOptions @@ -324,8 +323,8 @@ Polly.Retry.RetryStrategyOptions.UseJitter.get -> bool Polly.Retry.RetryStrategyOptions.UseJitter.set -> void Polly.RetryResilienceStrategyBuilderExtensions Polly.Telemetry.ExecutionAttemptArguments -Polly.Telemetry.ExecutionAttemptArguments.Attempt.get -> int -Polly.Telemetry.ExecutionAttemptArguments.ExecutionAttemptArguments(int attempt, System.TimeSpan executionTime, bool handled) -> void +Polly.Telemetry.ExecutionAttemptArguments.AttemptNumber.get -> int +Polly.Telemetry.ExecutionAttemptArguments.ExecutionAttemptArguments(int attemptNumber, System.TimeSpan executionTime, bool handled) -> void Polly.Telemetry.ExecutionAttemptArguments.ExecutionTime.get -> System.TimeSpan Polly.Telemetry.ExecutionAttemptArguments.Handled.get -> bool Polly.Telemetry.ResilienceEvent diff --git a/src/Polly.Core/Retry/OnRetryArguments.cs b/src/Polly.Core/Retry/OnRetryArguments.cs index 34bc2bbb399..9edbf14e2a3 100644 --- a/src/Polly.Core/Retry/OnRetryArguments.cs +++ b/src/Polly.Core/Retry/OnRetryArguments.cs @@ -8,12 +8,12 @@ public sealed class OnRetryArguments /// /// Initializes a new instance of the class. /// - /// The zero-based attempt number. + /// The zero-based attempt number. /// The delay before the next retry. /// The execution time of this attempt. - public OnRetryArguments(int attempt, TimeSpan retryDelay, TimeSpan executionTime) + public OnRetryArguments(int attemptNumber, TimeSpan retryDelay, TimeSpan executionTime) { - Attempt = attempt; + AttemptNumber = attemptNumber; RetryDelay = retryDelay; ExecutionTime = executionTime; } @@ -21,7 +21,7 @@ public OnRetryArguments(int attempt, TimeSpan retryDelay, TimeSpan executionTime /// /// Gets the zero-based attempt number. /// - public int Attempt { get; } + public int AttemptNumber { get; } /// /// Gets the delay before the next retry. diff --git a/src/Polly.Core/Retry/RetryDelayArguments.cs b/src/Polly.Core/Retry/RetryDelayArguments.cs index 854c8b3212a..f9b974c2822 100644 --- a/src/Polly.Core/Retry/RetryDelayArguments.cs +++ b/src/Polly.Core/Retry/RetryDelayArguments.cs @@ -13,18 +13,18 @@ public readonly struct RetryDelayArguments /// /// Initializes a new instance of the struct. /// - /// The zero-based attempt number. + /// The zero-based attempt number. /// The delay suggested by the retry strategy. - public RetryDelayArguments(int attempt, TimeSpan delayHint) + public RetryDelayArguments(int attemptNumber, TimeSpan delayHint) { - Attempt = attempt; + AttemptNumber = attemptNumber; DelayHint = delayHint; } /// /// Gets The zero-based attempt number. /// - public int Attempt { get; } + public int AttemptNumber { get; } /// /// Gets the delay suggested by the retry strategy. diff --git a/src/Polly.Core/Retry/RetryPredicateArguments.cs b/src/Polly.Core/Retry/RetryPredicateArguments.cs index cb13a97733d..5e597bb1984 100644 --- a/src/Polly.Core/Retry/RetryPredicateArguments.cs +++ b/src/Polly.Core/Retry/RetryPredicateArguments.cs @@ -13,11 +13,11 @@ public readonly struct RetryPredicateArguments /// /// Initializes a new instance of the struct. /// - /// The zero-based attempt number. - public RetryPredicateArguments(int attempt) => Attempt = attempt; + /// The zero-based attempt number. + public RetryPredicateArguments(int attemptNumber) => AttemptNumber = attemptNumber; /// /// Gets the zero-based attempt number. /// - public int Attempt { get; } + public int AttemptNumber { get; } } diff --git a/src/Polly.Core/Telemetry/ExecutionAttemptArguments.Pool.cs b/src/Polly.Core/Telemetry/ExecutionAttemptArguments.Pool.cs index 38cee68d3df..07d1ad22c25 100644 --- a/src/Polly.Core/Telemetry/ExecutionAttemptArguments.Pool.cs +++ b/src/Polly.Core/Telemetry/ExecutionAttemptArguments.Pool.cs @@ -5,14 +5,14 @@ public partial class ExecutionAttemptArguments private static readonly ObjectPool Pool = new(() => new ExecutionAttemptArguments(), args => { args.ExecutionTime = TimeSpan.Zero; - args.Attempt = 0; + args.AttemptNumber = 0; args.Handled = false; }); internal static ExecutionAttemptArguments Get(int attempt, TimeSpan executionTime, bool handled) { var args = Pool.Get(); - args.Attempt = attempt; + args.AttemptNumber = attempt; args.ExecutionTime = executionTime; args.Handled = handled; return args; diff --git a/src/Polly.Core/Telemetry/ExecutionAttemptArguments.cs b/src/Polly.Core/Telemetry/ExecutionAttemptArguments.cs index df3dc859f58..a1376f7af3a 100644 --- a/src/Polly.Core/Telemetry/ExecutionAttemptArguments.cs +++ b/src/Polly.Core/Telemetry/ExecutionAttemptArguments.cs @@ -8,12 +8,12 @@ public partial class ExecutionAttemptArguments /// /// Initializes a new instance of the class. /// - /// The execution attempt. + /// The execution attempt number. /// The execution time. /// Determines whether the attempt was handled by the strategy. - public ExecutionAttemptArguments(int attempt, TimeSpan executionTime, bool handled) + public ExecutionAttemptArguments(int attemptNumber, TimeSpan executionTime, bool handled) { - Attempt = attempt; + AttemptNumber = attemptNumber; ExecutionTime = executionTime; Handled = handled; } @@ -25,7 +25,7 @@ private ExecutionAttemptArguments() /// /// Gets the attempt number. /// - public int Attempt { get; private set; } + public int AttemptNumber { get; private set; } /// /// Gets the execution time of the attempt. diff --git a/src/Polly.Extensions/Telemetry/ResilienceTelemetryDiagnosticSource.cs b/src/Polly.Extensions/Telemetry/ResilienceTelemetryDiagnosticSource.cs index 5e832f86e14..de92acce86d 100644 --- a/src/Polly.Extensions/Telemetry/ResilienceTelemetryDiagnosticSource.cs +++ b/src/Polly.Extensions/Telemetry/ResilienceTelemetryDiagnosticSource.cs @@ -99,7 +99,7 @@ private void MeterEvent(TelemetryEventArguments args) var enrichmentContext = EnrichmentContext.Get(args.Context, args.Arguments, args.Outcome); AddCommonTags(args, source, enrichmentContext); - enrichmentContext.Tags.Add(new(ResilienceTelemetryTags.AttemptNumber, executionAttempt.Attempt.AsBoxedInt())); + enrichmentContext.Tags.Add(new(ResilienceTelemetryTags.AttemptNumber, executionAttempt.AttemptNumber.AsBoxedInt())); enrichmentContext.Tags.Add(new(ResilienceTelemetryTags.AttemptHandled, executionAttempt.Handled.AsBoxedBool())); EnrichmentUtil.Enrich(enrichmentContext, _enrichers); AttemptDuration.Record(executionAttempt.ExecutionTime.TotalMilliseconds, enrichmentContext.TagsSpan); @@ -142,7 +142,7 @@ private void LogEvent(TelemetryEventArguments args) args.Context.OperationKey, result, executionAttempt.Handled, - executionAttempt.Attempt, + executionAttempt.AttemptNumber, executionAttempt.ExecutionTime.TotalMilliseconds, args.Outcome?.Exception); } diff --git a/test/Polly.Core.Tests/Hedging/Controller/HedgingExecutionContextTests.cs b/test/Polly.Core.Tests/Hedging/Controller/HedgingExecutionContextTests.cs index 043e9ea3cbd..d533672df6f 100644 --- a/test/Polly.Core.Tests/Hedging/Controller/HedgingExecutionContextTests.cs +++ b/test/Polly.Core.Tests/Hedging/Controller/HedgingExecutionContextTests.cs @@ -236,7 +236,7 @@ public async Task LoadExecutionAsync_EnsureCorrectAttemptNumber() context.Initialize(_resilienceContext); Generator = args => { - attempt = args.Attempt; + attempt = args.AttemptNumber; return null; }; @@ -453,7 +453,7 @@ private void ConfigureSecondaryTasks(params TimeSpan[] delays) { Generator = args => { - var attempt = args.Attempt - 1; + var attempt = args.AttemptNumber - 1; if (attempt >= delays.Length) { diff --git a/test/Polly.Core.Tests/Hedging/Controller/TaskExecutionTests.cs b/test/Polly.Core.Tests/Hedging/Controller/TaskExecutionTests.cs index 05f4665d047..c7214cffef5 100644 --- a/test/Polly.Core.Tests/Hedging/Controller/TaskExecutionTests.cs +++ b/test/Polly.Core.Tests/Hedging/Controller/TaskExecutionTests.cs @@ -23,7 +23,7 @@ public TaskExecutionTests() { if (args.Arguments is ExecutionAttemptArguments attempt) { - _args.Add(ExecutionAttemptArguments.Get(attempt.Attempt, attempt.ExecutionTime, attempt.Handled)); + _args.Add(ExecutionAttemptArguments.Get(attempt.AttemptNumber, attempt.ExecutionTime, attempt.Handled)); } }); @@ -64,7 +64,7 @@ await execution.InitializeAsync(HedgedTaskType.Primary, _snapshot, _args.Should().HaveCount(1); _args[0].Handled.Should().Be(handled); - _args[0].Attempt.Should().Be(99); + _args[0].AttemptNumber.Should().Be(99); } [Fact] @@ -90,7 +90,7 @@ public async Task Initialize_Secondary_Ok(string value, bool handled) Generator = args => { AssertSecondaryContext(args.ActionContext, execution); - args.Attempt.Should().Be(4); + args.AttemptNumber.Should().Be(4); return () => Outcome.FromResultAsTask(new DisposableResult { Name = value }); }; diff --git a/test/Polly.Core.Tests/Hedging/HedgingActionGeneratorArgumentsTests.cs b/test/Polly.Core.Tests/Hedging/HedgingActionGeneratorArgumentsTests.cs index 9d669c3dfd7..0c871989a16 100644 --- a/test/Polly.Core.Tests/Hedging/HedgingActionGeneratorArgumentsTests.cs +++ b/test/Polly.Core.Tests/Hedging/HedgingActionGeneratorArgumentsTests.cs @@ -11,7 +11,7 @@ public void Ctor_Ok() args.PrimaryContext.Should().NotBeNull(); args.ActionContext.Should().NotBeNull(); - args.Attempt.Should().Be(5); + args.AttemptNumber.Should().Be(5); args.Callback.Should().NotBeNull(); } } diff --git a/test/Polly.Core.Tests/Hedging/HedgingActions.cs b/test/Polly.Core.Tests/Hedging/HedgingActions.cs index b542803acf5..e2267d250ab 100644 --- a/test/Polly.Core.Tests/Hedging/HedgingActions.cs +++ b/test/Polly.Core.Tests/Hedging/HedgingActions.cs @@ -19,11 +19,11 @@ public HedgingActions(TimeProvider timeProvider) Generator = args => { - if (args.Attempt <= Functions.Count) + if (args.AttemptNumber <= Functions.Count) { return async () => { - return await Functions[args.Attempt - 1]!(args.ActionContext); + return await Functions[args.AttemptNumber - 1]!(args.ActionContext); }; } diff --git a/test/Polly.Core.Tests/Hedging/HedgingDelayArgumentsTests.cs b/test/Polly.Core.Tests/Hedging/HedgingDelayArgumentsTests.cs index 0c130aa1f89..8880231719f 100644 --- a/test/Polly.Core.Tests/Hedging/HedgingDelayArgumentsTests.cs +++ b/test/Polly.Core.Tests/Hedging/HedgingDelayArgumentsTests.cs @@ -10,6 +10,6 @@ public void Ctor_Ok() var args = new HedgingDelayArguments(ResilienceContextPool.Shared.Get(), 5); args.Context.Should().NotBeNull(); - args.Attempt.Should().Be(5); + args.AttemptNumber.Should().Be(5); } } diff --git a/test/Polly.Core.Tests/Hedging/HedgingResilienceStrategyBuilderExtensionsTests.cs b/test/Polly.Core.Tests/Hedging/HedgingResilienceStrategyBuilderExtensionsTests.cs index 8c5ffa6cb2b..a1b77af6729 100644 --- a/test/Polly.Core.Tests/Hedging/HedgingResilienceStrategyBuilderExtensionsTests.cs +++ b/test/Polly.Core.Tests/Hedging/HedgingResilienceStrategyBuilderExtensionsTests.cs @@ -75,7 +75,7 @@ public async Task AddHedging_IntegrationTest() { await Task.Delay(25, args.ActionContext.CancellationToken); - if (args.Attempt == 3) + if (args.AttemptNumber == 3) { return Outcome.FromResult((object)"success"); } diff --git a/test/Polly.Core.Tests/Hedging/HedgingResilienceStrategyTests.cs b/test/Polly.Core.Tests/Hedging/HedgingResilienceStrategyTests.cs index 2b942d8a34c..fd2c84ababb 100644 --- a/test/Polly.Core.Tests/Hedging/HedgingResilienceStrategyTests.cs +++ b/test/Polly.Core.Tests/Hedging/HedgingResilienceStrategyTests.cs @@ -88,11 +88,11 @@ public void ExecutePrimaryAndSecondary_EnsureAttemptReported() attempts[0].Handled.Should().BeTrue(); attempts[0].ExecutionTime.Should().BeGreaterThan(TimeSpan.Zero); - attempts[0].Attempt.Should().Be(0); + attempts[0].AttemptNumber.Should().Be(0); attempts[1].Handled.Should().BeTrue(); attempts[1].ExecutionTime.Should().BeGreaterThan(TimeSpan.Zero); - attempts[1].Attempt.Should().Be(1); + attempts[1].AttemptNumber.Should().Be(1); } [Fact] @@ -171,7 +171,7 @@ public async Task ExecuteAsync_EnsurePrimaryContextFlows() { args.Context.Should().Be(primaryContext); - if (args.Arguments.Attempt == 0) + if (args.Arguments.AttemptNumber == 0) { args.Context.Properties.Set(key, "dummy"); } @@ -738,7 +738,7 @@ public async Task ExecuteAsync_ExceptionsHandled_ShouldThrowAnyException() }, args => { - Exception exception = args.Attempt switch + Exception exception = args.AttemptNumber switch { 1 => new ArgumentException(), 2 => new InvalidOperationException(), @@ -770,7 +770,7 @@ public async Task ExecuteAsync_ExceptionsHandled_ShouldThrowLastException() }, args => { - Exception exception = args.Attempt switch + Exception exception = args.AttemptNumber switch { 1 => new ArgumentException(), 2 => new InvalidOperationException(), @@ -819,7 +819,7 @@ public async Task ExecuteAsync_ExceptionsHandled_ShouldReturnLastResult() }, args => { - Exception? exception = args.Attempt switch + Exception? exception = args.AttemptNumber switch { 1 => new ArgumentException(), 2 => new InvalidOperationException(), @@ -887,7 +887,7 @@ public async Task ExecuteAsync_EnsureOnHedgingCalled() { args.Arguments.HasOutcome.Should().BeTrue(); args.Result.Should().Be(Failure); - attempts.Add(args.Arguments.Attempt); + attempts.Add(args.Arguments.AttemptNumber); return default; }; diff --git a/test/Polly.Core.Tests/Hedging/OnHedgingArgumentsTests.cs b/test/Polly.Core.Tests/Hedging/OnHedgingArgumentsTests.cs index 9ece83f440f..35e83a47086 100644 --- a/test/Polly.Core.Tests/Hedging/OnHedgingArgumentsTests.cs +++ b/test/Polly.Core.Tests/Hedging/OnHedgingArgumentsTests.cs @@ -9,7 +9,7 @@ public void Ctor_Ok() { var args = new OnHedgingArguments(1, true, TimeSpan.FromSeconds(1)); - args.Attempt.Should().Be(1); + args.AttemptNumber.Should().Be(1); args.HasOutcome.Should().BeTrue(); args.ExecutionTime.Should().Be(TimeSpan.FromSeconds(1)); } diff --git a/test/Polly.Core.Tests/Retry/OnRetryArgumentsTests.cs b/test/Polly.Core.Tests/Retry/OnRetryArgumentsTests.cs index 3237ee134ed..728bacdea97 100644 --- a/test/Polly.Core.Tests/Retry/OnRetryArgumentsTests.cs +++ b/test/Polly.Core.Tests/Retry/OnRetryArgumentsTests.cs @@ -9,7 +9,7 @@ public void Ctor_Ok() { var args = new OnRetryArguments(2, TimeSpan.FromSeconds(3), TimeSpan.MaxValue); - args.Attempt.Should().Be(2); + args.AttemptNumber.Should().Be(2); args.RetryDelay.Should().Be(TimeSpan.FromSeconds(3)); args.ExecutionTime.Should().Be(TimeSpan.MaxValue); } diff --git a/test/Polly.Core.Tests/Retry/RetryDelayArgumentsTests.cs b/test/Polly.Core.Tests/Retry/RetryDelayArgumentsTests.cs index 3dc9e50dce1..ca7830e006c 100644 --- a/test/Polly.Core.Tests/Retry/RetryDelayArgumentsTests.cs +++ b/test/Polly.Core.Tests/Retry/RetryDelayArgumentsTests.cs @@ -9,7 +9,7 @@ public void Ctor_Ok() { var args = new RetryDelayArguments(2, TimeSpan.FromSeconds(2)); - args.Attempt.Should().Be(2); + args.AttemptNumber.Should().Be(2); args.DelayHint.Should().Be(TimeSpan.FromSeconds(2)); } } diff --git a/test/Polly.Core.Tests/Retry/RetryResilienceStrategyTests.cs b/test/Polly.Core.Tests/Retry/RetryResilienceStrategyTests.cs index 20732fb78e5..7b5d4b404db 100644 --- a/test/Polly.Core.Tests/Retry/RetryResilienceStrategyTests.cs +++ b/test/Polly.Core.Tests/Retry/RetryResilienceStrategyTests.cs @@ -206,7 +206,7 @@ public async void OnRetry_EnsureCorrectArguments() var delays = new List(); _options.OnRetry = args => { - attempts.Add(args.Arguments.Attempt); + attempts.Add(args.Arguments.AttemptNumber); delays.Add(args.Arguments.RetryDelay); args.Exception.Should().BeNull(); @@ -267,7 +267,7 @@ public void Execute_EnsureAttemptReported() var attempt = args.Arguments.Should().BeOfType().Subject; attempt.Handled.Should().BeFalse(); - attempt.Attempt.Should().Be(0); + attempt.AttemptNumber.Should().Be(0); attempt.ExecutionTime.Should().Be(TimeSpan.FromSeconds(1)); called = true; }); @@ -309,7 +309,7 @@ public void RetryDelayGenerator_EnsureCorrectArguments() var hints = new List(); _options.RetryDelayGenerator = args => { - attempts.Add(args.Arguments.Attempt); + attempts.Add(args.Arguments.AttemptNumber); hints.Add(args.Arguments.DelayHint); args.Exception.Should().BeNull(); diff --git a/test/Polly.Core.Tests/Retry/ShouldRetryArgumentsTests.cs b/test/Polly.Core.Tests/Retry/ShouldRetryArgumentsTests.cs index f7ea700348b..0439064ae40 100644 --- a/test/Polly.Core.Tests/Retry/ShouldRetryArgumentsTests.cs +++ b/test/Polly.Core.Tests/Retry/ShouldRetryArgumentsTests.cs @@ -8,6 +8,6 @@ public class ShouldRetryArgumentsTests public void Ctor_Ok() { var args = new RetryPredicateArguments(2); - args.Attempt.Should().Be(2); + args.AttemptNumber.Should().Be(2); } } diff --git a/test/Polly.Core.Tests/Telemetry/ExecutionAttemptArgumentsTests.cs b/test/Polly.Core.Tests/Telemetry/ExecutionAttemptArgumentsTests.cs index 91a3c105c5d..001bdeadbe3 100644 --- a/test/Polly.Core.Tests/Telemetry/ExecutionAttemptArgumentsTests.cs +++ b/test/Polly.Core.Tests/Telemetry/ExecutionAttemptArgumentsTests.cs @@ -9,7 +9,7 @@ public void Ctor_Ok() { var args = new ExecutionAttemptArguments(99, TimeSpan.MaxValue, true); Assert.NotNull(args); - args.Attempt.Should().Be(99); + args.AttemptNumber.Should().Be(99); args.ExecutionTime.Should().Be(TimeSpan.MaxValue); args.Handled.Should().BeTrue(); } @@ -19,7 +19,7 @@ public void Get_Ok() { var args = ExecutionAttemptArguments.Get(99, TimeSpan.MaxValue, true); Assert.NotNull(args); - args.Attempt.Should().Be(99); + args.AttemptNumber.Should().Be(99); args.ExecutionTime.Should().Be(TimeSpan.MaxValue); args.Handled.Should().BeTrue(); } @@ -31,7 +31,7 @@ public void Return_EnsurePropertiesCleared() ExecutionAttemptArguments.Return(args); - args.Attempt.Should().Be(0); + args.AttemptNumber.Should().Be(0); args.ExecutionTime.Should().Be(TimeSpan.Zero); args.Handled.Should().BeFalse(); } diff --git a/test/Polly.TestUtils/TestUtilities.cs b/test/Polly.TestUtils/TestUtilities.cs index 166b5f85a7c..763eb1758fa 100644 --- a/test/Polly.TestUtils/TestUtilities.cs +++ b/test/Polly.TestUtils/TestUtilities.cs @@ -124,7 +124,7 @@ public override void Write(string name, object? value) if (arguments is ExecutionAttemptArguments attempt) { - arguments = ExecutionAttemptArguments.Get(attempt.Attempt, attempt.ExecutionTime, attempt.Handled); + arguments = ExecutionAttemptArguments.Get(attempt.AttemptNumber, attempt.ExecutionTime, attempt.Handled); } // copy the args because these are pooled and in tests we want to preserve them