Skip to content

Commit

Permalink
Fix analysis warnings
Browse files Browse the repository at this point in the history
- Fix CA1849 warning from updating snippets to .NET 8.
- Fix IDE0034 warning identified by the .NET 9 SDK in App-vNext#2003.
  • Loading branch information
martincostello committed Mar 1, 2024
1 parent d33ee4e commit 8ac8979
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
6 changes: 2 additions & 4 deletions docs/strategies/retry.md
Original file line number Diff line number Diff line change
Expand Up @@ -710,17 +710,15 @@ var ctsKey = new ResiliencePropertyKey<CancellationTokenSource>("cts");
var retry = new ResiliencePipelineBuilder()
.AddRetry(new()
{
OnRetry = args =>
OnRetry = async args =>
{
if (args.Outcome.Exception is TimeoutException)
{
if (args.Context.Properties.TryGetValue(ctsKey, out var cts))
{
cts.Cancel();
await cts.CancelAsync();
}
}

return ValueTask.CompletedTask;
}
})
.Build();
Expand Down
6 changes: 2 additions & 4 deletions src/Snippets/Docs/Retry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,17 +402,15 @@ public static void AntiPattern_CancellingRetry()
var retry = new ResiliencePipelineBuilder()
.AddRetry(new()
{
OnRetry = args =>
OnRetry = async args =>
{
if (args.Outcome.Exception is TimeoutException)
{
if (args.Context.Properties.TryGetValue(ctsKey, out var cts))
{
cts.Cancel();
await cts.CancelAsync();
}
}
return ValueTask.CompletedTask;
}
})
.Build();
Expand Down
2 changes: 1 addition & 1 deletion test/Polly.Specs/Retry/WaitAndRetryForeverAsyncSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void Should_throw_when_sleep_duration_provider_int_context_timespan_is_nu
{
Action policy = () => Policy
.Handle<Exception>()
.WaitAndRetryForeverAsync(default(Func<int, Context, TimeSpan>), default(Action<Exception, int, TimeSpan, Context>));
.WaitAndRetryForeverAsync(default, default(Action<Exception, int, TimeSpan, Context>));

policy.Should().Throw<ArgumentNullException>().And
.ParamName.Should().Be("sleepDurationProvider");
Expand Down

0 comments on commit 8ac8979

Please sign in to comment.