-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Remove RequestDelegateFactory call from RouteEndpointBuilder #42827
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
- Remove ModelEndpointDataSource. Use RouteEndpointDataSource instead
// Add MethodInfo and HttpMethodMetadata (if any) as first metadata items as they are intrinsic to the route much like | ||
// the pattern or default display name. This gives visibility to conventions like WithOpenApi() to intrinsic route details | ||
// (namely the MethodInfo) even when applied early as group conventions. | ||
builder.Metadata.Add(handler.Method); |
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 want to add this in either case so open api works.
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 adding it only for route handlers will actually help with our goal of making WithOpenApi
something you can only apply on RouteHandlerBuilder
types even though we removed that constraint. AFAIK, non-route handler scenarios don't need access to the method info.
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.
That's the question. Do we want OpenAPI for these endpoints or not? What if someone manually adds [Consumes]
or [Produces]
metadata to these endpoints? For now, I'm trying to keep this behavior consistent with the behavior we've already have.
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 should unify these endpoints mostly because of the amount of bugs where people end up calling the RequestDelegate overload and it things stop working.
Assert.Equal("METHOD", GetMethod(endpoint.Metadata[0])); | ||
Assert.Equal("ATTRIBUTE", GetMethod(endpoint.Metadata[1])); |
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.
Breaking change?
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.
Technically.
You'd had to have defined a custom attribute that implemented IHttpMethodMetadata
which no one on grepp.app has other than us in this very test, in one other test which notably didn't need to be changed because it wasn't overriding anything, and in .NET 6 preview diffs before I removed it from the MVC attributes. We certainly don't ship any such attributes.
Plus, we already made this "breaking" change for route handlers between .NET 6 and .NET 7 with #40926. See https://github.com/dotnet/aspnetcore/pull/40926/files#diff-f6727c82b3f6cff19c30c9c793f3e47c1c2ff2035a6453198ff4cedad8e84557
I almost went the other way and had RouteEndopintDataSource
copy the old .NET 6 behavior here so we didn't "break" anything for either Delegate
or RequestDelegate
, but it makes sense to configure metadata added implicitly by the MapXxx
call like the MethodInfo
and HttpMethodMetadata
before any additional metadata configured by the user.
This might be problematic as it will break people's expectations that these filters run in both cases like other MVC filters. Is there a specific reason to prevent these filters from applying to pages? |
Co-authored-by: Kahbazi <[email protected]> Co-authored-by: David Fowler <[email protected]>
This is my position as well. The problem is the way they were running in earlier previews is over the The same is true right now for MVC actions (until after this change merged after which those too will be skipped). @davidfowl opened a draft PR (#42557) to run these filters the way our customers expect for MVC actions. We wanted to include razor pages in this PR as well, but the problem is that razor pages can effectively have multiple |
I updated this PR to do the renames suggested in #43000 and #42592. I assigned both of these to myself. I also reacted to @davidfowl's and @captainsafia's feedback about adding the Are we sure want this to affect ApiExplorer too? I like that this keeps things consistent with |
Even if we do agree this is the direction we should take, I think we need an easy way to opt out of this globally for people who might not want this behavior but want to easily upgrade their existing apps using something like swashbuckle or nswag to .NET 7. Applications might call into libraries that call
Edit: Updated to reflect |
I think I've addressed all the PR feedback. I undid the renames to reduce merge conflicts in #42557. The renames weren't the point of this PR. I thought I was saving work, but I wasn't. We also want to expose the |
This reverts commit bb2b157.
- No. I do not think normalizing the display names is a breaking change.
7afa072
to
8426c40
Compare
This is somewhat dependent on #42557 to ensure we have a nice experience where "endpoint" filters run on both route handlers, normal RequestDelegates and MVC actions.
Fixes #42703