Skip to content

Commit eed8718

Browse files
authored
fix: Correct BindCommand Nullability Annotations (#2745)
* fix: Correct BindCommand nullability annotations * fix: Visual Studio silently inserting new lines
1 parent 740ae1a commit eed8718

8 files changed

+25
-25
lines changed

src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net472.approved.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,27 +68,27 @@ namespace ReactiveUI
6868
}
6969
public static class CommandBinder
7070
{
71-
public static ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl>(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> propertyName, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlName, string? toEvent = null)
71+
public static ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl>(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> propertyName, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlName, string? toEvent = null)
7272
where TView : class, ReactiveUI.IViewFor<TViewModel>
7373
where TViewModel : class
7474
where TProp : System.Windows.Input.ICommand { }
75-
public static ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> propertyName, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlName, System.IObservable<TParam> withParameter, string? toEvent = null)
75+
public static ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> propertyName, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlName, System.IObservable<TParam> withParameter, string? toEvent = null)
7676
where TView : class, ReactiveUI.IViewFor<TViewModel>
7777
where TViewModel : class
7878
where TProp : System.Windows.Input.ICommand { }
79-
public static ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> propertyName, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlName, System.Linq.Expressions.Expression<System.Func<TViewModel, TParam>> withParameter, string? toEvent = null)
79+
public static ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> propertyName, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlName, System.Linq.Expressions.Expression<System.Func<TViewModel, TParam>> withParameter, string? toEvent = null)
8080
where TView : class, ReactiveUI.IViewFor<TViewModel>
8181
where TViewModel : class
8282
where TProp : System.Windows.Input.ICommand { }
8383
}
8484
public class CommandBinderImplementation : Splat.IEnableLogger
8585
{
8686
public CommandBinderImplementation() { }
87-
public ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(TViewModel viewModel, TView view, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> vmProperty, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlProperty, System.Func<TParam> withParameter, string? toEvent = null)
87+
public ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> vmProperty, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlProperty, System.Func<TParam> withParameter, string? toEvent = null)
8888
where TView : class, ReactiveUI.IViewFor<TViewModel>
8989
where TViewModel : class
9090
where TProp : System.Windows.Input.ICommand { }
91-
public ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(TViewModel viewModel, TView view, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> vmProperty, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlProperty, System.IObservable<TParam> withParameter, string? toEvent = null)
91+
public ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> vmProperty, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlProperty, System.IObservable<TParam> withParameter, string? toEvent = null)
9292
where TView : class, ReactiveUI.IViewFor<TViewModel>
9393
where TViewModel : class
9494
where TProp : System.Windows.Input.ICommand { }

src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net5.0.approved.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,27 +70,27 @@ namespace ReactiveUI
7070
}
7171
public static class CommandBinder
7272
{
73-
public static ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl>(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> propertyName, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlName, string? toEvent = null)
73+
public static ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl>(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> propertyName, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlName, string? toEvent = null)
7474
where TView : class, ReactiveUI.IViewFor<TViewModel>
7575
where TViewModel : class
7676
where TProp : System.Windows.Input.ICommand { }
77-
public static ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> propertyName, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlName, System.IObservable<TParam> withParameter, string? toEvent = null)
77+
public static ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> propertyName, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlName, System.IObservable<TParam> withParameter, string? toEvent = null)
7878
where TView : class, ReactiveUI.IViewFor<TViewModel>
7979
where TViewModel : class
8080
where TProp : System.Windows.Input.ICommand { }
81-
public static ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> propertyName, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlName, System.Linq.Expressions.Expression<System.Func<TViewModel, TParam>> withParameter, string? toEvent = null)
81+
public static ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> propertyName, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlName, System.Linq.Expressions.Expression<System.Func<TViewModel, TParam>> withParameter, string? toEvent = null)
8282
where TView : class, ReactiveUI.IViewFor<TViewModel>
8383
where TViewModel : class
8484
where TProp : System.Windows.Input.ICommand { }
8585
}
8686
public class CommandBinderImplementation : Splat.IEnableLogger
8787
{
8888
public CommandBinderImplementation() { }
89-
public ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(TViewModel viewModel, TView view, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> vmProperty, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlProperty, System.Func<TParam> withParameter, string? toEvent = null)
89+
public ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> vmProperty, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlProperty, System.Func<TParam> withParameter, string? toEvent = null)
9090
where TView : class, ReactiveUI.IViewFor<TViewModel>
9191
where TViewModel : class
9292
where TProp : System.Windows.Input.ICommand { }
93-
public ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(TViewModel viewModel, TView view, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> vmProperty, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlProperty, System.IObservable<TParam> withParameter, string? toEvent = null)
93+
public ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> vmProperty, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlProperty, System.IObservable<TParam> withParameter, string? toEvent = null)
9494
where TView : class, ReactiveUI.IViewFor<TViewModel>
9595
where TViewModel : class
9696
where TProp : System.Windows.Input.ICommand { }

