From 86300437909d4f48bc14f73bd951d51467aee867 Mon Sep 17 00:00:00 2001 From: Iliar Turdushev Date: Wed, 14 Aug 2024 16:47:50 +0200 Subject: [PATCH 01/14] Fixes #4924 and #4770 Disables HttpClient Timeout for standard resilience and hending handlers --- eng/packages/TestOnly.props | 2 +- .../ResilienceHttpClientBuilderExtensions.Hedging.cs | 4 ++++ ...eHttpClientBuilderExtensions.StandardResilience.cs | 4 ++++ .../Hedging/StandardHedgingTests.cs | 8 ++++++++ .../HttpClientBuilderExtensionsTests.Standard.cs | 11 +++++++++++ 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/eng/packages/TestOnly.props b/eng/packages/TestOnly.props index 2f35392510e..df39b892596 100644 --- a/eng/packages/TestOnly.props +++ b/eng/packages/TestOnly.props @@ -5,7 +5,7 @@ - + diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/Hedging/ResilienceHttpClientBuilderExtensions.Hedging.cs b/src/Libraries/Microsoft.Extensions.Http.Resilience/Hedging/ResilienceHttpClientBuilderExtensions.Hedging.cs index e6039bd65c4..3f7b82ba0de 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/Hedging/ResilienceHttpClientBuilderExtensions.Hedging.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/Hedging/ResilienceHttpClientBuilderExtensions.Hedging.cs @@ -3,6 +3,7 @@ using System; using System.Net.Http; +using System.Threading; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Http.Resilience; @@ -139,6 +140,9 @@ public static IStandardHedgingHandlerBuilder AddStandardHedgingHandler(this IHtt }) .SelectPipelineByAuthority(); + // Disable the HttpClient timeout to allow the timeout strategies to control the timeout. + _ = builder.ConfigureHttpClient(client => client.Timeout = Timeout.InfiniteTimeSpan); + return new StandardHedgingHandlerBuilder(builder.Name, builder.Services, routingBuilder); } diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/Resilience/ResilienceHttpClientBuilderExtensions.StandardResilience.cs b/src/Libraries/Microsoft.Extensions.Http.Resilience/Resilience/ResilienceHttpClientBuilderExtensions.StandardResilience.cs index f27c2e76eac..a4315eaa006 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/Resilience/ResilienceHttpClientBuilderExtensions.StandardResilience.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/Resilience/ResilienceHttpClientBuilderExtensions.StandardResilience.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Threading; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Http.Resilience; @@ -86,6 +87,9 @@ public static IHttpStandardResiliencePipelineBuilder AddStandardResilienceHandle .AddTimeout(options.AttemptTimeout); }); + // Disable the HttpClient timeout to allow the timeout strategies to control the timeout. + _ = builder.ConfigureHttpClient(client => client.Timeout = Timeout.InfiniteTimeSpan); + return new HttpStandardResiliencePipelineBuilder(optionsName, builder.Services); } diff --git a/test/Libraries/Microsoft.Extensions.Http.Resilience.Tests/Hedging/StandardHedgingTests.cs b/test/Libraries/Microsoft.Extensions.Http.Resilience.Tests/Hedging/StandardHedgingTests.cs index 237ccfa6e73..7db71a08873 100644 --- a/test/Libraries/Microsoft.Extensions.Http.Resilience.Tests/Hedging/StandardHedgingTests.cs +++ b/test/Libraries/Microsoft.Extensions.Http.Resilience.Tests/Hedging/StandardHedgingTests.cs @@ -265,6 +265,14 @@ public async Task DynamicReloads_Ok(bool asynchronous = true) AssertNoResponse(); } + [Fact] + public void AddStandardResilienceHandler_EnsureHttpClientTimeoutDisabled() + { + var client = CreateClientWithHandler(); + + client.Timeout.Should().Be(Timeout.InfiniteTimeSpan); + } + [Theory] #if NET6_0_OR_GREATER [CombinatorialData] diff --git a/test/Libraries/Microsoft.Extensions.Http.Resilience.Tests/Resilience/HttpClientBuilderExtensionsTests.Standard.cs b/test/Libraries/Microsoft.Extensions.Http.Resilience.Tests/Resilience/HttpClientBuilderExtensionsTests.Standard.cs index 79ce7aa654d..faecd6e317d 100644 --- a/test/Libraries/Microsoft.Extensions.Http.Resilience.Tests/Resilience/HttpClientBuilderExtensionsTests.Standard.cs +++ b/test/Libraries/Microsoft.Extensions.Http.Resilience.Tests/Resilience/HttpClientBuilderExtensionsTests.Standard.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Net; using System.Net.Http; +using System.Threading; using System.Threading.Tasks; using FluentAssertions; using Microsoft.Extensions.Configuration; @@ -257,6 +258,16 @@ public async Task DynamicReloads_Ok(bool asynchronous = true) requests.Should().HaveCount(11); } + [Fact] + public void AddStandardResilienceHandler_EnsureHttpClientTimeoutDisabled() + { + var builder = new ServiceCollection().AddLogging().AddMetrics().AddHttpClient("test").AddStandardResilienceHandler(); + + using var client = builder.Services.BuildServiceProvider().GetRequiredService().CreateClient("test"); + + client.Timeout.Should().Be(Timeout.InfiniteTimeSpan); + } + private static void AddStandardResilienceHandler( MethodArgs mode, IHttpClientBuilder builder, From 6227c4612dbdde9c4eae44a527eda2d69d6bd736 Mon Sep 17 00:00:00 2001 From: Iliar Turdushev Date: Thu, 15 Aug 2024 10:08:18 +0200 Subject: [PATCH 02/14] Fixes #4924 Adds a note mentioning requirements on the Grpc.Net.ClientFactory version to avoid issues with the M.E.Http.Resilience package --- src/Libraries/Microsoft.Extensions.Http.Resilience/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/README.md b/src/Libraries/Microsoft.Extensions.Http.Resilience/README.md index a157dcfa4bc..8ba5335f5e7 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/README.md +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/README.md @@ -4,6 +4,11 @@ Resilience mechanisms for `HttpClient` built on the [Polly framework](https://ww ## Install the package +> [!IMPORTANT] +> If you're using the `Grpc.Net.ClientFactory` package then update it to the version `>=2.64.0` +> before installing the `Microsoft.Extensions.Http.Resilience` package. This will help you to +> avoid issues like the [following](https://github.com/dotnet/extensions/issues/4924). + From the command-line: ```console From 141c7dbeca637a5df70e6417203ff23b81a80d52 Mon Sep 17 00:00:00 2001 From: Iliar Turdushev Date: Wed, 28 Aug 2024 08:34:14 +0200 Subject: [PATCH 03/14] Fixes #4924 Added a target that notifies users that they use a version of the Grpc.Net.ClientFactory package that might cause the #4924 issue --- Directory.Build.targets | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Directory.Build.targets b/Directory.Build.targets index bcf3171ca0d..6b71f336952 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -92,4 +92,42 @@ + + + + + + <_GrpcNetClientFactoryPackageReference Include="@(PackageReference)" Condition=" '%(PackageReference.Identity)' == 'Grpc.Net.ClientFactory' " /> + + + <_GrpcNetClientFactoryPackageVersion Include="@(PackageVersion)" Condition=" '%(PackageVersion.Identity)' == 'Grpc.Net.ClientFactory' " /> + + + + <_ErrorMessage>Grpc.Net.ClientFactory v2.64.0 or later is required (see https://github.com/dotnet/extensions/issues/4924 for more details). The check can be suppressed with SuppressCheckGrpcNetClientFactoryVersion=true. + + + + + + + + + + + From 62de03faed16d2081d1b85ce647f7d07085f573e Mon Sep 17 00:00:00 2001 From: Iliar Turdushev Date: Fri, 30 Aug 2024 11:19:49 +0200 Subject: [PATCH 04/14] Fixes #4924 Revert changes to the Directory.Build.targets --- Directory.Build.targets | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/Directory.Build.targets b/Directory.Build.targets index 6b71f336952..bcf3171ca0d 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -92,42 +92,4 @@ - - - - - - <_GrpcNetClientFactoryPackageReference Include="@(PackageReference)" Condition=" '%(PackageReference.Identity)' == 'Grpc.Net.ClientFactory' " /> - - - <_GrpcNetClientFactoryPackageVersion Include="@(PackageVersion)" Condition=" '%(PackageVersion.Identity)' == 'Grpc.Net.ClientFactory' " /> - - - - <_ErrorMessage>Grpc.Net.ClientFactory v2.64.0 or later is required (see https://github.com/dotnet/extensions/issues/4924 for more details). The check can be suppressed with SuppressCheckGrpcNetClientFactoryVersion=true. - - - - - - - - - - - From 8d08cb885a4851b0420a31ddc7a1768564fdef3d Mon Sep 17 00:00:00 2001 From: Iliar Turdushev Date: Mon, 2 Sep 2024 13:57:43 +0200 Subject: [PATCH 05/14] Fixes #4924 Adds a target that checks whether M.E.Http.Resilience package is used together with Grpc.Net.ClientFactory 2.64.0 or later. If not the target warns a user. --- ...icrosoft.Extensions.Http.Resilience.csproj | 69 +++++++++++++++++++ ...Microsoft.Extensions.Http.Resilience.props | 8 +++ ...crosoft.Extensions.Http.Resilience.targets | 47 +++++++++++++ 3 files changed, 124 insertions(+) create mode 100644 src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.props create mode 100644 src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.targets diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/Microsoft.Extensions.Http.Resilience.csproj b/src/Libraries/Microsoft.Extensions.Http.Resilience/Microsoft.Extensions.Http.Resilience.csproj index 7bf27efddb3..f7b7fa6d85c 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/Microsoft.Extensions.Http.Resilience.csproj +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/Microsoft.Extensions.Http.Resilience.csproj @@ -38,4 +38,73 @@ + + + + + + + + + + + <_AdditionalNETStandardCompatErrorFileContents> + + + + + <_GrpcNetClientFactoryPackageReference Include="%40(PackageReference)" Condition=" '%(PackageReference.Identity)' == '%24(_GrpcNetClientFactory)' " /> + + + <_GrpcNetClientFactoryPackageVersion Include="%40(PackageVersion)" Condition=" '%(PackageVersion.Identity)' == '%24(_GrpcNetClientFactory)' " /> + + + <_GrpcNetClientFactoryTransitiveDependency Include="%40(ReferencePath)" Condition=" '%(ReferencePath.NuGetPackageId)' == '%24(_GrpcNetClientFactory)' " /> + + + + + + + + + + + + + + +]]> + + diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.props b/src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.props new file mode 100644 index 00000000000..4e37a85ef2f --- /dev/null +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.props @@ -0,0 +1,8 @@ + + + false + <_GrpcNetClientFactory>Grpc.Net.ClientFactory + <_CompatibleGrpcNetClientFactoryVersion>2.64.0 + <_GrpcNetClientFactoryVersionIsIncorrect>Grpc.Net.ClientFactory 2.63.0 or earlier could cause issues when used together with Microsoft.Extensions.Http.Resilience. For more details, see https://github.com/dotnet/extensions/tree/main/src/Libraries/Microsoft.Extensions.Http.Resilience#known-issues. Consider using Grpc.Net.ClientFactory $(_CompatibleGrpcNetClientFactoryVersion) or later. To suppress the error set SuppressCheckGrpcNetClientFactoryVersion=true. + + diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.targets b/src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.targets new file mode 100644 index 00000000000..ebac54d914e --- /dev/null +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.targets @@ -0,0 +1,47 @@ + + + + + + <_GrpcNetClientFactoryPackageReference Include="@(PackageReference)" Condition=" '%(PackageReference.Identity)' == '$(_GrpcNetClientFactory)' " /> + + + <_GrpcNetClientFactoryPackageVersion Include="@(PackageVersion)" Condition=" '%(PackageVersion.Identity)' == '$(_GrpcNetClientFactory)' " /> + + + <_GrpcNetClientFactoryTransitiveDependency Include="@(ReferencePath)" Condition=" '%(ReferencePath.NuGetPackageId)' == '$(_GrpcNetClientFactory)' " /> + + + + + + + + + + + + + + + From 37fc46de2e8a2756c8ac7abbc6531a92fba14c8b Mon Sep 17 00:00:00 2001 From: Iliar Turdushev Date: Mon, 2 Sep 2024 15:39:50 +0200 Subject: [PATCH 06/14] Fixes #4924 Adds a Known issues section to the doc describing the issue with Grpc.Net.ClientFactory --- .../README.md | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/README.md b/src/Libraries/Microsoft.Extensions.Http.Resilience/README.md index 8ba5335f5e7..cf665afcfcd 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/README.md +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/README.md @@ -4,11 +4,6 @@ Resilience mechanisms for `HttpClient` built on the [Polly framework](https://ww ## Install the package -> [!IMPORTANT] -> If you're using the `Grpc.Net.ClientFactory` package then update it to the version `>=2.64.0` -> before installing the `Microsoft.Extensions.Http.Resilience` package. This will help you to -> avoid issues like the [following](https://github.com/dotnet/extensions/issues/4924). - From the command-line: ```console @@ -78,6 +73,37 @@ clientBuilder.AddResilienceHandler("myHandler", b => }); ``` +## Known issues + +### Compatibility with the `Grpc.Net.ClientFactory` package + +If you're using `Grpc.Net.ClientFactory` `2.63.0` or earlier then enabling the standard resilience or +hedging handlers for a gRPC client could cause a runtime exception. Specifically, the following code sample + +```csharp +services + .AddGrpcClient() + .AddStandardResilienceHandler(); +``` + +will cause the following exception + +``` +System.InvalidOperationException: The ConfigureHttpClient method is not supported when creating gRPC clients. Unable to create client with name 'GreeterClient'. +``` + +If you're getting this exception consider using `Grpc.Net.ClientFactory` `2.64.0.` or later. + +We've implemented a build time check that verifies if your using `Grpc.Net.ClientFactory` `2.63.0` +or earlier, and if you are the check produces a compilation error. You can suppress the check and the +error by setting the following property in the project's file: + +```xml + + true + +``` + ## Feedback & Contributing We welcome feedback and contributions in [our GitHub repo](https://github.com/dotnet/extensions). From 904dda2c15961c4aaae257793f9d49f815666844 Mon Sep 17 00:00:00 2001 From: Iliar Turdushev Date: Tue, 3 Sep 2024 11:32:45 +0200 Subject: [PATCH 07/14] Fixes #4924 * Moves the contents of the .props file into the .targets file * For net462 we now import the contents of the .targets file instead of setting it as a CDATA value in the .csproj file --- ...icrosoft.Extensions.Http.Resilience.csproj | 58 +++---------------- ...Microsoft.Extensions.Http.Resilience.props | 8 --- ...crosoft.Extensions.Http.Resilience.targets | 6 ++ 3 files changed, 13 insertions(+), 59 deletions(-) delete mode 100644 src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.props diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/Microsoft.Extensions.Http.Resilience.csproj b/src/Libraries/Microsoft.Extensions.Http.Resilience/Microsoft.Extensions.Http.Resilience.csproj index f7b7fa6d85c..76d4b885772 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/Microsoft.Extensions.Http.Resilience.csproj +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/Microsoft.Extensions.Http.Resilience.csproj @@ -40,18 +40,18 @@ - - - + + PackagePath="buildTransitive\net462\Microsoft.Extensions.Http.Resilience.net462.targets" /> - - - - <_GrpcNetClientFactoryPackageReference Include="%40(PackageReference)" Condition=" '%(PackageReference.Identity)' == '%24(_GrpcNetClientFactory)' " /> - - - <_GrpcNetClientFactoryPackageVersion Include="%40(PackageVersion)" Condition=" '%(PackageVersion.Identity)' == '%24(_GrpcNetClientFactory)' " /> - - - <_GrpcNetClientFactoryTransitiveDependency Include="%40(ReferencePath)" Condition=" '%(ReferencePath.NuGetPackageId)' == '%24(_GrpcNetClientFactory)' " /> - - - - - - - - - - - - - - + ]]> diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.props b/src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.props deleted file mode 100644 index 4e37a85ef2f..00000000000 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.props +++ /dev/null @@ -1,8 +0,0 @@ - - - false - <_GrpcNetClientFactory>Grpc.Net.ClientFactory - <_CompatibleGrpcNetClientFactoryVersion>2.64.0 - <_GrpcNetClientFactoryVersionIsIncorrect>Grpc.Net.ClientFactory 2.63.0 or earlier could cause issues when used together with Microsoft.Extensions.Http.Resilience. For more details, see https://github.com/dotnet/extensions/tree/main/src/Libraries/Microsoft.Extensions.Http.Resilience#known-issues. Consider using Grpc.Net.ClientFactory $(_CompatibleGrpcNetClientFactoryVersion) or later. To suppress the error set SuppressCheckGrpcNetClientFactoryVersion=true. - - diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.targets b/src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.targets index ebac54d914e..a76f0eee661 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.targets +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.targets @@ -1,4 +1,10 @@ + + <_GrpcNetClientFactory>Grpc.Net.ClientFactory + <_CompatibleGrpcNetClientFactoryVersion>2.64.0 + <_GrpcNetClientFactoryVersionIsIncorrect>Grpc.Net.ClientFactory 2.63.0 or earlier could cause issues when used together with Microsoft.Extensions.Http.Resilience. For more details, see https://github.com/dotnet/extensions/tree/main/src/Libraries/Microsoft.Extensions.Http.Resilience#known-issues. Consider using Grpc.Net.ClientFactory $(_CompatibleGrpcNetClientFactoryVersion) or later. To suppress the error set SuppressCheckGrpcNetClientFactoryVersion=true. + + + true + + - + + + + PackagePath="buildTransitive\net462\" + Condition="'$(PackNet462)' == 'true'" /> - + PackagePath="buildTransitive\net462\$(MSBuildProjectName).net462.targets" + Condition="'$(PackNet462)' == 'true'" /> - <_AdditionalNETStandardCompatErrorFileContents> + <_AdditionalNETStandardCompatErrorFileContents Condition="'$(PackNet462)' == 'true'"> ]]> diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.targets b/src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.targets index a76f0eee661..b1ab4c91308 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.targets +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.targets @@ -2,13 +2,13 @@ <_GrpcNetClientFactory>Grpc.Net.ClientFactory <_CompatibleGrpcNetClientFactoryVersion>2.64.0 - <_GrpcNetClientFactoryVersionIsIncorrect>Grpc.Net.ClientFactory 2.63.0 or earlier could cause issues when used together with Microsoft.Extensions.Http.Resilience. For more details, see https://github.com/dotnet/extensions/tree/main/src/Libraries/Microsoft.Extensions.Http.Resilience#known-issues. Consider using Grpc.Net.ClientFactory $(_CompatibleGrpcNetClientFactoryVersion) or later. To suppress the error set SuppressCheckGrpcNetClientFactoryVersion=true. + <_GrpcNetClientFactoryVersionIsIncorrect>Grpc.Net.ClientFactory 2.63.0 or earlier could cause issues when used together with Microsoft.Extensions.Http.Resilience. For more details, see https://learn.microsoft.com/en-us/dotnet/core/resilience/http-resilience#known-issues. Consider using Grpc.Net.ClientFactory $(_CompatibleGrpcNetClientFactoryVersion) or later. To suppress the error set SuppressCheckGrpcNetClientFactoryVersion=true. Date: Wed, 4 Sep 2024 17:32:39 +0200 Subject: [PATCH 10/14] Fixes #4924 * Applies editorial changes to the Known issues section --- .../Microsoft.Extensions.Http.Resilience/README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/README.md b/src/Libraries/Microsoft.Extensions.Http.Resilience/README.md index cf665afcfcd..d272458da62 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/README.md +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/README.md @@ -77,8 +77,8 @@ clientBuilder.AddResilienceHandler("myHandler", b => ### Compatibility with the `Grpc.Net.ClientFactory` package -If you're using `Grpc.Net.ClientFactory` `2.63.0` or earlier then enabling the standard resilience or -hedging handlers for a gRPC client could cause a runtime exception. Specifically, the following code sample +If you're using `Grpc.Net.ClientFactory` version `2.63.0` or earlier, then enabling the standard resilience or hedging +handlers for a gRPC client could cause a runtime exception. Specifically, consider the following code sample: ```csharp services @@ -86,17 +86,17 @@ services .AddStandardResilienceHandler(); ``` -will cause the following exception +The preceding code results in the following exception: ``` System.InvalidOperationException: The ConfigureHttpClient method is not supported when creating gRPC clients. Unable to create client with name 'GreeterClient'. ``` -If you're getting this exception consider using `Grpc.Net.ClientFactory` `2.64.0.` or later. +To resolve this issue, we recommend upgrading to `Grpc.Net.ClientFactory` version `2.64.0` or later. -We've implemented a build time check that verifies if your using `Grpc.Net.ClientFactory` `2.63.0` -or earlier, and if you are the check produces a compilation error. You can suppress the check and the -error by setting the following property in the project's file: +We've implemented a build time check that verifies if you're using `Grpc.Net.ClientFactory` version +`2.63.0` or earlier, and if you are the check produces a compilation error. You can suppress the +check and the error by setting the following property in your project file: ```xml From 51721ade83eb82d9f8f6eb5b54dc056130811b41 Mon Sep 17 00:00:00 2001 From: Iliar Turdushev Date: Thu, 5 Sep 2024 14:31:50 +0200 Subject: [PATCH 11/14] Fixes #4924 * Changes the level of the compatibility log messages from Error to Warning * Updates the logic of copying buildTransitive files --- eng/MSBuild/Packaging.targets | 8 ++-- ...icrosoft.Extensions.Http.Resilience.csproj | 22 ++++------- .../README.md | 4 +- ...crosoft.Extensions.Http.Resilience.targets | 39 ++++++++++--------- 4 files changed, 34 insertions(+), 39 deletions(-) diff --git a/eng/MSBuild/Packaging.targets b/eng/MSBuild/Packaging.targets index e233142f1fa..14a5a04d492 100644 --- a/eng/MSBuild/Packaging.targets +++ b/eng/MSBuild/Packaging.targets @@ -11,15 +11,17 @@ false $(BeforePack);_VerifyMinimumSupportedTfmForPackagingIsUsed;_AddNETStandardCompatErrorFileForPackaging + true + Condition="'$(IsPackNet462)' == 'true'" /> diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/Microsoft.Extensions.Http.Resilience.csproj b/src/Libraries/Microsoft.Extensions.Http.Resilience/Microsoft.Extensions.Http.Resilience.csproj index ad98c4c8865..856145718c0 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/Microsoft.Extensions.Http.Resilience.csproj +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/Microsoft.Extensions.Http.Resilience.csproj @@ -39,43 +39,35 @@ - - - true - - - - + - + + Condition="'$(IsPackNet462)' == 'true'" /> + Condition="'$(IsPackNet462)' == 'true'" /> - <_AdditionalNETStandardCompatErrorFileContents Condition="'$(PackNet462)' == 'true'"> + <_AdditionalNETStandardCompatErrorFileContents> ]]> diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/README.md b/src/Libraries/Microsoft.Extensions.Http.Resilience/README.md index d272458da62..26cd62c329b 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/README.md +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/README.md @@ -95,8 +95,8 @@ System.InvalidOperationException: The ConfigureHttpClient method is not supporte To resolve this issue, we recommend upgrading to `Grpc.Net.ClientFactory` version `2.64.0` or later. We've implemented a build time check that verifies if you're using `Grpc.Net.ClientFactory` version -`2.63.0` or earlier, and if you are the check produces a compilation error. You can suppress the -check and the error by setting the following property in your project file: +`2.63.0` or earlier, and if you are the check produces a compilation warning. You can suppress the +warning by setting the following property in your project file: ```xml diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.targets b/src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.targets index b1ab4c91308..e2afdbf92cf 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.targets +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.targets @@ -2,7 +2,7 @@ <_GrpcNetClientFactory>Grpc.Net.ClientFactory <_CompatibleGrpcNetClientFactoryVersion>2.64.0 - <_GrpcNetClientFactoryVersionIsIncorrect>Grpc.Net.ClientFactory 2.63.0 or earlier could cause issues when used together with Microsoft.Extensions.Http.Resilience. For more details, see https://learn.microsoft.com/en-us/dotnet/core/resilience/http-resilience#known-issues. Consider using Grpc.Net.ClientFactory $(_CompatibleGrpcNetClientFactoryVersion) or later. To suppress the error set SuppressCheckGrpcNetClientFactoryVersion=true. + <_GrpcNetClientFactoryVersionIsIncorrect>Grpc.Net.ClientFactory 2.63.0 or earlier could cause issues when used together with Microsoft.Extensions.Http.Resilience. For more details, see https://learn.microsoft.com/en-us/dotnet/core/resilience/http-resilience#known-issues. Consider using Grpc.Net.ClientFactory $(_CompatibleGrpcNetClientFactoryVersion) or later. To suppress the warning set SuppressCheckGrpcNetClientFactoryVersion=true. - + - + - + - + From db347b9dceba2217e8ea916d322a7088981e9ecc Mon Sep 17 00:00:00 2001 From: Iliar Turdushev Date: Thu, 5 Sep 2024 14:35:52 +0200 Subject: [PATCH 12/14] Removed extra spaces --- .../Microsoft.Extensions.Http.Resilience.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/Microsoft.Extensions.Http.Resilience.csproj b/src/Libraries/Microsoft.Extensions.Http.Resilience/Microsoft.Extensions.Http.Resilience.csproj index 856145718c0..f0499dada26 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/Microsoft.Extensions.Http.Resilience.csproj +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/Microsoft.Extensions.Http.Resilience.csproj @@ -49,7 +49,7 @@ + to set the _AdditionalNETStandardCompatErrorFileContents variable. --> Date: Fri, 6 Sep 2024 10:57:34 +0200 Subject: [PATCH 13/14] Applied suggestions to update the documentation --- .../Microsoft.Extensions.Http.Resilience/README.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/README.md b/src/Libraries/Microsoft.Extensions.Http.Resilience/README.md index 26cd62c329b..d4ad24b5e00 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/README.md +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/README.md @@ -75,10 +75,11 @@ clientBuilder.AddResilienceHandler("myHandler", b => ## Known issues +The following sections detail various known issues. + ### Compatibility with the `Grpc.Net.ClientFactory` package -If you're using `Grpc.Net.ClientFactory` version `2.63.0` or earlier, then enabling the standard resilience or hedging -handlers for a gRPC client could cause a runtime exception. Specifically, consider the following code sample: +If you're using `Grpc.Net.ClientFactory` version `2.63.0` or earlier, then enabling the standard resilience or hedging handlers for a gRPC client could cause a runtime exception. Specifically, consider the following code sample: ```csharp services @@ -88,15 +89,13 @@ services The preceding code results in the following exception: -``` +```Output System.InvalidOperationException: The ConfigureHttpClient method is not supported when creating gRPC clients. Unable to create client with name 'GreeterClient'. ``` To resolve this issue, we recommend upgrading to `Grpc.Net.ClientFactory` version `2.64.0` or later. -We've implemented a build time check that verifies if you're using `Grpc.Net.ClientFactory` version -`2.63.0` or earlier, and if you are the check produces a compilation warning. You can suppress the -warning by setting the following property in your project file: +There's a build time check that verifies if you're using `Grpc.Net.ClientFactory` version `2.63.0` or earlier, and if you are the check produces a compilation warning. You can suppress the warning by setting the following property in your project file: ```xml From a548fbc6cbae7bbf1f7b3dbc036763fbc1bc291a Mon Sep 17 00:00:00 2001 From: Iliar Turdushev Date: Mon, 9 Sep 2024 09:15:36 +0200 Subject: [PATCH 14/14] Removed locale from the URL --- .../Microsoft.Extensions.Http.Resilience.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.targets b/src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.targets index e2afdbf92cf..268f0720433 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.targets +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.targets @@ -2,7 +2,7 @@ <_GrpcNetClientFactory>Grpc.Net.ClientFactory <_CompatibleGrpcNetClientFactoryVersion>2.64.0 - <_GrpcNetClientFactoryVersionIsIncorrect>Grpc.Net.ClientFactory 2.63.0 or earlier could cause issues when used together with Microsoft.Extensions.Http.Resilience. For more details, see https://learn.microsoft.com/en-us/dotnet/core/resilience/http-resilience#known-issues. Consider using Grpc.Net.ClientFactory $(_CompatibleGrpcNetClientFactoryVersion) or later. To suppress the warning set SuppressCheckGrpcNetClientFactoryVersion=true. + <_GrpcNetClientFactoryVersionIsIncorrect>Grpc.Net.ClientFactory 2.63.0 or earlier could cause issues when used together with Microsoft.Extensions.Http.Resilience. For more details, see https://learn.microsoft.com/dotnet/core/resilience/http-resilience#known-issues. Consider using Grpc.Net.ClientFactory $(_CompatibleGrpcNetClientFactoryVersion) or later. To suppress the warning set SuppressCheckGrpcNetClientFactoryVersion=true.