-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Set EndpointName and DisplayName given method name in endpoints #35439
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
6eff9d2
to
870b2df
Compare
src/Http/Routing/src/Builder/MinimalActionEndpointRouteBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
870b2df
to
8fb48c3
Compare
src/Http/Routing/src/Builder/MinimalActionEndpointRouteBuilderExtensions.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
src/Http/Routing/src/Builder/MinimalActionEndpointRouteBuilderExtensions.cs
Show resolved
Hide resolved
src/Shared/RoslynUtils/TypeHelper.cs
Outdated
/// <summary> | ||
/// Checks to see if a given type is compiler generated. | ||
/// <remarks> | ||
/// The compiler doesn't always annotate every time it generates with the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check the member itself first, then containing type, then its containing type, etc.
@@ -184,6 +187,21 @@ public static class MinimalActionEndpointRouteBuilderExtensions | |||
// Add MethodInfo as metadata to assist with OpenAPI generation for the endpoint. | |||
builder.Metadata.Add(action.Method); | |||
|
|||
// Methods defined in a top-level program are generated as statics so the delegate | |||
// target will be null. Inline lambdas are compiler generated properties so they can |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/Http/Routing/test/UnitTests/Builder/MinimalActionEndpointRouteBuilderExtensionsTest.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just nits but this looks good
@davidfowl Since you're filling in as M2 while Kevin is out, want to apply the cc: @wtgodbe Need your help merging once it's all clear. |
Don't forget to forward port to main, it wont be automatic. |
src/Http/Routing/test/UnitTests/Builder/MinimalActionEndpointRouteBuilderExtensionsTest.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to check if the method is a local function before excluding it for being compiler generated.
src/Http/Routing/src/Builder/MinimalActionEndpointRouteBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
Adds support for automatically setting the name of an endpoint given the name of the method used as a delegate. For example:
will produce
HelloWorld
as an endpoint name.The method name is also incorporated into the display name to make it easier for users to debug issues with routes.
Old display name: /hello HTTP: GET
New display name: HTTP: GET /hello => HelloWorld
Customer Impact
The changes in this PR make it easier for users to interact with the OpenAPI improvements that were shipped in RC1. They also make it easier for users to debug issues related to duplicate route names by improving the display name used to represent routes.
Regression?
Risk
Changes here are isolated to minimal APIs and are part of new changes that were introduced in rc1.
Verification
Packaging changes reviewed?
Fixes #35435 and #34540.