<PackageReference Include="Polly.Core" Version="8.0.0-alpha.3" />

TimeoutAttribute

using System; using System.ComponentModel.DataAnnotations; using System.Globalization; using System.Runtime.CompilerServices; namespace Polly.Timeout { internal sealed class TimeoutAttribute : ValidationAttribute { [System.Runtime.CompilerServices.NullableContext(2)] protected override ValidationResult IsValid(object value, [System.Runtime.CompilerServices.Nullable(1)] ValidationContext validationContext) { if (value is TimeSpan) { TimeSpan timeSpan = (TimeSpan)value; if (!TimeoutUtil.IsTimeoutValid(timeSpan)) return new ValidationResult(string.Format(CultureInfo.InvariantCulture, "The '{0}' must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).", timeSpan)); } return ValidationResult.Success; } } }