Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes Experimental attribute from ResilienceHandler class #5670

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scripts/MakeApiBaselines.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Write-Output "Installing required toolset"
InitializeDotNetCli -install $true | Out-Null

$Project = $PSScriptRoot + "/../eng/Tools/ApiChief/ApiChief.csproj"
$Command = $PSScriptRoot + "/../artifacts/bin/ApiChief/Debug/net8.0/ApiChief.dll"
$Command = $PSScriptRoot + "/../artifacts/bin/ApiChief/Debug/net9.0/ApiChief.dll"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now build the ApiChief tool for net9.0 that is why I changed this.

$LibrariesFolder = $PSScriptRoot + "/../src/Libraries"

Write-Output "Building ApiChief tool"
Expand All @@ -28,7 +28,7 @@ Write-Output "Creating API baseline files in the src/Libraries folder"
Get-ChildItem -Path $LibrariesFolder -Depth 1 -Include *.csproj | ForEach-Object `
{
$name = Split-Path $_.FullName -LeafBase
$path = "$PSScriptRoot\..\artifacts\bin\$name\Debug\net8.0\$name.dll"
$path = "$PSScriptRoot\..\artifacts\bin\$name\Debug\net9.0\$name.dll"
Write-Host " Processing" $name
dotnet $Command $path emit baseline -o "$LibrariesFolder/$name/$name.json"
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
<MinMutationScore>100</MinMutationScore>
</PropertyGroup>

<PropertyGroup>
<!-- Disable "Published symbols cannot be deleted to maintain compatibility" warning
because we have different APIs for different TFMs. -->
<NoWarn Condition="'$(TargetFramework)' == 'net462'">$(NoWarn);LA0006</NoWarn>
</PropertyGroup>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to suppress LA0006 - Published symbols cannot be deleted to maintain compatibility warning. The reason is the following. Together with making the ResilienceHandler class stable, we also made stable protected members SendAsync and Send. These members are inherited from DelegatingHandler and ResilienceHandler overrides them. The Send method is not available on net462 and this causes the build pipeline to fail with the LA0006 warning. To make the build pipeline "green" we have to suppress the LA0006 warning.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is suppressing all of the warnings on public symbols though, right? Is there not a way to suppress that single change?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I'm not very familiar to which analyzer is throwing those errors, but FWIW we do run package validation when we pack projects, which would catch compatibility issues in packages. In this case, net462 and net6.0+ aren't even supposed to be compatible with each other so perhaps the analyzer tooling being used here is not correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joperezr

This is suppressing all of the warnings on public symbols though, right? Is there not a way to suppress that single change?

Sometime ago I tried to suppress the warning in a source file for a particular change, but it didn't work. Here is another fresher PR #5690 where I tried it again and it didn't work. Unfortunately, we have to suppress the warning for the whole project.

Also, I'm not very familiar to which analyzer is throwing those errors, but FWIW we do run package validation when we pack projects, which would catch compatibility issues in packages. In this case, net462 and net6.0+ aren't even supposed to be compatible with each other so perhaps the analyzer tooling being used here is not correct.

Yes, I agree. I don't understand what exactly the analyzer is catching. Adding a non-abstract method that is available in net6+ and is not on net462 is alright in regards of compatibility, i.e. upgrading from net462 to net6+ will not break. Right?


<ItemGroup>
<ProjectReference Include="..\Microsoft.Extensions.Resilience\Microsoft.Extensions.Resilience.csproj" />
<ProjectReference Include="..\Microsoft.Extensions.Http.Diagnostics\Microsoft.Extensions.Http.Diagnostics.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Name": "Microsoft.Extensions.Http.Resilience, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35",
"Name": "Microsoft.Extensions.Http.Resilience, Version=9.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API json file hasn't been updated since dotnet/extensions 8.0.0 therefore the changes to this file also include APIs that were changed/updated earlier.

"Types": [
{
"Type": "class Microsoft.Extensions.Http.Resilience.HedgingEndpointOptions",
Expand Down Expand Up @@ -42,6 +42,10 @@
{
"Member": "static bool Microsoft.Extensions.Http.Resilience.HttpClientHedgingResiliencePredicates.IsTransient(Polly.Outcome<System.Net.Http.HttpResponseMessage> outcome);",
"Stage": "Stable"
},
{
"Member": "static bool Microsoft.Extensions.Http.Resilience.HttpClientHedgingResiliencePredicates.IsTransient(Polly.Outcome<System.Net.Http.HttpResponseMessage> outcome, System.Threading.CancellationToken cancellationToken);",
"Stage": "Experimental"
}
]
},
Expand All @@ -52,6 +56,10 @@
{
"Member": "static bool Microsoft.Extensions.Http.Resilience.HttpClientResiliencePredicates.IsTransient(Polly.Outcome<System.Net.Http.HttpResponseMessage> outcome);",
"Stage": "Stable"
},
{
"Member": "static bool Microsoft.Extensions.Http.Resilience.HttpClientResiliencePredicates.IsTransient(Polly.Outcome<System.Net.Http.HttpResponseMessage> outcome, System.Threading.CancellationToken cancellationToken);",
"Stage": "Experimental"
}
]
},
Expand All @@ -75,6 +83,20 @@
}
]
},
{
"Type": "static class Polly.HttpResilienceContextExtensions",
"Stage": "Experimental",
"Methods": [
{
"Member": "static System.Net.Http.HttpRequestMessage? Polly.HttpResilienceContextExtensions.GetRequestMessage(this Polly.ResilienceContext context);",
"Stage": "Experimental"
},
{
"Member": "static void Polly.HttpResilienceContextExtensions.SetRequestMessage(this Polly.ResilienceContext context, System.Net.Http.HttpRequestMessage? requestMessage);",
"Stage": "Experimental"
}
]
},
{
"Type": "static class System.Net.Http.HttpResilienceHttpRequestMessageExtensions",
"Stage": "Stable",
Expand Down Expand Up @@ -287,6 +309,28 @@
}
]
},
{
"Type": "class Microsoft.Extensions.Http.Resilience.ResilienceHandler : System.Net.Http.DelegatingHandler",
"Stage": "Stable",
"Methods": [
{
"Member": "Microsoft.Extensions.Http.Resilience.ResilienceHandler.ResilienceHandler(System.Func<System.Net.Http.HttpRequestMessage, Polly.ResiliencePipeline<System.Net.Http.HttpResponseMessage>> pipelineProvider);",
"Stage": "Stable"
},
{
"Member": "Microsoft.Extensions.Http.Resilience.ResilienceHandler.ResilienceHandler(Polly.ResiliencePipeline<System.Net.Http.HttpResponseMessage> pipeline);",
"Stage": "Stable"
},
{
"Member": "override System.Net.Http.HttpResponseMessage Microsoft.Extensions.Http.Resilience.ResilienceHandler.Send(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken);",
"Stage": "Stable"
},
{
"Member": "override System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> Microsoft.Extensions.Http.Resilience.ResilienceHandler.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken);",
"Stage": "Stable"
}
]
},
{
"Type": "sealed class Microsoft.Extensions.Http.Resilience.ResilienceHandlerContext",
"Stage": "Stable",
Expand Down Expand Up @@ -520,4 +564,4 @@
]
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Http.Diagnostics;
using Microsoft.Extensions.Http.Resilience.Internal;
using Microsoft.Shared.DiagnosticIds;
using Microsoft.Shared.Diagnostics;
using Polly;

Expand All @@ -17,7 +15,6 @@ namespace Microsoft.Extensions.Http.Resilience;
/// <summary>
/// Base class for resilience handler, i.e. handlers that use resilience strategies to send the requests.
/// </summary>
[Experimental(diagnosticId: DiagnosticIds.Experiments.Resilience, UrlFormat = DiagnosticIds.UrlFormat)]
public class ResilienceHandler : DelegatingHandler
{
private readonly Func<HttpRequestMessage, ResiliencePipeline<HttpResponseMessage>> _pipelineProvider;
Expand Down
Loading