ChaosLatencyStrategy
using Polly.Telemetry;
using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace Polly.Simmy.Latency
{
    [System.Runtime.CompilerServices.NullableContext(1)]
    [System.Runtime.CompilerServices.Nullable(0)]
    internal sealed class ChaosLatencyStrategy : ChaosStrategy
    {
        private readonly TimeProvider _timeProvider;
        private readonly ResilienceStrategyTelemetry _telemetry;
        [System.Runtime.CompilerServices.Nullable(2)]
        [field: System.Runtime.CompilerServices.Nullable(2)]
        public Func<OnLatencyInjectedArguments, ValueTask> OnLatencyInjected {
            [System.Runtime.CompilerServices.NullableContext(2)]
            get;
        }
        [System.Runtime.CompilerServices.Nullable(new byte[] {
            1,
            0
        })]
        [field: System.Runtime.CompilerServices.Nullable(new byte[] {
            1,
            0
        })]
        public Func<LatencyGeneratorArguments, ValueTask<TimeSpan>> LatencyGenerator {
            [return: System.Runtime.CompilerServices.Nullable(new byte[] {
                1,
                0
            })]
            get;
        }
        public TimeSpan? Latency { get; }
        public ChaosLatencyStrategy(ChaosLatencyStrategyOptions options, TimeProvider timeProvider, ResilienceStrategyTelemetry telemetry)
            : base(options)
        {
            Latency = options.Latency;
            LatencyGenerator = ((options.LatencyGenerator != null) ? options.LatencyGenerator : ((Func<LatencyGeneratorArguments, ValueTask<TimeSpan>>)((LatencyGeneratorArguments _) => new ValueTask<TimeSpan>(options.Latency))));
            OnLatencyInjected = options.OnLatencyInjected;
            _telemetry = telemetry;
            _timeProvider = timeProvider;
        }
        [AsyncStateMachine(typeof(<ExecuteCore>d__12<, >))]
        [return: System.Runtime.CompilerServices.Nullable(new byte[] {
            0,
            0,
            1
        })]
        protected internal override ValueTask<Outcome<TResult>> ExecuteCore<[System.Runtime.CompilerServices.Nullable(2)] TResult, [System.Runtime.CompilerServices.Nullable(2)] TState>([System.Runtime.CompilerServices.Nullable(new byte[] {
            1,
            1,
            1,
            0,
            0,
            1
        })] Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>> callback, ResilienceContext context, TState state)
        {
            <ExecuteCore>d__12<TResult, TState> stateMachine = default(<ExecuteCore>d__12<TResult, TState>);
            stateMachine.<>t__builder = AsyncValueTaskMethodBuilder<Outcome<TResult>>.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;
        }
    }
}