Skip to content

Commit

Permalink
Update samples to .NET 8 (#2004)
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
martincostello authored Mar 1, 2024
1 parent 3336d1c commit 44668fb
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 16 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
2 changes: 1 addition & 1 deletion samples/DependencyInjection/DependencyInjection.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions samples/GenericPipelines/GenericPipelines.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Polly.Core" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions samples/Intro/Intro.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Polly.Core"/>
<PackageReference Include="Polly.Core" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion samples/Retries/Retries.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
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 src/Snippets/Snippets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<ProjectType>Library</ProjectType>
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 44668fb

Please sign in to comment.