-
Notifications
You must be signed in to change notification settings - Fork 10k
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
[Blazor] Fixes issues with route precedence #27907
Conversation
Hello human! Please make sure you've included the Shiproom Template in a comment or (preferably) the PR description. Also, make sure this PR is not marked as a draft and is ready-to-merge. |
To build more confidence that the algorithmic changes don't have any unanticipated breaking effect on existing apps, I had a go at running the old tests against the new implementation. Six of the old tests fail with the new implementation, all of which may be intentional and for good reasons, but it's worth spelling out the exact details given this is going in a patch. Here are the old tests that fail with the new algorithm:
|
@SteveSandersonMS Great summary, Steve! Thanks for taking the time to assemble that. I think the change in how we handle optional and non-optional constraints for the same parameter might end up being the most impactful breaking change for users. Since this is being put into a patch release, what's our approach for handling the breaking changes here? |
@captainsafia I think we'll need to make this change opt-in (and on by default in the project template for new apps). |
fb00686
to
321d863
Compare
@javiercn I'm assuming I'm still finishing this off (and am working on it now), but if you preferred to take it back, please let me know! Just don't want us both to be working on it separately at the same time. |
src/Components/Components/src/Routing/LegacyRouteMatching/LegacyOptionalTypeRouteConstraint.cs
Show resolved
Hide resolved
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.
LGTM!
(I can't sign-off because I created the PR)
/AzurePipelines run AspNetCore-ci |
Azure Pipelines successfully started running 1 pipeline(s). |
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.
Signing off on behalf of @javiercn 👍
It's completely independent of the newer logic, because it's in a separate peer-level namespace. Nothing in the legacy namespace has a "using" for the newer namespace, and nothing in the newer namespace has a "using" for the legacy namespace. So they should not be able to reference each other accidentally.
…t routing via flag
d87593a
to
d932914
Compare
@mkArtakMSFT Looks like this is ready to merge. Our test coverage for the project templates is very weak at the moment (seems that all the Blazor template tests are currently quarantined and failing), so I hope we have CTI coverage and will get preview builds of the 5.0.1 SDK to test manually before it ships. |
Description We introduced a public property as part of #27907 to enable users to opt-in. Turns out that this caused issues since we didn't update the target pack. As a result, the Razor compiler treats this new property as a regular HTML attribute (of type string) instead of as a boolean. In turn this causes the template to error at runtime when the application starts. Customer Impact Customers using 5.0.1 won't be able to create and run new blazor apps out of the box. They can fix the template code by preceding the true value in the attribute with @ to force the compiler to interpret it as C#. (Which is the same fix we are applying). Regression? Yes, 5.0.0. Users were able to create new blazor templates without this issue. Risk Low. We've manually validated the fix against a new project from a 5.0.1 template.
In response to the API change that was introduced by #27907
Description
In 5.0 we introduced two features on Blazor routing that enable users to write routing templates that match paths with variable length segments. These two features are optional parameters
{parameter?}
and catch all parameters{*catchall}
.Our routing system ordered the routes based on precedence and the (now false) assumption that route templates would only match paths with an equal number of segments.
The implementation that we have worked for naïve scenarios but breaks on more real world scenarios. The change here includes fixes to the way we order the routes in the route table to match the expectations as well as fixes on the route matching algorithm to ensure we match routes with variable number of segments correctly.
Customer Impact
This was reported by customers on #27250
The impact is that a route with
{*catchall}
will prevent more specific routes like/page/{parameter}
from being accessible.There are no workarounds since precedence is a fundamental behavior of the routing system.
Regression?
No, these Blazor features were initially added in 5.0.
Risk
Low. These two features were just introduced in 5.0 and their usage is not as prevalent as in asp.net core routing. That said, it's important to fix them as otherwise we run the risk of diverting in behavior from asp.net core routing and Blazor routing, which is not something we want to do.
We have functional tests covering the area and we've added a significant amount of unit tests to validate the changes.