From dda44fd0ba8e089ee3c174b8f1cdf9dd45a7d917 Mon Sep 17 00:00:00 2001 From: Chris Pulman Date: Sun, 31 Dec 2023 16:44:22 +0000 Subject: [PATCH 1/2] Housekeeping Update usings, update namespaces --- .../Common/AutoDataTemplateBindingHook.cs | 3 --- .../Common/BooleanToVisibilityTypeConverter.cs | 4 ++++ src/ReactiveUI.Maui/Common/ReactivePage.cs | 4 ++++ src/ReactiveUI.Maui/Common/ReactiveUserControl.cs | 7 ++++--- src/ReactiveUI.Maui/Common/ViewModelViewHost.cs | 14 +------------- src/ReactiveUI.Maui/Registrations.cs | 5 +---- .../WinUI/DependencyObjectObservableForProperty.cs | 8 ++------ .../WinUI/DispatcherQueueScheduler.cs | 3 ++- src/ReactiveUI/Mixins/DependencyResolverMixins.cs | 9 +++------ 9 files changed, 21 insertions(+), 36 deletions(-) diff --git a/src/ReactiveUI.Maui/Common/AutoDataTemplateBindingHook.cs b/src/ReactiveUI.Maui/Common/AutoDataTemplateBindingHook.cs index a2d38afe89..ec4d0c90f9 100644 --- a/src/ReactiveUI.Maui/Common/AutoDataTemplateBindingHook.cs +++ b/src/ReactiveUI.Maui/Common/AutoDataTemplateBindingHook.cs @@ -4,9 +4,6 @@ // See the LICENSE file in the project root for full license information. #if WINUI_TARGET -using System; -using System.Diagnostics.CodeAnalysis; -using System.Linq; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; diff --git a/src/ReactiveUI.Maui/Common/BooleanToVisibilityTypeConverter.cs b/src/ReactiveUI.Maui/Common/BooleanToVisibilityTypeConverter.cs index 5a5d7a08b3..3065c3effc 100644 --- a/src/ReactiveUI.Maui/Common/BooleanToVisibilityTypeConverter.cs +++ b/src/ReactiveUI.Maui/Common/BooleanToVisibilityTypeConverter.cs @@ -9,7 +9,11 @@ using Microsoft.Maui; #endif +#if IS_MAUI +namespace ReactiveUI.Maui; +#else namespace ReactiveUI; +#endif /// /// This type convert converts between Boolean and XAML Visibility - the diff --git a/src/ReactiveUI.Maui/Common/ReactivePage.cs b/src/ReactiveUI.Maui/Common/ReactivePage.cs index c44c5affac..ec6259d626 100644 --- a/src/ReactiveUI.Maui/Common/ReactivePage.cs +++ b/src/ReactiveUI.Maui/Common/ReactivePage.cs @@ -10,7 +10,11 @@ using Microsoft.Maui.Controls; #endif +#if IS_MAUI +namespace ReactiveUI.Maui; +#else namespace ReactiveUI; +#endif /// /// A that is reactive. diff --git a/src/ReactiveUI.Maui/Common/ReactiveUserControl.cs b/src/ReactiveUI.Maui/Common/ReactiveUserControl.cs index 7a0886ad6f..ee7824a397 100644 --- a/src/ReactiveUI.Maui/Common/ReactiveUserControl.cs +++ b/src/ReactiveUI.Maui/Common/ReactiveUserControl.cs @@ -4,13 +4,14 @@ // See the LICENSE file in the project root for full license information. #if WINUI_TARGET -using System; -using System.Diagnostics.CodeAnalysis; - using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; +#if IS_MAUI +namespace ReactiveUI.Maui; +#else namespace ReactiveUI; +#endif /// /// A that is reactive. diff --git a/src/ReactiveUI.Maui/Common/ViewModelViewHost.cs b/src/ReactiveUI.Maui/Common/ViewModelViewHost.cs index c698cc05e3..feda467c44 100644 --- a/src/ReactiveUI.Maui/Common/ViewModelViewHost.cs +++ b/src/ReactiveUI.Maui/Common/ViewModelViewHost.cs @@ -3,17 +3,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -#if WINUI_TARGET -using System; -using System.Diagnostics.CodeAnalysis; -using System.Reactive; -using System.Reactive.Disposables; -using System.Reactive.Linq; - using Microsoft.UI.Xaml; -using Microsoft.UI.Xaml.Controls; - -using Splat; namespace ReactiveUI; @@ -22,8 +12,7 @@ namespace ReactiveUI; /// the ViewModel property and display it. This control is very useful /// inside a DataTemplate to display the View associated with a ViewModel. /// -public - class ViewModelViewHost : TransitioningContentControl, IViewFor, IEnableLogger +public class ViewModelViewHost : TransitioningContentControl, IViewFor, IEnableLogger { /// /// The default content dependency property. @@ -158,4 +147,3 @@ private void ResolveViewForViewModel(object? viewModel, string? contract) Content = viewInstance; } } -#endif diff --git a/src/ReactiveUI.Maui/Registrations.cs b/src/ReactiveUI.Maui/Registrations.cs index cd17239baa..b0ec829aed 100644 --- a/src/ReactiveUI.Maui/Registrations.cs +++ b/src/ReactiveUI.Maui/Registrations.cs @@ -24,10 +24,7 @@ public class Registrations : IWantsToRegisterStuff /// public void Register(Action, Type> registerFunction) { - if (registerFunction is null) - { - throw new ArgumentNullException(nameof(registerFunction)); - } + ArgumentNullException.ThrowIfNull(registerFunction); registerFunction(() => new ActivationForViewFetcher(), typeof(IActivationForViewFetcher)); registerFunction(() => new BooleanToVisibilityTypeConverter(), typeof(IBindingTypeConverter)); diff --git a/src/ReactiveUI.Maui/WinUI/DependencyObjectObservableForProperty.cs b/src/ReactiveUI.Maui/WinUI/DependencyObjectObservableForProperty.cs index 1c7a1c9ff8..0a29bc9d5c 100644 --- a/src/ReactiveUI.Maui/WinUI/DependencyObjectObservableForProperty.cs +++ b/src/ReactiveUI.Maui/WinUI/DependencyObjectObservableForProperty.cs @@ -4,17 +4,13 @@ // See the LICENSE file in the project root for full license information. #if WINUI_TARGET -using System; using System.Globalization; +#if IS_MAUI using System.Linq.Expressions; -using System.Reactive.Disposables; -using System.Reactive.Linq; +#endif using System.Reflection; - using Microsoft.UI.Xaml; -using Splat; - namespace ReactiveUI; /// diff --git a/src/ReactiveUI.Maui/WinUI/DispatcherQueueScheduler.cs b/src/ReactiveUI.Maui/WinUI/DispatcherQueueScheduler.cs index 317bb4898d..fbfaef3a56 100644 --- a/src/ReactiveUI.Maui/WinUI/DispatcherQueueScheduler.cs +++ b/src/ReactiveUI.Maui/WinUI/DispatcherQueueScheduler.cs @@ -4,8 +4,9 @@ // #if WINUI_TARGET -using System.Reactive.Disposables; +#if IS_MAUI using System.Threading; +#endif using Microsoft.UI.Dispatching; namespace System.Reactive.Concurrency; diff --git a/src/ReactiveUI/Mixins/DependencyResolverMixins.cs b/src/ReactiveUI/Mixins/DependencyResolverMixins.cs index 1d67500b3a..ed9240ea1e 100644 --- a/src/ReactiveUI/Mixins/DependencyResolverMixins.cs +++ b/src/ReactiveUI/Mixins/DependencyResolverMixins.cs @@ -125,12 +125,9 @@ private static void RegisterType(IMutableDependencyResolver resolver, TypeInfo t private static Func TypeFactory(TypeInfo typeInfo) { var parameterlessConstructor = typeInfo.DeclaredConstructors.FirstOrDefault(ci => ci.IsPublic && ci.GetParameters().Length == 0); - if (parameterlessConstructor is null) - { - throw new Exception($"Failed to register type {typeInfo.FullName} because it's missing a parameterless constructor."); - } - - return Expression.Lambda>(Expression.New(parameterlessConstructor)).Compile(); + return parameterlessConstructor is null + ? throw new Exception($"Failed to register type {typeInfo.FullName} because it's missing a parameterless constructor.") + : Expression.Lambda>(Expression.New(parameterlessConstructor)).Compile(); } private static void ProcessRegistrationForNamespace(string namespaceName, AssemblyName assemblyName, IMutableDependencyResolver resolver) From 59ed23b971420c1215e2096a61a58147d9bbc970 Mon Sep 17 00:00:00 2001 From: Chris Pulman Date: Sun, 31 Dec 2023 17:37:35 +0000 Subject: [PATCH 2/2] Update Packages, update API --- src/Directory.build.props | 12 +++++----- src/ReactiveUI.Maui/ReactiveUI.Maui.csproj | 2 ++ ...valTests.ReactiveUI.DotNet6_0.verified.txt | 2 +- ...valTests.ReactiveUI.DotNet7_0.verified.txt | 2 +- ...valTests.ReactiveUI.DotNet8_0.verified.txt | 2 +- ...provalTests.ReactiveUI.Net4_7.verified.txt | 23 +++++++------------ 6 files changed, 19 insertions(+), 24 deletions(-) diff --git a/src/Directory.build.props b/src/Directory.build.props index 8fe59bdc87..2a12596fb8 100644 --- a/src/Directory.build.props +++ b/src/Directory.build.props @@ -33,7 +33,7 @@ true true true - 2.6.1 + 2.6.4