RetryResilienceStrategy<T>
using Polly.Telemetry;
using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace Polly.Retry
{
    [System.Runtime.CompilerServices.NullableContext(1)]
    [System.Runtime.CompilerServices.Nullable(new byte[] {
        0,
        1
    })]
    internal sealed class RetryResilienceStrategy<[System.Runtime.CompilerServices.Nullable(2)] T> : ResilienceStrategy<T>
    {
        private readonly TimeProvider _timeProvider;
        private readonly ResilienceStrategyTelemetry _telemetry;
        private readonly Func<double> _randomizer;
        public TimeSpan BaseDelay { get; }
        public TimeSpan? MaxDelay { get; }
        public DelayBackoffType BackoffType { get; }
        public int RetryCount { get; }
        [System.Runtime.CompilerServices.Nullable(new byte[] {
            1,
            0,
            1,
            0
        })]
        [field: System.Runtime.CompilerServices.Nullable(new byte[] {
            1,
            0,
            1,
            0
        })]
        public Func<RetryPredicateArguments<T>, ValueTask<bool>> ShouldHandle {
            [return: System.Runtime.CompilerServices.Nullable(new byte[] {
                1,
                0,
                1,
                0
            })]
            get;
        }
        [System.Runtime.CompilerServices.Nullable(new byte[] {
            2,
            0,
            1,
            0
        })]
        [field: System.Runtime.CompilerServices.Nullable(new byte[] {
            2,
            0,
            1,
            0
        })]
        public Func<RetryDelayGeneratorArguments<T>, ValueTask<TimeSpan?>> DelayGenerator {
            [return: System.Runtime.CompilerServices.Nullable(new byte[] {
                2,
                0,
                1,
                0
            })]
            get;
        }
        public bool UseJitter { get; }
        [System.Runtime.CompilerServices.Nullable(new byte[] {
            2,
            0,
            1
        })]
        [field: System.Runtime.CompilerServices.Nullable(new byte[] {
            2,
            0,
            1
        })]
        public Func<OnRetryArguments<T>, ValueTask> OnRetry {
            [return: System.Runtime.CompilerServices.Nullable(new byte[] {
                2,
                0,
                1
            })]
            get;
        }
        public RetryResilienceStrategy(RetryStrategyOptions<T> options, TimeProvider timeProvider, ResilienceStrategyTelemetry telemetry)
        {
            ShouldHandle = options.ShouldHandle;
            BaseDelay = options.Delay;
            MaxDelay = options.MaxDelay;
            BackoffType = options.BackoffType;
            RetryCount = options.MaxRetryAttempts;
            OnRetry = options.OnRetry;
            DelayGenerator = options.DelayGenerator;
            UseJitter = options.UseJitter;
            _timeProvider = timeProvider;
            _telemetry = telemetry;
            _randomizer = options.Randomizer;
        }
        [AsyncStateMachine(typeof(<ExecuteCore>d__28<>))]
        [return: System.Runtime.CompilerServices.Nullable(new byte[] {
            0,
            0,
            1
        })]
        protected internal override ValueTask<Outcome<T>> ExecuteCore<[System.Runtime.CompilerServices.Nullable(2)] TState>([System.Runtime.CompilerServices.Nullable(new byte[] {
            1,
            1,
            1,
            0,
            0,
            1
        })] Func<ResilienceContext, TState, ValueTask<Outcome<T>>> callback, ResilienceContext context, TState state)
        {
            <ExecuteCore>d__28<TState> stateMachine = default(<ExecuteCore>d__28<TState>);
            stateMachine.<>t__builder = AsyncValueTaskMethodBuilder<Outcome<T>>.Create();
            stateMachine.<>4__this = this;
            stateMachine.callback = callback;
            stateMachine.context = context;
            stateMachine.state = state;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        internal bool IsLastAttempt(int attempt, out bool incrementAttempts)
        {
            if (attempt == 2147483647) {
                incrementAttempts = false;
                return false;
            }
            incrementAttempts = true;
            return attempt >= RetryCount;
        }
    }
}