Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix S3215 #2198

Closed
wants to merge 2 commits into from
Closed
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 @@ -8,7 +8,7 @@
<MutationScore>70</MutationScore>
<IncludePollyUsings>true</IncludePollyUsings>
<NoWarn>$(NoWarn);CA1010;CA1031;CA1051;CA1062;CA1063;CA1064;CA1710;CA1716;CA1724;CA1805;CA1815;CA1816;CA2211</NoWarn>
<NoWarn>$(NoWarn);S2223;S3215;S3246;S3971;S4039;S4457</NoWarn>
<NoWarn>$(NoWarn);S2223;S3246;S3971;S4039;S4457</NoWarn>
<!--Public API Analyzers: We do not need to fix these as it would break compatibility with released Polly versions-->
<NoWarn>$(NoWarn);RS0037;</NoWarn>
</PropertyGroup>
Expand Down
10 changes: 6 additions & 4 deletions src/Polly/Wrap/IAsyncPolicyPolicyWrapExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static AsyncPolicyWrap WrapAsync(this IAsyncPolicy outerPolicy, IAsyncPol
throw new ArgumentNullException(nameof(outerPolicy));
}

return ((AsyncPolicy)outerPolicy).WrapAsync(innerPolicy);
return outerPolicy.WrapAsync(innerPolicy);
}

/// <summary>
Expand All @@ -35,7 +35,7 @@ public static AsyncPolicyWrap<TResult> WrapAsync<TResult>(this IAsyncPolicy oute
throw new ArgumentNullException(nameof(outerPolicy));
}

return ((AsyncPolicy)outerPolicy).WrapAsync(innerPolicy);
return outerPolicy.WrapAsync(innerPolicy);
}

/// <summary>
Expand All @@ -52,7 +52,7 @@ public static AsyncPolicyWrap<TResult> WrapAsync<TResult>(this IAsyncPolicy<TRes
throw new ArgumentNullException(nameof(outerPolicy));
}

return ((AsyncPolicy<TResult>)outerPolicy).WrapAsync(innerPolicy);
return outerPolicy.WrapAsync(innerPolicy);
}

/// <summary>
Expand All @@ -69,7 +69,7 @@ public static AsyncPolicyWrap<TResult> WrapAsync<TResult>(this IAsyncPolicy<TRes
throw new ArgumentNullException(nameof(outerPolicy));
}

return ((AsyncPolicy<TResult>)outerPolicy).WrapAsync(innerPolicy);
return outerPolicy.WrapAsync(innerPolicy);
}
}

Expand Down Expand Up @@ -148,6 +148,7 @@ public AsyncPolicyWrap<TResult> WrapAsync(IAsyncPolicy<TResult> innerPolicy)
}
}

#pragma warning disable S3215 // "interface" instances should not be cast to concrete types
public partial class Policy
{
private const int MinimumPoliciesRequiredForWrap = 2;
Expand Down Expand Up @@ -181,3 +182,4 @@ public static AsyncPolicyWrap<TResult> WrapAsync<TResult>(params IAsyncPolicy<TR
_ => WrapAsync(policies[0], WrapAsync(policies.Skip(1).ToArray())),
};
}
#pragma warning restore S3215 // "interface" instances should not be cast to concrete types
10 changes: 6 additions & 4 deletions src/Polly/Wrap/ISyncPolicyPolicyWrapExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static PolicyWrap Wrap(this ISyncPolicy outerPolicy, ISyncPolicy innerPol
throw new ArgumentNullException(nameof(outerPolicy));
}

return ((Policy)outerPolicy).Wrap(innerPolicy);
return outerPolicy.Wrap(innerPolicy);
}

/// <summary>
Expand All @@ -35,7 +35,7 @@ public static PolicyWrap<TResult> Wrap<TResult>(this ISyncPolicy outerPolicy, IS
throw new ArgumentNullException(nameof(outerPolicy));
}

return ((Policy)outerPolicy).Wrap(innerPolicy);
return outerPolicy.Wrap(innerPolicy);
}

/// <summary>
Expand All @@ -52,7 +52,7 @@ public static PolicyWrap<TResult> Wrap<TResult>(this ISyncPolicy<TResult> outerP
throw new ArgumentNullException(nameof(outerPolicy));
}

return ((Policy<TResult>)outerPolicy).Wrap(innerPolicy);
return outerPolicy.Wrap(innerPolicy);
}

/// <summary>
Expand All @@ -69,7 +69,7 @@ public static PolicyWrap<TResult> Wrap<TResult>(this ISyncPolicy<TResult> outerP
throw new ArgumentNullException(nameof(outerPolicy));
}

return ((Policy<TResult>)outerPolicy).Wrap(innerPolicy);
return outerPolicy.Wrap(innerPolicy);
}
}

Expand Down Expand Up @@ -148,6 +148,7 @@ public PolicyWrap<TResult> Wrap(ISyncPolicy<TResult> innerPolicy)
}
}

#pragma warning disable S3215 // "interface" instances should not be cast to concrete types
public partial class Policy
{
/// <summary>
Expand Down Expand Up @@ -179,3 +180,4 @@ public static PolicyWrap<TResult> Wrap<TResult>(params ISyncPolicy<TResult>[] po
_ => Wrap(policies[0], Wrap(policies.Skip(1).ToArray())),
};
}
#pragma warning restore S3215 // "interface" instances should not be cast to concrete types
Loading