Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Polly/Polly.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ProjectType>Library</ProjectType>
<MutationScore>70</MutationScore>
<IncludePollyUsings>true</IncludePollyUsings>
<NoWarn>$(NoWarn);S3872;SA1414;S3215</NoWarn>
<NoWarn>$(NoWarn);SA1414;S3215</NoWarn>
<NoWarn>$(NoWarn);IDE1006;CA1062;CA1068;S4039;CA1063;CA1031;CA1051</NoWarn>
<NoWarn>$(NoWarn);CA2211;S2223;CA1032;CA1815;CA1816;S4457;CA1033</NoWarn>
<NoWarn>$(NoWarn);CA1010;CA1064;SA1118</NoWarn>
Expand Down
12 changes: 12 additions & 0 deletions src/Polly/Timeout/TimeoutSyntax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,23 @@ public static TimeoutPolicy Timeout(int seconds, TimeoutStrategy timeoutStrategy
return Timeout(_ => TimeSpan.FromSeconds(seconds), timeoutStrategy, onTimeout);
}

#pragma warning disable S3872
/// <summary>
/// Builds a <see cref="Policy"/> that will wait for a delegate to complete for a specified period of time. A <see cref="TimeoutRejectedException"/> will be thrown if the delegate does not complete within the configured timeout.
/// </summary>
/// <param name="timeout">The timeout.</param>
/// <returns>The policy instance.</returns>
/// <exception cref="ArgumentOutOfRangeException">timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).</exception>
public static TimeoutPolicy Timeout(TimeSpan timeout)
#pragma warning restore S3872
{
TimeoutValidator.ValidateTimeSpanTimeout(timeout);
Action<Context, TimeSpan, Task, Exception> doNothing = (_, _, _, _) => { };

return Timeout(_ => timeout, TimeoutStrategy.Optimistic, doNothing);
}

#pragma warning disable S3872
/// <summary>
/// Builds a <see cref="Policy" /> that will wait for a delegate to complete for a specified period of time. A <see cref="TimeoutRejectedException" /> will be thrown if the delegate does not complete within the configured timeout.
/// </summary>
Expand All @@ -125,13 +128,15 @@ public static TimeoutPolicy Timeout(TimeSpan timeout)
/// <returns>The policy instance.</returns>
/// <exception cref="ArgumentOutOfRangeException">timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).</exception>
public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutStrategy timeoutStrategy)
#pragma warning restore S3872
{
TimeoutValidator.ValidateTimeSpanTimeout(timeout);
Action<Context, TimeSpan, Task, Exception> doNothing = (_, _, _, _) => { };

return Timeout(_ => timeout, timeoutStrategy, doNothing);
}

#pragma warning disable S3872
/// <summary>
/// Builds a <see cref="Policy"/> that will wait for a delegate to complete for a specified period of time. A <see cref="TimeoutRejectedException"/> will be thrown if the delegate does not complete within the configured timeout.
/// </summary>
Expand All @@ -142,12 +147,14 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutStrategy timeoutStr
/// <exception cref="ArgumentOutOfRangeException">timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).</exception>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="onTimeout"/> is <see langword="null"/>.</exception>
public static TimeoutPolicy Timeout(TimeSpan timeout, Action<Context, TimeSpan, Task> onTimeout)
#pragma warning restore S3872
{
TimeoutValidator.ValidateTimeSpanTimeout(timeout);

return Timeout(_ => timeout, TimeoutStrategy.Optimistic, onTimeout);
}

#pragma warning disable S3872
/// <summary>
/// Builds a <see cref="Policy"/> that will wait for a delegate to complete for a specified period of time. A <see cref="TimeoutRejectedException"/> will be thrown if the delegate does not complete within the configured timeout.
/// </summary>
Expand All @@ -158,12 +165,14 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, Action<Context, TimeSpan,
/// <exception cref="ArgumentOutOfRangeException">timeout;Value must be greater than zero.</exception>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="onTimeout"/> is <see langword="null"/>.</exception>
public static TimeoutPolicy Timeout(TimeSpan timeout, Action<Context, TimeSpan, Task, Exception> onTimeout)
#pragma warning restore S3872
{
TimeoutValidator.ValidateTimeSpanTimeout(timeout);

return Timeout(_ => timeout, TimeoutStrategy.Optimistic, onTimeout);
}

