Skip to content

Commit 98c6848

Browse files
authored
Restrict AddPopup extensions to View to avoid ContentPage from being allowed (#2715)
1 parent e12a572 commit 98c6848

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/CommunityToolkit.Maui/Extensions/ServiceCollectionExtensions.shared.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ public static class ServiceCollectionExtensions
1717
/// Adds a <see cref="View"/> of the type specified in <typeparamref name="TPopupView"/>
1818
/// <see cref="IServiceCollection"/> with <see cref="ServiceLifetime.Transient"/> lifetime.
1919
/// </summary>
20-
/// <typeparam name="TPopupView">The type of the Popup to add. Constrained to <see cref="IView"/></typeparam>
20+
/// <typeparam name="TPopupView">The type of the Popup to add. Constrained to <see cref="View"/></typeparam>
2121
/// <param name="services">The <see cref="IServiceCollection"/> to add the service to.</param>
2222
/// <returns>A reference to this instance after the operation has completed.</returns>
2323
public static IServiceCollection AddTransientPopup<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TPopupView>(this IServiceCollection services)
24-
where TPopupView : IView
24+
where TPopupView : View
2525
{
2626
PopupService.AddPopup<TPopupView>(services, ServiceLifetime.Transient);
2727

@@ -33,13 +33,13 @@ public static class ServiceCollectionExtensions
3333
/// of the type specified in <typeparamref name="TPopupViewModel"/> to the specified
3434
/// <see cref="IServiceCollection"/> with <see cref="ServiceLifetime.Transient"/> lifetime.
3535
/// </summary>
36-
/// <typeparam name="TPopupView">The type of the Popup to add. Constrained to <see cref="IView"/></typeparam>
36+
/// <typeparam name="TPopupView">The type of the Popup to add. Constrained to <see cref="View"/></typeparam>
3737
/// <typeparam name="TPopupViewModel">The type of the ViewModel to add. Constrained to
3838
/// <see cref="INotifyPropertyChanged"/></typeparam>
3939
/// <param name="services">The <see cref="IServiceCollection"/> to add the service to.</param>
4040
/// <returns>A reference to this instance after the operation has completed.</returns>
4141
public static IServiceCollection AddTransientPopup<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TPopupView, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TPopupViewModel>(this IServiceCollection services)
42-
where TPopupView : IView
42+
where TPopupView : View
4343
where TPopupViewModel : notnull
4444
{
4545
PopupService.AddPopup<TPopupView, TPopupViewModel>(services, ServiceLifetime.Transient);
@@ -51,11 +51,11 @@ public static class ServiceCollectionExtensions
5151
/// Adds a <see cref="View"/> of the type specified in <typeparamref name="TPopupView"/> and a ViewModel
5252
/// <see cref="IServiceCollection"/> with <see cref="ServiceLifetime.Transient"/> lifetime.
5353
/// </summary>
54-
/// <typeparam name="TPopupView">The type of the Popup to add. Constrained to <see cref="IView"/></typeparam>
54+
/// <typeparam name="TPopupView">The type of the Popup to add. Constrained to <see cref="View"/></typeparam>
5555
/// <param name="services">The <see cref="IServiceCollection"/> to add the service to.</param>
5656
/// <returns>A reference to this instance after the operation has completed.</returns>
5757
public static IServiceCollection AddSingletonPopup<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TPopupView>(this IServiceCollection services)
58-
where TPopupView : IView
58+
where TPopupView : View
5959
{
6060
PopupService.AddPopup<TPopupView>(services, ServiceLifetime.Singleton);
6161

@@ -67,13 +67,13 @@ public static class ServiceCollectionExtensions
6767
/// of the type specified in <typeparamref name="TPopupViewModel"/> to the specified
6868
/// <see cref="IServiceCollection"/> with <see cref="ServiceLifetime.Transient"/> lifetime.
6969
/// </summary>
70-
/// <typeparam name="TPopupView">The type of the Popup to add. Constrained to <see cref="IView"/></typeparam>
70+
/// <typeparam name="TPopupView">The type of the Popup to add. Constrained to <see cref="View"/></typeparam>
7171
/// <typeparam name="TPopupViewModel">The type of the ViewModel to add. Constrained to
7272
/// <see cref="INotifyPropertyChanged"/></typeparam>
7373
/// <param name="services">The <see cref="IServiceCollection"/> to add the service to.</param>
7474
/// <returns>A reference to this instance after the operation has completed.</returns>
7575
public static IServiceCollection AddSingletonPopup<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TPopupView, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TPopupViewModel>(this IServiceCollection services)
76-
where TPopupView : IView
76+
where TPopupView : View
7777
where TPopupViewModel : notnull
7878
{
7979
PopupService.AddPopup<TPopupView, TPopupViewModel>(services, ServiceLifetime.Singleton);
@@ -85,11 +85,11 @@ public static class ServiceCollectionExtensions
8585
/// Adds a <see cref="View"/> of the type specified in <typeparamref name="TPopupView"/> and a ViewModel
8686
/// <see cref="IServiceCollection"/> with <see cref="ServiceLifetime.Transient"/> lifetime.
8787
/// </summary>
88-
/// <typeparam name="TPopupView">The type of the Popup to add. Constrained to <see cref="IView"/></typeparam>
88+
/// <typeparam name="TPopupView">The type of the Popup to add. Constrained to <see cref="View"/></typeparam>
8989
/// <param name="services">The <see cref="IServiceCollection"/> to add the service to.</param>
9090
/// <returns>A reference to this instance after the operation has completed.</returns>
9191
public static IServiceCollection AddScopedPopup<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TPopupView>(this IServiceCollection services)
92-
where TPopupView : IView
92+
where TPopupView : View
9393
{
9494
PopupService.AddPopup<TPopupView>(services, ServiceLifetime.Scoped);
9595

@@ -101,13 +101,13 @@ public static class ServiceCollectionExtensions
101101
/// of the type specified in <typeparamref name="TPopupViewModel"/> to the specified
102102
/// <see cref="IServiceCollection"/> with <see cref="ServiceLifetime.Transient"/> lifetime.
103103
/// </summary>
104-
/// <typeparam name="TPopupView">The type of the Popup to add. Constrained to <see cref="IView"/></typeparam>
104+
/// <typeparam name="TPopupView">The type of the Popup to add. Constrained to <see cref="View"/></typeparam>
105105
/// <typeparam name="TPopupViewModel">The type of the ViewModel to add. Constrained to
106106
/// <see cref="INotifyPropertyChanged"/></typeparam>
107107
/// <param name="services">The <see cref="IServiceCollection"/> to add the service to.</param>
108108
/// <returns>A reference to this instance after the operation has completed.</returns>
109109
public static IServiceCollection AddScopedPopup<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TPopupView, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TPopupViewModel>(this IServiceCollection services)
110-
where TPopupView : IView
110+
where TPopupView : View
111111
where TPopupViewModel : notnull
112112
{
113113
PopupService.AddPopup<TPopupView, TPopupViewModel>(services, ServiceLifetime.Scoped);

0 commit comments

Comments
 (0)