diff --git a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net472.approved.txt b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net472.approved.txt index 9f4af14a9e..cbc697588b 100644 --- a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net472.approved.txt +++ b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net472.approved.txt @@ -433,7 +433,7 @@ namespace ReactiveUI } public static class ObservableFuncMixins { - public static System.IObservable ToObservable(this TSource? source, System.Linq.Expressions.Expression> expression, bool beforeChange = false, bool skipInitial = false) { } + public static System.IObservable ToObservable(this System.Linq.Expressions.Expression> expression, TSource? source, bool beforeChange = false, bool skipInitial = false) { } } public static class ObservableLoggingMixin { diff --git a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net5.0.approved.txt b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net5.0.approved.txt index f0f88b0dab..36937c3b6d 100644 --- a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net5.0.approved.txt +++ b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net5.0.approved.txt @@ -428,7 +428,7 @@ namespace ReactiveUI } public static class ObservableFuncMixins { - public static System.IObservable ToObservable(this TSource? source, System.Linq.Expressions.Expression> expression, bool beforeChange = false, bool skipInitial = false) { } + public static System.IObservable ToObservable(this System.Linq.Expressions.Expression> expression, TSource? source, bool beforeChange = false, bool skipInitial = false) { } } public static class ObservableLoggingMixin { diff --git a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.netcoreapp3.1.approved.txt b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.netcoreapp3.1.approved.txt index 7a858719b5..92e650d726 100644 --- a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.netcoreapp3.1.approved.txt +++ b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.netcoreapp3.1.approved.txt @@ -426,7 +426,7 @@ namespace ReactiveUI } public static class ObservableFuncMixins { - public static System.IObservable ToObservable(this TSource? source, System.Linq.Expressions.Expression> expression, bool beforeChange = false, bool skipInitial = false) { } + public static System.IObservable ToObservable(this System.Linq.Expressions.Expression> expression, TSource? source, bool beforeChange = false, bool skipInitial = false) { } } public static class ObservableLoggingMixin { diff --git a/src/ReactiveUI.Tests/Mocks/PropertyBindViewModel.cs b/src/ReactiveUI.Tests/Mocks/PropertyBindViewModel.cs index e887d52aa8..4e4bf42d4c 100644 --- a/src/ReactiveUI.Tests/Mocks/PropertyBindViewModel.cs +++ b/src/ReactiveUI.Tests/Mocks/PropertyBindViewModel.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows; using DynamicData.Binding; namespace ReactiveUI.Tests @@ -18,14 +19,15 @@ namespace ReactiveUI.Tests /// public class PropertyBindViewModel : ReactiveObject { - private string? _Property1; - private PropertyBindModel? _Model; - private int _Property2; - private double _JustADouble; - private decimal _JustADecimal; - private double? _NullableDouble; - private int _JustAInt32; - private bool _JustABoolean; + private string? _property1; + private PropertyBindModel? _model; + private int _property2; + private double _justADouble; + private decimal _justADecimal; + private double? _nullableDouble; + private int _justAInt32; + private bool _justABoolean; + private Visibility _justAVisibility; /// /// Initializes a new instance of the class. @@ -42,8 +44,8 @@ public PropertyBindViewModel(PropertyBindModel? model = null) /// public string? Property1 { - get => _Property1; - set => this.RaiseAndSetIfChanged(ref _Property1, value); + get => _property1; + set => this.RaiseAndSetIfChanged(ref _property1, value); } /// @@ -51,8 +53,8 @@ public string? Property1 /// public int Property2 { - get => _Property2; - set => this.RaiseAndSetIfChanged(ref _Property2, value); + get => _property2; + set => this.RaiseAndSetIfChanged(ref _property2, value); } /// @@ -60,8 +62,8 @@ public int Property2 /// public double JustADouble { - get => _JustADouble; - set => this.RaiseAndSetIfChanged(ref _JustADouble, value); + get => _justADouble; + set => this.RaiseAndSetIfChanged(ref _justADouble, value); } /// @@ -72,8 +74,8 @@ public double JustADouble /// public bool JustABoolean { - get => _JustABoolean; - set => this.RaiseAndSetIfChanged(ref _JustABoolean, value); + get => _justABoolean; + set => this.RaiseAndSetIfChanged(ref _justABoolean, value); } /// @@ -81,8 +83,8 @@ public bool JustABoolean /// public decimal JustADecimal { - get => _JustADecimal; - set => this.RaiseAndSetIfChanged(ref _JustADecimal, value); + get => _justADecimal; + set => this.RaiseAndSetIfChanged(ref _justADecimal, value); } /// @@ -90,8 +92,8 @@ public decimal JustADecimal /// public int JustAInt32 { - get => _JustAInt32; - set => this.RaiseAndSetIfChanged(ref _JustAInt32, value); + get => _justAInt32; + set => this.RaiseAndSetIfChanged(ref _justAInt32, value); } /// @@ -99,8 +101,14 @@ public int JustAInt32 /// public double? NullableDouble { - get => _NullableDouble; - set => this.RaiseAndSetIfChanged(ref _NullableDouble, value); + get => _nullableDouble; + set => this.RaiseAndSetIfChanged(ref _nullableDouble, value); + } + + public Visibility JustAVisibility + { + get => _justAVisibility; + set => this.RaiseAndSetIfChanged(ref _justAVisibility, value); } /// @@ -116,8 +124,8 @@ public double? NullableDouble /// public PropertyBindModel? Model { - get => _Model; - set => this.RaiseAndSetIfChanged(ref _Model, value); + get => _model; + set => this.RaiseAndSetIfChanged(ref _model, value); } } } diff --git a/src/ReactiveUI.Tests/Platforms/windows-xaml/PropertyBindingTest.cs b/src/ReactiveUI.Tests/Platforms/windows-xaml/PropertyBindingTest.cs index 3b28e4a8be..32a2edcc9f 100644 --- a/src/ReactiveUI.Tests/Platforms/windows-xaml/PropertyBindingTest.cs +++ b/src/ReactiveUI.Tests/Platforms/windows-xaml/PropertyBindingTest.cs @@ -8,6 +8,9 @@ using System.Globalization; using System.Linq; using System.Reactive; +using System.Reactive.Disposables; +using System.Reactive.Linq; +using System.Reactive.Subjects; using DynamicData.Binding; using Xunit; @@ -37,7 +40,7 @@ public void TwoWayBindWithFuncConvertersSmokeTest() vm.JustADecimal = 123.45m; Assert.NotEqual(vm.JustADecimal.ToString(CultureInfo.InvariantCulture), view.SomeTextBox.Text); - var disp = fixture.Bind(vm, view, x => x.JustADecimal, x => x.SomeTextBox.Text, (IObservable?)null, d => d.ToString(), decimal.Parse); + var disp = fixture.Bind(vm, view, x => x.JustADecimal, x => x.SomeTextBox.Text, (IObservable?)null, d => d.ToString(), t => decimal.TryParse(t, out var res) ? res : decimal.Zero); Assert.Equal(vm.JustADecimal.ToString(CultureInfo.InvariantCulture), view.SomeTextBox.Text); Assert.Equal(123.45m, vm.JustADecimal); @@ -551,7 +554,21 @@ public void BindWithFuncShouldWorkAsExtensionMethodSmokeTest() PropertyBindViewModel? vm = new(); var view = new PropertyBindView { ViewModel = vm }; - view.Bind(vm, x => x.JustADecimal, x => x.SomeTextBox.Text, d => d.ToString(CultureInfo.InvariantCulture), decimal.Parse); + vm.JustADecimal = 123.45m; + Assert.NotEqual(vm.JustADecimal.ToString(CultureInfo.InvariantCulture), view.SomeTextBox.Text); + + view.Bind(vm, x => x.JustADecimal, x => x.SomeTextBox.Text, d => d.ToString(CultureInfo.InvariantCulture), t => decimal.TryParse(t, out var res) ? res : 0m); + + Assert.Equal(view.SomeTextBox.Text, "123.45"); + + vm.JustADecimal = 1.0M; + Assert.Equal(view.SomeTextBox.Text, "1.0"); + + vm.JustADecimal = 2.0M; + Assert.Equal(view.SomeTextBox.Text, "2.0"); + + view.SomeTextBox.Text = "3.0"; + Assert.Equal(vm.JustADecimal, 3.0M); } /// @@ -578,5 +595,97 @@ public void BindInitialViewModelShouldBeGarbageCollectedWhenOverwritten() Assert.False(weakRef.IsAlive); } + + [Fact] + public void OneWayBindWithHintTest() + { + CompositeDisposable dis = new(); + PropertyBindViewModel? vm = new(); + PropertyBindView view = new() { ViewModel = vm }; + PropertyBinderImplementation fixture = new(); + + fixture.OneWayBind(vm, view, vm => vm.JustABoolean, v => v.SomeTextBox.Visibility, BooleanToVisibilityHint.Inverse).DisposeWith(dis); + Assert.Equal(view.SomeTextBox.Visibility, System.Windows.Visibility.Visible); + + vm.JustABoolean = true; + Assert.Equal(view.SomeTextBox.Visibility, System.Windows.Visibility.Collapsed); + + dis.Dispose(); + Assert.True(dis.IsDisposed); + } + + [Fact] + public void OneWayBindWithHintTestDisposeWithFailure() + { + CompositeDisposable? dis = null; + PropertyBindViewModel? vm = new(); + PropertyBindView view = new() { ViewModel = vm }; + PropertyBinderImplementation fixture = new(); + + Assert.Throws(() => fixture.OneWayBind(vm, view, vm => vm.JustABoolean, v => v.SomeTextBox.Visibility, BooleanToVisibilityHint.Inverse).DisposeWith(dis!)); + } + + [Fact] + public void BindToWithHintTest() + { + CompositeDisposable dis = new(); + PropertyBindViewModel? vm = new(); + var view = new PropertyBindView { ViewModel = vm }; + var obs = vm.WhenAnyValue(x => x.JustABoolean); + var a = new PropertyBinderImplementation().BindTo(obs, view, v => v.SomeTextBox.Visibility, BooleanToVisibilityHint.Inverse).DisposeWith(dis); + Assert.Equal(view.SomeTextBox.Visibility, System.Windows.Visibility.Visible); + + vm.JustABoolean = true; + Assert.Equal(view.SomeTextBox.Visibility, System.Windows.Visibility.Collapsed); + + dis.Dispose(); + Assert.True(dis.IsDisposed); + } + + [Fact] + public void BindWithFuncToTriggerUpdateTest() + { + CompositeDisposable dis = new(); + PropertyBindViewModel? vm = new(); + var view = new PropertyBindView { ViewModel = vm }; + var update = new Subject(); + + vm.JustADecimal = 123.45m; + Assert.NotEqual(vm.JustADecimal.ToString(CultureInfo.InvariantCulture), view.SomeTextBox.Text); + + view.Bind(vm, x => x.JustADecimal, x => x.SomeTextBox.Text, update.AsObservable(), d => d.ToString(CultureInfo.InvariantCulture), t => decimal.TryParse(t, out var res) ? res : decimal.Zero).DisposeWith(dis); + + vm.JustADecimal = 1.0M; + + // value should have pre bind value + Assert.Equal(view.SomeTextBox.Text, "123.45"); + + // trigger UI update + update.OnNext(true); + Assert.Equal(view.SomeTextBox.Text, "1.0"); + + vm.JustADecimal = 2.0M; + Assert.Equal(view.SomeTextBox.Text, "1.0"); + + update.OnNext(true); + Assert.Equal(view.SomeTextBox.Text, "2.0"); + + // test reverse bind no trigger required + view.SomeTextBox.Text = "3.0"; + Assert.Equal(vm.JustADecimal, 3.0M); + + view.SomeTextBox.Text = "4.0"; + Assert.Equal(vm.JustADecimal, 4.0M); + + // test forward bind to ensure trigger is still honoured. + vm.JustADecimal = 2.0M; + Assert.Equal(view.SomeTextBox.Text, "4.0"); + + update.OnNext(true); + Assert.Equal(view.SomeTextBox.Text, "2.0"); + + dis.Dispose(); + Assert.True(dis.IsDisposed); + } } } diff --git a/src/ReactiveUI.Tests/Platforms/winforms/CommandBindingImplementationTests.cs b/src/ReactiveUI.Tests/Platforms/winforms/CommandBindingImplementationTests.cs index 5eb1b3cb30..caccfc0460 100644 --- a/src/ReactiveUI.Tests/Platforms/winforms/CommandBindingImplementationTests.cs +++ b/src/ReactiveUI.Tests/Platforms/winforms/CommandBindingImplementationTests.cs @@ -25,7 +25,7 @@ public void CommandBindByNameWireup() var fixture = new CommandBinderImplementation(); var invokeCount = 0; - vm.Command1.Subscribe(_ => invokeCount += 1); + vm.Command1.Subscribe(_ => ++invokeCount); var disp = fixture.BindCommand(vm, view, x => x.Command1, x => x.Command1); @@ -53,7 +53,7 @@ public void CommandBindToExplicitEventWireup() var fixture = new CommandBinderImplementation(); var invokeCount = 0; - vm.Command2.Subscribe(_ => invokeCount += 1); + vm.Command2.Subscribe(_ => ++invokeCount); var disp = fixture.BindCommand(vm, view, x => x.Command2, x => x.Command2, "MouseUp"); @@ -64,5 +64,66 @@ public void CommandBindToExplicitEventWireup() view.Command2.RaiseMouseUpEvent(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); Assert.Equal(1, invokeCount); } + + [Fact] + public void CommandBindByNameWireupWithParameter() + { + var vm = new WinformCommandBindViewModel(); + var view = new WinformCommandBindView { ViewModel = vm }; + ICommandBinderImplementation fixture = new CommandBinderImplementation(); + + var invokeCount = 0; + vm.Command3.Subscribe(_ => ++invokeCount); + + var disp = CommandBinderImplementationMixins.BindCommand(fixture, vm, view, vm => vm.Command3, v => v.Command1, vm => vm.Parameter); + + view.Command1.PerformClick(); + Assert.Equal(1, invokeCount); + Assert.Equal(10, vm.ParameterResult); + + // update the parameter to ensure its updated when the command is executed + vm.Parameter = 2; + view.Command1.PerformClick(); + Assert.Equal(2, invokeCount); + Assert.Equal(20, vm.ParameterResult); + + // break the Command3 subscription + var newCmd = ReactiveCommand.Create(i => vm.ParameterResult = i * 2); + vm.Command3 = newCmd; + + // ensure that the invoke count does not update and that the Command3 is now using the new math + view.Command1.PerformClick(); + Assert.Equal(2, invokeCount); + Assert.Equal(4, vm.ParameterResult); + + disp.Dispose(); + } + + [Fact] + public void CommandBindToExplicitEventWireupWithParameter() + { + var vm = new WinformCommandBindViewModel(); + var view = new WinformCommandBindView { ViewModel = vm }; + var fixture = new CommandBinderImplementation(); + + var invokeCount = 0; + vm.Command3.Subscribe(_ => ++invokeCount); + + var disp = CommandBinderImplementationMixins.BindCommand(fixture, vm, view, x => x.Command3, x => x.Command2, vm => vm.Parameter, "MouseUp"); + + view.Command2.RaiseMouseUpEvent(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); + Assert.Equal(10, vm.ParameterResult); + Assert.Equal(1, invokeCount); + + vm.Parameter = 2; + view.Command2.RaiseMouseUpEvent(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); + Assert.Equal(20, vm.ParameterResult); + Assert.Equal(2, invokeCount); + + disp.Dispose(); + + view.Command2.RaiseMouseUpEvent(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); + Assert.Equal(2, invokeCount); + } } } diff --git a/src/ReactiveUI.Tests/Platforms/winforms/Mocks/WinformCommandBindViewModel.cs b/src/ReactiveUI.Tests/Platforms/winforms/Mocks/WinformCommandBindViewModel.cs index 4db106d9b9..75e5c2021d 100644 --- a/src/ReactiveUI.Tests/Platforms/winforms/Mocks/WinformCommandBindViewModel.cs +++ b/src/ReactiveUI.Tests/Platforms/winforms/Mocks/WinformCommandBindViewModel.cs @@ -11,13 +11,16 @@ namespace ReactiveUI.Tests.Winforms public class WinformCommandBindViewModel : ReactiveObject { private ReactiveCommand _command1; - private ReactiveCommand _command2; + private ReactiveCommand _command3; + private int _parameter = 1; + private int _parameterResult; public WinformCommandBindViewModel() { _command1 = ReactiveCommand.Create(() => { }, outputScheduler: ImmediateScheduler.Instance); _command2 = ReactiveCommand.Create(() => { }, outputScheduler: ImmediateScheduler.Instance); + _command3 = ReactiveCommand.Create(i => ParameterResult = i * 10, outputScheduler: ImmediateScheduler.Instance); } public ReactiveCommand Command1 @@ -31,5 +34,23 @@ public ReactiveCommand Command2 get => _command2; set => this.RaiseAndSetIfChanged(ref _command2, value); } + + public ReactiveCommand Command3 + { + get => _command3; + set => this.RaiseAndSetIfChanged(ref _command3, value); + } + + public int Parameter + { + get => _parameter; + set => this.RaiseAndSetIfChanged(ref _parameter, value); + } + + public int ParameterResult + { + get => _parameterResult; + set => this.RaiseAndSetIfChanged(ref _parameterResult, value); + } } } diff --git a/src/ReactiveUI.Tests/RandomTests.cs b/src/ReactiveUI.Tests/RandomTests.cs new file mode 100644 index 0000000000..4790f5f11a --- /dev/null +++ b/src/ReactiveUI.Tests/RandomTests.cs @@ -0,0 +1,94 @@ +// Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved. +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for full license information. + +using System; +using Splat; +using Xunit; + +namespace ReactiveUI.Tests +{ + public class RandomTests + { + [Fact] + public void StringConverterAffinityTest() + { + var fixture = new StringConverter(); + var result = fixture.GetAffinityForObjects(typeof(object), typeof(string)); + Assert.Equal(result, 2); + result = fixture.GetAffinityForObjects(typeof(object), typeof(int)); + Assert.Equal(result, 0); + } + + [Fact] + public void StringConverterTryConvertTest() + { + var fixture = new StringConverter(); + var expected = fixture.GetType().FullName; + var result = fixture.TryConvert(fixture, typeof(string), null, out var actualResult); + Assert.True(result); + Assert.Equal(expected, actualResult); + } + + [Fact] + public void UnhandledErrorExceptionTest() + { + var fixture = new UnhandledErrorException(); + Assert.Equal(fixture.Message, "Exception of type 'ReactiveUI.UnhandledErrorException' was thrown."); + } + + [Fact] + public void UnhandledErrorExceptionTestWithMessage() + { + var fixture = new UnhandledErrorException("We are terribly sorry but a unhandled error occured."); + Assert.Equal(fixture.Message, "We are terribly sorry but a unhandled error occured."); + } + + [Fact] + public void UnhandledErrorExceptionTestWithMessageAndInnerException() + { + var fixture = new UnhandledErrorException("We are terribly sorry but a unhandled error occured.", new Exception("Inner Exception added.")); + Assert.Equal(fixture.Message, "We are terribly sorry but a unhandled error occured."); + Assert.Equal(fixture.InnerException?.Message, "Inner Exception added."); + } + + [Fact] + public void ViewLocatorNotFoundExceptionTest() + { + var fixture = new ViewLocatorNotFoundException(); + Assert.Equal(fixture.Message, "Exception of type 'ReactiveUI.ViewLocatorNotFoundException' was thrown."); + } + + [Fact] + public void ViewLocatorNotFoundExceptionTestWithMessage() + { + var fixture = new ViewLocatorNotFoundException("We are terribly sorry but the View Locator was Not Found."); + Assert.Equal(fixture.Message, "We are terribly sorry but the View Locator was Not Found."); + } + + [Fact] + public void ViewLocatorNotFoundExceptionTestWithMessageAndInnerException() + { + var fixture = new ViewLocatorNotFoundException("We are terribly sorry but the View Locator was Not Found.", new Exception("Inner Exception added.")); + Assert.Equal(fixture.Message, "We are terribly sorry but the View Locator was Not Found."); + Assert.Equal(fixture.InnerException?.Message, "Inner Exception added."); + } + + [Fact] + public void ViewLocatorCurrentTest() + { + RxApp.EnsureInitialized(); + var fixture = ViewLocator.Current; + Assert.NotNull(fixture); + } + + [Fact] + public void ViewLocatorCurrentFailedTest() + { + Locator.CurrentMutable.UnregisterCurrent(typeof(IViewLocator)); + Assert.Throws(() => ViewLocator.Current); + Locator.CurrentMutable.Register(() => new DefaultViewLocator(), typeof(IViewLocator)); + } + } +} diff --git a/src/ReactiveUI.Tests/Routing/RoutingStateTests.cs b/src/ReactiveUI.Tests/Routing/RoutingStateTests.cs index 019d2e168d..9fdabe3642 100644 --- a/src/ReactiveUI.Tests/Routing/RoutingStateTests.cs +++ b/src/ReactiveUI.Tests/Routing/RoutingStateTests.cs @@ -42,7 +42,7 @@ public async Task NavigationPushPopTest() [Fact] public async Task CurrentViewModelObservableIsAccurate() { - var fixture = new RoutingState(); + var fixture = new RoutingState(RxApp.MainThreadScheduler); fixture.CurrentViewModel.ToObservableChangeSet(ImmediateScheduler.Instance).Bind(out var output).Subscribe(); Assert.Equal(1, output.Count); diff --git a/src/ReactiveUI.XamForms.Tests/RoutedViewHostTest.cs b/src/ReactiveUI.XamForms.Tests/RoutedViewHostTest.cs index 052ae1463e..5c441b551e 100644 --- a/src/ReactiveUI.XamForms.Tests/RoutedViewHostTest.cs +++ b/src/ReactiveUI.XamForms.Tests/RoutedViewHostTest.cs @@ -303,6 +303,9 @@ public async Task GoBackFromChildView(bool animated, bool fast) await _navigationViewModel.Navigate(nameof(ChildViewModel)); await fixture.PopAsyncInner(animated, fast).ConfigureAwait(true); + var viewModelSearch = _navigationViewModel.Router.FindViewModelInStack(); + Assert.NotNull(viewModelSearch); + Assert.Equal(1, fixture.StackDepth); var navigationStack = _navigationViewModel.Router.NavigationStack; Assert.Equal(1, navigationStack.Count); diff --git a/src/ReactiveUI/Activation/ViewForMixins.cs b/src/ReactiveUI/Activation/ViewForMixins.cs index 0f9a854db2..c1d9fe047a 100644 --- a/src/ReactiveUI/Activation/ViewForMixins.cs +++ b/src/ReactiveUI/Activation/ViewForMixins.cs @@ -41,7 +41,7 @@ public static class ViewForMixins /// View is activated. It returns a list of Disposables that will be /// cleaned up when the View is deactivated. /// - public static void WhenActivated(this IActivatableViewModel item, Func> block) + public static void WhenActivated(this IActivatableViewModel item, Func> block) // TODO: Create Test { if (item is null) { @@ -87,7 +87,7 @@ public static void WhenActivated(this IActivatableViewModel item, Action - public static void WhenActivated(this IActivatableViewModel item, Action block) + public static void WhenActivated(this IActivatableViewModel item, Action block) // TODO: Create Test { if (item is null) { @@ -113,7 +113,7 @@ public static void WhenActivated(this IActivatableViewModel item, Action /// A Disposable that deactivates this registration. - public static IDisposable WhenActivated(this IActivatableView item, Func> block) + public static IDisposable WhenActivated(this IActivatableView item, Func> block) // TODO: Create Test { if (item is null) { @@ -139,7 +139,7 @@ public static IDisposable WhenActivated(this IActivatableView item, Func /// A Disposable that deactivates this registration. - public static IDisposable WhenActivated(this IActivatableView item, Func> block, IViewFor? view) + public static IDisposable WhenActivated(this IActivatableView item, Func> block, IViewFor? view) // TODO: Create Test { if (item is null) { @@ -196,7 +196,7 @@ public static IDisposable WhenActivated(this IActivatableView item, Func /// A Disposable that deactivates this registration. - public static IDisposable WhenActivated(this IActivatableView item, Action> block, IViewFor view) => + public static IDisposable WhenActivated(this IActivatableView item, Action> block, IViewFor view) => // TODO: Create Test item.WhenActivated( () => { @@ -222,7 +222,7 @@ public static IDisposable WhenActivated(this IActivatableView item, Action /// A Disposable that deactivates this registration. - public static IDisposable WhenActivated(this IActivatableView item, Action block, IViewFor? view = null) => + public static IDisposable WhenActivated(this IActivatableView item, Action block, IViewFor? view = null) => // TODO: Create Test item.WhenActivated( () => { diff --git a/src/ReactiveUI/Bindings/Command/CommandBinderImplementation.cs b/src/ReactiveUI/Bindings/Command/CommandBinderImplementation.cs index e1fa62a2bd..4fdbd38de0 100644 --- a/src/ReactiveUI/Bindings/Command/CommandBinderImplementation.cs +++ b/src/ReactiveUI/Bindings/Command/CommandBinderImplementation.cs @@ -70,7 +70,7 @@ public IReactiveBinding BindCommand(); - var bindingDisposable = BindCommandInternal(source, view, controlExpression, viewModel.ToObservable(withParameter), toEvent); + var bindingDisposable = BindCommandInternal(source, view, controlExpression, withParameter.ToObservable(viewModel), toEvent); return new ReactiveBinding( view, diff --git a/src/ReactiveUI/Bindings/Interaction/InteractionBinderImplementation.cs b/src/ReactiveUI/Bindings/Interaction/InteractionBinderImplementation.cs index a086f4b612..15a3ab0740 100644 --- a/src/ReactiveUI/Bindings/Interaction/InteractionBinderImplementation.cs +++ b/src/ReactiveUI/Bindings/Interaction/InteractionBinderImplementation.cs @@ -22,7 +22,7 @@ public IDisposable BindInteraction( TViewModel? viewModel, TView view, Expression>> propertyName, - Func, Task> handler) + Func, Task> handler) // TODO: Create Test where TViewModel : class where TView : class, IViewFor { @@ -54,7 +54,7 @@ public IDisposable BindInteraction>> propertyName, - Func, IObservable> handler) + Func, IObservable> handler) // TODO: Create Test where TViewModel : class where TView : class, IViewFor { diff --git a/src/ReactiveUI/Bindings/Interaction/InteractionBindingMixins.cs b/src/ReactiveUI/Bindings/Interaction/InteractionBindingMixins.cs index b68b2162e3..71074b92e3 100644 --- a/src/ReactiveUI/Bindings/Interaction/InteractionBindingMixins.cs +++ b/src/ReactiveUI/Bindings/Interaction/InteractionBindingMixins.cs @@ -14,12 +14,12 @@ namespace ReactiveUI /// public static class InteractionBindingMixins { - private static readonly IInteractionBinderImplementation binderImplementation; + private static readonly IInteractionBinderImplementation _binderImplementation; static InteractionBindingMixins() { RxApp.EnsureInitialized(); - binderImplementation = new InteractionBinderImplementation(); + _binderImplementation = new InteractionBinderImplementation(); } /// @@ -41,7 +41,7 @@ public static IDisposable BindInteraction( Func, Task> handler) where TViewModel : class where TView : class, IViewFor => - binderImplementation.BindInteraction( + _binderImplementation.BindInteraction( viewModel, view, propertyName, @@ -67,7 +67,7 @@ public static IDisposable BindInteraction, IObservable> handler) where TViewModel : class where TView : class, IViewFor => - binderImplementation.BindInteraction( + _binderImplementation.BindInteraction( viewModel, view, propertyName, diff --git a/src/ReactiveUI/Bindings/Property/PropertyBinderImplementation.cs b/src/ReactiveUI/Bindings/Property/PropertyBinderImplementation.cs index 155d17c3df..1c6ad8f67b 100644 --- a/src/ReactiveUI/Bindings/Property/PropertyBinderImplementation.cs +++ b/src/ReactiveUI/Bindings/Property/PropertyBinderImplementation.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; @@ -386,26 +387,26 @@ private bool EvalBindingHooks(TViewModel? viewModel, TView vi var vmExpression = Reflection.Rewrite(vmProperty.Body); var viewExpression = Reflection.Rewrite(viewProperty.Body); - var signalObservable = signalViewUpdate != null - ? signalViewUpdate.Select(_ => false) - : view.WhenAnyDynamic(viewExpression, x => (TVProp?)x.Value).Select(_ => false); - var somethingChanged = Observable.Merge( - Reflection.ViewModelWhenAnyValue(viewModel, view, vmExpression).Select(_ => true), - signalInitialUpdate.Select(_ => true), - signalObservable); - - var changeWithValues = somethingChanged.Select(isVm => - !Reflection.TryGetValueForPropertyChain(out TVMProp vmValue, view.ViewModel, vmExpression.GetExpressionChain()) || + signalViewUpdate == null ? + Reflection.ViewModelWhenAnyValue(viewModel, view, vmExpression).Select(_ => true) : + signalViewUpdate.Select(_ => true) + .Merge(Reflection.ViewModelWhenAnyValue(viewModel, view, vmExpression).Select(_ => true).Take(1)), + signalInitialUpdate.Select(_ => true), + view.WhenAnyDynamic(viewExpression, x => (TVProp?)x.Value).Select(_ => false)); + + var changeWithValues = somethingChanged + .Select(isVm => + !Reflection.TryGetValueForPropertyChain(out TVMProp vmValue, view.ViewModel, vmExpression.GetExpressionChain()) || !Reflection.TryGetValueForPropertyChain(out TVProp vValue, view, viewExpression.GetExpressionChain()) - ? (false, null, false) - : isVm - ? !vmToViewConverter(vmValue, out var vmAsView) || EqualityComparer.Default.Equals(vValue, vmAsView) ? (false, null, false) - : (true, vmAsView, isVm) - : !viewToVmConverter(vValue, out var vAsViewModel) || EqualityComparer.Default.Equals(vmValue, vAsViewModel) - ? (false, null, false) - : (true, vAsViewModel, isVm)); + : isVm + ? !vmToViewConverter(vmValue, out var vmAsView) || EqualityComparer.Default.Equals(vValue, vmAsView) + ? (false, null, false) + : (true, vmAsView, isVm) + : !viewToVmConverter(vValue, out var vAsViewModel) || EqualityComparer.Default.Equals(vmValue, vAsViewModel) + ? (false, null, false) + : (true, vAsViewModel, isVm)); var ret = EvalBindingHooks(viewModel, view, vmExpression, viewExpression, BindingDirection.TwoWay); if (!ret) diff --git a/src/ReactiveUI/Bindings/Property/PropertyBindingMixins.cs b/src/ReactiveUI/Bindings/Property/PropertyBindingMixins.cs index fa2d8617e2..bb10d33dcf 100644 --- a/src/ReactiveUI/Bindings/Property/PropertyBindingMixins.cs +++ b/src/ReactiveUI/Bindings/Property/PropertyBindingMixins.cs @@ -130,7 +130,7 @@ static PropertyBindingMixins() IObservable? signalViewUpdate, object? conversionHint = null, IBindingTypeConverter? vmToViewConverterOverride = null, - IBindingTypeConverter? viewToVMConverterOverride = null) + IBindingTypeConverter? viewToVMConverterOverride = null) // TODO: Create Test where TViewModel : class where TView : class, IViewFor => _binderImplementation.Bind(viewModel, view, vmProperty, viewProperty, signalViewUpdate, conversionHint, vmToViewConverterOverride, viewToVMConverterOverride); diff --git a/src/ReactiveUI/Expression/Reflection.cs b/src/ReactiveUI/Expression/Reflection.cs index 44716c1248..97e10b6ba7 100644 --- a/src/ReactiveUI/Expression/Reflection.cs +++ b/src/ReactiveUI/Expression/Reflection.cs @@ -62,7 +62,7 @@ public static class Reflection /// /// The expression to generate the property names from. /// A string form for the property the expression is pointing to. - public static string ExpressionToPropertyNames(Expression? expression) + public static string ExpressionToPropertyNames(Expression? expression) // TODO: Create Test { if (expression == null) { @@ -110,7 +110,7 @@ public static string ExpressionToPropertyNames(Expression? expression) /// /// The member info to convert. /// A Func that takes in the object/indexes and returns the value. - public static Func? GetValueFetcherForProperty(MemberInfo? member) + public static Func? GetValueFetcherForProperty(MemberInfo? member) // TODO: Create Test { if (member is null) { @@ -135,7 +135,7 @@ public static string ExpressionToPropertyNames(Expression? expression) /// /// The member info to convert. /// A Func that takes in the object/indexes and returns the value. - public static Func GetValueFetcherOrThrow(MemberInfo? member) + public static Func GetValueFetcherOrThrow(MemberInfo? member) // TODO: Create Test { if (member is null) { @@ -155,7 +155,7 @@ public static string ExpressionToPropertyNames(Expression? expression) /// /// The member info to convert. /// A Func that takes in the object/indexes and sets the value. - public static Action GetValueSetterForProperty(MemberInfo? member) + public static Action GetValueSetterForProperty(MemberInfo? member) // TODO: Create Test { if (member is null) { @@ -180,7 +180,7 @@ public static string ExpressionToPropertyNames(Expression? expression) /// /// The member info to convert. /// A Func that takes in the object/indexes and sets the value. - public static Action? GetValueSetterOrThrow(MemberInfo? member) + public static Action? GetValueSetterOrThrow(MemberInfo? member) // TODO: Create Test { if (member is null) { @@ -203,7 +203,7 @@ public static string ExpressionToPropertyNames(Expression? expression) /// A list of expressions which will point towards a property or field. /// The type of the end value we are trying to get. /// If the value was successfully retrieved or not. - public static bool TryGetValueForPropertyChain(out TValue changeValue, object? current, IEnumerable expressionChain) + public static bool TryGetValueForPropertyChain(out TValue changeValue, object? current, IEnumerable expressionChain) // TODO: Create Test { var expressions = expressionChain.ToList(); foreach (var expression in expressions.SkipLast(1)) @@ -239,7 +239,7 @@ public static bool TryGetValueForPropertyChain(out TValue changeValue, o /// The object that starts the property chain. /// A list of expressions which will point towards a property or field. /// If the value was successfully retrieved or not. - public static bool TryGetAllValuesForPropertyChain(out IObservedChange[] changeValues, object? current, IEnumerable expressionChain) + public static bool TryGetAllValuesForPropertyChain(out IObservedChange[] changeValues, object? current, IEnumerable expressionChain) // TODO: Create Test { var currentIndex = 0; var expressions = expressionChain.ToList(); @@ -283,7 +283,7 @@ public static bool TryGetAllValuesForPropertyChain(out IObservedChangeIf we should throw if we are unable to set the value. /// The type of the end value we are trying to set. /// If the value was successfully retrieved or not. - public static bool TrySetValueToPropertyChain(object? target, IEnumerable expressionChain, TValue value, bool shouldThrow = true) + public static bool TrySetValueToPropertyChain(object? target, IEnumerable expressionChain, TValue value, bool shouldThrow = true) // TODO: Create Test { var expressions = expressionChain.ToList(); foreach (var expression in expressions.SkipLast(1)) @@ -325,7 +325,7 @@ public static bool TrySetValueToPropertyChain(object? target, IEnumerabl /// If we should throw an exception if the type can't be found. /// The type that was found or null. /// If we were unable to find the type. - public static Type? ReallyFindType(string? type, bool throwOnFailure) + public static Type? ReallyFindType(string? type, bool throwOnFailure) // TODO: Create Test { var ret = _typeCache.Get(type ?? string.Empty); return ret != null || !throwOnFailure ? ret : throw new TypeLoadException(); @@ -338,7 +338,7 @@ public static bool TrySetValueToPropertyChain(object? target, IEnumerabl /// The mame of the event. /// The Type of the EventArgs to use. /// If there is no event matching the name on the target type. - public static Type GetEventArgsTypeForEvent(Type type, string? eventName) + public static Type GetEventArgsTypeForEvent(Type type, string? eventName) // TODO: Create Test { if (type == null) { @@ -364,7 +364,7 @@ public static Type GetEventArgsTypeForEvent(Type type, string? eventName) /// The object to check. /// The name of the methods to check. /// Thrown if the methods aren't overriden on the target object. - public static void ThrowIfMethodsNotOverloaded(string callingTypeName, object targetObject, params string[] methodsToCheck) + public static void ThrowIfMethodsNotOverloaded(string callingTypeName, object targetObject, params string[] methodsToCheck) // TODO: Create Test { var (methodName, methodImplementation) = methodsToCheck .Select(x => @@ -385,7 +385,7 @@ public static void ThrowIfMethodsNotOverloaded(string callingTypeName, object ta /// /// The property information to check. /// If the property is static or not. - public static bool IsStatic(this PropertyInfo item) + public static bool IsStatic(this PropertyInfo item) // TODO: Create Test { if (item == null) { diff --git a/src/ReactiveUI/Mixins/AutoPersistHelper.cs b/src/ReactiveUI/Mixins/AutoPersistHelper.cs index fbe7b50314..54429114df 100644 --- a/src/ReactiveUI/Mixins/AutoPersistHelper.cs +++ b/src/ReactiveUI/Mixins/AutoPersistHelper.cs @@ -132,7 +132,7 @@ public static IDisposable AutoPersist(this T @this, Func /// A Disposable to disable automatic persistence. - public static IDisposable AutoPersistCollection(this ObservableCollection @this, Func> doPersist, TimeSpan? interval = null) + public static IDisposable AutoPersistCollection(this ObservableCollection @this, Func> doPersist, TimeSpan? interval = null) // TODO: Create Test where TItem : IReactiveObject => AutoPersistCollection(@this, doPersist, Observable.Never, interval); @@ -180,7 +180,7 @@ public static IDisposable AutoPersistCollection(this Observabl /// it is possible that it will never be saved. /// /// A Disposable to disable automatic persistence. - public static IDisposable AutoPersistCollection(this ReadOnlyObservableCollection @this, Func> doPersist, IObservable manualSaveSignal, TimeSpan? interval = null) + public static IDisposable AutoPersistCollection(this ReadOnlyObservableCollection @this, Func> doPersist, IObservable manualSaveSignal, TimeSpan? interval = null) // TODO: Create Test where TItem : IReactiveObject => AutoPersistCollection, TDontCare>(@this, doPersist, manualSaveSignal, interval); @@ -205,7 +205,7 @@ public static IDisposable AutoPersistCollection(this ReadOnlyO /// it is possible that it will never be saved. /// /// A Disposable to disable automatic persistence. - public static IDisposable AutoPersistCollection(this TCollection @this, Func> doPersist, IObservable manualSaveSignal, TimeSpan? interval = null) + public static IDisposable AutoPersistCollection(this TCollection @this, Func> doPersist, IObservable manualSaveSignal, TimeSpan? interval = null) // TODO: Create Test where TItem : IReactiveObject where TCollection : INotifyCollectionChanged, IEnumerable { @@ -250,7 +250,7 @@ public static IDisposable AutoPersistCollection(t /// A method to be called when an object is removed from the collection. /// /// A Disposable that deactivates this behavior. - public static IDisposable ActOnEveryObject(this ObservableCollection @this, Action onAdd, Action onRemove) + public static IDisposable ActOnEveryObject(this ObservableCollection @this, Action onAdd, Action onRemove) // TODO: Create Test where TItem : IReactiveObject => ActOnEveryObject>(@this, onAdd, onRemove); @@ -270,7 +270,7 @@ public static IDisposable ActOnEveryObject(this ObservableCollection /// A Disposable that deactivates this behavior. - public static IDisposable ActOnEveryObject(this ReadOnlyObservableCollection @this, Action onAdd, Action onRemove) + public static IDisposable ActOnEveryObject(this ReadOnlyObservableCollection @this, Action onAdd, Action onRemove) // TODO: Create Test where TItem : IReactiveObject => ActOnEveryObject>(@this, onAdd, onRemove); diff --git a/src/ReactiveUI/Mixins/ChangeSetMixin.cs b/src/ReactiveUI/Mixins/ChangeSetMixin.cs index 0ad3bca242..37a41e2b55 100644 --- a/src/ReactiveUI/Mixins/ChangeSetMixin.cs +++ b/src/ReactiveUI/Mixins/ChangeSetMixin.cs @@ -19,7 +19,7 @@ public static class ChangeSetMixin /// /// The change list to evaluate. /// If the change set is caused by the count being changed. - public static bool HasCountChanged(this IChangeSet changeSet) + public static bool HasCountChanged(this IChangeSet changeSet) // TODO: Create Test { if (changeSet is null) { @@ -34,7 +34,7 @@ public static bool HasCountChanged(this IChangeSet changeSet) /// /// The change list to evaluate. /// An observable of changes that only have count changes. - public static IObservable CountChanged(this IObservable changeSet) => changeSet.Where(HasCountChanged); + public static IObservable CountChanged(this IObservable changeSet) => changeSet.Where(HasCountChanged); // TODO: Create Test /// /// Is the change set associated with a count change. @@ -42,6 +42,6 @@ public static bool HasCountChanged(this IChangeSet changeSet) /// The change set type. /// The change list to evaluate. /// An observable of changes that only have count changes. - public static IObservable> CountChanged(this IObservable> changeSet) => changeSet.Where(x => x.HasCountChanged()); + public static IObservable> CountChanged(this IObservable> changeSet) => changeSet.Where(x => x.HasCountChanged()); // TODO: Create Test } } diff --git a/src/ReactiveUI/Mixins/ExpressionMixins.cs b/src/ReactiveUI/Mixins/ExpressionMixins.cs index e0625ae955..82a2854a73 100644 --- a/src/ReactiveUI/Mixins/ExpressionMixins.cs +++ b/src/ReactiveUI/Mixins/ExpressionMixins.cs @@ -121,7 +121,7 @@ public static IEnumerable GetExpressionChain(this Expression express /// /// The expression. /// The parent expression. - public static Expression? GetParent(this Expression expression) + public static Expression? GetParent(this Expression expression) // TODO: Create Test { if (expression is null) { @@ -143,7 +143,7 @@ public static IEnumerable GetExpressionChain(this Expression express /// /// The expression. /// An array of arguments. - public static object?[]? GetArgumentsArray(this Expression expression) + public static object?[]? GetArgumentsArray(this Expression expression) // TODO: Create Test { if (expression is null) { diff --git a/src/ReactiveUI/Mixins/ObservableLoggingMixin.cs b/src/ReactiveUI/Mixins/ObservableLoggingMixin.cs index 9777955dcb..203c47e370 100644 --- a/src/ReactiveUI/Mixins/ObservableLoggingMixin.cs +++ b/src/ReactiveUI/Mixins/ObservableLoggingMixin.cs @@ -29,7 +29,7 @@ public static IObservable Log( this IObservable @this, TObj logObject, string? message = null, - Func? stringifier = null) + Func? stringifier = null) // TODO: Create Test where TObj : IEnableLogger { message ??= string.Empty; @@ -58,7 +58,7 @@ public static IObservable Log( /// The Observable to replace the current one OnError. /// An error message to print. /// The same Observable. - public static IObservable LoggedCatch(this IObservable @this, TObj klass, IObservable? next = null, string? message = null) + public static IObservable LoggedCatch(this IObservable @this, TObj klass, IObservable? next = null, string? message = null) // TODO: Create Test where TObj : IEnableLogger { next ??= Observable.Default; @@ -81,7 +81,7 @@ public static IObservable LoggedCatch(this IObservable @this, TOb /// current one OnError. /// An error message to print. /// The same Observable. - public static IObservable LoggedCatch(this IObservable @this, TObj klass, Func> next, string? message = null) + public static IObservable LoggedCatch(this IObservable @this, TObj klass, Func> next, string? message = null) // TODO: Create Test where TObj : IEnableLogger where TException : Exception => @this.Catch(ex => diff --git a/src/ReactiveUI/Mixins/ObservedChangedMixin.cs b/src/ReactiveUI/Mixins/ObservedChangedMixin.cs index 127608c277..5c98911b65 100644 --- a/src/ReactiveUI/Mixins/ObservedChangedMixin.cs +++ b/src/ReactiveUI/Mixins/ObservedChangedMixin.cs @@ -59,7 +59,7 @@ item is null /// /// The current value of the property. /// - public static TValue? GetValueOrDefault(this IObservedChange item) => + public static TValue? GetValueOrDefault(this IObservedChange item) => // TODO: Create Test item is null ? throw new ArgumentNullException(nameof(item)) : !item.TryGetValue(out var returnValue) ? default : returnValue; /// @@ -75,8 +75,7 @@ item is null /// An Observable representing the stream of current values of /// the given change notification stream. /// - public static IObservable Value( - this IObservable> item) => + public static IObservable Value(this IObservable> item) => // TODO: Create Test item.Select(GetValue); /// diff --git a/src/ReactiveUI/Mixins/ReactiveNotifyPropertyChangedMixin.cs b/src/ReactiveUI/Mixins/ReactiveNotifyPropertyChangedMixin.cs index eb565120ab..5951831a38 100644 --- a/src/ReactiveUI/Mixins/ReactiveNotifyPropertyChangedMixin.cs +++ b/src/ReactiveUI/Mixins/ReactiveNotifyPropertyChangedMixin.cs @@ -107,7 +107,7 @@ public static IObservable ObservableForProperty( this TSender? item, Expression> property, Func selector, - bool beforeChange = false) + bool beforeChange = false) // TODO: Create Test where TSender : class { if (selector is null) @@ -137,7 +137,7 @@ public static IObservable> SubscribeToExpressio Expression? expression, bool beforeChange = false, bool skipInitial = true, - bool suppressWarnings = false) + bool suppressWarnings = false) // TODO: Create Test { if (source is null) { diff --git a/src/ReactiveUI/ObservableForProperty/OAPHCreationHelperMixin.cs b/src/ReactiveUI/ObservableForProperty/OAPHCreationHelperMixin.cs index 5d1aba9db0..dc639e5b75 100644 --- a/src/ReactiveUI/ObservableForProperty/OAPHCreationHelperMixin.cs +++ b/src/ReactiveUI/ObservableForProperty/OAPHCreationHelperMixin.cs @@ -49,7 +49,7 @@ public static ObservableAsPropertyHelper ToProperty( TObj source, Expression> property, bool deferSubscription = false, - IScheduler? scheduler = null) + IScheduler? scheduler = null) // TODO: Create Test where TObj : class, IReactiveObject { if (target is null) @@ -109,7 +109,7 @@ public static ObservableAsPropertyHelper ToProperty( Expression> property, TRet initialValue, bool deferSubscription = false, - IScheduler? scheduler = null) + IScheduler? scheduler = null) // TODO: Create Test where TObj : class, IReactiveObject => ToProperty(target, source, property, () => initialValue, deferSubscription, scheduler); @@ -152,7 +152,7 @@ public static ObservableAsPropertyHelper ToProperty( Expression> property, Func getInitialValue, bool deferSubscription = false, - IScheduler? scheduler = null) + IScheduler? scheduler = null) // TODO: Create Test where TObj : class, IReactiveObject => source.ObservableToProperty(target, property, getInitialValue, deferSubscription, scheduler); /// @@ -194,7 +194,7 @@ public static ObservableAsPropertyHelper ToProperty( Expression> property, out ObservableAsPropertyHelper result, bool deferSubscription = false, - IScheduler? scheduler = null) + IScheduler? scheduler = null) // TODO: Create Test where TObj : class, IReactiveObject { if (target is null) @@ -262,7 +262,7 @@ public static ObservableAsPropertyHelper ToProperty( out ObservableAsPropertyHelper result, TRet initialValue, bool deferSubscription = false, - IScheduler? scheduler = null) + IScheduler? scheduler = null) // TODO: Create Test where TObj : class, IReactiveObject => ToProperty(target, source, property, out result, () => initialValue, deferSubscription, scheduler); @@ -309,7 +309,7 @@ public static ObservableAsPropertyHelper ToProperty( out ObservableAsPropertyHelper result, Func getInitialValue, bool deferSubscription = false, - IScheduler? scheduler = null) + IScheduler? scheduler = null) // TODO: Create Test where TObj : class, IReactiveObject { var ret = source.ObservableToProperty(target, property, getInitialValue, deferSubscription, scheduler); @@ -358,7 +358,7 @@ public static ObservableAsPropertyHelper ToProperty( string property, TRet initialValue, bool deferSubscription = false, - IScheduler? scheduler = null) + IScheduler? scheduler = null) // TODO: Create Test where TObj : class, IReactiveObject => ToProperty(target, source, property, () => initialValue, deferSubscription, scheduler); @@ -398,7 +398,7 @@ public static ObservableAsPropertyHelper ToProperty( TObj source, string property, bool deferSubscription = false, - IScheduler? scheduler = null) + IScheduler? scheduler = null) // TODO: Create Test where TObj : class, IReactiveObject { if (target is null) @@ -459,7 +459,7 @@ public static ObservableAsPropertyHelper ToProperty( string property, Func getInitialValue, bool deferSubscription = false, - IScheduler? scheduler = null) + IScheduler? scheduler = null) // TODO: Create Test where TObj : class, IReactiveObject { if (target is null) @@ -519,7 +519,7 @@ public static ObservableAsPropertyHelper ToProperty( string property, out ObservableAsPropertyHelper result, bool deferSubscription = false, - IScheduler? scheduler = null) + IScheduler? scheduler = null) // TODO: Create Test where TObj : class, IReactiveObject { if (target is null) @@ -589,7 +589,7 @@ public static ObservableAsPropertyHelper ToProperty( out ObservableAsPropertyHelper result, Func getInitialValue, bool deferSubscription = false, - IScheduler? scheduler = null) + IScheduler? scheduler = null) // TODO: Create Test where TObj : class, IReactiveObject { if (target is null) diff --git a/src/ReactiveUI/ObservableForProperty/ObservableAsPropertyHelper.cs b/src/ReactiveUI/ObservableForProperty/ObservableAsPropertyHelper.cs index 89a9244ca2..1fe765fae5 100644 --- a/src/ReactiveUI/ObservableForProperty/ObservableAsPropertyHelper.cs +++ b/src/ReactiveUI/ObservableForProperty/ObservableAsPropertyHelper.cs @@ -97,7 +97,7 @@ public ObservableAsPropertyHelper( Action? onChanging = null, T? initialValue = default, bool deferSubscription = false, - IScheduler? scheduler = null) + IScheduler? scheduler = null) // TODO: Create Test : this(observable, onChanged, onChanging, () => initialValue, deferSubscription, scheduler) { } @@ -230,13 +230,13 @@ public T? Value /// normally be a Dispatcher-based scheduler. /// /// A default property helper. - public static ObservableAsPropertyHelper Default(T? initialValue = default, IScheduler? scheduler = null) => + public static ObservableAsPropertyHelper Default(T? initialValue = default, IScheduler? scheduler = null) => // TODO: Create Test new(Observable.Never, _ => { }, initialValue!, false, scheduler); /// /// Disposes this ObservableAsPropertyHelper. /// - public void Dispose() + public void Dispose() // TODO: Create Test { _disposable?.Dispose(); _disposable = null!; diff --git a/src/ReactiveUI/ObservableFuncMixins.cs b/src/ReactiveUI/ObservableFuncMixins.cs index c8420bb9d7..80a5e55147 100644 --- a/src/ReactiveUI/ObservableFuncMixins.cs +++ b/src/ReactiveUI/ObservableFuncMixins.cs @@ -19,18 +19,18 @@ public static class ObservableFuncMixins /// /// The type of the view model. /// The type of the result. - /// The view model. /// The expression. + /// The view model. /// if set to true [before change]. /// if set to true [skip initial]. /// /// An observable Result. /// public static IObservable ToObservable( - this TSource? source, - Expression> expression, + this Expression> expression, + TSource? source, bool beforeChange = false, - bool skipInitial = false) + bool skipInitial = false) // TODO: Create Test { var sParam = Reflection.Rewrite(expression.Body); return source.SubscribeToExpressionChain(sParam, beforeChange, skipInitial, RxApp.SuppressViewCommandBindingMessage) diff --git a/src/ReactiveUI/Platforms/android/AndroidCommandBinders.cs b/src/ReactiveUI/Platforms/android/AndroidCommandBinders.cs index 02a7872b81..74ad0af211 100644 --- a/src/ReactiveUI/Platforms/android/AndroidCommandBinders.cs +++ b/src/ReactiveUI/Platforms/android/AndroidCommandBinders.cs @@ -19,7 +19,7 @@ public class AndroidCommandBinders : FlexibleCommandBinder /// /// Initializes a new instance of the class. /// - public AndroidCommandBinders() + public AndroidCommandBinders() // TODO: Create Test { var view = typeof(View); Register(view, 9, (cmd, t, cp) => ForEvent(cmd, t, cp, "Click", view.GetRuntimeProperty("Enabled"))); @@ -28,6 +28,6 @@ public AndroidCommandBinders() /// /// Gets the static instance of . /// - public static Lazy Instance { get; } = new(); + public static Lazy Instance { get; } = new(); // TODO: Create Test } } diff --git a/src/ReactiveUI/Platforms/android/AutoSuspendHelper.cs b/src/ReactiveUI/Platforms/android/AutoSuspendHelper.cs index 7fd7eb289a..7c6c0edb74 100644 --- a/src/ReactiveUI/Platforms/android/AutoSuspendHelper.cs +++ b/src/ReactiveUI/Platforms/android/AutoSuspendHelper.cs @@ -38,7 +38,7 @@ public class AutoSuspendHelper : IEnableLogger, IDisposable /// Initializes a new instance of the class. /// /// The host application. - public AutoSuspendHelper(Application hostApplication) + public AutoSuspendHelper(Application hostApplication) // TODO: Create Test { if (hostApplication is null) { diff --git a/src/ReactiveUI/Platforms/android/BundleSuspensionDriver.cs b/src/ReactiveUI/Platforms/android/BundleSuspensionDriver.cs index acfa3dffe3..09ba58382a 100644 --- a/src/ReactiveUI/Platforms/android/BundleSuspensionDriver.cs +++ b/src/ReactiveUI/Platforms/android/BundleSuspensionDriver.cs @@ -17,7 +17,7 @@ namespace ReactiveUI public class BundleSuspensionDriver : ISuspensionDriver { /// - public IObservable LoadState() + public IObservable LoadState() // TODO: Create Test { try { @@ -39,7 +39,7 @@ public IObservable LoadState() } /// - public IObservable SaveState(object state) + public IObservable SaveState(object state) // TODO: Create Test { try { @@ -56,7 +56,7 @@ public IObservable SaveState(object state) } /// - public IObservable InvalidateState() + public IObservable InvalidateState() // TODO: Create Test { try { diff --git a/src/ReactiveUI/Platforms/android/ContextExtensions.cs b/src/ReactiveUI/Platforms/android/ContextExtensions.cs index 700a3f95db..62fe5b9bfa 100644 --- a/src/ReactiveUI/Platforms/android/ContextExtensions.cs +++ b/src/ReactiveUI/Platforms/android/ContextExtensions.cs @@ -22,7 +22,8 @@ public static class ContextExtensions /// The Context to bind the Service from. /// Identifies the service to connect to. The Intent may specify either an explicit component name, or a logical description (action, category, etc) to match an IntentFilter published by a service. /// Operation options for the binding. The default is Bind.None. - public static IObservable ServiceBound(this Context context, Intent intent, Bind flags = Bind.None) => ServiceBound(context, intent, flags); + public static IObservable ServiceBound(this Context context, Intent intent, Bind flags = Bind.None) => // TODO: Create Test + ServiceBound(context, intent, flags); /// /// Binds the service. @@ -32,7 +33,7 @@ public static class ContextExtensions /// Identifies the service to connect to. The Intent may specify either an explicit component name, or a logical description (action, category, etc) to match an IntentFilter published by a service. /// Operation options for the binding. The default is Bind.None. /// The type of the returned service binder. - public static IObservable ServiceBound(this Context context, Intent intent, Bind flags = Bind.None) + public static IObservable ServiceBound(this Context context, Intent intent, Bind flags = Bind.None) // TODO: Create Test where TBinder : class, IBinder => Observable.Create(observer => { diff --git a/src/ReactiveUI/Platforms/android/ControlFetcherMixin.cs b/src/ReactiveUI/Platforms/android/ControlFetcherMixin.cs index 1b01ee2651..76fb8b872c 100644 --- a/src/ReactiveUI/Platforms/android/ControlFetcherMixin.cs +++ b/src/ReactiveUI/Platforms/android/ControlFetcherMixin.cs @@ -31,7 +31,7 @@ public static partial class ControlFetcherMixin /// The activity. /// The property name. /// The return view. - public static View? GetControl(this Activity activity, [CallerMemberName] string? propertyName = null) + public static View? GetControl(this Activity activity, [CallerMemberName] string? propertyName = null) // TODO: Create Test => GetCachedControl(propertyName, activity, () => activity.FindViewById(GetControlIdByName(activity.GetType().Assembly, propertyName))); /// @@ -41,7 +41,7 @@ public static partial class ControlFetcherMixin /// The assembly containing the user-defined view. /// The property. /// The return view. - public static View? GetControl(this View view, Assembly assembly, [CallerMemberName] string? propertyName = null) + public static View? GetControl(this View view, Assembly assembly, [CallerMemberName] string? propertyName = null) // TODO: Create Test => GetCachedControl(propertyName, view, () => view.FindViewById(GetControlIdByName(assembly, propertyName))); /// @@ -49,7 +49,7 @@ public static partial class ControlFetcherMixin /// /// The layout view host. /// The resolve members. - public static void WireUpControls(this ILayoutViewHost layoutHost, ResolveStrategy resolveMembers = ResolveStrategy.Implicit) + public static void WireUpControls(this ILayoutViewHost layoutHost, ResolveStrategy resolveMembers = ResolveStrategy.Implicit) // TODO: Create Test { if (layoutHost is null) { @@ -77,7 +77,7 @@ public static void WireUpControls(this ILayoutViewHost layoutHost, ResolveStrate /// /// The view. /// The resolve members. - public static void WireUpControls(this View view, ResolveStrategy resolveMembers = ResolveStrategy.Implicit) + public static void WireUpControls(this View view, ResolveStrategy resolveMembers = ResolveStrategy.Implicit) // TODO: Create Test { if (view is null) { @@ -112,7 +112,7 @@ public static void WireUpControls(this View view, ResolveStrategy resolveMembers /// The inflated view. /// The resolve members. [Obsolete("This class is obsoleted in this android platform")] - public static void WireUpControls(this Fragment fragment, View inflatedView, ResolveStrategy resolveMembers = ResolveStrategy.Implicit) + public static void WireUpControls(this Fragment fragment, View inflatedView, ResolveStrategy resolveMembers = ResolveStrategy.Implicit) // TODO: Create Test { if (fragment is null) { @@ -144,7 +144,7 @@ public static void WireUpControls(this Fragment fragment, View inflatedView, Res /// /// The Activity. /// The resolve members. - public static void WireUpControls(this Activity activity, ResolveStrategy resolveMembers = ResolveStrategy.Implicit) + public static void WireUpControls(this Activity activity, ResolveStrategy resolveMembers = ResolveStrategy.Implicit) // TODO: Create Test { if (activity is null) { diff --git a/src/ReactiveUI/Platforms/android/FlexibleCommandBinder.cs b/src/ReactiveUI/Platforms/android/FlexibleCommandBinder.cs index b00803f8ac..dc6ab4b6fb 100644 --- a/src/ReactiveUI/Platforms/android/FlexibleCommandBinder.cs +++ b/src/ReactiveUI/Platforms/android/FlexibleCommandBinder.cs @@ -117,7 +117,7 @@ protected static IDisposable ForEvent(ICommand? command, object? target, IObserv // initial enabled state enabledSetter(target, command.CanExecute(latestParam), null); - var compDisp = new CompositeDisposable( + return new CompositeDisposable( actionDisp, commandParameter.Subscribe(x => latestParam = x), Observable.FromEvent( @@ -129,8 +129,6 @@ protected static IDisposable ForEvent(ICommand? command, object? target, IObserv x => command.CanExecuteChanged += x, x => command.CanExecuteChanged -= x) .Subscribe(x => enabledSetter(target, x, null))); - - return compDisp; } /// diff --git a/src/ReactiveUI/Platforms/android/HandlerScheduler.cs b/src/ReactiveUI/Platforms/android/HandlerScheduler.cs index d1336c18c4..078cb6448f 100644 --- a/src/ReactiveUI/Platforms/android/HandlerScheduler.cs +++ b/src/ReactiveUI/Platforms/android/HandlerScheduler.cs @@ -70,7 +70,7 @@ public IDisposable Schedule(TState state, Func - public IDisposable Schedule(TState state, TimeSpan dueTime, Func action) + public IDisposable Schedule(TState state, TimeSpan dueTime, Func action) // TODO: Create Test { var isCancelled = false; var innerDisp = new SerialDisposable() { Disposable = Disposable.Empty }; @@ -93,7 +93,7 @@ public IDisposable Schedule(TState state, TimeSpan dueTime, Func - public IDisposable Schedule(TState state, DateTimeOffset dueTime, Func action) + public IDisposable Schedule(TState state, DateTimeOffset dueTime, Func action) // TODO: Create Test { if (dueTime <= Now) { diff --git a/src/ReactiveUI/Platforms/android/PlatformOperations.cs b/src/ReactiveUI/Platforms/android/PlatformOperations.cs index 5919722274..0bbf5e28d3 100644 --- a/src/ReactiveUI/Platforms/android/PlatformOperations.cs +++ b/src/ReactiveUI/Platforms/android/PlatformOperations.cs @@ -16,7 +16,7 @@ namespace ReactiveUI public class PlatformOperations : IPlatformOperations { /// - public string? GetOrientation() + public string? GetOrientation() // TODO: Create Test { if (Application.Context.GetSystemService(Context.WindowService) is not IWindowManager wm) { diff --git a/src/ReactiveUI/Platforms/android/PlatformRegistrations.cs b/src/ReactiveUI/Platforms/android/PlatformRegistrations.cs index e8ca79f150..6d1438ea24 100644 --- a/src/ReactiveUI/Platforms/android/PlatformRegistrations.cs +++ b/src/ReactiveUI/Platforms/android/PlatformRegistrations.cs @@ -16,7 +16,7 @@ namespace ReactiveUI public class PlatformRegistrations : IWantsToRegisterStuff { /// - public void Register(Action, Type> registerFunction) + public void Register(Action, Type> registerFunction) // TODO: Create Test { if (registerFunction is null) { diff --git a/src/ReactiveUI/Platforms/android/ReactiveActivity.cs b/src/ReactiveUI/Platforms/android/ReactiveActivity.cs index 2edd7e2a82..2f307acc13 100644 --- a/src/ReactiveUI/Platforms/android/ReactiveActivity.cs +++ b/src/ReactiveUI/Platforms/android/ReactiveActivity.cs @@ -106,12 +106,12 @@ protected ReactiveActivity(IntPtr handle, JniHandleOwnership ownership) /// /// Gets a signal when the activity is activated. /// - public IObservable Activated => _activated.AsObservable(); + public IObservable Activated => _activated.AsObservable(); // TODO: Create Test /// /// Gets a signal when the activity is deactivated. /// - public IObservable Deactivated => _deactivated.AsObservable(); + public IObservable Deactivated => _deactivated.AsObservable(); // TODO: Create Test /// /// Gets the activity result. @@ -119,7 +119,8 @@ protected ReactiveActivity(IntPtr handle, JniHandleOwnership ownership) /// /// The activity result. /// - public IObservable<(int requestCode, Result resultCode, Intent? intent)> ActivityResult => _activityResult.AsObservable(); + public IObservable<(int requestCode, Result resultCode, Intent? intent)> ActivityResult => // TODO: Create Test + _activityResult.AsObservable(); /// /// When this method is called, an object will not fire change @@ -128,13 +129,16 @@ protected ReactiveActivity(IntPtr handle, JniHandleOwnership ownership) /// /// An object that, when disposed, reenables change /// notifications. - public IDisposable SuppressChangeNotifications() => IReactiveObjectExtensions.SuppressChangeNotifications(this); + public IDisposable SuppressChangeNotifications() => // TODO: Create Test + IReactiveObjectExtensions.SuppressChangeNotifications(this); /// - void IReactiveObject.RaisePropertyChanging(PropertyChangingEventArgs args) => PropertyChanging?.Invoke(this, args); + void IReactiveObject.RaisePropertyChanging(PropertyChangingEventArgs args) => // TODO: Create Test + PropertyChanging?.Invoke(this, args); /// - void IReactiveObject.RaisePropertyChanged(PropertyChangedEventArgs args) => PropertyChanged?.Invoke(this, args); + void IReactiveObject.RaisePropertyChanged(PropertyChangedEventArgs args) => // TODO: Create Test + PropertyChanged?.Invoke(this, args); /// /// Starts the activity for result asynchronously. @@ -142,7 +146,7 @@ protected ReactiveActivity(IntPtr handle, JniHandleOwnership ownership) /// The intent. /// The request code. /// A task with the result and the intent. - public Task<(Result resultCode, Intent? intent)> StartActivityForResultAsync(Intent? intent, int requestCode) + public Task<(Result resultCode, Intent? intent)> StartActivityForResultAsync(Intent? intent, int requestCode) // TODO: Create Test { // NB: It's important that we set up the subscription *before* we // call ActivityForResult @@ -162,7 +166,7 @@ protected ReactiveActivity(IntPtr handle, JniHandleOwnership ownership) /// The type. /// The request code. /// A task with the result and intent. - public Task<(Result resultCode, Intent? intent)> StartActivityForResultAsync(Type type, int requestCode) + public Task<(Result resultCode, Intent? intent)> StartActivityForResultAsync(Type type, int requestCode) // TODO: Create Test { // NB: It's important that we set up the subscription *before* we // call ActivityForResult diff --git a/src/ReactiveUI/Platforms/android/ReactivePreferenceActivity.cs b/src/ReactiveUI/Platforms/android/ReactivePreferenceActivity.cs index 767affb5f4..16ff073f7e 100644 --- a/src/ReactiveUI/Platforms/android/ReactivePreferenceActivity.cs +++ b/src/ReactiveUI/Platforms/android/ReactivePreferenceActivity.cs @@ -111,7 +111,7 @@ protected ReactivePreferenceActivity(IntPtr handle, JniHandleOwnership ownership /// /// The deactivated. /// - public IObservable Activated => _activated.AsObservable(); + public IObservable Activated => _activated.AsObservable(); // TODO: Create Test /// /// Gets a signal when the activity is deactivated. @@ -119,7 +119,7 @@ protected ReactivePreferenceActivity(IntPtr handle, JniHandleOwnership ownership /// /// The deactivated. /// - public IObservable Deactivated => _deactivated.AsObservable(); + public IObservable Deactivated => _deactivated.AsObservable(); // TODO: Create Test /// /// Gets a signal with an activity result. @@ -127,7 +127,8 @@ protected ReactivePreferenceActivity(IntPtr handle, JniHandleOwnership ownership /// /// The deactivated. /// - public IObservable<(int requestCode, Result resultCode, Intent? intent)> ActivityResult => _activityResult.AsObservable(); + public IObservable<(int requestCode, Result resultCode, Intent? intent)> ActivityResult => // TODO: Create Test + _activityResult.AsObservable(); /// /// When this method is called, an object will not fire change @@ -136,7 +137,8 @@ protected ReactivePreferenceActivity(IntPtr handle, JniHandleOwnership ownership /// /// An object that, when disposed, re-enables change /// notifications. - public IDisposable SuppressChangeNotifications() => IReactiveObjectExtensions.SuppressChangeNotifications(this); + public IDisposable SuppressChangeNotifications() => // TODO: Create Test + IReactiveObjectExtensions.SuppressChangeNotifications(this); /// void IReactiveObject.RaisePropertyChanging(PropertyChangingEventArgs args) => PropertyChanging?.Invoke(this, args); @@ -150,7 +152,7 @@ protected ReactivePreferenceActivity(IntPtr handle, JniHandleOwnership ownership /// The intent. /// The request code. /// A task with the result and intent. - public Task<(Result resultCode, Intent? intent)> StartActivityForResultAsync(Intent? intent, int requestCode) + public Task<(Result resultCode, Intent? intent)> StartActivityForResultAsync(Intent? intent, int requestCode) // TODO: Create Test { // NB: It's important that we set up the subscription *before* we // call ActivityForResult @@ -170,7 +172,7 @@ protected ReactivePreferenceActivity(IntPtr handle, JniHandleOwnership ownership /// The type. /// The request code. /// A task with the result and intent. - public Task<(Result resultCode, Intent? intent)> StartActivityForResultAsync(Type type, int requestCode) + public Task<(Result resultCode, Intent? intent)> StartActivityForResultAsync(Type type, int requestCode) // TODO: Create Test { // NB: It's important that we set up the subscription *before* we // call ActivityForResult diff --git a/src/ReactiveUI/Platforms/android/ReactivePreferenceFragment.cs b/src/ReactiveUI/Platforms/android/ReactivePreferenceFragment.cs index d56bbcecba..1c2003e830 100644 --- a/src/ReactiveUI/Platforms/android/ReactivePreferenceFragment.cs +++ b/src/ReactiveUI/Platforms/android/ReactivePreferenceFragment.cs @@ -103,21 +103,21 @@ protected ReactivePreferenceFragment(IntPtr handle, JniHandleOwnership ownership /// /// Gets a signal when the fragment is activated. /// - public IObservable Activated => _activated.AsObservable(); + public IObservable Activated => _activated.AsObservable(); // TODO: Create Test /// /// Gets a signal when the fragment is deactivated. /// - public IObservable Deactivated => _deactivated.AsObservable(); + public IObservable Deactivated => _deactivated.AsObservable(); // TODO: Create Test /// - public IDisposable SuppressChangeNotifications() => IReactiveObjectExtensions.SuppressChangeNotifications(this); + public IDisposable SuppressChangeNotifications() => IReactiveObjectExtensions.SuppressChangeNotifications(this); // TODO: Create Test /// - void IReactiveObject.RaisePropertyChanged(PropertyChangedEventArgs args) => PropertyChanged?.Invoke(this, args); + void IReactiveObject.RaisePropertyChanged(PropertyChangedEventArgs args) => PropertyChanged?.Invoke(this, args); // TODO: Create Test /// - void IReactiveObject.RaisePropertyChanging(PropertyChangingEventArgs args) => PropertyChanging?.Invoke(this, args); + void IReactiveObject.RaisePropertyChanging(PropertyChangingEventArgs args) => PropertyChanging?.Invoke(this, args); // TODO: Create Test /// [Obsolete("deprecated")] diff --git a/src/ReactiveUI/Platforms/android/ReactiveViewHost.cs b/src/ReactiveUI/Platforms/android/ReactiveViewHost.cs index e2e787f73e..1cb3b587ef 100644 --- a/src/ReactiveUI/Platforms/android/ReactiveViewHost.cs +++ b/src/ReactiveUI/Platforms/android/ReactiveViewHost.cs @@ -90,13 +90,13 @@ public TViewModel? ViewModel /// /// An object that, when disposed, reenables change /// notifications. - public IDisposable SuppressChangeNotifications() => IReactiveObjectExtensions.SuppressChangeNotifications(this); + public IDisposable SuppressChangeNotifications() => IReactiveObjectExtensions.SuppressChangeNotifications(this); // TODO: Create Test /// /// Gets a value indicating if change notifications are enabled. /// /// A value indicating if change notifications are on or off. - public bool AreChangeNotificationsEnabled() => IReactiveObjectExtensions.AreChangeNotificationsEnabled(this); + public bool AreChangeNotificationsEnabled() => IReactiveObjectExtensions.AreChangeNotificationsEnabled(this); // TODO: Create Test /// void IReactiveObject.RaisePropertyChanging(PropertyChangingEventArgs args) => PropertyChanging?.Invoke(this, args); diff --git a/src/ReactiveUI/Platforms/android/SharedPreferencesExtensions.cs b/src/ReactiveUI/Platforms/android/SharedPreferencesExtensions.cs index c8b626e9a2..8c39d2d6c7 100644 --- a/src/ReactiveUI/Platforms/android/SharedPreferencesExtensions.cs +++ b/src/ReactiveUI/Platforms/android/SharedPreferencesExtensions.cs @@ -20,7 +20,7 @@ public static class SharedPreferencesExtensions /// /// The observable sequence of keys for changed shared preferences. /// The shared preferences to get the changes from. - public static IObservable PreferenceChanged(this ISharedPreferences sharedPreferences) => + public static IObservable PreferenceChanged(this ISharedPreferences sharedPreferences) => // TODO: Create Test Observable.Create(observer => { var listener = new OnSharedPreferenceChangeListener(observer); diff --git a/src/ReactiveUI/Platforms/android/UsbManagerExtensions.cs b/src/ReactiveUI/Platforms/android/UsbManagerExtensions.cs index 63678146fd..9f8643d52e 100644 --- a/src/ReactiveUI/Platforms/android/UsbManagerExtensions.cs +++ b/src/ReactiveUI/Platforms/android/UsbManagerExtensions.cs @@ -27,7 +27,7 @@ public static class UsbManagerExtensions /// The UsbManager system service. /// The Context to request the permission from. /// The UsbDevice to request permission for. - public static IObservable PermissionRequested(this UsbManager manager, Context context, UsbDevice device) => + public static IObservable PermissionRequested(this UsbManager manager, Context context, UsbDevice device) => // TODO: Create Test Observable.Create(observer => { var usbPermissionReceiver = new UsbDevicePermissionReceiver(observer, device); @@ -47,7 +47,7 @@ public static IObservable PermissionRequested(this UsbManager manager, Con /// The UsbManager system service. /// The Context to request the permission from. /// The UsbAccessory to request permission for. - public static IObservable PermissionRequested(this UsbManager manager, Context context, UsbAccessory accessory) => + public static IObservable PermissionRequested(this UsbManager manager, Context context, UsbAccessory accessory) => // TODO: Create Test Observable.Create(observer => { var usbPermissionReceiver = new UsbAccessoryPermissionReceiver(observer, accessory); diff --git a/src/ReactiveUI/Platforms/android/ViewCommandExtensions.cs b/src/ReactiveUI/Platforms/android/ViewCommandExtensions.cs index 18b93dd607..9c54646be3 100644 --- a/src/ReactiveUI/Platforms/android/ViewCommandExtensions.cs +++ b/src/ReactiveUI/Platforms/android/ViewCommandExtensions.cs @@ -24,7 +24,7 @@ public static class ViewCommandExtensions /// The command. /// The control. /// A disposable. - public static IDisposable BindToTarget(this ICommand command, View control) + public static IDisposable BindToTarget(this ICommand command, View control) // TODO: Create Test { if (command is null) { diff --git a/src/ReactiveUI/Platforms/android/ViewMixins.cs b/src/ReactiveUI/Platforms/android/ViewMixins.cs index aebb2f377d..28d1e74ffb 100644 --- a/src/ReactiveUI/Platforms/android/ViewMixins.cs +++ b/src/ReactiveUI/Platforms/android/ViewMixins.cs @@ -21,7 +21,7 @@ public static class ViewMixins /// The layout view host type. /// The view. /// The view host. - public static T GetViewHost(this View item) + public static T GetViewHost(this View item) // TODO: Create Test where T : ILayoutViewHost { var tagData = item?.GetTag(ViewHostTag); @@ -39,6 +39,7 @@ public static T GetViewHost(this View item) /// /// The view. /// The view host. - public static ILayoutViewHost? GetViewHost(this View item) => item?.GetTag(ViewHostTag)?.ToNetObject(); + public static ILayoutViewHost? GetViewHost(this View item) => // TODO: Create Test + item?.GetTag(ViewHostTag)?.ToNetObject(); } } diff --git a/src/ReactiveUI/ReactiveObject/ReactiveObject.cs b/src/ReactiveUI/ReactiveObject/ReactiveObject.cs index d2dbaa5585..7c171d7034 100644 --- a/src/ReactiveUI/ReactiveObject/ReactiveObject.cs +++ b/src/ReactiveUI/ReactiveObject/ReactiveObject.cs @@ -88,25 +88,30 @@ public event PropertyChangedEventHandler? PropertyChanged public IObservable ThrownExceptions => _thrownExceptions.Value; /// - void IReactiveObject.RaisePropertyChanging(PropertyChangingEventArgs args) => PropertyChangingHandler?.Invoke(this, args); + void IReactiveObject.RaisePropertyChanging(PropertyChangingEventArgs args) => + PropertyChangingHandler?.Invoke(this, args); /// - void IReactiveObject.RaisePropertyChanged(PropertyChangedEventArgs args) => PropertyChangedHandler?.Invoke(this, args); + void IReactiveObject.RaisePropertyChanged(PropertyChangedEventArgs args) => + PropertyChangedHandler?.Invoke(this, args); /// - public IDisposable SuppressChangeNotifications() => IReactiveObjectExtensions.SuppressChangeNotifications(this); + public IDisposable SuppressChangeNotifications() => // TODO: Create Test + IReactiveObjectExtensions.SuppressChangeNotifications(this); /// /// Determines if change notifications are enabled or not. /// /// A value indicating whether change notifications are enabled. - public bool AreChangeNotificationsEnabled() => IReactiveObjectExtensions.AreChangeNotificationsEnabled(this); + public bool AreChangeNotificationsEnabled() => // TODO: Create Test + IReactiveObjectExtensions.AreChangeNotificationsEnabled(this); /// /// Delays notifications until the return IDisposable is disposed. /// /// A disposable which when disposed will send delayed notifications. - public IDisposable DelayChangeNotifications() => IReactiveObjectExtensions.DelayChangeNotifications(this); + public IDisposable DelayChangeNotifications() => + IReactiveObjectExtensions.DelayChangeNotifications(this); } } diff --git a/src/ReactiveUI/ReactiveObject/ReactiveRecord.cs b/src/ReactiveUI/ReactiveObject/ReactiveRecord.cs index 8e3bd51502..d8d1682a37 100644 --- a/src/ReactiveUI/ReactiveObject/ReactiveRecord.cs +++ b/src/ReactiveUI/ReactiveObject/ReactiveRecord.cs @@ -77,11 +77,13 @@ public event PropertyChangedEventHandler? PropertyChanged /// [IgnoreDataMember] - public IObservable> Changing => _changing.Value; + public IObservable> Changing => // TODO: Create Test + _changing.Value; /// [IgnoreDataMember] - public IObservable> Changed => _changed.Value; + public IObservable> Changed => // TODO: Create Test + _changed.Value; /// [IgnoreDataMember] @@ -94,18 +96,21 @@ public event PropertyChangedEventHandler? PropertyChanged void IReactiveObject.RaisePropertyChanged(PropertyChangedEventArgs args) => PropertyChangedHandler?.Invoke(this, args); /// - public IDisposable SuppressChangeNotifications() => IReactiveObjectExtensions.SuppressChangeNotifications(this); + public IDisposable SuppressChangeNotifications() => // TODO: Create Test + IReactiveObjectExtensions.SuppressChangeNotifications(this); /// /// Determines if change notifications are enabled or not. /// /// A value indicating whether change notifications are enabled. - public bool AreChangeNotificationsEnabled() => IReactiveObjectExtensions.AreChangeNotificationsEnabled(this); + public bool AreChangeNotificationsEnabled() => // TODO: Create Test + IReactiveObjectExtensions.AreChangeNotificationsEnabled(this); /// /// Delays notifications until the return IDisposable is disposed. /// /// A disposable which when disposed will send delayed notifications. - public IDisposable DelayChangeNotifications() => IReactiveObjectExtensions.DelayChangeNotifications(this); + public IDisposable DelayChangeNotifications() => // TODO: Create Test + IReactiveObjectExtensions.DelayChangeNotifications(this); } } diff --git a/src/ReactiveUI/Routing/MessageBus.cs b/src/ReactiveUI/Routing/MessageBus.cs index d5963f1e85..67be2e5515 100644 --- a/src/ReactiveUI/Routing/MessageBus.cs +++ b/src/ReactiveUI/Routing/MessageBus.cs @@ -35,7 +35,7 @@ public class MessageBus : IMessageBus /// /// Gets or sets the Current MessageBus. /// - public static IMessageBus Current { get; set; } = new MessageBus(); + public static IMessageBus Current { get; set; } = new MessageBus(); // TODO: Create Test /// /// Registers a scheduler for the type, which may be specified at runtime, and the contract. @@ -47,7 +47,8 @@ public class MessageBus : IMessageBus /// A unique string to distinguish messages with /// identical types (i.e. "MyCoolViewModel") - if the message type is /// only used for one purpose, leave this as null. - public void RegisterScheduler(IScheduler scheduler, string? contract = null) => _schedulerMappings[(typeof(T), contract)] = scheduler; + public void RegisterScheduler(IScheduler scheduler, string? contract = null) => // TODO: Create Test + _schedulerMappings[(typeof(T), contract)] = scheduler; /// /// Listen provides an Observable that will fire whenever a Message is @@ -76,7 +77,7 @@ public IObservable Listen(string? contract = null) /// only used for one purpose, leave this as null. /// An Observable representing the notifications posted to the /// message bus. - public IObservable ListenIncludeLatest(string? contract = null) + public IObservable ListenIncludeLatest(string? contract = null) // TODO: Create Test { this.Log().Info(CultureInfo.InvariantCulture, "Listening to {0}:{1}", typeof(T), contract); diff --git a/src/ReactiveUI/Routing/RoutingState.cs b/src/ReactiveUI/Routing/RoutingState.cs index e57272308d..98fd954163 100644 --- a/src/ReactiveUI/Routing/RoutingState.cs +++ b/src/ReactiveUI/Routing/RoutingState.cs @@ -109,7 +109,7 @@ public IScheduler Scheduler /// Gets or sets an observable which will signal when the Navigation changes. /// [IgnoreDataMember] - public IObservable> NavigationChanged { get; protected set; } + public IObservable> NavigationChanged { get; protected set; } // TODO: Create Test [OnDeserialized] private void SetupRx(StreamingContext sc) => SetupRx(); diff --git a/src/ReactiveUI/Scheduler/ScheduledSubject.cs b/src/ReactiveUI/Scheduler/ScheduledSubject.cs index e44b621d2f..615bcdfbfa 100644 --- a/src/ReactiveUI/Scheduler/ScheduledSubject.cs +++ b/src/ReactiveUI/Scheduler/ScheduledSubject.cs @@ -50,10 +50,10 @@ public void Dispose() } /// - public void OnCompleted() => _subject.OnCompleted(); + public void OnCompleted() => _subject.OnCompleted(); // TODO: Create Test /// - public void OnError(Exception error) => _subject.OnError(error); + public void OnError(Exception error) => _subject.OnError(error); // TODO: Create Test /// public void OnNext(T value) => _subject.OnNext(value); diff --git a/src/ReactiveUI/Scheduler/WaitForDispatcherScheduler.cs b/src/ReactiveUI/Scheduler/WaitForDispatcherScheduler.cs index 4c6d09af53..aefc7cac4a 100644 --- a/src/ReactiveUI/Scheduler/WaitForDispatcherScheduler.cs +++ b/src/ReactiveUI/Scheduler/WaitForDispatcherScheduler.cs @@ -38,13 +38,16 @@ public WaitForDispatcherScheduler(Func schedulerFactory) public DateTimeOffset Now => AttemptToCreateScheduler().Now; /// - public IDisposable Schedule(TState state, Func action) => AttemptToCreateScheduler().Schedule(state, action); + public IDisposable Schedule(TState state, Func action) => + AttemptToCreateScheduler().Schedule(state, action); /// - public IDisposable Schedule(TState state, TimeSpan dueTime, Func action) => AttemptToCreateScheduler().Schedule(state, dueTime, action); + public IDisposable Schedule(TState state, TimeSpan dueTime, Func action) => // TODO: Create Test + AttemptToCreateScheduler().Schedule(state, dueTime, action); /// - public IDisposable Schedule(TState state, DateTimeOffset dueTime, Func action) => AttemptToCreateScheduler().Schedule(state, dueTime, action); + public IDisposable Schedule(TState state, DateTimeOffset dueTime, Func action) => // TODO: Create Test + AttemptToCreateScheduler().Schedule(state, dueTime, action); private IScheduler AttemptToCreateScheduler() { diff --git a/src/ReactiveUI/Suspension/DummySuspensionDriver.cs b/src/ReactiveUI/Suspension/DummySuspensionDriver.cs index 3fe0edee6b..98b7018050 100644 --- a/src/ReactiveUI/Suspension/DummySuspensionDriver.cs +++ b/src/ReactiveUI/Suspension/DummySuspensionDriver.cs @@ -17,12 +17,15 @@ namespace ReactiveUI public class DummySuspensionDriver : ISuspensionDriver { /// - public IObservable LoadState() => Observable.Default; + public IObservable LoadState() => // TODO: Create Test + Observable.Default; /// - public IObservable SaveState(object state) => Observables.Unit; + public IObservable SaveState(object state) => // TODO: Create Test + Observables.Unit; /// - public IObservable InvalidateState() => Observables.Unit; + public IObservable InvalidateState() => // TODO: Create Test + Observables.Unit; } } diff --git a/src/ReactiveUI/Suspension/SuspensionHost.cs b/src/ReactiveUI/Suspension/SuspensionHost.cs index ab7a055634..58fe6f9700 100644 --- a/src/ReactiveUI/Suspension/SuspensionHost.cs +++ b/src/ReactiveUI/Suspension/SuspensionHost.cs @@ -50,7 +50,7 @@ public SuspensionHost() /// /// Gets or sets a observable which notifies when the application is resuming. /// - public IObservable IsResuming + public IObservable IsResuming // TODO: Create Test { get => _isResuming.Switch(); set => _isResuming.OnNext(value); @@ -59,7 +59,7 @@ public IObservable IsResuming /// /// Gets or sets a observable which notifies when the application is un-pausing. /// - public IObservable IsUnpausing + public IObservable IsUnpausing // TODO: Create Test { get => _isUnpausing.Switch(); set => _isUnpausing.OnNext(value); @@ -68,7 +68,7 @@ public IObservable IsUnpausing /// /// Gets or sets a observable which notifies when the application should persist its state. /// - public IObservable ShouldPersistState + public IObservable ShouldPersistState // TODO: Create Test { get => _shouldPersistState.Switch(); set => _shouldPersistState.OnNext(value); @@ -77,7 +77,7 @@ public IObservable ShouldPersistState /// /// Gets or sets a observable which notifies when a application is launching new. /// - public IObservable IsLaunchingNew + public IObservable IsLaunchingNew // TODO: Create Test { get => _isLaunchingNew.Switch(); set => _isLaunchingNew.OnNext(value); @@ -86,7 +86,7 @@ public IObservable IsLaunchingNew /// /// Gets or sets a observable which notifies when the application state should be invalidated. /// - public IObservable ShouldInvalidateState + public IObservable ShouldInvalidateState // TODO: Create Test { get => _shouldInvalidateState.Switch(); set => _shouldInvalidateState.OnNext(value); diff --git a/src/ReactiveUI/View/DefaultViewLocator.cs b/src/ReactiveUI/View/DefaultViewLocator.cs index ed06f6079c..152ed09184 100644 --- a/src/ReactiveUI/View/DefaultViewLocator.cs +++ b/src/ReactiveUI/View/DefaultViewLocator.cs @@ -21,7 +21,8 @@ public sealed class DefaultViewLocator : IViewLocator /// Initializes a new instance of the class. /// /// The method which will convert a ViewModel name into a View. - internal DefaultViewLocator(Func? viewModelToViewFunc = null) => ViewModelToViewFunc = viewModelToViewFunc ?? (vm => vm.Replace("ViewModel", "View")); + internal DefaultViewLocator(Func? viewModelToViewFunc = null) => + ViewModelToViewFunc = viewModelToViewFunc ?? (vm => vm.Replace("ViewModel", "View")); /// /// Gets or sets a function that is used to convert a view model name to a proposed view name. diff --git a/src/ReactiveUI/View/ViewLocator.cs b/src/ReactiveUI/View/ViewLocator.cs index 87913dbb1e..3bc445652a 100644 --- a/src/ReactiveUI/View/ViewLocator.cs +++ b/src/ReactiveUI/View/ViewLocator.cs @@ -5,7 +5,6 @@ using System; using System.Diagnostics.CodeAnalysis; -using ReactiveUI; using Splat; namespace ReactiveUI