Skip to content

Commit 2d7801e

Browse files
authored
Housekeeping - Update usings and namespaces (#3702)
<!-- Please be sure to read the [Contribute](https://github.com/reactiveui/reactiveui#contribute) section of the README --> **What kind of change does this PR introduce?** <!-- Bug fix, feature, docs update, ... --> Housekeeping **What is the current behavior?** <!-- You can also link to an open issue here. --> unused usings exist namespaces for maui using base ReactiveUI namespace **What is the new behavior?** <!-- If this is a feature change --> unused usings removed namespaces for ReactiveUI.Maui updated API packages updated and test amended as necessary - NO API actually changed, pure formatting update. **What might this PR break?** XAML includes using the ReactiveUI namespace will need to update to ReactiveUI.Maui to standardise across all controls. **Please check if the PR fulfills these requirements** - [ ] Tests for the changes have been added (for bug fixes / features) - [ ] Docs have been added / updated (for bug fixes / features) **Other information**: ---------
1 parent 845fb4d commit 2d7801e

14 files changed

+38
-60
lines changed

src/Directory.build.props

+6-6
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<EmbedUntrackedSources>true</EmbedUntrackedSources>
3434
<IncludePackageReferencesDuringMarkupCompilation>true</IncludePackageReferencesDuringMarkupCompilation>
3535
<PublishRepositoryUrl>true</PublishRepositoryUrl>
36-
<XunitVersion>2.6.1</XunitVersion>
36+
<XunitVersion>2.6.4</XunitVersion>
3737
</PropertyGroup>
3838
<!--<PropertyGroup Condition="$(IsTestProject) != 'true'">
3939
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@@ -52,13 +52,13 @@
5252
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
5353
<PackageReference Include="xunit" Version="$(XunitVersion)" />
5454
<PackageReference Include="xunit.runner.console" Version="$(XunitVersion)" />
55-
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
55+
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6" />
5656
<PackageReference Include="Xunit.StaFact" Version="1.1.11" />
5757
<PackageReference Include="FluentAssertions" Version="6.12.0" />
5858
<PackageReference Include="Microsoft.Reactive.Testing" Version="6.0.0" />
59-
<PackageReference Include="PublicApiGenerator" Version="11.0.0" />
59+
<PackageReference Include="PublicApiGenerator" Version="11.1.0" />
6060
<PackageReference Include="coverlet.msbuild" Version="6.0.0" PrivateAssets="All" />
61-
<PackageReference Include="Verify.Xunit" Version="22.5.0" />
61+
<PackageReference Include="Verify.Xunit" Version="22.11.1" />
6262
</ItemGroup>
6363

6464
<ItemGroup Condition="'$(IsTestProject)' != 'true'">
@@ -77,8 +77,8 @@
7777

7878
<ItemGroup>
7979
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.133" PrivateAssets="all" />
80-
<PackageReference Include="stylecop.analyzers" Version="1.2.0-beta.507" PrivateAssets="all" />
81-
<PackageReference Include="Roslynator.Analyzers" Version="4.6.2" PrivateAssets="All" />
80+
<PackageReference Include="stylecop.analyzers" Version="1.2.0-beta.556" PrivateAssets="all" />
81+
<PackageReference Include="Roslynator.Analyzers" Version="4.7.0" PrivateAssets="All" />
8282
</ItemGroup>
8383
<ItemGroup>
8484
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" />

src/ReactiveUI.Maui/Common/AutoDataTemplateBindingHook.cs

-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
// See the LICENSE file in the project root for full license information.
55

66
#if WINUI_TARGET
7-
using System;
8-
using System.Diagnostics.CodeAnalysis;
9-
using System.Linq;
107

118
using Microsoft.UI.Xaml;
129
using Microsoft.UI.Xaml.Controls;

src/ReactiveUI.Maui/Common/BooleanToVisibilityTypeConverter.cs

+4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
using Microsoft.Maui;
1010
#endif
1111

12+
#if IS_MAUI
13+
namespace ReactiveUI.Maui;
14+
#else
1215
namespace ReactiveUI;
16+
#endif
1317

1418
/// <summary>
1519
/// This type convert converts between Boolean and XAML Visibility - the

src/ReactiveUI.Maui/Common/ReactivePage.cs

+4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
using Microsoft.Maui.Controls;
1111
#endif
1212

13+
#if IS_MAUI
14+
namespace ReactiveUI.Maui;
15+
#else
1316
namespace ReactiveUI;
17+
#endif
1418

1519
/// <summary>
1620
/// A <see cref="Page"/> that is reactive.

src/ReactiveUI.Maui/Common/ReactiveUserControl.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
// See the LICENSE file in the project root for full license information.
55

66
#if WINUI_TARGET
7-
using System;
8-
using System.Diagnostics.CodeAnalysis;
9-
107
using Microsoft.UI.Xaml;
118
using Microsoft.UI.Xaml.Controls;
129

10+
#if IS_MAUI
11+
namespace ReactiveUI.Maui;
12+
#else
1313
namespace ReactiveUI;
14+
#endif
1415

1516
/// <summary>
1617
/// A <see cref="UserControl"/> that is reactive.

src/ReactiveUI.Maui/Common/ViewModelViewHost.cs

+1-13
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,7 @@
33
// The .NET Foundation licenses this file to you under the MIT license.
44
// See the LICENSE file in the project root for full license information.
55

6-
#if WINUI_TARGET
7-
using System;
8-
using System.Diagnostics.CodeAnalysis;
9-
using System.Reactive;
10-
using System.Reactive.Disposables;
11-
using System.Reactive.Linq;
12-
136
using Microsoft.UI.Xaml;
14-
using Microsoft.UI.Xaml.Controls;
15-
16-
using Splat;
177

188
namespace ReactiveUI;
199

@@ -22,8 +12,7 @@ namespace ReactiveUI;
2212
/// the ViewModel property and display it. This control is very useful
2313
/// inside a DataTemplate to display the View associated with a ViewModel.
2414
/// </summary>
25-
public
26-
class ViewModelViewHost : TransitioningContentControl, IViewFor, IEnableLogger
15+
public class ViewModelViewHost : TransitioningContentControl, IViewFor, IEnableLogger
2716
{
2817
/// <summary>
2918
/// The default content dependency property.
@@ -158,4 +147,3 @@ private void ResolveViewForViewModel(object? viewModel, string? contract)
158147
Content = viewInstance;
159148
}
160149
}
161-
#endif

src/ReactiveUI.Maui/Registrations.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ public class Registrations : IWantsToRegisterStuff
2424
/// <inheritdoc/>
2525
public void Register(Action<Func<object>, Type> registerFunction)
2626
{
27-
if (registerFunction is null)
28-
{
29-
throw new ArgumentNullException(nameof(registerFunction));
30-
}
27+
ArgumentNullException.ThrowIfNull(registerFunction);
3128

3229
registerFunction(() => new ActivationForViewFetcher(), typeof(IActivationForViewFetcher));
3330
registerFunction(() => new BooleanToVisibilityTypeConverter(), typeof(IBindingTypeConverter));

src/ReactiveUI.Maui/WinUI/DependencyObjectObservableForProperty.cs

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@
44
// See the LICENSE file in the project root for full license information.
55

66
#if WINUI_TARGET
7-
using System;
87
using System.Globalization;
8+
#if IS_MAUI
99
using System.Linq.Expressions;
10-
using System.Reactive.Disposables;
11-
using System.Reactive.Linq;
10+
#endif
1211
using System.Reflection;
13-
1412
using Microsoft.UI.Xaml;
1513

16-
using Splat;
17-
1814
namespace ReactiveUI;
1915

2016
/// <summary>

src/ReactiveUI.Maui/WinUI/DispatcherQueueScheduler.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
// <auto-generated />
55

66
#if WINUI_TARGET
7-
using System.Reactive.Disposables;
7+
#if IS_MAUI
88
using System.Threading;
9+
#endif
910
using Microsoft.UI.Dispatching;
1011

1112
namespace System.Reactive.Concurrency;

src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.DotNet6_0.verified.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1058,4 +1058,4 @@ namespace ReactiveUI
10581058
public static System.IObservable<TRet> WhenAnyObservable<TSender, TRet, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this TSender? sender, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T1>?>> obs1, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T2>?>> obs2, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T3>?>> obs3, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T4>?>> obs4, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T5>?>> obs5, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T6>?>> obs6, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T7>?>> obs7, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T8>?>> obs8, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T9>?>> obs9, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T10>?>> obs10, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T11>?>> obs11, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T12>?>> obs12, System.Func<T1?, T2?, T3?, T4?, T5?, T6?, T7?, T8?, T9?, T10?, T11?, T12?, TRet> selector)
10591059
where TSender : class { }
10601060
}
1061-
}
1061+
}

