-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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 RouteAttribute non-inherited #10236
Conversation
Fixes: #5529 Inheriting and looking for inherited route attributes will cause nothing but trouble. We had a bug tracking what to do about this and we decided to make it really clear that routes are not inherited. Previously the attribute was marked as inherited, but we woulnd't look for inherited routes.
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.
Would be great to have an extra unit test in RouteTableTests
to represent this.
Besides that, looks great!
Added some tests |
@@ -8,7 +8,7 @@ namespace Microsoft.AspNetCore.Components | |||
/// <summary> | |||
/// Indicates that the associated component should match the specified route template pattern. | |||
/// </summary> | |||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] | |||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)] | |||
public class RouteAttribute : Attribute |
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.
Make it sealed? I think you're allowed to redefine AttributeUsage
on derived types so you could get in to the same problem.
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.
Hmm that's wierd that we didn't do this already. Since github didn't show your comment until after I merged, I'm going to add this to the API review item.
@rynowak @SteveSandersonMS One possible legitimate scenario with inherited route templates I could see, is when the API scheme is using API version in the URL path, and one would like to avoid duplicating the same Right now I’m having to resort to a |
This issue was related to Blazor. What you're suggesting with work fine with MVC. |
Fixes: #5529
Inheriting and looking for inherited route attributes will cause nothing
but trouble. We had a bug tracking what to do about this and we decided
to make it really clear that routes are not inherited.
Previously the attribute was marked as inherited, but we woulnd't look
for inherited routes.