diff --git a/Directory.Build.props b/Directory.Build.props
index 3a2a538285..15a18d5b96 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -17,6 +17,12 @@
$(MSBuildThisFileDirectory)images/prism-logo.png$(MSBuildThisFileDirectory)LICENSElatest
+
+ System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute;
+ System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes;
+ System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute;
+ System.Runtime.CompilerServices.IsExternalInit;
+
diff --git a/Directory.Build.targets b/Directory.Build.targets
index 7b11db7a98..436a97b645 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -12,4 +12,27 @@
$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb
+
+
+
+
+ $(IntermediateOutputPath)NotTrimmable.g.cs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Directory.Packages.props b/Directory.Packages.props
index f5a8bcc187..57cd264285 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -1,8 +1,9 @@
-
-
-
+
+
+
+
@@ -81,4 +82,4 @@
-
+
\ No newline at end of file
diff --git a/src/Forms/Prism.Forms/Modularity/IModuleCatalogExtensions.cs b/src/Forms/Prism.Forms/Modularity/IModuleCatalogExtensions.cs
index 38c424ea20..fe36faa2ce 100644
--- a/src/Forms/Prism.Forms/Modularity/IModuleCatalogExtensions.cs
+++ b/src/Forms/Prism.Forms/Modularity/IModuleCatalogExtensions.cs
@@ -1,6 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
+using System.Diagnostics.CodeAnalysis;
namespace Prism.Modularity
{
@@ -16,7 +14,7 @@ public static class IModuleCatalogExtensions
/// Catalog
///
/// The type parameter.
- public static IModuleCatalog AddModule(this IModuleCatalog catalog, InitializationMode mode = InitializationMode.WhenAvailable)
+ public static IModuleCatalog AddModule<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(this IModuleCatalog catalog, InitializationMode mode = InitializationMode.WhenAvailable)
where T : IModule =>
catalog.AddModule(typeof(T).Name, mode);
@@ -27,7 +25,7 @@ public static IModuleCatalog AddModule(this IModuleCatalog catalog, Initializ
/// Catalog.
/// Name.
/// The type parameter.
- public static IModuleCatalog AddModule(this IModuleCatalog catalog, string name)
+ public static IModuleCatalog AddModule<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(this IModuleCatalog catalog, string name)
where T : IModule =>
catalog.AddModule(name, InitializationMode.WhenAvailable);
@@ -39,7 +37,7 @@ public static IModuleCatalog AddModule(this IModuleCatalog catalog, string na
/// Name.
/// .
/// The type parameter.
- public static IModuleCatalog AddModule(this IModuleCatalog catalog, string name, InitializationMode mode)
+ public static IModuleCatalog AddModule<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(this IModuleCatalog catalog, string name, InitializationMode mode)
where T : IModule =>
catalog.AddModule(new ModuleInfo(typeof(T), name, mode));
@@ -50,7 +48,7 @@ public static IModuleCatalog AddModule(this IModuleCatalog catalog, string na
/// The to add the to.
/// The names of the 's that should be loaded when this is loaded.
/// The
- public static IModuleCatalog AddModule(this IModuleCatalog catalog, params string[] dependsOn)
+ public static IModuleCatalog AddModule<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(this IModuleCatalog catalog, params string[] dependsOn)
where T : IModule => catalog.AddModule(InitializationMode.WhenAvailable, dependsOn);
///
@@ -61,7 +59,7 @@ public static IModuleCatalog AddModule(this IModuleCatalog catalog, params st
/// The name of the
/// The names of the 's that should be loaded when this is loaded.
/// The
- public static IModuleCatalog AddModule(this IModuleCatalog catalog, string name, params string[] dependsOn)
+ public static IModuleCatalog AddModule<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(this IModuleCatalog catalog, string name, params string[] dependsOn)
where T : IModule =>
catalog.AddModule(name, InitializationMode.WhenAvailable, dependsOn);
@@ -73,7 +71,7 @@ public static IModuleCatalog AddModule(this IModuleCatalog catalog, string na
///
/// The names of the 's that should be loaded when this is loaded.
/// The
- public static IModuleCatalog AddModule(this IModuleCatalog catalog, InitializationMode mode, params string[] dependsOn)
+ public static IModuleCatalog AddModule<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(this IModuleCatalog catalog, InitializationMode mode, params string[] dependsOn)
where T : IModule =>
catalog.AddModule(typeof(T).Name, mode, dependsOn);
@@ -86,7 +84,7 @@ public static IModuleCatalog AddModule(this IModuleCatalog catalog, Initializ
/// The
/// The names of the 's that should be loaded when this is loaded.
/// The
- public static IModuleCatalog AddModule(this IModuleCatalog catalog, string name, InitializationMode mode, params string[] dependsOn)
+ public static IModuleCatalog AddModule<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(this IModuleCatalog catalog, string name, InitializationMode mode, params string[] dependsOn)
where T : IModule
{
var moduleInfo = new ModuleInfo(name, typeof(T).AssemblyQualifiedName, dependsOn)
diff --git a/src/Forms/Prism.Forms/Prism.Forms.csproj b/src/Forms/Prism.Forms/Prism.Forms.csproj
index 3ae7ab68f7..4c2a119b81 100644
--- a/src/Forms/Prism.Forms/Prism.Forms.csproj
+++ b/src/Forms/Prism.Forms/Prism.Forms.csproj
@@ -15,6 +15,10 @@ Prism for Xamarin.Forms helps you more easily design and build rich, flexible, a
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/src/Forms/Prism.Forms/PrismApplicationBase.cs b/src/Forms/Prism.Forms/PrismApplicationBase.cs
index 3af9466821..b17b8d71c6 100644
--- a/src/Forms/Prism.Forms/PrismApplicationBase.cs
+++ b/src/Forms/Prism.Forms/PrismApplicationBase.cs
@@ -102,7 +102,7 @@ protected virtual void ConfigureViewModelLocator()
{
ViewModelLocationProvider.SetDefaultViewModelFactory((view, type) =>
{
- List<(Type Type, object Instance)> overrides = new List<(Type, object)>();
+ List<(Type Type, object Instance)> overrides = [];
if (Container.IsRegistered())
{
var resolver = Container.Resolve();
@@ -148,8 +148,6 @@ protected virtual void Initialize()
PlatformInitializer?.RegisterTypes(_containerExtension);
RegisterTypes(_containerExtension);
- _containerExtension.FinalizeExtension();
-
_moduleCatalog = Container.Resolve();
ConfigureModuleCatalog(_moduleCatalog);
}
diff --git a/src/Maui/Prism.Maui/Ioc/BehaviorFactoryRegistrationExtensions.cs b/src/Maui/Prism.Maui/Ioc/BehaviorFactoryRegistrationExtensions.cs
index 4827e91821..f2e93c490f 100644
--- a/src/Maui/Prism.Maui/Ioc/BehaviorFactoryRegistrationExtensions.cs
+++ b/src/Maui/Prism.Maui/Ioc/BehaviorFactoryRegistrationExtensions.cs
@@ -1,4 +1,5 @@
-using Prism.Behaviors;
+using System.Diagnostics.CodeAnalysis;
+using Prism.Behaviors;
namespace Prism.Ioc;
@@ -31,7 +32,7 @@ public static IContainerRegistry RegisterPageBehaviorFactory(this IContainerRegi
///
///
///
- public static IContainerRegistry RegisterPageBehavior(this IContainerRegistry container)
+ public static IContainerRegistry RegisterPageBehavior<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TBehavior>(this IContainerRegistry container)
where TBehavior : Behavior =>
container
.Register()
@@ -44,7 +45,7 @@ public static IContainerRegistry RegisterPageBehavior(this IContainer
/// The type of Behavior
///
///
- public static IContainerRegistry RegisterPageBehavior(this IContainerRegistry container)
+ public static IContainerRegistry RegisterPageBehavior(this IContainerRegistry container)
where TPage : Page
where TBehavior : Behavior =>
container
@@ -81,7 +82,7 @@ public static IServiceCollection RegisterPageBehaviorFactory(this IServiceCollec
/// The type.
/// The .
/// The .
- public static IServiceCollection RegisterPageBehavior(this IServiceCollection services)
+ public static IServiceCollection RegisterPageBehavior<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TBehavior>(this IServiceCollection services)
where TBehavior : Behavior =>
services
.AddTransient()
@@ -94,7 +95,7 @@ public static IServiceCollection RegisterPageBehavior(this IServiceCo
/// The type.
/// The .
/// The .
- public static IServiceCollection RegisterPageBehavior(this IServiceCollection services)
+ public static IServiceCollection RegisterPageBehavior(this IServiceCollection services)
where TPage : Page
where TBehavior : Behavior =>
services
diff --git a/src/Maui/Prism.Maui/Ioc/DialogRegistrationExtensions.cs b/src/Maui/Prism.Maui/Ioc/DialogRegistrationExtensions.cs
index a8f1c23593..cb5735b0fc 100644
--- a/src/Maui/Prism.Maui/Ioc/DialogRegistrationExtensions.cs
+++ b/src/Maui/Prism.Maui/Ioc/DialogRegistrationExtensions.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Prism.Dialogs;
using Prism.Mvvm;
@@ -5,11 +6,11 @@ namespace Prism.Ioc;
public static class DialogRegistrationExtensions
{
- public static IContainerRegistry RegisterDialog(this IContainerRegistry containerRegistry, string name = null)
+ public static IContainerRegistry RegisterDialog<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView>(this IContainerRegistry containerRegistry, string name = null)
where TView : View =>
containerRegistry.RegisterDialog(typeof(TView), null, name);
- public static IContainerRegistry RegisterDialog(this IContainerRegistry containerRegistry, string name = null)
+ public static IContainerRegistry RegisterDialog<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TViewModel>(this IContainerRegistry containerRegistry, string name = null)
where TView : View =>
containerRegistry.RegisterDialog(typeof(TView), typeof(TViewModel), name);
@@ -23,15 +24,15 @@ public static IContainerRegistry RegisterDialog(this IContainerRegistry containe
return container;
}
- public static IContainerRegistry RegisterDialogContainer(this IContainerRegistry container)
+ public static IContainerRegistry RegisterDialogContainer<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(this IContainerRegistry container)
where T : class, IDialogContainer =>
container.Register();
- public static IServiceCollection RegisterDialog(this IServiceCollection services, string name = null)
+ public static IServiceCollection RegisterDialog<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView>(this IServiceCollection services, string name = null)
where TView : View =>
services.RegisterDialog(typeof(TView), null, name);
- public static IServiceCollection RegisterDialog(this IServiceCollection services, string name = null)
+ public static IServiceCollection RegisterDialog<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TViewModel>(this IServiceCollection services, string name = null)
where TView : View =>
services.RegisterDialog(typeof(TView), typeof(TViewModel), name);
@@ -45,14 +46,13 @@ public static IServiceCollection RegisterDialog(this IServiceCollection services
return services;
}
- public static IServiceCollection RegisterDialogContainer(this IServiceCollection services)
+ public static IServiceCollection RegisterDialogContainer<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(this IServiceCollection services)
where T : class, IDialogContainer =>
services.AddTransient();
private static ViewRegistration GetViewRegistration(Type view, Type viewModel, string name)
{
- if (view is null)
- throw new ArgumentNullException(nameof(view));
+ ArgumentNullException.ThrowIfNull(view);
if (!view.IsAssignableTo(typeof(View)))
throw new InvalidOperationException($"The Dialog '{view.FullName}' must inherit from Microsoft.Maui.Controls.View");
diff --git a/src/Maui/Prism.Maui/Ioc/MicrosoftDependencyInjectionExtensions.cs b/src/Maui/Prism.Maui/Ioc/MicrosoftDependencyInjectionExtensions.cs
index b714514cdf..6b95e9a87b 100644
--- a/src/Maui/Prism.Maui/Ioc/MicrosoftDependencyInjectionExtensions.cs
+++ b/src/Maui/Prism.Maui/Ioc/MicrosoftDependencyInjectionExtensions.cs
@@ -1,4 +1,5 @@
-using Prism.Mvvm;
+using System.Diagnostics.CodeAnalysis;
+using Prism.Mvvm;
namespace Prism.Ioc;
@@ -10,11 +11,11 @@ public static class MicrosoftDependencyInjectionExtensions
#if !UNO_WINUI_PROJECT
private static readonly Type PageType = typeof(Page);
- public static IServiceCollection RegisterForNavigation(this IServiceCollection services, string name = null)
+ public static IServiceCollection RegisterForNavigation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView>(this IServiceCollection services, string name = null)
where TView : Page =>
services.RegisterForNavigation(typeof(TView), null, name);
- public static IServiceCollection RegisterForNavigation(this IServiceCollection services, string name = null)
+ public static IServiceCollection RegisterForNavigation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TViewModel>(this IServiceCollection services, string name = null)
where TView : Page =>
services.RegisterForNavigation(typeof(TView), typeof(TViewModel), name);
diff --git a/src/Maui/Prism.Maui/Ioc/NavigationRegistrationExtensions.cs b/src/Maui/Prism.Maui/Ioc/NavigationRegistrationExtensions.cs
index 688c886ed6..d56f82f51d 100644
--- a/src/Maui/Prism.Maui/Ioc/NavigationRegistrationExtensions.cs
+++ b/src/Maui/Prism.Maui/Ioc/NavigationRegistrationExtensions.cs
@@ -1,14 +1,15 @@
-using Prism.Mvvm;
+using System.Diagnostics.CodeAnalysis;
+using Prism.Mvvm;
namespace Prism.Ioc;
public static class NavigationRegistrationExtensions
{
- public static IContainerRegistry RegisterForNavigation(this IContainerRegistry container, string name = null)
+ public static IContainerRegistry RegisterForNavigation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView>(this IContainerRegistry container, string name = null)
where TView : Page =>
container.RegisterForNavigation(typeof(TView), null, name);
- public static IContainerRegistry RegisterForNavigation(this IContainerRegistry container, string name = null)
+ public static IContainerRegistry RegisterForNavigation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TViewModel>(this IContainerRegistry container, string name = null)
where TView : Page =>
container.RegisterForNavigation(typeof(TView), typeof(TViewModel), name);
diff --git a/src/Maui/Prism.Maui/Ioc/RegionNavigationRegistrationExtensions.cs b/src/Maui/Prism.Maui/Ioc/RegionNavigationRegistrationExtensions.cs
index 3850b841e1..7c412c0547 100644
--- a/src/Maui/Prism.Maui/Ioc/RegionNavigationRegistrationExtensions.cs
+++ b/src/Maui/Prism.Maui/Ioc/RegionNavigationRegistrationExtensions.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Microsoft.Maui.Controls.Compatibility;
using Prism.Mvvm;
using Prism.Navigation.Regions;
@@ -18,7 +19,7 @@ public static class RegionNavigationRegistrationExtensions
/// The Type of to register
/// used to register type for Navigation.
/// The unique name to register with the View
- public static IContainerRegistry RegisterForRegionNavigation(this IContainerRegistry containerRegistry, string name = null)
+ public static IContainerRegistry RegisterForRegionNavigation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView>(this IContainerRegistry containerRegistry, string name = null)
where TView : View =>
containerRegistry.RegisterForNavigationWithViewModel(typeof(TView), null, name);
@@ -29,7 +30,7 @@ public static IContainerRegistry RegisterForRegionNavigation(this IContai
/// The ViewModel to use as the BindingContext for the View
/// The unique name to register with the View
///
- public static IContainerRegistry RegisterForRegionNavigation(this IContainerRegistry containerRegistry, string name = null)
+ public static IContainerRegistry RegisterForRegionNavigation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TViewModel>(this IContainerRegistry containerRegistry, string name = null)
where TView : View
where TViewModel : class =>
containerRegistry.RegisterForNavigationWithViewModel(typeof(TView), typeof(TViewModel), name);
@@ -60,7 +61,7 @@ private static IContainerRegistry RegisterForNavigationWithViewModel(this IConta
/// The Type of to register
/// used to register type for Navigation.
/// The unique name to register with the View
- public static IServiceCollection RegisterForRegionNavigation(this IServiceCollection services, string name = null)
+ public static IServiceCollection RegisterForRegionNavigation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView>(this IServiceCollection services, string name = null)
where TView : View =>
services.RegisterForNavigationWithViewModel(typeof(TView), null, name);
@@ -71,7 +72,7 @@ public static IServiceCollection RegisterForRegionNavigation(this IServic
/// The ViewModel to use as the BindingContext for the View
/// The unique name to register with the View
///
- public static IServiceCollection RegisterForRegionNavigation(this IServiceCollection services, string name = null)
+ public static IServiceCollection RegisterForRegionNavigation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TViewModel>(this IServiceCollection services, string name = null)
where TView : View
where TViewModel : class =>
services.RegisterForNavigationWithViewModel(typeof(TView), typeof(TViewModel), name);
diff --git a/src/Maui/Prism.Maui/Modularity/IModuleCatalogExtensions.cs b/src/Maui/Prism.Maui/Modularity/IModuleCatalogExtensions.cs
index f624f9ba81..3aedbde350 100644
--- a/src/Maui/Prism.Maui/Modularity/IModuleCatalogExtensions.cs
+++ b/src/Maui/Prism.Maui/Modularity/IModuleCatalogExtensions.cs
@@ -1,4 +1,6 @@
-namespace Prism.Modularity;
+using System.Diagnostics.CodeAnalysis;
+
+namespace Prism.Modularity;
///
/// extensions.
@@ -12,7 +14,7 @@ public static class IModuleCatalogExtensions
/// Catalog
///
/// The type parameter.
- public static IModuleCatalog AddModule(this IModuleCatalog catalog, InitializationMode mode = InitializationMode.WhenAvailable)
+ public static IModuleCatalog AddModule<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(this IModuleCatalog catalog, InitializationMode mode = InitializationMode.WhenAvailable)
where T : IModule =>
catalog.AddModule(typeof(T).Name, mode);
@@ -23,7 +25,7 @@ public static IModuleCatalog AddModule(this IModuleCatalog catalog, Initializ
/// Catalog.
/// Name.
/// The type parameter.
- public static IModuleCatalog AddModule(this IModuleCatalog catalog, string name)
+ public static IModuleCatalog AddModule<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(this IModuleCatalog catalog, string name)
where T : IModule =>
catalog.AddModule(name, InitializationMode.WhenAvailable);
@@ -35,7 +37,7 @@ public static IModuleCatalog AddModule(this IModuleCatalog catalog, string na
/// Name.
/// .
/// The type parameter.
- public static IModuleCatalog AddModule(this IModuleCatalog catalog, string name, InitializationMode mode)
+ public static IModuleCatalog AddModule<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(this IModuleCatalog catalog, string name, InitializationMode mode)
where T : IModule =>
catalog.AddModule(new ModuleInfo(typeof(T), name, mode));
@@ -46,7 +48,7 @@ public static IModuleCatalog AddModule(this IModuleCatalog catalog, string na
/// The to add the to.
/// The names of the 's that should be loaded when this is loaded.
/// The
- public static IModuleCatalog AddModule(this IModuleCatalog catalog, params string[] dependsOn)
+ public static IModuleCatalog AddModule<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(this IModuleCatalog catalog, params string[] dependsOn)
where T : IModule => catalog.AddModule(InitializationMode.WhenAvailable, dependsOn);
///
@@ -57,7 +59,7 @@ public static IModuleCatalog AddModule(this IModuleCatalog catalog, params st
/// The name of the
/// The names of the 's that should be loaded when this is loaded.
/// The
- public static IModuleCatalog AddModule(this IModuleCatalog catalog, string name, params string[] dependsOn)
+ public static IModuleCatalog AddModule<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(this IModuleCatalog catalog, string name, params string[] dependsOn)
where T : IModule =>
catalog.AddModule(name, InitializationMode.WhenAvailable, dependsOn);
@@ -69,7 +71,7 @@ public static IModuleCatalog AddModule(this IModuleCatalog catalog, string na
///
/// The names of the 's that should be loaded when this is loaded.
/// The
- public static IModuleCatalog AddModule(this IModuleCatalog catalog, InitializationMode mode, params string[] dependsOn)
+ public static IModuleCatalog AddModule<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(this IModuleCatalog catalog, InitializationMode mode, params string[] dependsOn)
where T : IModule =>
catalog.AddModule(typeof(T).Name, mode, dependsOn);
@@ -82,7 +84,7 @@ public static IModuleCatalog AddModule(this IModuleCatalog catalog, Initializ
/// The
/// The names of the 's that should be loaded when this is loaded.
/// The
- public static IModuleCatalog AddModule(this IModuleCatalog catalog, string name, InitializationMode mode, params string[] dependsOn)
+ public static IModuleCatalog AddModule<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(this IModuleCatalog catalog, string name, InitializationMode mode, params string[] dependsOn)
where T : IModule
{
var moduleInfo = new ModuleInfo(name, typeof(T).AssemblyQualifiedName, dependsOn)
diff --git a/src/Maui/Prism.Maui/Navigation/Regions/Adapters/RegionAdapterMappings.cs b/src/Maui/Prism.Maui/Navigation/Regions/Adapters/RegionAdapterMappings.cs
index 41e1953e73..30c9a12b46 100644
--- a/src/Maui/Prism.Maui/Navigation/Regions/Adapters/RegionAdapterMappings.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Adapters/RegionAdapterMappings.cs
@@ -1,5 +1,5 @@
-using System.Globalization;
-using Prism.Ioc;
+using System.Diagnostics.CodeAnalysis;
+using System.Globalization;
using Prism.Properties;
namespace Prism.Navigation.Regions.Adapters;
@@ -9,7 +9,7 @@ namespace Prism.Navigation.Regions.Adapters;
///
public class RegionAdapterMappings
{
- private readonly Dictionary mappings = new Dictionary();
+ private readonly Dictionary mappings = [];
///
/// Registers the mapping between a type and an adapter.
@@ -17,7 +17,7 @@ public class RegionAdapterMappings
/// The type of the control
/// The type of the IRegionAdapter to use with the TControl
/// Throws when a mapping has already been defined for a specified control type.
- public void RegisterMapping() where TAdapter : IRegionAdapter
+ public void RegisterMapping() where TAdapter : IRegionAdapter
{
var controlType = typeof(TControl);
@@ -35,7 +35,7 @@ public void RegisterMapping() where TAdapter : IRegionAdapte
///
/// The type of the control
/// The type of the IRegionAdapter to use with the TControl
- public void RegisterOrReplaceMapping() where TAdapter : IRegionAdapter
+ public void RegisterOrReplaceMapping() where TAdapter : IRegionAdapter
{
var controlType = typeof(TControl);
var adapter = ContainerLocator.Container.Resolve();
@@ -46,7 +46,7 @@ public void RegisterOrReplaceMapping() where TAdapter : IReg
mappings.Add(controlType, adapter);
}
- internal void RegisterDefaultMapping() where TAdapter : IRegionAdapter
+ internal void RegisterDefaultMapping() where TAdapter : IRegionAdapter
{
var controlType = typeof(TControl);
@@ -74,9 +74,9 @@ public IRegionAdapter GetMapping(Type controlType)
while (currentType != null)
{
- if (mappings.ContainsKey(currentType))
+ if (mappings.TryGetValue(currentType, out IRegionAdapter value))
{
- return mappings[currentType];
+ return value;
}
currentType = currentType.BaseType;
}
diff --git a/src/Maui/Prism.Maui/PrismAppBuilder.cs b/src/Maui/Prism.Maui/PrismAppBuilder.cs
index 7a2143e6d8..ccf6eab6f6 100644
--- a/src/Maui/Prism.Maui/PrismAppBuilder.cs
+++ b/src/Maui/Prism.Maui/PrismAppBuilder.cs
@@ -27,12 +27,12 @@ public sealed class PrismAppBuilder
internal PrismAppBuilder(IContainerExtension containerExtension, MauiAppBuilder builder)
{
- if (containerExtension is null)
- throw new ArgumentNullException(nameof(containerExtension));
+ ArgumentNullException.ThrowIfNull(containerExtension);
+ ArgumentNullException.ThrowIfNull(builder);
_container = containerExtension;
- _registrations = new List>();
- _initializations = new List>();
+ _registrations = [];
+ _initializations = [];
ViewModelCreationException.SetViewNameDelegate(view =>
{
@@ -89,7 +89,7 @@ internal PrismAppBuilder(IContainerExtension containerExtension, MauiAppBuilder
///
public MauiAppBuilder MauiBuilder { get; }
- private void ConfigureViewModelLocator()
+ private static void ConfigureViewModelLocator()
{
ViewModelLocationProvider.SetDefaultViewToViewModelTypeResolver(view =>
{
diff --git a/src/Prism.Core/Mvvm/ViewModelLocationProvider.cs b/src/Prism.Core/Mvvm/ViewModelLocationProvider.cs
index 2dec25efca..8e3fd5c994 100644
--- a/src/Prism.Core/Mvvm/ViewModelLocationProvider.cs
+++ b/src/Prism.Core/Mvvm/ViewModelLocationProvider.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
+using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Reflection;
@@ -194,7 +195,7 @@ public static void Register(string viewTypeName, Func
/// The View
/// The ViewModel
- public static void Register()
+ public static void Register<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] VM>()
{
var viewType = typeof(T);
var viewModelType = typeof(VM);
diff --git a/src/Prism.Core/Prism.Core.csproj b/src/Prism.Core/Prism.Core.csproj
index 7a49528da9..16b36f91c6 100644
--- a/src/Prism.Core/Prism.Core.csproj
+++ b/src/Prism.Core/Prism.Core.csproj
@@ -12,6 +12,10 @@
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/src/Prism.Core/Properties/IsExternalInit.cs b/src/Prism.Core/Properties/IsExternalInit.cs
deleted file mode 100644
index 3f552b2f19..0000000000
--- a/src/Prism.Core/Properties/IsExternalInit.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Linq;
-
-#if NETSTANDARD || NET461_OR_GREATER
-namespace System.Runtime.CompilerServices;
-
-internal static class IsExternalInit
-{
-}
-#endif
diff --git a/src/Uno/Prism.Uno/PrismApplicationBase.cs b/src/Uno/Prism.Uno/PrismApplicationBase.cs
old mode 100755
new mode 100644
index 71dba9e1a7..74b2e47eef
--- a/src/Uno/Prism.Uno/PrismApplicationBase.cs
+++ b/src/Uno/Prism.Uno/PrismApplicationBase.cs
@@ -126,7 +126,6 @@ protected virtual void Initialize(IApplicationBuilder builder)
_containerExtension.RegisterInstance(builder.Window);
RegisterRequiredTypes(_containerExtension);
RegisterTypes(_containerExtension);
- _containerExtension.FinalizeExtension();
ConfigureModuleCatalog(Container.Resolve());
diff --git a/src/Wpf/Prism.Wpf/Ioc/IContainerRegistryExtensions.cs b/src/Wpf/Prism.Wpf/Ioc/IContainerRegistryExtensions.cs
index 47746cf81d..0ab09e2a1f 100644
--- a/src/Wpf/Prism.Wpf/Ioc/IContainerRegistryExtensions.cs
+++ b/src/Wpf/Prism.Wpf/Ioc/IContainerRegistryExtensions.cs
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics.CodeAnalysis;
using Prism.Mvvm;
namespace Prism.Ioc
@@ -14,7 +15,7 @@ public static class IContainerRegistryExtensions
/// The Type of object to register as the dialog
///
/// The unique name to register with the dialog.
- public static void RegisterDialog(this IContainerRegistry containerRegistry, string name = null)
+ public static void RegisterDialog<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView>(this IContainerRegistry containerRegistry, string name = null)
{
containerRegistry.RegisterForNavigation(name);
}
@@ -26,7 +27,7 @@ public static void RegisterDialog(this IContainerRegistry containerRegist
/// The ViewModel to use as the DataContext for the dialog
///
/// The unique name to register with the dialog.
- public static void RegisterDialog(this IContainerRegistry containerRegistry, string name = null) where TViewModel : Dialogs.IDialogAware
+ public static void RegisterDialog<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TViewModel>(this IContainerRegistry containerRegistry, string name = null) where TViewModel : Dialogs.IDialogAware
{
containerRegistry.RegisterForNavigation(name);
}
@@ -36,7 +37,7 @@ public static void RegisterDialog(this IContainerRegistry con
///
/// The Type of the Window class that will be used to host dialogs in the IDialogService
///
- public static void RegisterDialogWindow(this IContainerRegistry containerRegistry) where TWindow : Dialogs.IDialogWindow
+ public static void RegisterDialogWindow<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TWindow>(this IContainerRegistry containerRegistry) where TWindow : Dialogs.IDialogWindow
{
containerRegistry.Register(typeof(Dialogs.IDialogWindow), typeof(TWindow));
}
@@ -47,7 +48,7 @@ public static void RegisterDialogWindow(this IContainerRegistry contain
/// The Type of the Window class that will be used to host dialogs in the IDialogService
///
/// The name of the dialog window
- public static void RegisterDialogWindow(this IContainerRegistry containerRegistry, string name) where TWindow : Dialogs.IDialogWindow
+ public static void RegisterDialogWindow<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TWindow>(this IContainerRegistry containerRegistry, string name) where TWindow : Dialogs.IDialogWindow
{
containerRegistry.Register(typeof(Dialogs.IDialogWindow), typeof(TWindow), name);
}
@@ -69,7 +70,7 @@ public static void RegisterForNavigation(this IContainerRegistry containerRegist
/// The Type of the object to register as the view
///
/// The unique name to register with the object.
- public static void RegisterForNavigation(this IContainerRegistry containerRegistry, string name = null)
+ public static void RegisterForNavigation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(this IContainerRegistry containerRegistry, string name = null)
{
Type type = typeof(T);
string viewName = string.IsNullOrWhiteSpace(name) ? type.Name : name;
@@ -83,12 +84,12 @@ public static void RegisterForNavigation(this IContainerRegistry containerReg
/// The ViewModel to use as the DataContext for the view
///
/// The unique name to register with the view
- public static void RegisterForNavigation(this IContainerRegistry containerRegistry, string name = null)
+ public static void RegisterForNavigation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TViewModel>(this IContainerRegistry containerRegistry, string name = null)
{
containerRegistry.RegisterForNavigationWithViewModel(typeof(TView), name);
}
- private static void RegisterForNavigationWithViewModel(this IContainerRegistry containerRegistry, Type viewType, string name)
+ private static void RegisterForNavigationWithViewModel<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TViewModel>(this IContainerRegistry containerRegistry, Type viewType, string name)
{
if (string.IsNullOrWhiteSpace(name))
name = viewType.Name;
diff --git a/src/Wpf/Prism.Wpf/Navigation/Regions/RegionAdapterMappings.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/RegionAdapterMappings.cs
index d42f48fb29..9419a7a823 100644
--- a/src/Wpf/Prism.Wpf/Navigation/Regions/RegionAdapterMappings.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/RegionAdapterMappings.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using Prism.Ioc;
using Prism.Properties;
@@ -49,7 +50,7 @@ public void RegisterMapping(IRegionAdapter adapter)
///
/// The type of the control
/// The type of the IRegionAdapter to use with the TControl
- public void RegisterMapping() where TAdapter : IRegionAdapter
+ public void RegisterMapping() where TAdapter : IRegionAdapter
{
RegisterMapping(typeof(TControl), ContainerLocator.Container.Resolve());
}
diff --git a/src/Wpf/Prism.Wpf/Prism.Wpf.csproj b/src/Wpf/Prism.Wpf/Prism.Wpf.csproj
index 895c29a940..6f3d679b9c 100644
--- a/src/Wpf/Prism.Wpf/Prism.Wpf.csproj
+++ b/src/Wpf/Prism.Wpf/Prism.Wpf.csproj
@@ -30,6 +30,10 @@ Prism.Wpf helps you more easily design and build rich, flexible, and easy to mai
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/src/Wpf/Prism.Wpf/PrismApplicationBase.cs b/src/Wpf/Prism.Wpf/PrismApplicationBase.cs
index ce6a615f24..86954c2772 100644
--- a/src/Wpf/Prism.Wpf/PrismApplicationBase.cs
+++ b/src/Wpf/Prism.Wpf/PrismApplicationBase.cs
@@ -61,7 +61,6 @@ protected virtual void Initialize()
_moduleCatalog = CreateModuleCatalog();
RegisterRequiredTypes(_containerExtension);
RegisterTypes(_containerExtension);
- _containerExtension.FinalizeExtension();
ConfigureModuleCatalog(_moduleCatalog);
diff --git a/src/Wpf/Prism.Wpf/PrismBootstrapperBase.cs b/src/Wpf/Prism.Wpf/PrismBootstrapperBase.cs
index e1d9cc386d..5cb14eaef0 100644
--- a/src/Wpf/Prism.Wpf/PrismBootstrapperBase.cs
+++ b/src/Wpf/Prism.Wpf/PrismBootstrapperBase.cs
@@ -58,7 +58,6 @@ protected virtual void Initialize()
_moduleCatalog = CreateModuleCatalog();
RegisterRequiredTypes(_containerExtension);
RegisterTypes(_containerExtension);
- _containerExtension.FinalizeExtension();
ConfigureModuleCatalog(_moduleCatalog);
diff --git a/tests/Wpf/Prism.Container.Wpf.Shared/Fixtures/Ioc/ContainerProviderExtensionFixture.cs b/tests/Wpf/Prism.Container.Wpf.Shared/Fixtures/Ioc/ContainerProviderExtensionFixture.cs
index 57a35cb5ab..720c5a6197 100644
--- a/tests/Wpf/Prism.Container.Wpf.Shared/Fixtures/Ioc/ContainerProviderExtensionFixture.cs
+++ b/tests/Wpf/Prism.Container.Wpf.Shared/Fixtures/Ioc/ContainerProviderExtensionFixture.cs
@@ -36,7 +36,6 @@ static ContainerProviderExtensionFixture()
{
_containerExtension.RegisterInstance(kvp.Value, kvp.Key);
}
- _containerExtension.FinalizeExtension();
}
public ContainerProviderExtensionFixture()