From 17936eec3a0ad7c5661e270ff2b8a4ff1a4fb487 Mon Sep 17 00:00:00 2001
From: iamdmitrij <3024338+iamdmitrij@users.noreply.github.com>
Date: Wed, 15 May 2024 18:40:27 +0300
Subject: [PATCH 1/4] Make S3872 a suggestion
---
.editorconfig | 4 ++++
src/Polly/Polly.csproj | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/.editorconfig b/.editorconfig
index c73c66ab9ba..b9449d38ed1 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -18,6 +18,10 @@ indent_style = space
indent_size = 2
tab_width = 2
+# S3872 // Interfaces should not be empty
+[**/Timeout/{TimeoutSyntax,TimeoutTResultSyntax}.cs]
+dotnet_diagnostic.S3872.severity = suggestion
+
# C# files
[*.cs]
diff --git a/src/Polly/Polly.csproj b/src/Polly/Polly.csproj
index b7353686b1c..651825f1047 100644
--- a/src/Polly/Polly.csproj
+++ b/src/Polly/Polly.csproj
@@ -7,7 +7,7 @@
Library
70
true
- $(NoWarn);S3872;SA1414;S3215
+ $(NoWarn);SA1414;S3215
$(NoWarn);IDE1006;CA1062;CA1068;S4039;CA1063;CA1031;CA1051
$(NoWarn);CA2211;S2223;CA1032;CA1815;CA1816;S4457;CA1033
$(NoWarn);CA1010;CA1064;SA1118
From e2497870ff9709d3fa87c6aa4e522b8844fbd4c4 Mon Sep 17 00:00:00 2001
From: iamdmitrij <3024338+iamdmitrij@users.noreply.github.com>
Date: Wed, 15 May 2024 18:57:14 +0300
Subject: [PATCH 2/4] Introduce explicit suppressions for S3872
---
.editorconfig | 4 ----
src/Polly/Timeout/TimeoutSyntax.cs | 12 ++++++++++++
src/Polly/Timeout/TimeoutTResultSyntax.cs | 15 ++++++++++++++-
3 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/.editorconfig b/.editorconfig
index b9449d38ed1..c73c66ab9ba 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -18,10 +18,6 @@ indent_style = space
indent_size = 2
tab_width = 2
-# S3872 // Interfaces should not be empty
-[**/Timeout/{TimeoutSyntax,TimeoutTResultSyntax}.cs]
-dotnet_diagnostic.S3872.severity = suggestion
-
# C# files
[*.cs]
diff --git a/src/Polly/Timeout/TimeoutSyntax.cs b/src/Polly/Timeout/TimeoutSyntax.cs
index 11e93aef83a..6be52ab6700 100644
--- a/src/Polly/Timeout/TimeoutSyntax.cs
+++ b/src/Polly/Timeout/TimeoutSyntax.cs
@@ -109,7 +109,9 @@ public static TimeoutPolicy Timeout(int seconds, TimeoutStrategy timeoutStrategy
/// The timeout.
/// The policy instance.
/// timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).
+#pragma warning disable S3872
public static TimeoutPolicy Timeout(TimeSpan timeout)
+#pragma warning restore S3872
{
TimeoutValidator.ValidateTimeSpanTimeout(timeout);
Action doNothing = (_, _, _, _) => { };
@@ -124,7 +126,9 @@ public static TimeoutPolicy Timeout(TimeSpan timeout)
/// The timeout strategy.
/// The policy instance.
/// timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).
+#pragma warning disable S3872
public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutStrategy timeoutStrategy)
+#pragma warning restore S3872
{
TimeoutValidator.ValidateTimeSpanTimeout(timeout);
Action doNothing = (_, _, _, _) => { };
@@ -141,7 +145,9 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutStrategy timeoutStr
/// The policy instance.
/// timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).
/// Thrown when is .
+#pragma warning disable S3872
public static TimeoutPolicy Timeout(TimeSpan timeout, Action onTimeout)
+#pragma warning restore S3872
{
TimeoutValidator.ValidateTimeSpanTimeout(timeout);
@@ -157,7 +163,9 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, ActionThe policy instance.
/// timeout;Value must be greater than zero.
/// Thrown when is .
+#pragma warning disable S3872
public static TimeoutPolicy Timeout(TimeSpan timeout, Action onTimeout)
+#pragma warning restore S3872
{
TimeoutValidator.ValidateTimeSpanTimeout(timeout);
@@ -174,7 +182,9 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, ActionThe policy instance.
/// timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).
/// Thrown when is .
+#pragma warning disable S3872
public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutStrategy timeoutStrategy, Action onTimeout)
+#pragma warning restore S3872
{
TimeoutValidator.ValidateTimeSpanTimeout(timeout);
@@ -191,7 +201,9 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutStrategy timeoutStr
/// The policy instance.
/// timeout;Value must be greater than zero.
/// Thrown when is .
+#pragma warning disable S3872
public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutStrategy timeoutStrategy, Action onTimeout)
+#pragma warning restore S3872
{
TimeoutValidator.ValidateTimeSpanTimeout(timeout);
diff --git a/src/Polly/Timeout/TimeoutTResultSyntax.cs b/src/Polly/Timeout/TimeoutTResultSyntax.cs
index 4bac3b4d8b6..ad180921f6f 100644
--- a/src/Polly/Timeout/TimeoutTResultSyntax.cs
+++ b/src/Polly/Timeout/TimeoutTResultSyntax.cs
@@ -115,7 +115,10 @@ public static TimeoutPolicy Timeout(int seconds, TimeoutStrate
/// The timeout.
/// The policy instance.
/// timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).
- public static TimeoutPolicy Timeout(TimeSpan timeout)
+#pragma warning disable S3872
+ public static TimeoutPolicy Timeout(TimeSpan
+ timeout)
+#pragma warning restore S3872
{
TimeoutValidator.ValidateTimeSpanTimeout(timeout);
Action doNothing = (_, _, _, _) => { };
@@ -131,7 +134,9 @@ public static TimeoutPolicy Timeout(TimeSpan timeout)
/// The timeout strategy.
/// The policy instance.
/// timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).
+#pragma warning disable S3872
public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutStrategy timeoutStrategy)
+#pragma warning restore S3872
{
TimeoutValidator.ValidateTimeSpanTimeout(timeout);
Action doNothing = (_, _, _, _) => { };
@@ -149,7 +154,9 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutS
/// The policy instance.
/// timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).
/// Thrown when is .
+#pragma warning disable S3872
public static TimeoutPolicy Timeout(TimeSpan timeout, Action onTimeout)
+#pragma warning restore S3872
{
TimeoutValidator.ValidateTimeSpanTimeout(timeout);
return Timeout(_ => timeout, TimeoutStrategy.Optimistic, onTimeout);
@@ -165,7 +172,9 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, ActionThe policy instance.
/// timeout;Value must be greater than zero.
/// Thrown when is .
+#pragma warning disable S3872
public static TimeoutPolicy Timeout(TimeSpan timeout, Action onTimeout)
+#pragma warning restore S3872
{
TimeoutValidator.ValidateTimeSpanTimeout(timeout);
return Timeout(_ => timeout, TimeoutStrategy.Optimistic, onTimeout);
@@ -182,7 +191,9 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, ActionThe policy instance.
/// timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).
/// Thrown when is .
+#pragma warning disable S3872
public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutStrategy timeoutStrategy, Action onTimeout)
+#pragma warning restore S3872
{
TimeoutValidator.ValidateTimeSpanTimeout(timeout);
return Timeout(_ => timeout, timeoutStrategy, onTimeout);
@@ -199,7 +210,9 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutS
/// The policy instance.
/// timeout;Value must be greater than zero.
/// Thrown when is .
+#pragma warning disable S3872
public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutStrategy timeoutStrategy, Action onTimeout)
+#pragma warning restore S3872
{
TimeoutValidator.ValidateTimeSpanTimeout(timeout);
return Timeout(_ => timeout, timeoutStrategy, onTimeout);
From 38cffec9a58722f700997839409367ebedd1729a Mon Sep 17 00:00:00 2001
From: iamdmitrij <3024338+iamdmitrij@users.noreply.github.com>
Date: Wed, 15 May 2024 19:00:00 +0300
Subject: [PATCH 3/4] Fix code formatter mistake
---
src/Polly/Timeout/TimeoutTResultSyntax.cs | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/Polly/Timeout/TimeoutTResultSyntax.cs b/src/Polly/Timeout/TimeoutTResultSyntax.cs
index ad180921f6f..2f56c3017a0 100644
--- a/src/Polly/Timeout/TimeoutTResultSyntax.cs
+++ b/src/Polly/Timeout/TimeoutTResultSyntax.cs
@@ -116,8 +116,7 @@ public static TimeoutPolicy Timeout(int seconds, TimeoutStrate
/// The policy instance.
/// timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).
#pragma warning disable S3872
- public static TimeoutPolicy Timeout(TimeSpan
- timeout)
+ public static TimeoutPolicy Timeout(TimeSpan timeout)
#pragma warning restore S3872
{
TimeoutValidator.ValidateTimeSpanTimeout(timeout);
From ecd9d0debde4db23e29f631732ded2f350a81cf6 Mon Sep 17 00:00:00 2001
From: iamdmitrij <3024338+iamdmitrij@users.noreply.github.com>
Date: Wed, 15 May 2024 20:49:39 +0300
Subject: [PATCH 4/4] Move suppressions above summary block
---
src/Polly/Timeout/TimeoutSyntax.cs | 12 ++++++------
src/Polly/Timeout/TimeoutTResultSyntax.cs | 12 ++++++------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/Polly/Timeout/TimeoutSyntax.cs b/src/Polly/Timeout/TimeoutSyntax.cs
index 6be52ab6700..5c9574eae07 100644
--- a/src/Polly/Timeout/TimeoutSyntax.cs
+++ b/src/Polly/Timeout/TimeoutSyntax.cs
@@ -103,13 +103,13 @@ public static TimeoutPolicy Timeout(int seconds, TimeoutStrategy timeoutStrategy
return Timeout(_ => TimeSpan.FromSeconds(seconds), timeoutStrategy, onTimeout);
}
+#pragma warning disable S3872
///
/// Builds a that will wait for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout.
///
/// The timeout.
/// The policy instance.
/// timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).
-#pragma warning disable S3872
public static TimeoutPolicy Timeout(TimeSpan timeout)
#pragma warning restore S3872
{
@@ -119,6 +119,7 @@ public static TimeoutPolicy Timeout(TimeSpan timeout)
return Timeout(_ => timeout, TimeoutStrategy.Optimistic, doNothing);
}
+#pragma warning disable S3872
///
/// Builds a that will wait for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout.
///
@@ -126,7 +127,6 @@ public static TimeoutPolicy Timeout(TimeSpan timeout)
/// The timeout strategy.
/// The policy instance.
/// timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).
-#pragma warning disable S3872
public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutStrategy timeoutStrategy)
#pragma warning restore S3872
{
@@ -136,6 +136,7 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutStrategy timeoutStr
return Timeout(_ => timeout, timeoutStrategy, doNothing);
}
+#pragma warning disable S3872
///
/// Builds a that will wait for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout.
///
@@ -145,7 +146,6 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutStrategy timeoutStr
/// The policy instance.
/// timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).
/// Thrown when is .
-#pragma warning disable S3872
public static TimeoutPolicy Timeout(TimeSpan timeout, Action onTimeout)
#pragma warning restore S3872
{
@@ -154,6 +154,7 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, Action timeout, TimeoutStrategy.Optimistic, onTimeout);
}
+#pragma warning disable S3872
///
/// Builds a that will wait for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout.
///
@@ -163,7 +164,6 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, ActionThe policy instance.
/// timeout;Value must be greater than zero.
/// Thrown when is .
-#pragma warning disable S3872
public static TimeoutPolicy Timeout(TimeSpan timeout, Action onTimeout)
#pragma warning restore S3872
{
@@ -172,6 +172,7 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, Action timeout, TimeoutStrategy.Optimistic, onTimeout);
}
+#pragma warning disable S3872
///
/// Builds a that will wait for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout.
///
@@ -182,7 +183,6 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, ActionThe policy instance.
/// timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).
/// Thrown when is .
-#pragma warning disable S3872
public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutStrategy timeoutStrategy, Action onTimeout)
#pragma warning restore S3872
{
@@ -191,6 +191,7 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutStrategy timeoutStr
return Timeout(_ => timeout, timeoutStrategy, onTimeout);
}
+#pragma warning disable S3872
///
/// Builds a that will wait for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout.
///
@@ -201,7 +202,6 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutStrategy timeoutStr
/// The policy instance.
/// timeout;Value must be greater than zero.
/// Thrown when is .
-#pragma warning disable S3872
public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutStrategy timeoutStrategy, Action onTimeout)
#pragma warning restore S3872
{
diff --git a/src/Polly/Timeout/TimeoutTResultSyntax.cs b/src/Polly/Timeout/TimeoutTResultSyntax.cs
index 2f56c3017a0..0bb9490ae09 100644
--- a/src/Polly/Timeout/TimeoutTResultSyntax.cs
+++ b/src/Polly/Timeout/TimeoutTResultSyntax.cs
@@ -108,6 +108,7 @@ public static TimeoutPolicy Timeout(int seconds, TimeoutStrate
return Timeout(_ => TimeSpan.FromSeconds(seconds), timeoutStrategy, onTimeout);
}
+#pragma warning disable S3872
///
/// Builds a that will wait for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout.
///
@@ -115,7 +116,6 @@ public static TimeoutPolicy Timeout(int seconds, TimeoutStrate
/// The timeout.
/// The policy instance.
/// timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).
-#pragma warning disable S3872
public static TimeoutPolicy Timeout(TimeSpan timeout)
#pragma warning restore S3872
{
@@ -125,6 +125,7 @@ public static TimeoutPolicy Timeout(TimeSpan timeout)
return Timeout(_ => timeout, TimeoutStrategy.Optimistic, doNothing);
}
+#pragma warning disable S3872
///
/// Builds a that will wait for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout.
///
@@ -133,7 +134,6 @@ public static TimeoutPolicy Timeout(TimeSpan timeout)
/// The timeout strategy.
/// The policy instance.
/// timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).
-#pragma warning disable S3872
public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutStrategy timeoutStrategy)
#pragma warning restore S3872
{
@@ -143,6 +143,7 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutS
return Timeout(_ => timeout, timeoutStrategy, doNothing);
}
+#pragma warning disable S3872
///
/// Builds a that will wait for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout.
///
@@ -153,7 +154,6 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutS
/// The policy instance.
/// timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).
/// Thrown when is .
-#pragma warning disable S3872
public static TimeoutPolicy Timeout(TimeSpan timeout, Action onTimeout)
#pragma warning restore S3872
{
@@ -161,6 +161,7 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, Action(_ => timeout, TimeoutStrategy.Optimistic, onTimeout);
}
+#pragma warning disable S3872
///
/// Builds a that will wait for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout.
///
@@ -171,7 +172,6 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, ActionThe policy instance.
/// timeout;Value must be greater than zero.
/// Thrown when is .
-#pragma warning disable S3872
public static TimeoutPolicy Timeout(TimeSpan timeout, Action onTimeout)
#pragma warning restore S3872
{
@@ -179,6 +179,7 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, Action(_ => timeout, TimeoutStrategy.Optimistic, onTimeout);
}
+#pragma warning disable S3872
///
/// Builds a that will wait for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout.
///
@@ -190,7 +191,6 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, ActionThe policy instance.
/// timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout).
/// Thrown when is .
-#pragma warning disable S3872
public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutStrategy timeoutStrategy, Action onTimeout)
#pragma warning restore S3872
{
@@ -198,6 +198,7 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutS
return Timeout(_ => timeout, timeoutStrategy, onTimeout);
}
+#pragma warning disable S3872
///
/// Builds a that will wait for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout.
///
@@ -209,7 +210,6 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutS
/// The policy instance.
/// timeout;Value must be greater than zero.
/// Thrown when is .
-#pragma warning disable S3872
public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutStrategy timeoutStrategy, Action onTimeout)
#pragma warning restore S3872
{