diff --git a/.editorconfig b/.editorconfig
index 1d25ab7aa0..b947be645f 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -10,14 +10,22 @@ root = true
[*]
indent_style = space
-end_of_line = CRLF
+end_of_line = crlf
trim_trailing_whitespace = true
insert_final_newline = true
+charset = utf-8
##########################################
# File Extension Settings
##########################################
+[*.{yml,yaml}]
+indent_size = 2
+
+[.vsconfig]
+indent_size = 2
+end_of_line = lf
+
[*.sln]
indent_style = tab
indent_size = 2
@@ -25,40 +33,135 @@ indent_size = 2
[*.{csproj,proj,projitems,shproj}]
indent_size = 2
-[*.json]
+[*.{json,slnf}]
indent_size = 2
+end_of_line = lf
[*.{props,targets}]
indent_size = 2
-[*.targets]
+[*.xaml]
indent_size = 2
+charset = utf-8-bom
-[*.xaml]
+[*.xml]
indent_size = 2
+end_of_line = lf
[*.plist]
indent_size = 2
indent_style = tab
+end_of_line = lf
+
+[*.manifest]
+indent_size = 2
+
+[*.appxmanifest]
+indent_size = 2
+
+[*.{json,css,webmanifest}]
+indent_size = 2
+end_of_line = lf
+
+[web.config]
+indent_size = 2
+end_of_line = lf
[*.sh]
indent_size = 2
end_of_line = lf
[*.cs]
+# EOL should be normalized by Git. See https://github.com/dotnet/format/issues/1099
+end_of_line = unset
+
+# See https://github.com/dotnet/roslyn/issues/20356#issuecomment-310143926
+trim_trailing_whitespace = false
+
+tab_width = 4
indent_size = 4
# Sort using and Import directives with System.* appearing first
dotnet_sort_system_directives_first = true
+
# Avoid "this." and "Me." if not necessary
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion
-# Suggest more modern language features when available
-dotnet_style_object_initializer = true:suggestion
-dotnet_style_collection_initializer = true:suggestion
+#### Naming styles ####
+
+# Naming rules
+
+dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
+dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
+dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
+
+dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
+dotnet_naming_rule.types_should_be_pascal_case.symbols = types
+dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
+
+dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
+dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
+dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
+
+# Symbol specifications
+
+dotnet_naming_symbols.interface.applicable_kinds = interface
+dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
+dotnet_naming_symbols.interface.required_modifiers =
+
+dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
+dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
+dotnet_naming_symbols.types.required_modifiers =
+
+dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
+dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
+dotnet_naming_symbols.non_field_members.required_modifiers =
+
+# Naming styles
+
+dotnet_naming_style.begins_with_i.required_prefix = I
+dotnet_naming_style.begins_with_i.required_suffix =
+dotnet_naming_style.begins_with_i.word_separator =
+dotnet_naming_style.begins_with_i.capitalization = pascal_case
+
+dotnet_naming_style.pascal_case.required_prefix =
+dotnet_naming_style.pascal_case.required_suffix =
+dotnet_naming_style.pascal_case.word_separator =
+dotnet_naming_style.pascal_case.capitalization = pascal_case
+
+dotnet_naming_style.pascal_case.required_prefix =
+dotnet_naming_style.pascal_case.required_suffix =
+dotnet_naming_style.pascal_case.word_separator =
+dotnet_naming_style.pascal_case.capitalization = pascal_case
+dotnet_style_operator_placement_when_wrapping = beginning_of_line
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
+dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
+dotnet_style_prefer_auto_properties = true:silent
+dotnet_style_object_initializer = true:suggestion
+dotnet_style_collection_initializer = true:suggestion
+dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
+dotnet_style_prefer_conditional_expression_over_assignment = true:silent
+dotnet_style_prefer_conditional_expression_over_return = true:silent
dotnet_style_explicit_tuple_names = true:suggestion
+dotnet_style_prefer_inferred_tuple_names = true:suggestion
+
+csharp_indent_labels = one_less_than_current
+csharp_using_directive_placement = outside_namespace:silent
+csharp_prefer_simple_using_statement = true:suggestion
+csharp_prefer_braces = true:silent
+csharp_style_namespace_declarations = file_scoped:warning
+csharp_style_prefer_method_group_conversion = true:silent
+csharp_style_prefer_top_level_statements = true:silent
+csharp_style_prefer_primary_constructors = true:suggestion
+csharp_style_expression_bodied_methods = false:silent
+csharp_style_expression_bodied_constructors = false:silent
+csharp_style_expression_bodied_operators = false:silent
+csharp_style_expression_bodied_properties = true:silent
+csharp_style_expression_bodied_indexers = true:silent
+csharp_style_expression_bodied_accessors = true:silent
+csharp_style_expression_bodied_lambdas = true:silent
+csharp_style_expression_bodied_local_functions = false:silent
diff --git a/Directory.Build.props b/Directory.Build.props
index 1ee16833a4..43748d9883 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -54,9 +54,34 @@
3.0.44
-
- $(DefineConstants);UNO_WINUI_PROJECT
-
+
+
+
+
+ $(DefineConstants);WPF
+
+
+
+
+
+
+
+
+
+
+ $(DefineConstants);UNO_WINUI
+ $(DefineConstants);UNO_WASM
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Forms/Prism.Forms/Modularity/ModuleCatalog.cs b/src/Forms/Prism.Forms/Modularity/ModuleCatalog.cs
index 9fe37060dd..2822ae2d62 100644
--- a/src/Forms/Prism.Forms/Modularity/ModuleCatalog.cs
+++ b/src/Forms/Prism.Forms/Modularity/ModuleCatalog.cs
@@ -7,7 +7,7 @@ namespace Prism.Modularity
/// application. Each module is described in a class, that records the
/// name and type of the module.
///
-#if HAS_WINUI
+#if UNO_WINUI
[Microsoft.UI.Xaml.Markup.ContentProperty(Name = nameof(Items))]
#else
[Xamarin.Forms.ContentProperty(nameof(Items))]
diff --git a/src/Forms/Prism.Forms/Modularity/ModuleInfo.cs b/src/Forms/Prism.Forms/Modularity/ModuleInfo.cs
index 3a59795c65..ec68f434aa 100644
--- a/src/Forms/Prism.Forms/Modularity/ModuleInfo.cs
+++ b/src/Forms/Prism.Forms/Modularity/ModuleInfo.cs
@@ -9,7 +9,7 @@ namespace Prism.Modularity
///
/// Defines the metadata that describes a module.
///
-#if HAS_WINUI
+#if UNO_WINUI
[Microsoft.UI.Xaml.Markup.ContentProperty(Name = nameof(DependsOn))]
#else
[Xamarin.Forms.ContentProperty(nameof(DependsOn))]
diff --git a/src/Maui/Prism.Maui/Dialogs/DialogService.cs b/src/Maui/Prism.Maui/Dialogs/DialogService.cs
index 1d19984372..5034bb5007 100644
--- a/src/Maui/Prism.Maui/Dialogs/DialogService.cs
+++ b/src/Maui/Prism.Maui/Dialogs/DialogService.cs
@@ -1,9 +1,10 @@
using Prism.Commands;
using Prism.Common;
-using Prism.Ioc;
-using Prism.Navigation;
using Prism.Dialogs.Xaml;
+using Prism.Mvvm;
+using Prism.Navigation;
+#nullable enable
namespace Prism.Dialogs;
///
@@ -22,8 +23,10 @@ public sealed class DialogService : IDialogService
/// Throws when any constructor arguments are null.
public DialogService(IContainerProvider container, IPageAccessor pageAccessor)
{
- _container = container ?? throw new ArgumentNullException(nameof(container));
- _pageAccessor = pageAccessor ?? throw new ArgumentNullException(nameof(pageAccessor));
+ ArgumentNullException.ThrowIfNull(container);
+ ArgumentNullException.ThrowIfNull(pageAccessor);
+ _container = container;
+ _pageAccessor = pageAccessor;
}
///
@@ -37,7 +40,8 @@ public void ShowDialog(string name, IDialogParameters parameters, DialogCallback
// This needs to be resolved when called as a Module could load any time
// and register new dialogs
var registry = _container.Resolve();
- var view = registry.CreateView(_container, UriParsingHelper.GetSegmentName(name)) as View;
+ var view = registry.CreateView(_container, UriParsingHelper.GetSegmentName(name)) as View
+ ?? throw new ViewCreationException(name, ViewType.Dialog);
var currentPage = _pageAccessor.Page;
dialogModal = _container.Resolve();
@@ -76,12 +80,12 @@ async Task DialogAware_RequestClose(IDialogResult outResult)
if (dex.Message != DialogException.CanCloseIsFalse)
{
- await InvokeError(callback, dex, parameters);
+ await DialogService.InvokeError(callback, dex, parameters);
}
}
catch (Exception ex)
{
- await InvokeError(callback, ex, parameters);
+ await DialogService.InvokeError(callback, ex, parameters);
}
finally
{
@@ -120,7 +124,7 @@ async Task DialogAware_RequestClose(IDialogResult outResult)
}
}
- private async Task InvokeError(DialogCallback callback, Exception exception, IDialogParameters parameters)
+ private static async Task InvokeError(DialogCallback callback, Exception exception, IDialogParameters parameters)
{
var result = new DialogResult
{
diff --git a/src/Maui/Prism.Maui/Ioc/MicrosoftDependencyInjectionExtensions.cs b/src/Maui/Prism.Maui/Ioc/MicrosoftDependencyInjectionExtensions.cs
index 6b95e9a87b..7ea797a9bb 100644
--- a/src/Maui/Prism.Maui/Ioc/MicrosoftDependencyInjectionExtensions.cs
+++ b/src/Maui/Prism.Maui/Ioc/MicrosoftDependencyInjectionExtensions.cs
@@ -8,7 +8,7 @@ namespace Prism.Ioc;
///
public static class MicrosoftDependencyInjectionExtensions
{
-#if !UNO_WINUI_PROJECT
+#if !UNO_WINUI
private static readonly Type PageType = typeof(Page);
public static IServiceCollection RegisterForNavigation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView>(this IServiceCollection services, string name = null)
diff --git a/src/Maui/Prism.Maui/Navigation/INavigationServiceExtensions.cs b/src/Maui/Prism.Maui/Navigation/INavigationServiceExtensions.cs
index b38624fea9..89c472930f 100644
--- a/src/Maui/Prism.Maui/Navigation/INavigationServiceExtensions.cs
+++ b/src/Maui/Prism.Maui/Navigation/INavigationServiceExtensions.cs
@@ -1,4 +1,4 @@
-using Prism.Common;
+using Prism.Common;
namespace Prism.Navigation;
@@ -10,6 +10,7 @@ public static class INavigationServiceExtensions
///
/// Navigates to the most recent entry in the back navigation history by popping the calling Page off the navigation stack.
///
+ /// Service for handling navigation between views
/// The name of the View to navigate back to
/// indicating whether the request was successful or if there was an encountered .
public static Task GoBackToAsync(this INavigationService navigationService, string name) =>
@@ -52,6 +53,7 @@ public static Task GoBackToRootAsync(this INavigationService
///
/// Initiates navigation to the target specified by the .
///
+ /// Service for handling navigation between views
/// The Uri to navigate to
///
/// NavigateAsync(new Uri("MainPage?id=3&name=brian", UriKind.RelativeSource));
@@ -78,6 +80,7 @@ public static Task NavigateAsync(this INavigationService navi
///
/// Initiates navigation to the target specified by the .
///
+ /// Service for handling navigation between views
/// The name of the target to navigate to.
public static Task NavigateAsync(this INavigationService navigationService, string name) =>
navigationService.NavigateAsync(name, default(INavigationParameters));
@@ -85,6 +88,7 @@ public static Task NavigateAsync(this INavigationService navi
///
/// Initiates navigation to the target specified by the .
///
+ /// Service for handling navigation between views
/// The name of the target to navigate to.
/// The navigation parameters
public static Task NavigateAsync(this INavigationService navigationService, string name, INavigationParameters parameters)
diff --git a/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/RegionActiveAwareBehavior.cs b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/RegionActiveAwareBehavior.cs
index a61667e9b4..dd36ced1e2 100644
--- a/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/RegionActiveAwareBehavior.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/RegionActiveAwareBehavior.cs
@@ -1,4 +1,4 @@
-using System.Collections.Specialized;
+using System.Collections.Specialized;
using Prism.Common;
namespace Prism.Navigation.Regions.Behaviors;
@@ -11,7 +11,7 @@ namespace Prism.Navigation.Regions.Behaviors;
///
///
/// This class can also sync the active state for any scoped regions directly on the view based on the .
-/// If you use the method with the createRegionManagerScope option, the scoped manager will be attached to the view.
+/// If you use the method with the createRegionManagerScope option, the scoped manager will be attached to the view.
///
public class RegionActiveAwareBehavior : IRegionBehavior
{
diff --git a/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/RegionCreationException.cs b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/RegionCreationException.cs
index 54c0c3e0ee..240e957cdc 100644
--- a/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/RegionCreationException.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/RegionCreationException.cs
@@ -1,11 +1,10 @@
-using System.Runtime.Serialization;
+using System.Runtime.Serialization;
namespace Prism.Navigation.Regions.Behaviors;
///
/// Represents errors that occurred during region creation.
///
-[Serializable]
public partial class RegionCreationException : Exception
{
///
@@ -35,14 +34,4 @@ public RegionCreationException(string message, Exception inner)
: base(message, inner)
{
}
-
- ///
- /// Initializes a new instance of the class with serialized data.
- ///
- /// The that holds the serialized object data about the exception being thrown.
- /// The that contains contextual information about the source or destination.
- protected RegionCreationException(SerializationInfo info, StreamingContext context)
- : base(info, context)
- {
- }
}
diff --git a/src/Maui/Prism.Maui/Navigation/Regions/Navigation/RegionNavigationContentLoader.cs b/src/Maui/Prism.Maui/Navigation/Regions/Navigation/RegionNavigationContentLoader.cs
index 8940098965..c78063dce9 100644
--- a/src/Maui/Prism.Maui/Navigation/Regions/Navigation/RegionNavigationContentLoader.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Navigation/RegionNavigationContentLoader.cs
@@ -1,4 +1,4 @@
-using System.Globalization;
+using System.Globalization;
using Prism.Common;
using Prism.Ioc;
using Prism.Mvvm;
@@ -27,11 +27,8 @@ public class RegionNavigationContentLoader : IRegionNavigationContentLoader
/// when a new view cannot be created for the navigation request.
public object LoadContent(IRegion region, NavigationContext navigationContext)
{
- if (region == null)
- throw new ArgumentNullException(nameof(region));
-
- if (navigationContext == null)
- throw new ArgumentNullException(nameof(navigationContext));
+ ArgumentNullException.ThrowIfNull(region);
+ ArgumentNullException.ThrowIfNull(navigationContext);
string candidateTargetContract = GetContractFromNavigationContext(navigationContext);
@@ -58,6 +55,7 @@ public object LoadContent(IRegion region, NavigationContext navigationContext)
/// Provides a new item for the region based on the supplied candidate target contract name.
///
/// The target contract to build.
+ /// The to create the new Region Item in.
/// An instance of an item to put into the .
protected virtual object CreateNewRegionItem(string candidateTargetContract, IRegion region)
{
@@ -89,7 +87,7 @@ protected virtual object CreateNewRegionItem(string candidateTargetContract, IRe
/// The candidate contract to seek within the and to use, if not found, when resolving from the container.
protected virtual string GetContractFromNavigationContext(NavigationContext navigationContext)
{
- if (navigationContext == null) throw new ArgumentNullException(nameof(navigationContext));
+ ArgumentNullException.ThrowIfNull(navigationContext);
var candidateTargetContract = UriParsingHelper.EnsureAbsolute(navigationContext.Uri).AbsolutePath;
candidateTargetContract = candidateTargetContract.TrimStart('/');
@@ -104,17 +102,14 @@ protected virtual string GetContractFromNavigationContext(NavigationContext navi
/// An enumerable of candidate objects from the
protected virtual IEnumerable GetCandidatesFromRegion(IRegion region, string candidateNavigationContract)
{
- if (region is null)
- {
- throw new ArgumentNullException(nameof(region));
- }
+ ArgumentNullException.ThrowIfNull(region);
if (string.IsNullOrEmpty(candidateNavigationContract))
{
throw new ArgumentNullException(nameof(candidateNavigationContract));
}
- var contractCandidates = GetCandidatesFromRegionViews(region, candidateNavigationContract);
+ var contractCandidates = RegionNavigationContentLoader.GetCandidatesFromRegionViews(region, candidateNavigationContract);
if (!contractCandidates.Any())
{
@@ -122,16 +117,16 @@ protected virtual IEnumerable GetCandidatesFromRegion(IRegion reg
var registration = registry.Registrations.FirstOrDefault(x => x.Type == ViewType.Region && (x.Name == candidateNavigationContract || x.View.Name == candidateNavigationContract || x.View.FullName == candidateNavigationContract));
if (registration is null)
{
- GetCandidatesFromRegionViews(region, registration.View.FullName);
+ RegionNavigationContentLoader.GetCandidatesFromRegionViews(region, registration.View.FullName);
}
- return Array.Empty();
+ return [];
}
return contractCandidates;
}
- private IEnumerable GetCandidatesFromRegionViews(IRegion region, string candidateNavigationContract)
+ private static IEnumerable GetCandidatesFromRegionViews(IRegion region, string candidateNavigationContract)
{
return region.Views.OfType().Where(v => ViewIsMatch(v.GetType(), candidateNavigationContract));
}
diff --git a/src/Uno/Prism.DryIoc.Uno/Prism.DryIoc.Uno.WinUI.csproj b/src/Uno/Prism.DryIoc.Uno/Prism.DryIoc.Uno.WinUI.csproj
index c2103d4f2d..0500408e6a 100644
--- a/src/Uno/Prism.DryIoc.Uno/Prism.DryIoc.Uno.WinUI.csproj
+++ b/src/Uno/Prism.DryIoc.Uno/Prism.DryIoc.Uno.WinUI.csproj
@@ -5,7 +5,6 @@
$(NoWarn);1591
Prism.DryIoc.Uno
Prism.DryIoc.Uno.WinUI
- $(DefineConstants);HAS_WINUI
enable