-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Avoid closure in IConnectionBuilder.Use #47845
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
Conversation
|
Thanks for your PR, @divyeshio. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
@dotnet-policy-service agree |
|
Could this change create ambiguous method errors when building? These two public static IConnectionBuilder Use(
this IConnectionBuilder connectionBuilder,
Func<ConnectionContext, Func<Task>, Task> middleware)And public static IConnectionBuilder Use(
this IConnectionBuilder connectionBuilder,
Func<ConnectionContext, ConnectionDelegate, Task> middleware)It looks like implicit lambda args won't work anymore: builder.Use((context, next) =>
{
return Task.CompletedTask;
});(I haven't tested this) |
|
Similar changes for middleware have been already merged. This has been discussed at #31463 |
|
Ok! Are there any places the existing overload is used in aspnetcore that can be changed to the new method? |
|
I tried to look for any references for previous method but couldn't find in anywhere including samples, tests. Note: This is my first ever contribution, I might be missing something. |
src/Servers/Connections.Abstractions/src/ConnectionBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
Maybe here? |
|
This does look pretty analogous to #31784, so @BrennanConroy might have thoughts. |
|
There should at least be a test you can use this in. |
None of the tests use this extension method |
I meant that you can copy an existing test and adapt it to use these extensions. |
|
We want a test to use the new method to ensure it works correctly. |
|
Thanks |
Avoid closure in IConnectionBuilder.Use
Add new Use connectionbuilder extension method
Description
Add a new IConnectionBuilder.Use overload that requires users to pass the ConnectionContext to the next function which will save allocations over the previous extension method.
Fixes #46533