From 0bf0ba11ae52f491c1d6196597580ce98633f8fa Mon Sep 17 00:00:00 2001 From: Artjom Graf Date: Sun, 2 May 2021 01:24:40 +0300 Subject: [PATCH 1/2] fix: Correct BindCommand nullability annotations --- .../ApiApprovalTests.ReactiveUI.net472.approved.txt | 12 ++++++------ .../ApiApprovalTests.ReactiveUI.net5.0.approved.txt | 12 ++++++------ ...provalTests.ReactiveUI.netcoreapp3.1.approved.txt | 12 ++++++------ .../wpf/Mocks/FakeXamlCommandBindingView.cs | 2 +- src/ReactiveUI/Bindings/Command/CommandBinder.cs | 6 +++--- .../Bindings/Command/CommandBinderImplementation.cs | 4 ++-- .../Command/CommandBinderImplementationMixins.cs | 4 ++-- .../Bindings/Command/ICommandBinderImplementation.cs | 4 ++-- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net472.approved.txt b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net472.approved.txt index c1e244b05b..e0cbcaaedf 100644 --- a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net472.approved.txt +++ b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net472.approved.txt @@ -68,15 +68,15 @@ namespace ReactiveUI } public static class CommandBinder { - public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, string? toEvent = null) + public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, string? toEvent = null) where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } - public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, System.IObservable withParameter, string? toEvent = null) + public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, System.IObservable withParameter, string? toEvent = null) where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } - public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, System.Linq.Expressions.Expression> withParameter, string? toEvent = null) + public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, System.Linq.Expressions.Expression> withParameter, string? toEvent = null) where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } @@ -84,11 +84,11 @@ namespace ReactiveUI public class CommandBinderImplementation : Splat.IEnableLogger { public CommandBinderImplementation() { } - public ReactiveUI.IReactiveBinding BindCommand(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> controlProperty, System.Func withParameter, string? toEvent = null) + public ReactiveUI.IReactiveBinding BindCommand(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> controlProperty, System.Func withParameter, string? toEvent = null) where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } - public ReactiveUI.IReactiveBinding BindCommand(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> controlProperty, System.IObservable withParameter, string? toEvent = null) + public ReactiveUI.IReactiveBinding BindCommand(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> controlProperty, System.IObservable withParameter, string? toEvent = null) where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } @@ -901,4 +901,4 @@ namespace System.Reactive.Disposables public static T DisposeWith(this T item, System.Reactive.Disposables.CompositeDisposable compositeDisposable) where T : System.IDisposable { } } -} \ No newline at end of file +} 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 3154b3f96c..1e5fb266bd 100644 --- a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net5.0.approved.txt +++ b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net5.0.approved.txt @@ -70,15 +70,15 @@ namespace ReactiveUI } public static class CommandBinder { - public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, string? toEvent = null) + public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, string? toEvent = null) where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } - public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, System.IObservable withParameter, string? toEvent = null) + public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, System.IObservable withParameter, string? toEvent = null) where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } - public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, System.Linq.Expressions.Expression> withParameter, string? toEvent = null) + public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, System.Linq.Expressions.Expression> withParameter, string? toEvent = null) where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } @@ -86,11 +86,11 @@ namespace ReactiveUI public class CommandBinderImplementation : Splat.IEnableLogger { public CommandBinderImplementation() { } - public ReactiveUI.IReactiveBinding BindCommand(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> controlProperty, System.Func withParameter, string? toEvent = null) + public ReactiveUI.IReactiveBinding BindCommand(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> controlProperty, System.Func withParameter, string? toEvent = null) where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } - public ReactiveUI.IReactiveBinding BindCommand(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> controlProperty, System.IObservable withParameter, string? toEvent = null) + public ReactiveUI.IReactiveBinding BindCommand(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> controlProperty, System.IObservable withParameter, string? toEvent = null) where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } @@ -896,4 +896,4 @@ namespace System.Reactive.Disposables public static T DisposeWith(this T item, System.Reactive.Disposables.CompositeDisposable compositeDisposable) where T : System.IDisposable { } } -} \ No newline at end of file +} 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 0ca16ef123..d308d0e79e 100644 --- a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.netcoreapp3.1.approved.txt +++ b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.netcoreapp3.1.approved.txt @@ -68,15 +68,15 @@ namespace ReactiveUI } public static class CommandBinder { - public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, string? toEvent = null) + public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, string? toEvent = null) where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } - public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, System.IObservable withParameter, string? toEvent = null) + public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, System.IObservable withParameter, string? toEvent = null) where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } - public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, System.Linq.Expressions.Expression> withParameter, string? toEvent = null) + public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, System.Linq.Expressions.Expression> withParameter, string? toEvent = null) where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } @@ -84,11 +84,11 @@ namespace ReactiveUI public class CommandBinderImplementation : Splat.IEnableLogger { public CommandBinderImplementation() { } - public ReactiveUI.IReactiveBinding BindCommand(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> controlProperty, System.Func withParameter, string? toEvent = null) + public ReactiveUI.IReactiveBinding BindCommand(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> controlProperty, System.Func withParameter, string? toEvent = null) where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } - public ReactiveUI.IReactiveBinding BindCommand(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> controlProperty, System.IObservable withParameter, string? toEvent = null) + public ReactiveUI.IReactiveBinding BindCommand(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> controlProperty, System.IObservable withParameter, string? toEvent = null) where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } @@ -894,4 +894,4 @@ namespace System.Reactive.Disposables public static T DisposeWith(this T item, System.Reactive.Disposables.CompositeDisposable compositeDisposable) where T : System.IDisposable { } } -} \ No newline at end of file +} diff --git a/src/ReactiveUI.Tests/Platforms/wpf/Mocks/FakeXamlCommandBindingView.cs b/src/ReactiveUI.Tests/Platforms/wpf/Mocks/FakeXamlCommandBindingView.cs index b6854eeda9..234f988f0c 100644 --- a/src/ReactiveUI.Tests/Platforms/wpf/Mocks/FakeXamlCommandBindingView.cs +++ b/src/ReactiveUI.Tests/Platforms/wpf/Mocks/FakeXamlCommandBindingView.cs @@ -24,7 +24,7 @@ public FakeXamlCommandBindingView() { _buttonDeclaredInXaml = new Button(); - this.BindCommand(ViewModel!, vm => vm!.Command2!, v => v._buttonDeclaredInXaml); + this.BindCommand(ViewModel, vm => vm!.Command2!, v => v._buttonDeclaredInXaml); } /// diff --git a/src/ReactiveUI/Bindings/Command/CommandBinder.cs b/src/ReactiveUI/Bindings/Command/CommandBinder.cs index fbe6ea0912..d53349f596 100644 --- a/src/ReactiveUI/Bindings/Command/CommandBinder.cs +++ b/src/ReactiveUI/Bindings/Command/CommandBinder.cs @@ -48,7 +48,7 @@ static CommandBinder() /// important to dispose the binding when the view is deactivated. public static IReactiveBinding BindCommand( this TView view, - TViewModel viewModel, + TViewModel? viewModel, Expression> propertyName, Expression> controlName, IObservable withParameter, @@ -78,7 +78,7 @@ public static IReactiveBinding BindCommand public static IReactiveBinding BindCommand( this TView view, - TViewModel viewModel, + TViewModel? viewModel, Expression> propertyName, Expression> controlName, string? toEvent = null) @@ -110,7 +110,7 @@ public static IReactiveBinding BindCommand public static IReactiveBinding BindCommand( this TView view, - TViewModel viewModel, + TViewModel? viewModel, Expression> propertyName, Expression> controlName, Expression> withParameter, diff --git a/src/ReactiveUI/Bindings/Command/CommandBinderImplementation.cs b/src/ReactiveUI/Bindings/Command/CommandBinderImplementation.cs index 094e073491..b80db1dd2b 100644 --- a/src/ReactiveUI/Bindings/Command/CommandBinderImplementation.cs +++ b/src/ReactiveUI/Bindings/Command/CommandBinderImplementation.cs @@ -38,7 +38,7 @@ public class CommandBinderImplementation : ICommandBinderImplementation /// A class representing the binding. Dispose it to disconnect /// the binding. public IReactiveBinding BindCommand( - TViewModel viewModel, + TViewModel? viewModel, TView view, Expression> vmProperty, Expression> controlProperty, @@ -103,7 +103,7 @@ public IReactiveBinding BindCommand public IReactiveBinding BindCommand( - TViewModel viewModel, + TViewModel? viewModel, TView view, Expression> vmProperty, Expression> controlProperty, diff --git a/src/ReactiveUI/Bindings/Command/CommandBinderImplementationMixins.cs b/src/ReactiveUI/Bindings/Command/CommandBinderImplementationMixins.cs index 1d513cc15b..27a49b45d9 100644 --- a/src/ReactiveUI/Bindings/Command/CommandBinderImplementationMixins.cs +++ b/src/ReactiveUI/Bindings/Command/CommandBinderImplementationMixins.cs @@ -17,7 +17,7 @@ internal static class CommandBinderImplementationMixins { public static IReactiveBinding BindCommand( this ICommandBinderImplementation @this, - TViewModel viewModel, + TViewModel? viewModel, TView view, Expression> propertyName, Expression> controlName, @@ -29,7 +29,7 @@ public static IReactiveBinding BindCommand BindCommand( this ICommandBinderImplementation @this, - TViewModel viewModel, + TViewModel? viewModel, TView view, Expression> propertyName, Expression> controlName, diff --git a/src/ReactiveUI/Bindings/Command/ICommandBinderImplementation.cs b/src/ReactiveUI/Bindings/Command/ICommandBinderImplementation.cs index e070a47f34..eb36d5ca7a 100644 --- a/src/ReactiveUI/Bindings/Command/ICommandBinderImplementation.cs +++ b/src/ReactiveUI/Bindings/Command/ICommandBinderImplementation.cs @@ -31,7 +31,7 @@ internal interface ICommandBinderImplementation : IEnableLogger /// The type of the parameter to pass to the ICommand. /// A reactive binding. Often only used for disposing the binding. IReactiveBinding BindCommand( - TViewModel viewModel, + TViewModel? viewModel, TView view, Expression> propertyName, Expression> controlName, @@ -57,7 +57,7 @@ IReactiveBinding BindCommandThe type of the parameter to pass to the ICommand. /// A reactive binding. Often only used for disposing the binding. IReactiveBinding BindCommand( - TViewModel viewModel, + TViewModel? viewModel, TView view, Expression> propertyName, Expression> controlName, From 2b124a14bc7ff021657a198a55745f752c64af1f Mon Sep 17 00:00:00 2001 From: Artjom Graf Date: Sun, 2 May 2021 01:50:56 +0300 Subject: [PATCH 2/2] fix: Visual Studio silently inserting new lines --- .../API/ApiApprovalTests.ReactiveUI.net472.approved.txt | 2 +- .../API/ApiApprovalTests.ReactiveUI.net5.0.approved.txt | 2 +- .../API/ApiApprovalTests.ReactiveUI.netcoreapp3.1.approved.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net472.approved.txt b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net472.approved.txt index e0cbcaaedf..d4a511ec6d 100644 --- a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net472.approved.txt +++ b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net472.approved.txt @@ -901,4 +901,4 @@ namespace System.Reactive.Disposables public static T DisposeWith(this T item, System.Reactive.Disposables.CompositeDisposable compositeDisposable) where T : System.IDisposable { } } -} +} \ No newline at end of file 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 1e5fb266bd..bd6ceac01d 100644 --- a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net5.0.approved.txt +++ b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net5.0.approved.txt @@ -896,4 +896,4 @@ namespace System.Reactive.Disposables public static T DisposeWith(this T item, System.Reactive.Disposables.CompositeDisposable compositeDisposable) where T : System.IDisposable { } } -} +} \ No newline at end of file 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 d308d0e79e..20ce1ee2ca 100644 --- a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.netcoreapp3.1.approved.txt +++ b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.netcoreapp3.1.approved.txt @@ -894,4 +894,4 @@ namespace System.Reactive.Disposables public static T DisposeWith(this T item, System.Reactive.Disposables.CompositeDisposable compositeDisposable) where T : System.IDisposable { } } -} +} \ No newline at end of file