-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat: Shell route templates with {param} path parameters #35110
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
Open
mattleibow
wants to merge
10
commits into
main
Choose a base branch
from
mattleibow/shell-route-templates-spec
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
088c59f
Shell route templates: spec + standalone prototype (28 passing tests)
mattleibow aeb7df4
feat: Shell route templates with {param} path parameters
mattleibow 70f6e52
fix: address review feedback — reject unsupported syntax, fix param l…
mattleibow 098f360
feat: optional params, catch-all, constraints, mixed segments, defaul…
mattleibow 5ad6986
test: add 19 combination tests for full feature coverage
mattleibow 78b0d83
fix: address review round 2 — parser bugs, validation, and missing tests
mattleibow 4e23a99
fix: review round 3 — template lookup bypass, SetRoute mutation, Full…
mattleibow a24b721
fix: review round 4 — IL2111 trimmer, stale ResolvedRoute, intermedia…
mattleibow e90ef3d
fix: review round 5 — strengthen tests, modal reuse path, prefixed pa…
mattleibow 1e9f8ef
fix: CS8618 nullable warnings in Sandbox pages breaking CI Samples tests
mattleibow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,49 @@ | ||
| <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| x:Class="Maui.Controls.Sample.MainPage" | ||
| xmlns:local="clr-namespace:Maui.Controls.Sample"> | ||
| xmlns:local="clr-namespace:Maui.Controls.Sample" | ||
| Title="Product Catalog"> | ||
| <ScrollView> | ||
| <VerticalStackLayout Padding="20" Spacing="15"> | ||
| <Label Text="🌱 Product Catalog" | ||
| FontSize="28" | ||
| FontAttributes="Bold" /> | ||
| <Label Text="Tap a product to navigate using {sku} path parameter." | ||
| FontSize="14" | ||
| TextColor="Gray" /> | ||
|
|
||
| <BoxView HeightRequest="1" Color="LightGray" /> | ||
|
|
||
| <Button Text="🍅 Seed Tomato" | ||
| AutomationId="ProductSeedTomato" | ||
| Clicked="OnProductTapped" | ||
| CommandParameter="seed-tomato" /> | ||
|
|
||
| <Button Text="🌿 Herb Basil" | ||
| AutomationId="ProductHerbBasil" | ||
| Clicked="OnProductTapped" | ||
| CommandParameter="herb-basil" /> | ||
|
|
||
| <Button Text="🥕 Root Carrot" | ||
| AutomationId="ProductRootCarrot" | ||
| Clicked="OnProductTapped" | ||
| CommandParameter="root-carrot" /> | ||
|
|
||
| <BoxView HeightRequest="1" Color="LightGray" /> | ||
|
|
||
| <Label Text="Multi-step navigation (product → review)" | ||
| FontSize="14" | ||
| FontAttributes="Bold" /> | ||
|
|
||
| <Button Text="🍅 Seed Tomato → Review (default ⭐5)" | ||
| AutomationId="ProductSeedTomatoReview" | ||
| Clicked="OnProductReviewTapped" | ||
| CommandParameter="seed-tomato" /> | ||
|
|
||
| <Button Text="🌿 Herb Basil → Review (⭐3)" | ||
| AutomationId="ProductHerbBasilReview3" | ||
| Clicked="OnProductReviewWithStars" | ||
| CommandParameter="herb-basil" /> | ||
| </VerticalStackLayout> | ||
| </ScrollView> | ||
| </ContentPage> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/Controls/samples/Controls.Sample.Sandbox/OrderDetailPage.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| x:Class="Maui.Controls.Sample.OrderDetailPage" | ||
| Title="Order Detail"> | ||
| <VerticalStackLayout Padding="20" Spacing="15"> | ||
| <Label Text="📋 Order Detail" | ||
| FontSize="24" | ||
| FontAttributes="Bold" /> | ||
| <Label x:Name="OrderIdLabel" | ||
| Text="Order ID: (from {orderId:int} path parameter)" | ||
| FontSize="18" /> | ||
| <Label Text="The orderId parameter uses {:int} constraint — only numeric values are accepted." | ||
| FontSize="14" | ||
| TextColor="Gray" /> | ||
| </VerticalStackLayout> | ||
| </ContentPage> |
23 changes: 23 additions & 0 deletions
23
src/Controls/samples/Controls.Sample.Sandbox/OrderDetailPage.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| namespace Maui.Controls.Sample; | ||
|
|
||
| [QueryProperty(nameof(OrderId), "orderId")] | ||
| public partial class OrderDetailPage : ContentPage | ||
| { | ||
| public OrderDetailPage() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
|
|
||
| public string? OrderId | ||
| { | ||
| get => _orderId; | ||
| set | ||
| { | ||
| _orderId = value; | ||
| OnPropertyChanged(); | ||
| if (OrderIdLabel is not null) | ||
| OrderIdLabel.Text = $"Order ID: #{value}"; | ||
| } | ||
| } | ||
| string? _orderId; | ||
| } |
33 changes: 33 additions & 0 deletions
33
src/Controls/samples/Controls.Sample.Sandbox/OrdersPage.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| x:Class="Maui.Controls.Sample.OrdersPage" | ||
| Title="Orders"> | ||
| <ScrollView> | ||
| <VerticalStackLayout Padding="20" Spacing="15"> | ||
| <Label Text="📦 Orders" | ||
| FontSize="28" | ||
| FontAttributes="Bold" /> | ||
| <Label Text="Tap an order to navigate using {orderId:int} constrained path parameter." | ||
| FontSize="14" | ||
| TextColor="Gray" /> | ||
|
|
||
| <BoxView HeightRequest="1" Color="LightGray" /> | ||
|
|
||
| <Button Text="Order #1001" | ||
| AutomationId="Order1001" | ||
| Clicked="OnOrderTapped" | ||
| CommandParameter="1001" /> | ||
|
|
||
| <Button Text="Order #1002" | ||
| AutomationId="Order1002" | ||
| Clicked="OnOrderTapped" | ||
| CommandParameter="1002" /> | ||
|
|
||
| <Button Text="Order #1003" | ||
| AutomationId="Order1003" | ||
| Clicked="OnOrderTapped" | ||
| CommandParameter="1003" /> | ||
| </VerticalStackLayout> | ||
| </ScrollView> | ||
| </ContentPage> |
15 changes: 15 additions & 0 deletions
15
src/Controls/samples/Controls.Sample.Sandbox/OrdersPage.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| namespace Maui.Controls.Sample; | ||
|
|
||
| public partial class OrdersPage : ContentPage | ||
| { | ||
| public OrdersPage() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
|
|
||
| async void OnOrderTapped(object sender, EventArgs e) | ||
| { | ||
| if (sender is Button btn && btn.CommandParameter is string orderId) | ||
| await Shell.Current.GoToAsync($"//orders/order/{orderId}"); | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
src/Controls/samples/Controls.Sample.Sandbox/ProductPage.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| x:Class="Maui.Controls.Sample.ProductPage" | ||
| Title="Product Detail"> | ||
| <VerticalStackLayout Padding="20" Spacing="15"> | ||
| <Label Text="Product Detail Page" | ||
| FontSize="24" | ||
| FontAttributes="Bold" /> | ||
| <Label x:Name="SkuLabel" | ||
| Text="SKU: (waiting for parameter)" | ||
| FontSize="18" /> | ||
| <Button Text="Go to Review →" | ||
| Clicked="OnGoToReview" | ||
| x:Name="ReviewButton" /> | ||
| </VerticalStackLayout> | ||
| </ContentPage> |
30 changes: 30 additions & 0 deletions
30
src/Controls/samples/Controls.Sample.Sandbox/ProductPage.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| namespace Maui.Controls.Sample; | ||
|
|
||
| [QueryProperty(nameof(Sku), "sku")] | ||
| public partial class ProductPage : ContentPage | ||
| { | ||
| public ProductPage() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
|
|
||
| public string? Sku | ||
| { | ||
| get => _sku; | ||
| set | ||
| { | ||
| _sku = value; | ||
| OnPropertyChanged(); | ||
| if (SkuLabel is not null) | ||
| SkuLabel.Text = $"SKU: {value}"; | ||
| if (ReviewButton is not null) | ||
| ReviewButton.IsVisible = !string.IsNullOrEmpty(value); | ||
| } | ||
| } | ||
| string? _sku; | ||
|
|
||
| async void OnGoToReview(object sender, EventArgs e) | ||
| { | ||
| await Shell.Current.GoToAsync("review"); | ||
| } | ||
| } |
20 changes: 20 additions & 0 deletions
20
src/Controls/samples/Controls.Sample.Sandbox/ReviewPage.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| x:Class="Maui.Controls.Sample.ReviewPage" | ||
| Title="Review"> | ||
| <VerticalStackLayout Padding="20" Spacing="15"> | ||
| <Label Text="📝 Write a Review" | ||
| FontSize="24" | ||
| FontAttributes="Bold" /> | ||
| <Label x:Name="SkuLabel" | ||
| Text="Product: (inherited from parent route)" | ||
| FontSize="18" /> | ||
| <Label x:Name="StarsLabel" | ||
| Text="Rating: (from {stars=5} default)" | ||
| FontSize="18" /> | ||
| <Label Text="The stars parameter uses {stars=5} — if you navigate without specifying stars, you get the default of 5." | ||
| FontSize="14" | ||
| TextColor="Gray" /> | ||
| </VerticalStackLayout> | ||
| </ContentPage> |
40 changes: 40 additions & 0 deletions
40
src/Controls/samples/Controls.Sample.Sandbox/ReviewPage.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| namespace Maui.Controls.Sample; | ||
|
|
||
| [QueryProperty(nameof(Sku), "sku")] | ||
| [QueryProperty(nameof(Stars), "stars")] | ||
| public partial class ReviewPage : ContentPage | ||
| { | ||
| public ReviewPage() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
|
|
||
| public string? Sku | ||
| { | ||
| get => _sku; | ||
| set | ||
| { | ||
| _sku = value; | ||
| OnPropertyChanged(); | ||
| if (SkuLabel is not null) | ||
| SkuLabel.Text = $"Product: {value}"; | ||
| } | ||
| } | ||
| string? _sku; | ||
|
|
||
| public string? Stars | ||
| { | ||
| get => _stars; | ||
| set | ||
| { | ||
| _stars = value; | ||
| OnPropertyChanged(); | ||
| if (StarsLabel is not null) | ||
| { | ||
| var count = int.TryParse(value, out var n) ? n : 0; | ||
| StarsLabel.Text = $"Rating: {new string('⭐', count)} ({value})"; | ||
| } | ||
| } | ||
| } | ||
| string? _stars; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
[suggestion] PR scoping — The Sandbox sample is being repurposed into a route-template demo (
product/{sku},review/{stars=5},order/{orderId:int}, plus 5 new*Page.xamlfiles and a rewrittenMainPage). Sandbox is a shared developer test bed used by everyone working on MAUI; permanently dedicating it to one feature's demo is unusual. Consider either (a) moving these pages into a dedicated sample undersrc/Controls/samples/Controls.SampleorControls.Sample.Mauiso other developers' sandbox state isn't disrupted, or (b) confirming with the team that this repurposing is intentional. At minimum, ensureApp.xaml.cschange at line 2 is intentional and not leftover scratch state.