From 44668fb2715d521f7d9564f964def70f942cb75b Mon Sep 17 00:00:00 2001 From: Martin Costello Date: Fri, 1 Mar 2024 15:47:58 +0000 Subject: [PATCH] Update samples to .NET 8 (#2004) - Update various sample projects from `net7.0` to `net8.0`. - Fix CA1849 warning from updating snippets to .NET 8. - Fix IDE0034 warning identified by the .NET 9 SDK in #2003. --- docs/strategies/retry.md | 6 ++---- samples/DependencyInjection/DependencyInjection.csproj | 2 +- samples/GenericPipelines/GenericPipelines.csproj | 4 ++-- samples/Intro/Intro.csproj | 4 ++-- samples/Retries/Retries.csproj | 2 +- src/Snippets/Docs/Retry.cs | 6 ++---- src/Snippets/Snippets.csproj | 2 +- test/Polly.Specs/Retry/WaitAndRetryForeverAsyncSpecs.cs | 2 +- 8 files changed, 12 insertions(+), 16 deletions(-) diff --git a/docs/strategies/retry.md b/docs/strategies/retry.md index a93b6f74546..c826dad27ee 100644 --- a/docs/strategies/retry.md +++ b/docs/strategies/retry.md @@ -710,17 +710,15 @@ var ctsKey = new ResiliencePropertyKey("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(); diff --git a/samples/DependencyInjection/DependencyInjection.csproj b/samples/DependencyInjection/DependencyInjection.csproj index f4628e7cdee..a588bb35037 100644 --- a/samples/DependencyInjection/DependencyInjection.csproj +++ b/samples/DependencyInjection/DependencyInjection.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 enable enable diff --git a/samples/GenericPipelines/GenericPipelines.csproj b/samples/GenericPipelines/GenericPipelines.csproj index ee418caeadd..0dea364499d 100644 --- a/samples/GenericPipelines/GenericPipelines.csproj +++ b/samples/GenericPipelines/GenericPipelines.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 enable enable @@ -10,5 +10,5 @@ - + diff --git a/samples/Intro/Intro.csproj b/samples/Intro/Intro.csproj index 8321197231a..499481d3d4e 100644 --- a/samples/Intro/Intro.csproj +++ b/samples/Intro/Intro.csproj @@ -2,13 +2,13 @@ Exe - net7.0 + net8.0 enable enable - + diff --git a/samples/Retries/Retries.csproj b/samples/Retries/Retries.csproj index 201d8ee38e0..499481d3d4e 100644 --- a/samples/Retries/Retries.csproj +++ b/samples/Retries/Retries.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 enable enable diff --git a/src/Snippets/Docs/Retry.cs b/src/Snippets/Docs/Retry.cs index c94afb17f62..e31ac2856bc 100644 --- a/src/Snippets/Docs/Retry.cs +++ b/src/Snippets/Docs/Retry.cs @@ -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(); diff --git a/src/Snippets/Snippets.csproj b/src/Snippets/Snippets.csproj index cd6edde1986..efcf28ecefb 100644 --- a/src/Snippets/Snippets.csproj +++ b/src/Snippets/Snippets.csproj @@ -2,7 +2,7 @@ Library - net7.0 + net8.0 enable enable Library diff --git a/test/Polly.Specs/Retry/WaitAndRetryForeverAsyncSpecs.cs b/test/Polly.Specs/Retry/WaitAndRetryForeverAsyncSpecs.cs index 2516619892f..6ab4b3e65ed 100644 --- a/test/Polly.Specs/Retry/WaitAndRetryForeverAsyncSpecs.cs +++ b/test/Polly.Specs/Retry/WaitAndRetryForeverAsyncSpecs.cs @@ -86,7 +86,7 @@ public void Should_throw_when_sleep_duration_provider_int_context_timespan_is_nu { Action policy = () => Policy .Handle() - .WaitAndRetryForeverAsync(default(Func), default(Action)); + .WaitAndRetryForeverAsync(default, default(Action)); policy.Should().Throw().And .ParamName.Should().Be("sleepDurationProvider");