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

Share route pattern parsing logic between analyzers and generators #46342

Open
captainsafia opened this issue Jan 31, 2023 · 3 comments
Open
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc
Milestone

Comments

@captainsafia
Copy link
Member

Both the route handler analyzers and the RequestDelegateGenerator share a requirement for being able to parse a route pattern string and extract information about the route parameters in it, constraints on those parameters, etc.

We should identify a way to share this code across the analyzers and generators.

As part of consuming this logic in the RequestDelegateGenerator we want to emit logic that will determine if a parameter appears in the route and sourcing it from the route values dictionary.

cc: @halter73 as this relates to the parameter binding work
cc: @JamesNK who has knowledge in this area

@captainsafia captainsafia added the area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels label Jan 31, 2023
@captainsafia captainsafia added this to the .NET 8 Planning milestone Jan 31, 2023
@ghost
Copy link

ghost commented Jan 31, 2023

Thanks for contacting us.

We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@halter73
Copy link
Member

Continuing the conversation from https://github.com/dotnet/aspnetcore/pull/46838/files#r1119362420

Compile-time pattern parsing won't work a lot of the time like when the IEndpointRouteBuilder is really a group with an unknown prefix.

I think our best option is going to be to continue validating the route values during the call to RouteEndpointDataSource.GetGroupedEndpoints(context) like we do in RDF today. Waiting until the RequestDelegate is invoked to throw the InvalidOperationException is too late.

We shouldn't be checking options?.RouteParameterNames?.Contains("{{endpointParameter.Name}}", StringComparer.OrdinalIgnoreCase) != true every single request for each potential route parameter for performance reasons anyway. We should be caching the result of this during GetGroupedEndpoints. This is more important than improving the compile-time analysis because the runtime check can always work.

@captainsafia
Copy link
Member Author

We shouldn't be checking options?.RouteParameterNames?.Contains("{{endpointParameter.Name}}", StringComparer.OrdinalIgnoreCase) != true every single request for each potential route parameter for performance reasons anyway.

Actually, I think this should be doable if we move the check from here to here. This is what uController does anyways (ref) and we've talked about doing it that way before but this detail was missed in the original implementation. I can take a look at fixing this.

@captainsafia captainsafia added area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc and removed area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels labels Jun 20, 2023
@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 13, 2024
@dotnet dotnet deleted a comment from dotnet-policy-service bot Feb 13, 2024
@dotnet dotnet deleted a comment from dotnet-policy-service bot Feb 13, 2024
@captainsafia captainsafia modified the milestones: .NET 8 Planning, Backlog Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc
Projects
No open projects
Status: Committed
Development

No branches or pull requests

3 participants