src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.netcoreapp3.1.approved.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,27 +68,27 @@ namespace ReactiveUI
6868
}
6969
public static class CommandBinder
7070
{
71-
public static ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl>(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> propertyName, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlName, string? toEvent = null)
71+
public static ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl>(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> propertyName, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlName, string? toEvent = null)
7272
where TView : class, ReactiveUI.IViewFor<TViewModel>
7373
where TViewModel : class
7474
where TProp : System.Windows.Input.ICommand { }
75-
public static ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> propertyName, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlName, System.IObservable<TParam> withParameter, string? toEvent = null)
75+
public static ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> propertyName, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlName, System.IObservable<TParam> withParameter, string? toEvent = null)
7676
where TView : class, ReactiveUI.IViewFor<TViewModel>
7777
where TViewModel : class
7878
where TProp : System.Windows.Input.ICommand { }
79-
public static ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> propertyName, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlName, System.Linq.Expressions.Expression<System.Func<TViewModel, TParam>> withParameter, string? toEvent = null)
79+
public static ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> propertyName, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlName, System.Linq.Expressions.Expression<System.Func<TViewModel, TParam>> withParameter, string? toEvent = null)
8080
where TView : class, ReactiveUI.IViewFor<TViewModel>
8181
where TViewModel : class
8282
where TProp : System.Windows.Input.ICommand { }
8383
}
8484
public class CommandBinderImplementation : Splat.IEnableLogger
8585
{
8686
public CommandBinderImplementation() { }
87-
public ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(TViewModel viewModel, TView view, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> vmProperty, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlProperty, System.Func<TParam> withParameter, string? toEvent = null)
87+
public ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> vmProperty, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlProperty, System.Func<TParam> withParameter, string? toEvent = null)
8888
where TView : class, ReactiveUI.IViewFor<TViewModel>
8989
where TViewModel : class
9090
where TProp : System.Windows.Input.ICommand { }
91-
public ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(TViewModel viewModel, TView view, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> vmProperty, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlProperty, System.IObservable<TParam> withParameter, string? toEvent = null)
91+
public ReactiveUI.IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression<System.Func<TViewModel, TProp>> vmProperty, System.Linq.Expressions.Expression<System.Func<TView, TControl>> controlProperty, System.IObservable<TParam> withParameter, string? toEvent = null)
9292
where TView : class, ReactiveUI.IViewFor<TViewModel>
9393
where TViewModel : class
9494
where TProp : System.Windows.Input.ICommand { }

src/ReactiveUI.Tests/Platforms/wpf/Mocks/FakeXamlCommandBindingView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public FakeXamlCommandBindingView()
2424
{
2525
_buttonDeclaredInXaml = new Button();
2626

27-
this.BindCommand(ViewModel!, vm => vm!.Command2!, v => v._buttonDeclaredInXaml);
27+
this.BindCommand(ViewModel, vm => vm!.Command2!, v => v._buttonDeclaredInXaml);
2828
}
2929

3030
/// <summary>