src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.DotNet7_0.verified.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1058,4 +1058,4 @@ namespace ReactiveUI
10581058
public static System.IObservable<TRet> WhenAnyObservable<TSender, TRet, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this TSender? sender, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T1>?>> obs1, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T2>?>> obs2, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T3>?>> obs3, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T4>?>> obs4, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T5>?>> obs5, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T6>?>> obs6, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T7>?>> obs7, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T8>?>> obs8, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T9>?>> obs9, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T10>?>> obs10, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T11>?>> obs11, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T12>?>> obs12, System.Func<T1?, T2?, T3?, T4?, T5?, T6?, T7?, T8?, T9?, T10?, T11?, T12?, TRet> selector)
10591059
where TSender : class { }
10601060
}
1061-
}
1061+
}

src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.DotNet8_0.verified.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1051,4 +1051,4 @@ namespace ReactiveUI
10511051
public static System.IObservable<TRet> WhenAnyObservable<TSender, TRet, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this TSender? sender, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T1>?>> obs1, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T2>?>> obs2, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T3>?>> obs3, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T4>?>> obs4, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T5>?>> obs5, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T6>?>> obs6, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T7>?>> obs7, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T8>?>> obs8, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T9>?>> obs9, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T10>?>> obs10, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T11>?>> obs11, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T12>?>> obs12, System.Func<T1?, T2?, T3?, T4?, T5?, T6?, T7?, T8?, T9?, T10?, T11?, T12?, TRet> selector)
10521052
where TSender : class { }
10531053
}
1054-
}
1054+
}

