Skip to content

Commit

Permalink
Merge pull request #3086 from PrismLibrary/dev/ds/global-using
Browse files Browse the repository at this point in the history
Code Refactorings
  • Loading branch information
dansiegel authored Feb 25, 2024
2 parents 2338a75 + 190c613 commit efbd9f7
Show file tree
Hide file tree
Showing 52 changed files with 246 additions and 331 deletions.
117 changes: 110 additions & 7 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,55 +10,158 @@ 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

[*.{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
31 changes: 28 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,34 @@
<MSBuildSdkExtrasVersion>3.0.44</MSBuildSdkExtrasVersion>
</PropertyGroup>

<PropertyGroup Condition="$(IsUnoProject)">
<DefineConstants>$(DefineConstants);UNO_WINUI_PROJECT</DefineConstants>
</PropertyGroup>
<!--
-->
<Choose>
<When Condition="$(IsWpfProject)">
<PropertyGroup>
<DefineConstants>$(DefineConstants);WPF</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Using Include="System.Windows" />
<Using Include="System.Windows.Controls" />
<Using Include="System.Windows.Controls.Primitives" />
<Using Include="System.Windows.Data" />
</ItemGroup>
</When>
<When Condition="$(IsUnoProject)">
<PropertyGroup>
<DefineConstants>$(DefineConstants);UNO_WINUI</DefineConstants>
<DefineConstants Condition="!$(TargetFramework.Contains('-')) OR $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'browser'">$(DefineConstants);UNO_WASM</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Using Include="Microsoft.UI.Xaml" />
<Using Include="Microsoft.UI.Xaml.Controls" />
<Using Include="Microsoft.UI.Xaml.Controls.Primitives" />
<Using Include="Microsoft.UI.Xaml.Data" />
<Using Include="Microsoft.UI.Xaml.Media" />
</ItemGroup>
</When>
</Choose>

<!-- Versioning -->
<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Forms/Prism.Forms/Modularity/ModuleCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Prism.Modularity
/// application. Each module is described in a <see cref="ModuleInfo"/> class, that records the
/// name and type of the module.
/// </summary>
#if HAS_WINUI
#if UNO_WINUI
[Microsoft.UI.Xaml.Markup.ContentProperty(Name = nameof(Items))]
#else
[Xamarin.Forms.ContentProperty(nameof(Items))]
Expand Down
2 changes: 1 addition & 1 deletion src/Forms/Prism.Forms/Modularity/ModuleInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Prism.Modularity
/// <summary>
/// Defines the metadata that describes a module.
/// </summary>
#if HAS_WINUI
#if UNO_WINUI
[Microsoft.UI.Xaml.Markup.ContentProperty(Name = nameof(DependsOn))]
#else
[Xamarin.Forms.ContentProperty(nameof(DependsOn))]
Expand Down
20 changes: 12 additions & 8 deletions src/Maui/Prism.Maui/Dialogs/DialogService.cs
Original file line number Diff line number Diff line change
@@ -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;

/// <summary>
Expand All @@ -22,8 +23,10 @@ public sealed class DialogService : IDialogService
/// <exception cref="ArgumentNullException">Throws when any constructor arguments are null.</exception>
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;
}

/// <inheritdoc/>
Expand All @@ -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<IDialogViewRegistry>();
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<IDialogContainer>();
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Prism.Ioc;
/// </summary>
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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Prism.Common;
using Prism.Common;

namespace Prism.Navigation;

Expand All @@ -10,6 +10,7 @@ public static class INavigationServiceExtensions
/// <summary>
/// Navigates to the most recent entry in the back navigation history by popping the calling Page off the navigation stack.
/// </summary>
/// <param name="navigationService">Service for handling navigation between views</param>
/// <param name="name">The name of the View to navigate back to</param>
/// <returns><see cref="INavigationResult"/> indicating whether the request was successful or if there was an encountered <see cref="Exception"/>.</returns>
public static Task<INavigationResult> GoBackToAsync(this INavigationService navigationService, string name) =>
Expand Down Expand Up @@ -52,6 +53,7 @@ public static Task<INavigationResult> GoBackToRootAsync(this INavigationService
/// <summary>
/// Initiates navigation to the target specified by the <paramref name="uri"/>.
/// </summary>
/// <param name="navigationService">Service for handling navigation between views</param>
/// <param name="uri">The Uri to navigate to</param>
/// <example>
/// NavigateAsync(new Uri("MainPage?id=3&amp;name=brian", UriKind.RelativeSource));
Expand All @@ -78,13 +80,15 @@ public static Task<INavigationResult> NavigateAsync(this INavigationService navi
/// <summary>
/// Initiates navigation to the target specified by the <paramref name="name"/>.
/// </summary>
/// <param name="navigationService">Service for handling navigation between views</param>
/// <param name="name">The name of the target to navigate to.</param>
public static Task<INavigationResult> NavigateAsync(this INavigationService navigationService, string name) =>
navigationService.NavigateAsync(name, default(INavigationParameters));

/// <summary>
/// Initiates navigation to the target specified by the <paramref name="name"/>.
/// </summary>
/// <param name="navigationService">Service for handling navigation between views</param>
/// <param name="name">The name of the target to navigate to.</param>
/// <param name="parameters">The navigation parameters</param>
public static Task<INavigationResult> NavigateAsync(this INavigationService navigationService, string name, INavigationParameters parameters)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Specialized;
using System.Collections.Specialized;
using Prism.Common;

namespace Prism.Navigation.Regions.Behaviors;
Expand All @@ -11,7 +11,7 @@ namespace Prism.Navigation.Regions.Behaviors;
/// </summary>
/// <remarks>
/// This class can also sync the active state for any scoped regions directly on the view based on the <see cref="SyncActiveStateAttribute"/>.
/// If you use the <see cref="Regions.Region.Add(VisualElement,string,bool)" /> method with the createRegionManagerScope option, the scoped manager will be attached to the view.
/// If you use the <see cref="Regions.Region.Add(object,string,bool)" /> method with the createRegionManagerScope option, the scoped manager will be attached to the view.
/// </remarks>
public class RegionActiveAwareBehavior : IRegionBehavior
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using System.Runtime.Serialization;
using System.Runtime.Serialization;

namespace Prism.Navigation.Regions.Behaviors;

/// <summary>
/// Represents errors that occurred during region creation.
/// </summary>
[Serializable]
public partial class RegionCreationException : Exception
{
/// <summary>
Expand Down Expand Up @@ -35,14 +34,4 @@ public RegionCreationException(string message, Exception inner)
: base(message, inner)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="RegionCreationException"/> class with serialized data.
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
protected RegionCreationException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
Loading

0 comments on commit efbd9f7

Please sign in to comment.