src/ReactiveUI/Bindings/Command/CommandBinder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static CommandBinder()
4848
/// important to dispose the binding when the view is deactivated.</param>
4949
public static IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(
5050
this TView view,
51-
TViewModel viewModel,
51+
TViewModel? viewModel,
5252
Expression<Func<TViewModel, TProp>> propertyName,
5353
Expression<Func<TView, TControl>> controlName,
5454
IObservable<TParam> withParameter,
@@ -78,7 +78,7 @@ public static IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TPro
7878
/// important to dispose the binding when the view is deactivated.</param>
7979
public static IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl>(
8080
this TView view,
81-
TViewModel viewModel,
81+
TViewModel? viewModel,
8282
Expression<Func<TViewModel, TProp>> propertyName,
8383
Expression<Func<TView, TControl>> controlName,
8484
string? toEvent = null)
@@ -110,7 +110,7 @@ public static IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TPro
110110
/// important to dispose the binding when the view is deactivated.</param>
111111
public static IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(
112112
this TView view,
113-
TViewModel viewModel,
113+
TViewModel? viewModel,
114114
Expression<Func<TViewModel, TProp>> propertyName,
115115
Expression<Func<TView, TControl>> controlName,
116116
Expression<Func<TViewModel, TParam>> withParameter,

src/ReactiveUI/Bindings/Command/CommandBinderImplementation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class CommandBinderImplementation : ICommandBinderImplementation
3838
/// <returns>A class representing the binding. Dispose it to disconnect
3939
/// the binding.</returns>
4040
public IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(
41-
TViewModel viewModel,
41+
TViewModel? viewModel,
4242
TView view,
4343
Expression<Func<TViewModel, TProp>> vmProperty,
4444
Expression<Func<TView, TControl>> controlProperty,
@@ -103,7 +103,7 @@ public IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TCon
103103
/// NOTE: If this parameter is used inside WhenActivated, it's
104104
/// important to dispose the binding when the view is deactivated.</param>
105105
public IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(
106-
TViewModel viewModel,
106+
TViewModel? viewModel,
107107
TView view,
108108
Expression<Func<TViewModel, TProp>> vmProperty,
109109
Expression<Func<TView, TControl>> controlProperty,

src/ReactiveUI/Bindings/Command/CommandBinderImplementationMixins.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ internal static class CommandBinderImplementationMixins
1717
{
1818
public static IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl>(
1919
this ICommandBinderImplementation @this,
20-
TViewModel viewModel,
20+
TViewModel? viewModel,
2121
TView view,
2222
Expression<Func<TViewModel, TProp>> propertyName,
2323
Expression<Func<TView, TControl>> controlName,
@@ -29,7 +29,7 @@ public static IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TPro
2929

3030
public static IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(
3131
this ICommandBinderImplementation @this,
32-
TViewModel viewModel,
32+
TViewModel? viewModel,
3333
TView view,
3434
Expression<Func<TViewModel, TProp>> propertyName,
3535
Expression<Func<TView, TControl>> controlName,

src/ReactiveUI/Bindings/Command/ICommandBinderImplementation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ internal interface ICommandBinderImplementation : IEnableLogger
3131
/// <typeparam name="TParam">The type of the parameter to pass to the ICommand.</typeparam>
3232
/// <returns>A reactive binding. Often only used for disposing the binding.</returns>
3333
IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(
34-
TViewModel viewModel,
34+
TViewModel? viewModel,
3535
TView view,
3636
Expression<Func<TViewModel, TProp>> propertyName,
3737
Expression<Func<TView, TControl>> controlName,
@@ -57,7 +57,7 @@ IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, T
5757
/// <typeparam name="TParam">The type of the parameter to pass to the ICommand.</typeparam>
5858
/// <returns>A reactive binding. Often only used for disposing the binding.</returns>
5959
IReactiveBinding<TView, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(
60-
TViewModel viewModel,
60+
TViewModel? viewModel,
6161
TView view,
6262
Expression<Func<TViewModel, TProp>> propertyName,
6363
Expression<Func<TView, TControl>> controlName,

0 commit comments

Comments
 (0)