Improvements
- Eliminated closure allocations across all
Fallback,Retry, andExecutepolicy processor methods by introducing internal/private overloads that accept the originalAction<TParam>,Func<TParam, T>,Func<TParam, CancellationToken, Task>andFunc<TParam, CancellationToken, Task<T>>delegates directly.
Applied these optimizations consistently to:DefaultRetryProcessor(sync and async variants, with and withoutRetryDelay/RetryCountInfo)DefaultFallbackProcessor(sync and async variants)SimplePolicyProcessor(sync and async execution paths)
- Add
DefaultRetryProcessorasync method overloads with requiredCancellationTokenparameter (noconfigureAwait), delegating to existing methods withconfigureAwaitset tofalse:RetryAsync<TParam>andRetryAsync<TParam, T>(with and withoutRetryDelay)RetryInfiniteAsync<TParam>andRetryInfiniteAsync<TParam, T>(with and withoutRetryDelay)RetryWithErrorContextAsync<TErrorContext>andRetryWithErrorContextAsync<TErrorContext, T>(with and withoutRetryDelay)RetryInfiniteWithErrorContextAsync<TErrorContext>andRetryInfiniteWithErrorContextAsync<TErrorContext, T>(with and withoutRetryDelay)
- Add
DefaultFallbackProcessorasync method overloads with requiredCancellationTokenparameter (noconfigureAwait), delegating to existing methods withconfigureAwaitset tofalse:FallbackAsync<TErrorContext>andFallbackAsync<TErrorContext, T>FallbackAsync<TParam>andFallbackAsync<TParam, T>
- Add
SimplePolicyProcessorasync method overloads with requiredCancellationTokenparameter (noconfigureAwait), delegating to existing methods withconfigureAwaitset tofalse:ExecuteAsync<TErrorContext>andExecuteAsync<TErrorContext, T>ExecuteAsync<TParam>andExecuteAsync<TParam, T>
- Introduce abstract
ErrorProcessor<TParam>with an overridableExecutemethod for parameter-aware error processing. - Introduce
void Policy.AddHandlerForPolicyResultextension method overloads. - Introduce an internal
PolicyResult.SetCanceledEarlymethod to markNoErrorastrueon early cancellation and apply it to all coreRetry,Fallback, andSimplepolicy processor methods.
Small changes
- Convert
SimplePolicyProcessor.AddErrorAndCatchBlockFilterErrorfrom a private method to an extension method on thePolicyResultclass. - Add internal
PolicyResult.ToLastPolicyResultStateextension method and refactor to useLastPolicyResultStateclass. - Refactor
PolicyProcessor.ExceptionFilterby extracting its logic into a new internalExceptionFilterSetclass. - DRY refactor
ConstantRetryDelay. - DRY refactor
ExponentialRetryDelay. - DRY refactor
LinearRetryDelay. - DRY refactor
TimeSeriesRetryDelay. - DRY refactoring of all internal
IPolicyProcessor.WithErrorContextProcessorOf<T, TErrorContext>extension methods to unify shared logic across their variousAction<Exception, ProcessingErrorInfo<TErrorContext>>overloads. - DRY refactoring of all internal
IPolicyProcessor.WithErrorContextProcessorOf<T, TErrorContext>extension methods to unify shared logic across their variousFunc<Exception, ProcessingErrorInfo<TErrorContext>, Task>overloads. - Refactor
PolicyDelegateCollectionResultBaseinternal constructor and add new tests forPolicyDelegateCollectionResult. - Mark
PolicyResult.ChangeByRetryDelayResultas obsolete. - Rename
DefaultRetryProcessor.RetryOverloads.csfile toDefaultRetryProcessor.RetryOverloads.RetryDelay.cs. - Move all
DefaultRetryProcessor.Retry...methods that take anint retryCountparameter intoDefaultRetryProcessor.RetryOverloads.LimitedRetries.cs. - Move all
DefaultRetryProcessor.Retry…methods withRetryDelayandint retryCountparameters intoDefaultRetryProcessor.RetryOverloads.RetryDelay.LimitedRetries.cs. - Move all
DefaultRetryProcessormethods that useConfigureAwait(false)into the new filesDefaultRetryProcessor.RetryAsync.ConfigureAwaitFalse.csandDefaultRetryProcessor.RetryDelay.RetryAsync.ConfigureAwaitFalse.cs - Move non-interface
DefaultRetryProcessor Retry(Async)methods toDefaultRetryProcessor.RetryOverloads.cs. - Add new tests for
RetryCountInfo.
Docs changes
- Update XML documentation for
ErrorProcessor.ProcessandErrorProcessor.ProcessAsyncto clarify that both methods directly callExecute. - Add
PolicyResult.WrappedStatuschecks to existing tests. - Edit 'Error processors' README Chapter.
- Edit 'Retry-Then-Fallback' README chapter.
- Update
PolicyResultREADME Chapter. - Add THIRD-PARTY-NOTICES.