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

Make sure route binding isn't case sensitive #35090

Merged
merged 1 commit into from
Aug 6, 2021

Conversation

davidfowl
Copy link
Member

  • For error handling cases, we were doing a case sensitive match against route parameters instead of a case insensitive one.
  • Added tests

Fixes #35087

- For error handling cases, we were doing a case sensitive match against route parameters instead of a case insensitive one.
- Added tests
@ghost ghost added the area-runtime label Aug 6, 2021
@davidfowl davidfowl added area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels feature-minimal-actions Controller-like actions for endpoint routing and removed area-runtime labels Aug 6, 2021
@@ -208,7 +208,7 @@ private static Expression CreateArgument(ParameterInfo parameter, FactoryContext

if (parameterCustomAttributes.OfType<IFromRouteMetadata>().FirstOrDefault() is { } routeAttribute)
{
if (factoryContext.RouteParameters is { } routeParams && !routeParams.Contains(parameter.Name))
if (factoryContext.RouteParameters is { } routeParams && !routeParams.Contains(parameter.Name, StringComparer.OrdinalIgnoreCase))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this using Linq? Can we turn this in to HashSet instead? or write a bespoke iterator? The Linq one will result in allocations: https://github.com/dotnet/runtime/blob/main/src/libraries/System.Linq/src/System/Linq/Contains.cs#L33

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should do that in another PR and did all the things. But I agree with you. There's too much LINQ usage here at startup

Copy link
Contributor

@pranavkm pranavkm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests look great. I know it's a one time cost, but the Linq allocations appears at Startup for a whole slew of data types / parameters and it would be great if we can avoid these allocations.

@davidfowl
Copy link
Member Author

We should file another item to measure and fix the low hanging startup performance fruit here

@davidfowl davidfowl merged commit fd94970 into main Aug 6, 2021
@davidfowl davidfowl deleted the davidfowl/case-sensitivity branch August 6, 2021 17:08
@ghost ghost added this to the 6.0-rc1 milestone Aug 6, 2021
@amcasey amcasey added the area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc label Jun 2, 2023
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 area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels feature-minimal-actions Controller-like actions for endpoint routing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ignore Casing for route parameters in Minimal APIs
3 participants