From c6e01a6bfa379155e7776797d21994bdedc23887 Mon Sep 17 00:00:00 2001 From: Dixin Date: Mon, 29 Jan 2024 01:54:45 -0800 Subject: [PATCH] Fix bugs. --- .../RetryStrategyOptions.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Source/TransientFaultHandling.Configuration.Core/RetryStrategyOptions.cs b/Source/TransientFaultHandling.Configuration.Core/RetryStrategyOptions.cs index 98133c3..bab16fa 100644 --- a/Source/TransientFaultHandling.Configuration.Core/RetryStrategyOptions.cs +++ b/Source/TransientFaultHandling.Configuration.Core/RetryStrategyOptions.cs @@ -10,9 +10,9 @@ public abstract record RetryStrategyOptions(bool FastFirstRetry); /// public record FixedIntervalOptions(bool FastFirstRetry, int RetryCount, TimeSpan RetryInterval) : RetryStrategyOptions(FastFirstRetry) { - private readonly int retryCount; + private readonly int retryCount = RetryCount.ThrowIfNegative(); - private readonly TimeSpan retryInterval; + private readonly TimeSpan retryInterval = RetryInterval.ThrowIfNegative(); /// /// Initializes a new instance of the record. @@ -45,11 +45,11 @@ public TimeSpan RetryInterval /// public record IncrementalOptions(bool FastFirstRetry, int RetryCount, TimeSpan InitialInterval, TimeSpan Increment) : RetryStrategyOptions(FastFirstRetry) { - private readonly int retryCount; + private readonly int retryCount = RetryCount.ThrowIfNegative(); - private readonly TimeSpan initialInterval; + private readonly TimeSpan initialInterval = InitialInterval.ThrowIfNegative(); - private readonly TimeSpan increment; + private readonly TimeSpan increment = Increment.ThrowIfNegative(); /// /// Initializes a new instance of the record. @@ -91,13 +91,13 @@ public TimeSpan Increment /// public record ExponentialBackoffOptions(bool FastFirstRetry, int RetryCount, TimeSpan MinBackOff, TimeSpan MaxBackOff, TimeSpan DeltaBackOff) : RetryStrategyOptions(FastFirstRetry) { - private readonly int retryCount; + private readonly int retryCount = RetryCount.ThrowIfNegative(); - private readonly TimeSpan minBackOff; + private readonly TimeSpan minBackOff = MinBackOff.ThrowIfOutOfRange(TimeSpan.Zero, MaxBackOff); - private readonly TimeSpan maxBackOff; + private readonly TimeSpan maxBackOff = MaxBackOff.ThrowIfNegative(); - private readonly TimeSpan deltaBackOff; + private readonly TimeSpan deltaBackOff = DeltaBackOff.ThrowIfNegative(); /// /// Initializes a new instance of the record. @@ -120,7 +120,7 @@ public int RetryCount /// public TimeSpan MinBackOff { - get => this.minBackOff; + get => this.minBackOff.ThrowIfOutOfRange(TimeSpan.Zero, this.maxBackOff); init => this.minBackOff = value.ThrowIfNegative(); }