ChaosStrategyHelper
using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace Polly.Simmy.Utils
{
    internal static class ChaosStrategyHelper
    {
        [NullableContext(1)]
        [AsyncStateMachine(typeof(<ShouldInjectAsync>d__0))]
        [return: Nullable(0)]
        public static ValueTask<bool> ShouldInjectAsync(ResilienceContext context, [Nullable(new byte[] {
            1,
            0
        })] Func<InjectionRateGeneratorArguments, ValueTask<double>> injectionRateGenerator, [Nullable(new byte[] {
            1,
            0
        })] Func<EnabledGeneratorArguments, ValueTask<bool>> enabledGenerator, Func<double> randomizer)
        {
            <ShouldInjectAsync>d__0 stateMachine = default(<ShouldInjectAsync>d__0);
            stateMachine.<>t__builder = AsyncValueTaskMethodBuilder<bool>.Create();
            stateMachine.context = context;
            stateMachine.injectionRateGenerator = injectionRateGenerator;
            stateMachine.enabledGenerator = enabledGenerator;
            stateMachine.randomizer = randomizer;
            stateMachine.<>1__state = -1;
            stateMachine.<>t__builder.Start(ref stateMachine);
            return stateMachine.<>t__builder.Task;
        }
        private static double CoerceInjectionThreshold(double injectionThreshold)
        {
            if (injectionThreshold < 0)
                return 0;
            if (injectionThreshold > 1)
                return 1;
            return injectionThreshold;
        }
    }
}