src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.Net4_7.verified.txt

+8-15
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,10 @@ namespace ReactiveUI
219219
{
220220
System.IDisposable BindInteraction<TViewModel, TView, TInput, TOutput>(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression<System.Func<TViewModel, ReactiveUI.IInteraction<TInput, TOutput>>> propertyName, System.Func<ReactiveUI.IInteractionContext<TInput, TOutput>, System.Threading.Tasks.Task> handler)
221221
where TViewModel : class
222-
where TView : class, ReactiveUI.IViewFor
223-
;
222+
where TView : class, ReactiveUI.IViewFor;
224223
System.IDisposable BindInteraction<TViewModel, TView, TInput, TOutput, TDontCare>(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression<System.Func<TViewModel, ReactiveUI.IInteraction<TInput, TOutput>>> propertyName, System.Func<ReactiveUI.IInteractionContext<TInput, TOutput>, System.IObservable<TDontCare>> handler)
225224
where TViewModel : class
226-
where TView : class, ReactiveUI.IViewFor
227-
;
225+
where TView : class, ReactiveUI.IViewFor;
228226
}
229227
public interface IInteractionContext<out TInput, in TOutput>
230228
{
@@ -275,26 +273,21 @@ namespace ReactiveUI
275273
"isViewModel"})]
276274
ReactiveUI.IReactiveBinding<TView, System.ValueTuple<object?, bool>> Bind<TViewModel, TView, TVMProp, TVProp, TDontCare>(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression<System.Func<TViewModel, TVMProp?>> vmProperty, System.Linq.Expressions.Expression<System.Func<TView, TVProp>> viewProperty, System.IObservable<TDontCare>? signalViewUpdate, System.Func<TVMProp?, TVProp> vmToViewConverter, System.Func<TVProp, TVMProp?> viewToVmConverter, ReactiveUI.TriggerUpdate triggerUpdate = 0)
277275
where TViewModel : class
278-
where TView : class, ReactiveUI.IViewFor
279-
;
276+
where TView : class, ReactiveUI.IViewFor;
280277
[return: System.Runtime.CompilerServices.TupleElementNames(new string?[]?[] {
281278
"view",
282279
"isViewModel"})]
283280
ReactiveUI.IReactiveBinding<TView, System.ValueTuple<object?, bool>> Bind<TViewModel, TView, TVMProp, TVProp, TDontCare>(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression<System.Func<TViewModel, TVMProp?>> vmProperty, System.Linq.Expressions.Expression<System.Func<TView, TVProp>> viewProperty, System.IObservable<TDontCare>? signalViewUpdate, object? conversionHint, ReactiveUI.IBindingTypeConverter? vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter? viewToVMConverterOverride = null, ReactiveUI.TriggerUpdate triggerUpdate = 0)
284281
where TViewModel : class
285-
where TView : class, ReactiveUI.IViewFor
286-
;
282+
where TView : class, ReactiveUI.IViewFor;
287283
System.IDisposable BindTo<TValue, TTarget, TTValue>(System.IObservable<TValue> observedChange, TTarget? target, System.Linq.Expressions.Expression<System.Func<TTarget, TTValue?>> propertyExpression, object? conversionHint, ReactiveUI.IBindingTypeConverter? vmToViewConverterOverride = null)
288-
where TTarget : class
289-
;
284+
where TTarget : class;
290285
ReactiveUI.IReactiveBinding<TView, TOut> OneWayBind<TViewModel, TView, TProp, TOut>(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp?>> vmProperty, System.Linq.Expressions.Expression<System.Func<TView, TOut>> viewProperty, System.Func<TProp, TOut> selector)
291286
where TViewModel : class
292-
where TView : class, ReactiveUI.IViewFor
293-
;
287+
where TView : class, ReactiveUI.IViewFor;
294288
ReactiveUI.IReactiveBinding<TView, TVProp> OneWayBind<TViewModel, TView, TVMProp, TVProp>(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression<System.Func<TViewModel, TVMProp?>> vmProperty, System.Linq.Expressions.Expression<System.Func<TView, TVProp>> viewProperty, object? conversionHint, ReactiveUI.IBindingTypeConverter? vmToViewConverterOverride = null)
295289
where TViewModel : class
296-
where TView : class, ReactiveUI.IViewFor
297-
;
290+
where TView : class, ReactiveUI.IViewFor;
298291
}
299292
public interface IPropertyBindingHook
300293
{
@@ -1063,4 +1056,4 @@ namespace ReactiveUI
10631056
public static System.IObservable<TRet> WhenAnyObservable<TSender, TRet, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this TSender? sender, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T1>?>> obs1, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T2>?>> obs2, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T3>?>> obs3, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T4>?>> obs4, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T5>?>> obs5, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T6>?>> obs6, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T7>?>> obs7, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T8>?>> obs8, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T9>?>> obs9, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T10>?>> obs10, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T11>?>> obs11, System.Linq.Expressions.Expression<System.Func<TSender, System.IObservable<T12>?>> obs12, System.Func<T1?, T2?, T3?, T4?, T5?, T6?, T7?, T8?, T9?, T10?, T11?, T12?, TRet> selector)
10641057
where TSender : class { }
10651058
}
1066-
}
1059+
}

src/ReactiveUI/Mixins/DependencyResolverMixins.cs

+3-6
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,9 @@ private static void RegisterType(IMutableDependencyResolver resolver, TypeInfo t
125125
private static Func<object> TypeFactory(TypeInfo typeInfo)
126126
{
127127
var parameterlessConstructor = typeInfo.DeclaredConstructors.FirstOrDefault(ci => ci.IsPublic && ci.GetParameters().Length == 0);
128-
if (parameterlessConstructor is null)
129-
{
130-
throw new Exception($"Failed to register type {typeInfo.FullName} because it's missing a parameterless constructor.");
131-
}
132-
133-
return Expression.Lambda<Func<object>>(Expression.New(parameterlessConstructor)).Compile();
128+
return parameterlessConstructor is null
129+
? throw new Exception($"Failed to register type {typeInfo.FullName} because it's missing a parameterless constructor.")
130+
: Expression.Lambda<Func<object>>(Expression.New(parameterlessConstructor)).Compile();
134131
}
135132

136133
private static void ProcessRegistrationForNamespace(string namespaceName, AssemblyName assemblyName, IMutableDependencyResolver resolver)

0 commit comments

Comments
 (0)