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

[Breaking change]: EndpointName metadata no longer automatically set for minimal endpoints #473

Open
1 of 2 tasks
captainsafia opened this issue Oct 18, 2021 · 0 comments
Labels
6.0.0 Breaking change Documented The breaking change has been published to the .NET Core docs source incompatible Source code may encounter a breaking change in behavior when targeting the new version.

Comments

@captainsafia
Copy link

Description

Starting in .NET 6 RC2, behavior that was introduced in .NET 6 RC1 to automatically set the IEndpointNameMetadata for endpoints has been reverted to avoid issues the logic generating duplicate endpoint names.

Version

.NET 6 RC 2

Previous behavior

In .NET 6 RC1 and above, the IEndpointNameMetadata was automatically set for endpoints that referenced a method group. For example, the following code:

app.MapGet("/foo", GetFoo);

Would produce an endpoint for /foo with a EndpointName set to "GetFoo".

New behavior

In .NET 6 RC 2 and onward, the IEndpointNameMetadata is no longer set. For example, the following code:

app.MapGet("/foo", GetFoo);

would not generated any IEndpointNameMetadat.

Type of breaking change

  • Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load/execute or different run-time behavior.
  • Source incompatible: Source code may encounter a breaking change in behavior when targeting the new runtime/component/SDK, such as compile errors or different run-time behavior.

Reason for change

The behavior of automatically setting endpoint name metadata was not robust and resulted in issues where the same name was set for different endpoints. See dotnet/aspnetcore#36487 for more info.

Recommended action

We recommend that developers manually set the IEndpointNameMetadata using the WithName extension method as follows to set the metadata.

app.MapGet("/foo", GetFoo).WithName("GetFoo");

Feature area

ASP.NET Core

Affected APIs

No response

@captainsafia captainsafia added Breaking change 6.0.0 source incompatible Source code may encounter a breaking change in behavior when targeting the new version. labels Oct 18, 2021
@gewarren gewarren added the Documented The breaking change has been published to the .NET Core docs label Oct 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.0.0 Breaking change Documented The breaking change has been published to the .NET Core docs source incompatible Source code may encounter a breaking change in behavior when targeting the new version.
Projects
None yet
Development

No branches or pull requests

2 participants