diff --git a/Stellar.Maui.UnitTests/HotReloadSubscriptionTests.cs b/Stellar.Maui.UnitTests/HotReloadSubscriptionTests.cs index 9c6f1c8..cacf4c3 100644 --- a/Stellar.Maui.UnitTests/HotReloadSubscriptionTests.cs +++ b/Stellar.Maui.UnitTests/HotReloadSubscriptionTests.cs @@ -62,6 +62,23 @@ public void Subscription_IsDroppedWhenAViewOutsideAListLeavesTheWindow() GC.KeepAlive(window); } + [Fact] + public void HotReload_ReachesAViewThatIsInAWindow() + { + var page = new ContentPage(); + var window = new Window(page); + var cell = new GridDataModelCell(); + + page.Content = cell; + + // ReloadView hands its work to the main thread, which a test host does not + // have, so reaching that hand-off is the evidence that the view was reloaded. + var thrown = Record.Exception(static () => HotReloadService.UpdateApplication(null)); + + Assert.NotNull(thrown); + GC.KeepAlive(window); + } + private static bool IsSubscribed(ITestCell cell) { var handlers = diff --git a/Stellar.Maui/MauiViewManager.cs b/Stellar.Maui/MauiViewManager.cs index 78f542a..0cbe501 100644 --- a/Stellar.Maui/MauiViewManager.cs +++ b/Stellar.Maui/MauiViewManager.cs @@ -191,7 +191,7 @@ private void Deactivate(IStellarView view, TViewModel? parkedViewMod private void HandleHotReload(Type[]? updatedTypes) { - if (_reloadView is null || _reloadView.TryGetTarget(out var target) || target is not IStellarView isv) + if (_reloadView is null || !_reloadView.TryGetTarget(out var target) || target is not IStellarView isv) { return; }