From 79ebe4ad7047662fd4d5d3108496eae1486931f7 Mon Sep 17 00:00:00 2001 From: martincostello Date: Fri, 13 Feb 2026 17:17:47 +0000 Subject: [PATCH] .NET 11 preparation - Update F# and VB examples from .NET 9 to .NET 10. - Suppress new code analysis warnings. - Use primary constructor. --- bench/Polly.Benchmarks/Cache.cs | 7 ++----- samples/Intro.FSharp/Intro.FSharp.fsproj | 2 +- samples/Intro.VisualBasic/Intro.VisualBasic.vbproj | 2 +- src/Polly/Context.Dictionary.cs | 2 ++ src/Polly/Polly.csproj | 2 +- test/Polly.Specs/Helpers/Caching/StubSerialized.cs | 4 ++-- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/bench/Polly.Benchmarks/Cache.cs b/bench/Polly.Benchmarks/Cache.cs index c1e3cb83de7..2ec48d559ed 100644 --- a/bench/Polly.Benchmarks/Cache.cs +++ b/bench/Polly.Benchmarks/Cache.cs @@ -45,12 +45,9 @@ public Task Cache_Asynchronous_Miss() => private static Task GetObjectAsync(CancellationToken cancellationToken) => Task.FromResult(new object()); - private sealed class MemoryCacheProvider : ISyncCacheProvider, IAsyncCacheProvider + private sealed class MemoryCacheProvider(IMemoryCache memoryCache) : ISyncCacheProvider, IAsyncCacheProvider { - private readonly IMemoryCache _cache; - - public MemoryCacheProvider(IMemoryCache memoryCache) => - _cache = memoryCache; + private readonly IMemoryCache _cache = memoryCache; public (bool, object?) TryGet(string key) { diff --git a/samples/Intro.FSharp/Intro.FSharp.fsproj b/samples/Intro.FSharp/Intro.FSharp.fsproj index 89b253d4a00..f88a1c3415f 100644 --- a/samples/Intro.FSharp/Intro.FSharp.fsproj +++ b/samples/Intro.FSharp/Intro.FSharp.fsproj @@ -2,7 +2,7 @@ Exe - net9.0 + net10.0 diff --git a/samples/Intro.VisualBasic/Intro.VisualBasic.vbproj b/samples/Intro.VisualBasic/Intro.VisualBasic.vbproj index 051a66db64e..f12bcc31035 100644 --- a/samples/Intro.VisualBasic/Intro.VisualBasic.vbproj +++ b/samples/Intro.VisualBasic/Intro.VisualBasic.vbproj @@ -2,7 +2,7 @@ Exe - net9.0 + net10.0 diff --git a/src/Polly/Context.Dictionary.cs b/src/Polly/Context.Dictionary.cs index ced993bdfac..fc43e1df132 100644 --- a/src/Polly/Context.Dictionary.cs +++ b/src/Polly/Context.Dictionary.cs @@ -6,7 +6,9 @@ /// Context that carries with a single execution through a Policy. Commonly-used properties are directly on the class. Backed by a dictionary of string key / object value pairs, to which user-defined values may be added. /// Do not re-use an instance of across more than one execution. /// +#pragma warning disable CA1010, CA1710 public partial class Context : IDictionary, IDictionary, IReadOnlyDictionary +#pragma warning restore CA1010, CA1710 { // For an individual execution through a policy or policywrap, it is expected that all execution steps (for example executing the user delegate, invoking policy-activity delegates such as onRetry, onBreak, onTimeout etc) execute sequentially. // Therefore, this class is intentionally not constructed to be safe for concurrent access from multiple threads. diff --git a/src/Polly/Polly.csproj b/src/Polly/Polly.csproj index 2d17bf02a62..e4b5cca0a7c 100644 --- a/src/Polly/Polly.csproj +++ b/src/Polly/Polly.csproj @@ -8,7 +8,7 @@ 100 true - $(NoWarn);RS0037 + $(NoWarn);CA1510;RS0037 diff --git a/test/Polly.Specs/Helpers/Caching/StubSerialized.cs b/test/Polly.Specs/Helpers/Caching/StubSerialized.cs index 625ba13e907..6f24c9d325c 100644 --- a/test/Polly.Specs/Helpers/Caching/StubSerialized.cs +++ b/test/Polly.Specs/Helpers/Caching/StubSerialized.cs @@ -1,7 +1,7 @@ namespace Polly.Specs.Helpers.Caching; /// -/// An intentionally naive class to be the simplest thing possible to support tests around serializing cache providers. This serialization does nothing but wrap the object to be serialized! +/// An intentionally naive class to be the simplest thing possible to support tests around serializing cache providers. This serialization does nothing but wrap the object to be serialized. /// /// The type of the item being 'serialized'. internal class StubSerialized @@ -13,7 +13,7 @@ public StubSerialized(TOriginal? original) => } /// -/// An intentionally naive class to be the simplest thing possible to support tests around serializing cache providers. This serialization does nothing but wrap the object to be serialized! +/// An intentionally naive class to be the simplest thing possible to support tests around serializing cache providers. This serialization does nothing but wrap the object to be serialized. /// internal class StubSerialized : StubSerialized {