#pragma warning disable S3872
/// <summary>
/// Builds a <see cref="Policy" /> that will wait for a delegate to complete for a specified period of time. A <see cref="TimeoutRejectedException" /> will be thrown if the delegate does not complete within the configured timeout.
/// </summary>
Expand All @@ -175,12 +184,14 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, Action<Context, TimeSpan,
/// <exception cref="ArgumentOutOfRangeException">timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).</exception>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="onTimeout"/> is <see langword="null"/>.</exception>
public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutStrategy timeoutStrategy, Action<Context, TimeSpan, Task> onTimeout)
#pragma warning restore S3872
{
TimeoutValidator.ValidateTimeSpanTimeout(timeout);

return Timeout(_ => timeout, timeoutStrategy, onTimeout);
}

#pragma warning disable S3872
/// <summary>
/// Builds a <see cref="Policy" /> that will wait for a delegate to complete for a specified period of time. A <see cref="TimeoutRejectedException" /> will be thrown if the delegate does not complete within the configured timeout.
/// </summary>
Expand All @@ -192,6 +203,7 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutStrategy timeoutStr
/// <exception cref="ArgumentOutOfRangeException">timeout;Value must be greater than zero.</exception>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="onTimeout"/> is <see langword="null"/>.</exception>
public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutStrategy timeoutStrategy, Action<Context, TimeSpan, Task, Exception> onTimeout)
#pragma warning restore S3872
{
TimeoutValidator.ValidateTimeSpanTimeout(timeout);

Expand Down
12 changes: 12 additions & 0 deletions src/Polly/Timeout/TimeoutTResultSyntax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public static TimeoutPolicy<TResult> Timeout<TResult>(int seconds, TimeoutStrate
return Timeout<TResult>(_ => TimeSpan.FromSeconds(seconds), timeoutStrategy, onTimeout);
}

#pragma warning disable S3872
/// <summary>
/// Builds a <see cref="Policy{TResult}"/> that will wait for a delegate to complete for a specified period of time. A <see cref="TimeoutRejectedException"/> will be thrown if the delegate does not complete within the configured timeout.
/// </summary>
Expand All @@ -116,13 +117,15 @@ public static TimeoutPolicy<TResult> Timeout<TResult>(int seconds, TimeoutStrate
/// <returns>The policy instance.</returns>
/// <exception cref="ArgumentOutOfRangeException">timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).</exception>
public static TimeoutPolicy<TResult> Timeout<TResult>(TimeSpan timeout)
#pragma warning restore S3872
{
TimeoutValidator.ValidateTimeSpanTimeout(timeout);
Action<Context, TimeSpan, Task, Exception> doNothing = (_, _, _, _) => { };

return Timeout<TResult>(_ => timeout, TimeoutStrategy.Optimistic, doNothing);
}

#pragma warning disable S3872
/// <summary>
/// Builds a <see cref="Policy{TResult}" /> that will wait for a delegate to complete for a specified period of time. A <see cref="TimeoutRejectedException" /> will be thrown if the delegate does not complete within the configured timeout.
/// </summary>
Expand All @@ -132,13 +135,15 @@ public static TimeoutPolicy<TResult> Timeout<TResult>(TimeSpan timeout)
/// <returns>The policy instance.</returns>
/// <exception cref="ArgumentOutOfRangeException">timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).</exception>
public static TimeoutPolicy<TResult> Timeout<TResult>(TimeSpan timeout, TimeoutStrategy timeoutStrategy)
#pragma warning restore S3872
{
TimeoutValidator.ValidateTimeSpanTimeout(timeout);
Action<Context, TimeSpan, Task, Exception> doNothing = (_, _, _, _) => { };

return Timeout<TResult>(_ => timeout, timeoutStrategy, doNothing);
}

#pragma warning disable S3872
/// <summary>
/// Builds a <see cref="Policy{TResult}"/> that will wait for a delegate to complete for a specified period of time. A <see cref="TimeoutRejectedException"/> will be thrown if the delegate does not complete within the configured timeout.
/// </summary>
Expand All @@ -150,11 +155,13 @@ public static TimeoutPolicy<TResult> Timeout<TResult>(TimeSpan timeout, TimeoutS
/// <exception cref="ArgumentOutOfRangeException">timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).</exception>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="onTimeout"/> is <see langword="null"/>.</exception>
public static TimeoutPolicy<TResult> Timeout<TResult>(TimeSpan timeout, Action<Context, TimeSpan, Task> onTimeout)
#pragma warning restore S3872
{
TimeoutValidator.ValidateTimeSpanTimeout(timeout);
return Timeout<TResult>(_ => timeout, TimeoutStrategy.Optimistic, onTimeout);
}

#pragma warning disable S3872
/// <summary>
/// Builds a <see cref="Policy{TResult}"/> that will wait for a delegate to complete for a specified period of time. A <see cref="TimeoutRejectedException"/> will be thrown if the delegate does not complete within the configured timeout.
/// </summary>
Expand All @@ -166,11 +173,13 @@ public static TimeoutPolicy<TResult> Timeout<TResult>(TimeSpan timeout, Action<C
/// <exception cref="ArgumentOutOfRangeException">timeout;Value must be greater than zero.</exception>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="onTimeout"/> is <see langword="null"/>.</exception>
public static TimeoutPolicy<TResult> Timeout<TResult>(TimeSpan timeout, Action<Context, TimeSpan, Task, Exception> onTimeout)
#pragma warning restore S3872
{
TimeoutValidator.ValidateTimeSpanTimeout(timeout);
return Timeout<TResult>(_ => timeout, TimeoutStrategy.Optimistic, onTimeout);
}

#pragma warning disable S3872
/// <summary>
/// Builds a <see cref="Policy{TResult}" /> that will wait for a delegate to complete for a specified period of time. A <see cref="TimeoutRejectedException" /> will be thrown if the delegate does not complete within the configured timeout.
/// </summary>
Expand All @@ -183,11 +192,13 @@ public static TimeoutPolicy<TResult> Timeout<TResult>(TimeSpan timeout, Action<C
/// <exception cref="ArgumentOutOfRangeException">timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).</exception>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="onTimeout"/> is <see langword="null"/>.</exception>
public static TimeoutPolicy<TResult> Timeout<TResult>(TimeSpan timeout, TimeoutStrategy timeoutStrategy, Action<Context, TimeSpan, Task> onTimeout)
#pragma warning restore S3872
{
TimeoutValidator.ValidateTimeSpanTimeout(timeout);
return Timeout<TResult>(_ => timeout, timeoutStrategy, onTimeout);
}

#pragma warning disable S3872
/// <summary>
/// Builds a <see cref="Policy{TResult}" /> that will wait for a delegate to complete for a specified period of time. A <see cref="TimeoutRejectedException" /> will be thrown if the delegate does not complete within the configured timeout.
/// </summary>
Expand All @@ -200,6 +211,7 @@ public static TimeoutPolicy<TResult> Timeout<TResult>(TimeSpan timeout, TimeoutS
/// <exception cref="ArgumentOutOfRangeException">timeout;Value must be greater than zero.</exception>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="onTimeout"/> is <see langword="null"/>.</exception>
public static TimeoutPolicy<TResult> Timeout<TResult>(TimeSpan timeout, TimeoutStrategy timeoutStrategy, Action<Context, TimeSpan, Task, Exception> onTimeout)
#pragma warning restore S3872
{
TimeoutValidator.ValidateTimeSpanTimeout(timeout);
return Timeout<TResult>(_ => timeout, timeoutStrategy, onTimeout);
Expand Down