Fix shell navigation, Cancel canExecute, AOT-safe FromEventPattern, and MAUI TFMs in sample projects#4321
Merged
glennawatson merged 2 commits intocleanup/remove-old-integration-testsfrom Apr 2, 2026
Conversation
…T-safe FromEventPattern, MAUI TFMs - Add AppShell.xaml + AppShell.xaml.cs for MAUI Shell navigation - Update App.xaml.cs to use new AppShell() instead of NavigationPage - Fix LoginPage.xaml.cs: replace async void Subscribe with SelectMany/FromAsync + instance DisplayAlert - Fix all three LoginViewModel.cs: Cancel uses Login.IsExecuting as canExecute via Subject<Unit> pattern - Fix WPF LoginView.xaml.cs: use strongly-typed Observable.FromEventPattern overload - Fix MAUI csproj: add proper platform-specific MAUI TFMs + OutputType=Exe Agent-Logs-Url: https://github.com/reactiveui/ReactiveUI/sessions/93dee6e0-8644-4b85-996e-8a19bd5ccf27 Co-authored-by: glennawatson <5834289+glennawatson@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix shell navigation issues and adapt for consistency
Fix shell navigation, Cancel canExecute, AOT-safe FromEventPattern, and MAUI TFMs in sample projects
Apr 2, 2026
glennawatson
added a commit
that referenced
this pull request
Apr 3, 2026
…nd MAUI TFMs in sample projects (#4321) Addresses all open review comments on #4319. The MAUI sample used `NavigationPage` while calling `Shell.Current?.DisplayAlert(...)`, guaranteeing a null reference and silent no-op alerts. The `Cancel` command in all three sample ViewModels was always enabled, contradicting its doc comment. The WPF `PasswordChanged` binding used reflection-based `FromEventPattern`, and the MAUI project targeted `net10.0` instead of deployable platform TFMs. ## MAUI: Shell navigation - Added `AppShell.xaml` / `AppShell.xaml.cs`; `App.xaml.cs` now creates `new AppShell()` instead of `new NavigationPage(new LoginPage())` ## MAUI: Alert handling — no more `async void` Replaced the `async void` subscribe + `Shell.Current?.DisplayAlert` pattern with a proper Rx chain using the `ContentPage` instance method: ```csharp ViewModel.Login .SelectMany(success => Observable.FromAsync(() => DisplayAlert( success ? "Login Successful" : "Login Failed", success ? "Welcome!" : "Invalid credentials.", "OK"))) .Subscribe() .DisposeWith(d); ``` ## All three ViewModels: `Cancel` respects `Login.IsExecuting` A `Subject<Unit>` breaks the circular dependency (`Login` needs a cancel signal; `Cancel` needs `Login.IsExecuting`): ```csharp var cancelSubject = new Subject<Unit>(); Login = ReactiveCommand.CreateFromObservable( () => Observable.Return(Password is "secret") .Delay(TimeSpan.FromSeconds(1), scheduler) .TakeUntil(cancelSubject), canLogin, scheduler); Cancel = ReactiveCommand.Create( () => cancelSubject.OnNext(Unit.Default), Login.IsExecuting, scheduler); ``` ## WPF: AOT-safe `FromEventPattern` Swapped the reflection overload for the strongly-typed delegate overload: ```csharp Observable.FromEventPattern<RoutedEventHandler, RoutedEventArgs>( h => Password.PasswordChanged += h, h => Password.PasswordChanged -= h) ``` ## MAUI csproj: proper platform TFMs Replaced `<TargetFramework>net10.0</TargetFramework>` with platform-specific TFMs (`net10.0-android`; `net10.0-ios`/`net10.0-maccatalyst` on macOS/Windows; `net10.0-windows10.0.19041.0` on Windows), added `<OutputType>Exe</OutputType>`, `SupportedOSPlatformVersion`, and Windows packaging properties. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: glennawatson <5834289+glennawatson@users.noreply.github.com>
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Addresses all open review comments on #4319. The MAUI sample used
NavigationPagewhile callingShell.Current?.DisplayAlert(...), guaranteeing a null reference and silent no-op alerts. TheCancelcommand in all three sample ViewModels was always enabled, contradicting its doc comment. The WPFPasswordChangedbinding used reflection-basedFromEventPattern, and the MAUI project targetednet10.0instead of deployable platform TFMs.MAUI: Shell navigation
AppShell.xaml/AppShell.xaml.cs;App.xaml.csnow createsnew AppShell()instead ofnew NavigationPage(new LoginPage())MAUI: Alert handling — no more
async voidReplaced the
async voidsubscribe +Shell.Current?.DisplayAlertpattern with a proper Rx chain using theContentPageinstance method:All three ViewModels:
CancelrespectsLogin.IsExecutingA
Subject<Unit>breaks the circular dependency (Loginneeds a cancel signal;CancelneedsLogin.IsExecuting):WPF: AOT-safe
FromEventPatternSwapped the reflection overload for the strongly-typed delegate overload:
MAUI csproj: proper platform TFMs
Replaced
<TargetFramework>net10.0</TargetFramework>with platform-specific TFMs (net10.0-android;net10.0-ios/net10.0-maccatalyston macOS/Windows;net10.0-windows10.0.19041.0on Windows), added<OutputType>Exe</OutputType>,SupportedOSPlatformVersion, and Windows packaging properties.