-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Make sure route binding isn't case sensitive #35090
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
- For error handling cases, we were doing a case sensitive match against route parameters instead of a case insensitive one. - Added tests
@@ -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)) |
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.
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
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 do that in another PR and did all the things. But I agree with you. There's too much LINQ usage here at startup
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.
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.
We should file another item to measure and fix the low hanging startup performance fruit here |
Fixes #35087