Skip to content

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

Open
@captainsafia

Description

@captainsafia

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    6.0.0Breaking changeDocumentedThe breaking change has been published to the .NET Core docssource incompatibleSource code may encounter a breaking change in behavior when targeting the new version.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions