From 9e17cd131d16e7c0f9b416737164c5fd3ef5dbab Mon Sep 17 00:00:00 2001
From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com>
Date: Sun, 25 May 2025 14:46:20 -0700
Subject: [PATCH 01/10] Add `Close()`
---
.../Extensions/PopupExtensions.shared.cs | 31 +++++++++++++++++++
.../Views/Popup/Popup.shared.cs | 5 +--
.../Views/Popup/PopupPage.shared.cs | 2 +-
3 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/src/CommunityToolkit.Maui/Extensions/PopupExtensions.shared.cs b/src/CommunityToolkit.Maui/Extensions/PopupExtensions.shared.cs
index e1ba2c9d28..3ac9234316 100644
--- a/src/CommunityToolkit.Maui/Extensions/PopupExtensions.shared.cs
+++ b/src/CommunityToolkit.Maui/Extensions/PopupExtensions.shared.cs
@@ -196,6 +196,37 @@ void HandlePopupClosed(object? sender, IPopupResult e)
}
}
+ ///
+ /// Close the Popup
+ ///
+ public static Task ClosePopup(this Page page)
+ {
+ ArgumentNullException.ThrowIfNull(page);
+
+ return ClosePopup(page.Navigation);
+ }
+
+ ///
+ /// Close the Popup
+ ///
+ public static Task ClosePopup(this INavigation navigation)
+ {
+ ArgumentNullException.ThrowIfNull(navigation);
+
+ var currentVisibleModalPage = navigation.ModalStack.LastOrDefault();
+ if (currentVisibleModalPage is null)
+ {
+ throw new PopupNotFoundException();
+ }
+
+ if (currentVisibleModalPage is not PopupPage)
+ {
+ throw new PopupBlockedException(currentVisibleModalPage);
+ }
+
+ return navigation.PopModalAsync(false);
+ }
+
static PopupResult GetPopupResult(in IPopupResult result)
{
return result switch
diff --git a/src/CommunityToolkit.Maui/Views/Popup/Popup.shared.cs b/src/CommunityToolkit.Maui/Views/Popup/Popup.shared.cs
index 894ace2b01..a006d555bc 100644
--- a/src/CommunityToolkit.Maui/Views/Popup/Popup.shared.cs
+++ b/src/CommunityToolkit.Maui/Views/Popup/Popup.shared.cs
@@ -130,5 +130,6 @@ public partial class Popup : Popup
public virtual Task Close(T result, CancellationToken token = default) => GetPopupPage().Close(new PopupResult(result, false), token);
}
-class InvalidPopupOperationException(string message) : InvalidOperationException(message);
-sealed class PopupNotFoundException() : InvalidPopupOperationException($"Unable to close popup: could not locate {nameof(PopupPage)}. {nameof(PopupExtensions.ShowPopup)} or {nameof(PopupExtensions.ShowPopupAsync)} must be called before {nameof(Popup.Close)}. If using a custom implementation of {nameof(Popup)}, override the {nameof(Popup.Close)} method");
\ No newline at end of file
+sealed class PopupNotFoundException() : InvalidPopupOperationException($"Unable to close popup: could not locate {nameof(PopupPage)}. {nameof(PopupExtensions.ShowPopup)} or {nameof(PopupExtensions.ShowPopupAsync)} must be called before {nameof(Popup.Close)}. If using a custom implementation of {nameof(Popup)}, override the {nameof(Popup.Close)} method");
+sealed class PopupBlockedException(in Page currentVisibleModalPage): InvalidPopupOperationException($"Unable to close Popup because it is blocked by the Modal Page {currentVisibleModalPage.GetType().FullName}. Please call `{nameof(Page.Navigation)}.{nameof(Page.Navigation.PopModalAsync)}()` to first remove {currentVisibleModalPage.GetType().FullName} from the {nameof(Page.Navigation.ModalStack)}");
+class InvalidPopupOperationException(in string message) : InvalidOperationException(message);
diff --git a/src/CommunityToolkit.Maui/Views/Popup/PopupPage.shared.cs b/src/CommunityToolkit.Maui/Views/Popup/PopupPage.shared.cs
index 550ed6de91..3a8a975158 100644
--- a/src/CommunityToolkit.Maui/Views/Popup/PopupPage.shared.cs
+++ b/src/CommunityToolkit.Maui/Views/Popup/PopupPage.shared.cs
@@ -95,7 +95,7 @@ public async Task Close(PopupResult result, CancellationToken token = default)
if (Navigation.ModalStack[^1] is Microsoft.Maui.Controls.Page currentVisibleModalPage
&& currentVisibleModalPage != popupPageToClose)
{
- throw new InvalidPopupOperationException($"Unable to close Popup because it is blocked by the Modal Page {currentVisibleModalPage.GetType().FullName}. Please call `{nameof(Navigation)}.{nameof(Navigation.PopModalAsync)}()` to first remove {currentVisibleModalPage.GetType().FullName} from the {nameof(Navigation.ModalStack)}");
+ throw new PopupBlockedException(currentVisibleModalPage);
}
// We call `.ThrowIfCancellationRequested()` again to avoid a race condition where a developer cancels the CancellationToken after we check for an InvalidOperationException
From 82552c6927d845d890ebe04b9a2074c7d0e78fa1 Mon Sep 17 00:00:00 2001
From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com>
Date: Sun, 25 May 2025 14:47:40 -0700
Subject: [PATCH 02/10] Update PopupExtensions.shared.cs
---
.../Extensions/PopupExtensions.shared.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/CommunityToolkit.Maui/Extensions/PopupExtensions.shared.cs b/src/CommunityToolkit.Maui/Extensions/PopupExtensions.shared.cs
index 3ac9234316..f4fc0281a3 100644
--- a/src/CommunityToolkit.Maui/Extensions/PopupExtensions.shared.cs
+++ b/src/CommunityToolkit.Maui/Extensions/PopupExtensions.shared.cs
@@ -197,7 +197,7 @@ void HandlePopupClosed(object? sender, IPopupResult e)
}
///
- /// Close the Popup
+ /// Close the Visible Popup
///
public static Task ClosePopup(this Page page)
{
@@ -207,7 +207,7 @@ public static Task ClosePopup(this Page page)
}
///
- /// Close the Popup
+ /// Close the Visible Popup
///
public static Task ClosePopup(this INavigation navigation)
{
From 6558dbdc33bc58460f51c8a5cc696bf9eb213d8a Mon Sep 17 00:00:00 2001
From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com>
Date: Sun, 25 May 2025 14:52:00 -0700
Subject: [PATCH 03/10] Add CancellationToken
---
.../Extensions/PopupExtensions.shared.cs | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/CommunityToolkit.Maui/Extensions/PopupExtensions.shared.cs b/src/CommunityToolkit.Maui/Extensions/PopupExtensions.shared.cs
index f4fc0281a3..f0b8e92e7b 100644
--- a/src/CommunityToolkit.Maui/Extensions/PopupExtensions.shared.cs
+++ b/src/CommunityToolkit.Maui/Extensions/PopupExtensions.shared.cs
@@ -199,17 +199,17 @@ void HandlePopupClosed(object? sender, IPopupResult e)
///
/// Close the Visible Popup
///
- public static Task ClosePopup(this Page page)
+ public static Task ClosePopup(this Page page, CancellationToken token = default)
{
ArgumentNullException.ThrowIfNull(page);
- return ClosePopup(page.Navigation);
+ return ClosePopup(page.Navigation, token);
}
///
/// Close the Visible Popup
///
- public static Task ClosePopup(this INavigation navigation)
+ public static Task ClosePopup(this INavigation navigation, CancellationToken token = default)
{
ArgumentNullException.ThrowIfNull(navigation);
@@ -223,8 +223,14 @@ public static Task ClosePopup(this INavigation navigation)
{
throw new PopupBlockedException(currentVisibleModalPage);
}
-
- return navigation.PopModalAsync(false);
+
+ // At first glance, calling `token.ThrowIfCancellationRequested()` may look redundant given that we are using `.WaitAsync(token)` in the next step,
+ // However, `Navigation.PopModalAsync()` may return a completed Task, and when a completed Task is returned, `.WaitAsync(token)` is never invoked.
+ // In other words, `.WaitAsync(token)` may not throw an `OperationCanceledException` as expected which is why we call `.ThrowIfCancellationRequested()` again here
+ // Here's the .NET MAUI Source code demonstrating that `Navigation.PopModalAsync()` sometimes returns `Task.FromResult()`: https://github.com/dotnet/maui/blob/e5c252ec7f430cbaf28c8a815a249e3270b49844/src/Controls/src/Core/NavigationProxy.cs#L192-L196
+ token.ThrowIfCancellationRequested();
+
+ return navigation.PopModalAsync(false).WaitAsync(token);
}
static PopupResult GetPopupResult(in IPopupResult result)
From 1492eb276a8b9ad074d7ab1a481eec0f0f40eeca Mon Sep 17 00:00:00 2001
From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com>
Date: Sun, 25 May 2025 15:08:18 -0700
Subject: [PATCH 04/10] Add Unit Tests
---
.../Extensions/PopupExtensionsTests.cs | 57 +++++++++++++++++--
.../Extensions/PopupExtensions.shared.cs | 2 +
2 files changed, 55 insertions(+), 4 deletions(-)
diff --git a/src/CommunityToolkit.Maui.UnitTests/Extensions/PopupExtensionsTests.cs b/src/CommunityToolkit.Maui.UnitTests/Extensions/PopupExtensionsTests.cs
index baef743785..e42fe9a2a0 100644
--- a/src/CommunityToolkit.Maui.UnitTests/Extensions/PopupExtensionsTests.cs
+++ b/src/CommunityToolkit.Maui.UnitTests/Extensions/PopupExtensionsTests.cs
@@ -31,8 +31,45 @@ public PopupExtensionsTests()
navigation = page.Navigation;
}
- [Fact]
- public void ShowPopupAsync_WithPopupType_ShowsPopup()
+ [Fact(Timeout = (int)TestDuration.Short)]
+ public async Task ClosePopup_TokenExpired_ShouldThrowOperationCancelledException()
+ {
+ // Arrange
+ var cts = new CancellationTokenSource();
+
+ // Act
+ await cts.CancelAsync();
+
+ // Assert
+ await Assert.ThrowsAsync(() => navigation.ClosePopup(cts.Token));
+ }
+
+ [Fact(Timeout = (int)TestDuration.Short)]
+ public async Task ClosePopup_NoExistingPopup_ShouldThrowPopupNotFoundException()
+ {
+ // Arrange
+
+ // Act
+
+ // Assert
+ await Assert.ThrowsAsync(() => navigation.ClosePopup(TestContext.Current.CancellationToken));
+ }
+
+ [Fact(Timeout = (int)TestDuration.Short)]
+ public async Task ClosePopup_PopupBlocked_ShouldThrowPopupBlockedException()
+ {
+ // Arrange
+
+ // Act
+ navigation.ShowPopup(new Button());
+ await navigation.PushModalAsync(new ContentPage());
+
+ // Assert
+ await Assert.ThrowsAsync(() => navigation.ClosePopup(TestContext.Current.CancellationToken));
+ }
+
+ [Fact(Timeout = (int)TestDuration.Short)]
+ public async Task ShowPopupAsync_WithPopupType_ShowsPopupAndClosesPopup()
{
// Arrange
var selfClosingPopup = ServiceProvider.GetRequiredService() ?? throw new InvalidOperationException();
@@ -43,10 +80,16 @@ public void ShowPopupAsync_WithPopupType_ShowsPopup()
// Assert
Assert.Single(navigation.ModalStack);
Assert.IsType(navigation.ModalStack[0]);
+
+ // Act
+ await navigation.ClosePopup(TestContext.Current.CancellationToken);
+
+ // Assert
+ Assert.Empty(navigation.ModalStack);
}
- [Fact]
- public void ShowPopupAsync_Shell_WithPopupType_ShowsPopup()
+ [Fact(Timeout = (int)TestDuration.Short)]
+ public async Task ShowPopupAsync_Shell_WithPopupType_ShowsPopupAndClosesPopup()
{
// Arrange
var shell = new Shell();
@@ -63,6 +106,12 @@ public void ShowPopupAsync_Shell_WithPopupType_ShowsPopup()
// Assert
Assert.Single(shellNavigation.ModalStack);
Assert.IsType(shellNavigation.ModalStack[0]);
+
+ // Act
+ await navigation.ClosePopup(TestContext.Current.CancellationToken);
+
+ // Assert
+ Assert.Empty(navigation.ModalStack);
}
[Fact]
diff --git a/src/CommunityToolkit.Maui/Extensions/PopupExtensions.shared.cs b/src/CommunityToolkit.Maui/Extensions/PopupExtensions.shared.cs
index f0b8e92e7b..1cffb5b102 100644
--- a/src/CommunityToolkit.Maui/Extensions/PopupExtensions.shared.cs
+++ b/src/CommunityToolkit.Maui/Extensions/PopupExtensions.shared.cs
@@ -211,6 +211,8 @@ public static Task ClosePopup(this Page page, CancellationToken token = default)
///
public static Task ClosePopup(this INavigation navigation, CancellationToken token = default)
{
+ token.ThrowIfCancellationRequested();
+
ArgumentNullException.ThrowIfNull(navigation);
var currentVisibleModalPage = navigation.ModalStack.LastOrDefault();
From f8dfe65bf7a6c8a748ee022247947e7c9b908bc1 Mon Sep 17 00:00:00 2001
From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com>
Date: Sun, 25 May 2025 15:21:02 -0700
Subject: [PATCH 05/10] Add Support for Shell
---
.../Extensions/PopupExtensionsTests.cs | 2 +-
.../Views/Popup/PopupPageTests.cs | 3 ++-
.../Extensions/PopupExtensions.shared.cs | 17 +++++++----------
3 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/src/CommunityToolkit.Maui.UnitTests/Extensions/PopupExtensionsTests.cs b/src/CommunityToolkit.Maui.UnitTests/Extensions/PopupExtensionsTests.cs
index e42fe9a2a0..83a0c5b16b 100644
--- a/src/CommunityToolkit.Maui.UnitTests/Extensions/PopupExtensionsTests.cs
+++ b/src/CommunityToolkit.Maui.UnitTests/Extensions/PopupExtensionsTests.cs
@@ -166,7 +166,7 @@ public async Task ShowPopupAsync_AwaitingShowPopupAsync_EnsurePreviousPopupClose
}
[Fact(Timeout = (int)TestDuration.Short)]
- public async Task qShowPopupAsync_Shell_AwaitingShowPopupAsync_EnsurePreviousPopupClosed()
+ public async Task ShowPopupAsync_Shell_AwaitingShowPopupAsync_EnsurePreviousPopupClosed()
{
// Arrange
var shell = new Shell();
diff --git a/src/CommunityToolkit.Maui.UnitTests/Views/Popup/PopupPageTests.cs b/src/CommunityToolkit.Maui.UnitTests/Views/Popup/PopupPageTests.cs
index 23746cecc6..6eff6d506c 100644
--- a/src/CommunityToolkit.Maui.UnitTests/Views/Popup/PopupPageTests.cs
+++ b/src/CommunityToolkit.Maui.UnitTests/Views/Popup/PopupPageTests.cs
@@ -196,7 +196,8 @@ public async Task PopupPageT_CloseAfterAdditionalModalPage_ShouldThrowInvalidOpe
await navigation.PushModalAsync(new ContentPage());
// Assert
- await Assert.ThrowsAsync(async () => await popupPage.Close(new PopupResult(false), CancellationToken.None));
+ await Assert.ThrowsAsync(async () => await popupPage.Close(new PopupResult(false), CancellationToken.None));
+ await Assert.ThrowsAnyAsync(async () => await popupPage.Close(new PopupResult(false), CancellationToken.None));
await Assert.ThrowsAnyAsync(async () => await popupPage.Close(new PopupResult(false), CancellationToken.None));
}
diff --git a/src/CommunityToolkit.Maui/Extensions/PopupExtensions.shared.cs b/src/CommunityToolkit.Maui/Extensions/PopupExtensions.shared.cs
index 1cffb5b102..7954406c38 100644
--- a/src/CommunityToolkit.Maui/Extensions/PopupExtensions.shared.cs
+++ b/src/CommunityToolkit.Maui/Extensions/PopupExtensions.shared.cs
@@ -215,24 +215,21 @@ public static Task ClosePopup(this INavigation navigation, CancellationToken tok
ArgumentNullException.ThrowIfNull(navigation);
- var currentVisibleModalPage = navigation.ModalStack.LastOrDefault();
+ var currentVisibleModalPage = Shell.Current is null
+ ? navigation.ModalStack.LastOrDefault()
+ : Shell.Current.Navigation.ModalStack.LastOrDefault();
+
if (currentVisibleModalPage is null)
{
throw new PopupNotFoundException();
}
- if (currentVisibleModalPage is not PopupPage)
+ if (currentVisibleModalPage is not PopupPage popupPage)
{
throw new PopupBlockedException(currentVisibleModalPage);
}
-
- // At first glance, calling `token.ThrowIfCancellationRequested()` may look redundant given that we are using `.WaitAsync(token)` in the next step,
- // However, `Navigation.PopModalAsync()` may return a completed Task, and when a completed Task is returned, `.WaitAsync(token)` is never invoked.
- // In other words, `.WaitAsync(token)` may not throw an `OperationCanceledException` as expected which is why we call `.ThrowIfCancellationRequested()` again here
- // Here's the .NET MAUI Source code demonstrating that `Navigation.PopModalAsync()` sometimes returns `Task.FromResult()`: https://github.com/dotnet/maui/blob/e5c252ec7f430cbaf28c8a815a249e3270b49844/src/Controls/src/Core/NavigationProxy.cs#L192-L196
- token.ThrowIfCancellationRequested();
-
- return navigation.PopModalAsync(false).WaitAsync(token);
+
+ return popupPage.Close(new PopupResult(false), token);
}
static PopupResult GetPopupResult(in IPopupResult result)
From 02e1ef890ba4ff4e9e8e8f10716d1b375bed3517 Mon Sep 17 00:00:00 2001
From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com>
Date: Sun, 25 May 2025 16:03:50 -0700
Subject: [PATCH 06/10] Add .NET 10 Compiler Error
This ensures we do not forget to remove the Obsolete Popup classes in our .NET 10 release
---
.../Handlers/Popup/PopupHandler.shared.cs | 3 +++
src/CommunityToolkit.Maui.Core/Interfaces/IPopup.shared.cs | 3 +++
.../Views/Popup/MauiPopup.android.cs | 3 +++
src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.macios.cs | 3 +++
src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs | 3 +++
.../Views/Popup/PopupExtensions.android.cs | 3 +++
.../Views/Popup/PopupExtensions.macios.cs | 3 +++
.../Views/Popup/PopupExtensions.windows.cs | 3 +++
.../Views/Popup/PopupOverlay.windows.cs | 3 +++
9 files changed, 27 insertions(+)
diff --git a/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.shared.cs b/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.shared.cs
index 73eee85143..52ef719e8a 100644
--- a/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.shared.cs
+++ b/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.shared.cs
@@ -3,6 +3,9 @@ namespace CommunityToolkit.Maui.Core.Handlers;
///
/// Handler Popup control
///
+#if NET10_0_OR_GREATER
+#error Remove PopupHandler
+#endif
[Obsolete($"{nameof(PopupHandler)} is no longer used by {nameof(CommunityToolkit)}.{nameof(Maui)} and will be removed in .NET 10")]
public partial class PopupHandler
{
diff --git a/src/CommunityToolkit.Maui.Core/Interfaces/IPopup.shared.cs b/src/CommunityToolkit.Maui.Core/Interfaces/IPopup.shared.cs
index bc048dc5ff..94552c27ec 100644
--- a/src/CommunityToolkit.Maui.Core/Interfaces/IPopup.shared.cs
+++ b/src/CommunityToolkit.Maui.Core/Interfaces/IPopup.shared.cs
@@ -6,6 +6,9 @@ namespace CommunityToolkit.Maui.Core;
///
/// Represents a small View that pops up at front the Page.
///
+#if NET10_0_OR_GREATER
+#error Remove IPopup
+#endif
[Obsolete($"{nameof(IPopup)} is no longer used by {nameof(CommunityToolkit)}.{nameof(Maui)} and will be removed in .NET 10")]
public interface IPopup : IElement, IVisualTreeElement, IAsynchronousHandler
{
diff --git a/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.android.cs b/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.android.cs
index 36515ba057..bc7466a867 100644
--- a/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.android.cs
+++ b/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.android.cs
@@ -9,6 +9,9 @@ namespace CommunityToolkit.Maui.Core.Views;
///
/// The native implementation of Popup control.
///
+#if NET10_0_OR_GREATER
+#error Remove MauiPopup
+#endif
[Obsolete($"{nameof(MauiPopup)} is no longer used by {nameof(CommunityToolkit)}.{nameof(Maui)} and will be removed in .NET 10")]
public class MauiPopup : Dialog, IDialogInterfaceOnCancelListener
{
diff --git a/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.macios.cs b/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.macios.cs
index e0842fd4ca..f8e3717bdf 100644
--- a/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.macios.cs
+++ b/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.macios.cs
@@ -13,6 +13,9 @@ namespace CommunityToolkit.Maui.Core.Views;
///
/// An instance of .
/// If is null an exception will be thrown.
+#if NET10_0_OR_GREATER
+#error Remove MauiPopup
+#endif
[Obsolete($"{nameof(MauiPopup)} is no longer used by {nameof(CommunityToolkit)}.{nameof(Maui)} and will be removed in .NET 10")]
public class MauiPopup(IMauiContext mauiContext) : UIViewController
{
diff --git a/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs b/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs
index 8c157130eb..3a390597ed 100644
--- a/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs
+++ b/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs
@@ -10,6 +10,9 @@ namespace CommunityToolkit.Maui.Core.Views;
///
/// The native implementation of Popup control.
///
+#if NET10_0_OR_GREATER
+#error Remove MauiPopup
+#endif
[Obsolete($"{nameof(MauiPopup)} is no longer used by {nameof(CommunityToolkit)}.{nameof(Maui)} and will be removed in .NET 10")]
public class MauiPopup : Popup
{
diff --git a/src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.android.cs b/src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.android.cs
index f9d5f4d21f..562d854b00 100644
--- a/src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.android.cs
+++ b/src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.android.cs
@@ -14,6 +14,9 @@ namespace CommunityToolkit.Maui.Core.Views;
///
/// Extension class where Helper methods for Popup lives.
///
+#if NET10_0_OR_GREATER
+#error Remove MauiPopup
+#endif
[Obsolete($"{nameof(PopupExtensions)} is no longer used by {nameof(CommunityToolkit)}.{nameof(Maui)} and will be removed in .NET 10")]
public static class PopupExtensions
{
diff --git a/src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.macios.cs b/src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.macios.cs
index 9342c90fd4..016b05fb29 100644
--- a/src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.macios.cs
+++ b/src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.macios.cs
@@ -5,6 +5,9 @@ namespace CommunityToolkit.Maui.Core.Views;
///
/// Extension class where Helper methods for Popup lives.
///
+#if NET10_0_OR_GREATER
+#error Remove PopupExtensions
+#endif
[Obsolete($"{nameof(PopupExtensions)} is no longer used by {nameof(CommunityToolkit)}.{nameof(Maui)} and will be removed in .NET 10")]
public static class PopupExtensions
{
diff --git a/src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.windows.cs b/src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.windows.cs
index 6a910d143d..1f2b73e5b6 100644
--- a/src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.windows.cs
+++ b/src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.windows.cs
@@ -10,6 +10,9 @@ namespace CommunityToolkit.Maui.Core.Views;
///
/// Extension class where Helper methods for Popup lives.
///
+#if NET10_0_OR_GREATER
+#error Remove PopupExtensions
+#endif
[Obsolete($"{nameof(PopupExtensions)} is no longer used by {nameof(CommunityToolkit)}.{nameof(Maui)} and will be removed in .NET 10")]
public static class PopupExtensions
{
diff --git a/src/CommunityToolkit.Maui.Core/Views/Popup/PopupOverlay.windows.cs b/src/CommunityToolkit.Maui.Core/Views/Popup/PopupOverlay.windows.cs
index d6cb21b566..c7019535bd 100644
--- a/src/CommunityToolkit.Maui.Core/Views/Popup/PopupOverlay.windows.cs
+++ b/src/CommunityToolkit.Maui.Core/Views/Popup/PopupOverlay.windows.cs
@@ -3,6 +3,9 @@
///
/// Displays Overlay in the Popup background.
///
+#if NET10_0_OR_GREATER
+#error Remove PopupOverlay
+#endif
[Obsolete($"{nameof(PopupOverlay)} is no longer used by {nameof(CommunityToolkit)}.{nameof(Maui)} and will be removed in .NET 10")]
class PopupOverlay : WindowOverlay
{
From db98d1c6cba23e7479b968eb7cefda655500c594 Mon Sep 17 00:00:00 2001
From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com>
Date: Mon, 26 May 2025 12:26:39 -0700
Subject: [PATCH 07/10] Rename `Close()` -> `CloseAsync()`
---
.../Views/Popups/ButtonPopup.xaml.cs | 2 +-
.../Views/Popups/MultipleButtonPopup.xaml.cs | 4 ++--
.../Popups/NoOutsideTapDismissPopup.xaml.cs | 2 +-
.../Views/Popups/ReturnResultPopup.xaml.cs | 2 +-
.../Views/Popups/TransparentPopup.xaml.cs | 2 +-
.../Extensions/PopupExtensionsTests.cs | 12 +++++------
.../Services/PopupServiceTests.cs | 4 ++--
.../Views/Popup/PopupPageTests.cs | 18 ++++++++---------
.../Views/Popup/PopupTests.cs | 20 +++++++++----------
.../Extensions/PopupExtensions.shared.cs | 6 +++---
.../Services/PopupService.shared.cs | 4 ++--
.../Views/Popup/Popup.shared.cs | 10 +++++-----
.../Views/Popup/PopupPage.shared.cs | 8 ++++----
13 files changed, 47 insertions(+), 47 deletions(-)
diff --git a/samples/CommunityToolkit.Maui.Sample/Views/Popups/ButtonPopup.xaml.cs b/samples/CommunityToolkit.Maui.Sample/Views/Popups/ButtonPopup.xaml.cs
index 28972839ba..06840d20cc 100644
--- a/samples/CommunityToolkit.Maui.Sample/Views/Popups/ButtonPopup.xaml.cs
+++ b/samples/CommunityToolkit.Maui.Sample/Views/Popups/ButtonPopup.xaml.cs
@@ -9,6 +9,6 @@ public ButtonPopup()
void Button_Clicked(object? sender, EventArgs e)
{
- Close();
+ CloseAsync();
}
}
\ No newline at end of file
diff --git a/samples/CommunityToolkit.Maui.Sample/Views/Popups/MultipleButtonPopup.xaml.cs b/samples/CommunityToolkit.Maui.Sample/Views/Popups/MultipleButtonPopup.xaml.cs
index 1406b4da52..a671119f2b 100644
--- a/samples/CommunityToolkit.Maui.Sample/Views/Popups/MultipleButtonPopup.xaml.cs
+++ b/samples/CommunityToolkit.Maui.Sample/Views/Popups/MultipleButtonPopup.xaml.cs
@@ -9,11 +9,11 @@ public MultipleButtonPopup()
async void Cancel_Clicked(object? sender, EventArgs e)
{
- await Close(false);
+ await CloseAsync(false);
}
async void Okay_Clicked(object? sender, EventArgs e)
{
- await Close(true);
+ await CloseAsync(true);
}
}
\ No newline at end of file
diff --git a/samples/CommunityToolkit.Maui.Sample/Views/Popups/NoOutsideTapDismissPopup.xaml.cs b/samples/CommunityToolkit.Maui.Sample/Views/Popups/NoOutsideTapDismissPopup.xaml.cs
index 10bc6a2a3b..2949a1d246 100644
--- a/samples/CommunityToolkit.Maui.Sample/Views/Popups/NoOutsideTapDismissPopup.xaml.cs
+++ b/samples/CommunityToolkit.Maui.Sample/Views/Popups/NoOutsideTapDismissPopup.xaml.cs
@@ -11,7 +11,7 @@ public NoOutsideTapDismissPopup()
async void Button_Clicked(object? sender, EventArgs e)
{
- await Close();
+ await CloseAsync();
await Toast.Make("Popup Dismissed By Button").Show();
}
}
\ No newline at end of file
diff --git a/samples/CommunityToolkit.Maui.Sample/Views/Popups/ReturnResultPopup.xaml.cs b/samples/CommunityToolkit.Maui.Sample/Views/Popups/ReturnResultPopup.xaml.cs
index 166aa1f746..a2699efcc8 100644
--- a/samples/CommunityToolkit.Maui.Sample/Views/Popups/ReturnResultPopup.xaml.cs
+++ b/samples/CommunityToolkit.Maui.Sample/Views/Popups/ReturnResultPopup.xaml.cs
@@ -9,6 +9,6 @@ public ReturnResultPopup()
async void Button_Clicked(object? sender, EventArgs e)
{
- await Close("Close button tapped");
+ await CloseAsync("Close button tapped");
}
}
\ No newline at end of file
diff --git a/samples/CommunityToolkit.Maui.Sample/Views/Popups/TransparentPopup.xaml.cs b/samples/CommunityToolkit.Maui.Sample/Views/Popups/TransparentPopup.xaml.cs
index aa325fd9a7..cfca5f7043 100644
--- a/samples/CommunityToolkit.Maui.Sample/Views/Popups/TransparentPopup.xaml.cs
+++ b/samples/CommunityToolkit.Maui.Sample/Views/Popups/TransparentPopup.xaml.cs
@@ -6,6 +6,6 @@ public partial class TransparentPopup : Maui.Views.Popup
void CloseButtonClicked(object? sender, EventArgs args)
{
- Close();
+ CloseAsync();
}
}
\ No newline at end of file
diff --git a/src/CommunityToolkit.Maui.UnitTests/Extensions/PopupExtensionsTests.cs b/src/CommunityToolkit.Maui.UnitTests/Extensions/PopupExtensionsTests.cs
index 66e85dd084..9a99a292f9 100644
--- a/src/CommunityToolkit.Maui.UnitTests/Extensions/PopupExtensionsTests.cs
+++ b/src/CommunityToolkit.Maui.UnitTests/Extensions/PopupExtensionsTests.cs
@@ -858,7 +858,7 @@ public async Task ShowPopupAsyncWithView_ShouldValidateProperBindingContext()
var popupPage = (PopupPage)navigation.ModalStack[0];
- await popupPage.Close(new PopupResult