diff --git a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.DotNet6_0.verified.txt b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.DotNet6_0.verified.txt index 72ceb2ac70..63c4473be6 100644 --- a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.DotNet6_0.verified.txt +++ b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.DotNet6_0.verified.txt @@ -81,15 +81,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) - where TView : class, ReactiveUI.IViewFor + 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) - where TView : class, ReactiveUI.IViewFor + 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) - where TView : class, ReactiveUI.IViewFor + where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } } @@ -97,11 +97,11 @@ namespace ReactiveUI { public CommandBinderImplementation() { } 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 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.Linq.Expressions.Expression> withParameter, string? toEvent = null) - where TView : class, ReactiveUI.IViewFor + where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } } diff --git a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.DotNet7_0.verified.txt b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.DotNet7_0.verified.txt index 7ba5eb2379..89ea095473 100644 --- a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.DotNet7_0.verified.txt +++ b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.DotNet7_0.verified.txt @@ -81,15 +81,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) - where TView : class, ReactiveUI.IViewFor + 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) - where TView : class, ReactiveUI.IViewFor + 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) - where TView : class, ReactiveUI.IViewFor + where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } } @@ -97,11 +97,11 @@ namespace ReactiveUI { public CommandBinderImplementation() { } 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 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.Linq.Expressions.Expression> withParameter, string? toEvent = null) - where TView : class, ReactiveUI.IViewFor + where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } } diff --git a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.DotNet8_0.verified.txt b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.DotNet8_0.verified.txt index 5e64bd4d15..3f36840f15 100644 --- a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.DotNet8_0.verified.txt +++ b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.DotNet8_0.verified.txt @@ -81,15 +81,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) - where TView : class, ReactiveUI.IViewFor + 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) - where TView : class, ReactiveUI.IViewFor + 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) - where TView : class, ReactiveUI.IViewFor + where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } } @@ -97,11 +97,11 @@ namespace ReactiveUI { public CommandBinderImplementation() { } 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 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.Linq.Expressions.Expression> withParameter, string? toEvent = null) - where TView : class, ReactiveUI.IViewFor + where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } } diff --git a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.Net4_7.verified.txt b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.Net4_7.verified.txt index 8bf6d33d37..a08268e9a0 100644 --- a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.Net4_7.verified.txt +++ b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.Net4_7.verified.txt @@ -79,15 +79,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) - where TView : class, ReactiveUI.IViewFor + 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) - where TView : class, ReactiveUI.IViewFor + 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) - where TView : class, ReactiveUI.IViewFor + where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } } @@ -95,11 +95,11 @@ namespace ReactiveUI { public CommandBinderImplementation() { } 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 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.Linq.Expressions.Expression> withParameter, string? toEvent = null) - where TView : class, ReactiveUI.IViewFor + where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } } diff --git a/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.DotNet6_0.verified.txt b/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.DotNet6_0.verified.txt index af951628a1..5d90003771 100644 --- a/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.DotNet6_0.verified.txt +++ b/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.DotNet6_0.verified.txt @@ -32,6 +32,11 @@ namespace ReactiveUI.Winforms public PlatformOperations() { } public string? GetOrientation() { } } + public class ReactiveUserControlNonGeneric : System.Windows.Forms.UserControl, ReactiveUI.IActivatableView, ReactiveUI.IViewFor + { + public ReactiveUserControlNonGeneric() { } + protected override void Dispose(bool disposing) { } + } public class ReactiveUserControl : System.Windows.Forms.UserControl, ReactiveUI.IActivatableView, ReactiveUI.IViewFor, ReactiveUI.IViewFor where TViewModel : class { diff --git a/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.DotNet7_0.verified.txt b/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.DotNet7_0.verified.txt index e576e83488..f8bac7dbb5 100644 --- a/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.DotNet7_0.verified.txt +++ b/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.DotNet7_0.verified.txt @@ -32,6 +32,11 @@ namespace ReactiveUI.Winforms public PlatformOperations() { } public string? GetOrientation() { } } + public class ReactiveUserControlNonGeneric : System.Windows.Forms.UserControl, ReactiveUI.IActivatableView, ReactiveUI.IViewFor + { + public ReactiveUserControlNonGeneric() { } + protected override void Dispose(bool disposing) { } + } public class ReactiveUserControl : System.Windows.Forms.UserControl, ReactiveUI.IActivatableView, ReactiveUI.IViewFor, ReactiveUI.IViewFor where TViewModel : class { diff --git a/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.DotNet8_0.verified.txt b/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.DotNet8_0.verified.txt index ee964cd932..32abdea373 100644 --- a/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.DotNet8_0.verified.txt +++ b/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.DotNet8_0.verified.txt @@ -32,6 +32,11 @@ namespace ReactiveUI.Winforms public PlatformOperations() { } public string? GetOrientation() { } } + public class ReactiveUserControlNonGeneric : System.Windows.Forms.UserControl, ReactiveUI.IActivatableView, ReactiveUI.IViewFor + { + public ReactiveUserControlNonGeneric() { } + protected override void Dispose(bool disposing) { } + } public class ReactiveUserControl : System.Windows.Forms.UserControl, ReactiveUI.IActivatableView, ReactiveUI.IViewFor, ReactiveUI.IViewFor where TViewModel : class { diff --git a/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.Net4_7.verified.txt b/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.Net4_7.verified.txt index 92e5468102..3b64ac1766 100644 --- a/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.Net4_7.verified.txt +++ b/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.Net4_7.verified.txt @@ -30,6 +30,11 @@ namespace ReactiveUI.Winforms public PlatformOperations() { } public string? GetOrientation() { } } + public class ReactiveUserControlNonGeneric : System.Windows.Forms.UserControl, ReactiveUI.IActivatableView, ReactiveUI.IViewFor + { + public ReactiveUserControlNonGeneric() { } + protected override void Dispose(bool disposing) { } + } public class ReactiveUserControl : System.Windows.Forms.UserControl, ReactiveUI.IActivatableView, ReactiveUI.IViewFor, ReactiveUI.IViewFor where TViewModel : class { diff --git a/src/ReactiveUI.Winforms/ReactiveUserControlNonGeneric.Designer.cs b/src/ReactiveUI.Winforms/ReactiveUserControlNonGeneric.Designer.cs new file mode 100644 index 0000000000..7648d0a303 --- /dev/null +++ b/src/ReactiveUI.Winforms/ReactiveUserControlNonGeneric.Designer.cs @@ -0,0 +1,23 @@ +namespace ReactiveUI.Winforms; + +partial class ReactiveUserControlNonGeneric +{ + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + } + + #endregion +} diff --git a/src/ReactiveUI.Winforms/ReactiveUserControlNonGeneric.cs b/src/ReactiveUI.Winforms/ReactiveUserControlNonGeneric.cs new file mode 100644 index 0000000000..0431b26499 --- /dev/null +++ b/src/ReactiveUI.Winforms/ReactiveUserControlNonGeneric.cs @@ -0,0 +1,39 @@ +// Copyright (c) 2023 .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.Windows.Forms; + +namespace ReactiveUI.Winforms; + +/// +/// This is an UserControl that is both and UserControl and has a ReactiveObject powers +/// (i.e. you can call RaiseAndSetIfChanged). +/// +/// +/// +public partial class ReactiveUserControlNonGeneric : UserControl, IViewFor +{ + /// + /// Initializes a new instance of the class. + /// + public ReactiveUserControlNonGeneric() => InitializeComponent(); + + /// + object? IViewFor.ViewModel { get; set; } + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing) + { + components?.Dispose(); + } + + base.Dispose(disposing); + } +} diff --git a/src/ReactiveUI/Bindings/Command/CommandBinder.cs b/src/ReactiveUI/Bindings/Command/CommandBinder.cs index 241e0c7145..9d278a66fc 100644 --- a/src/ReactiveUI/Bindings/Command/CommandBinder.cs +++ b/src/ReactiveUI/Bindings/Command/CommandBinder.cs @@ -50,7 +50,7 @@ static CommandBinder() Expression> controlName, IObservable withParameter, string? toEvent = null) - where TView : class, IViewFor + where TView : class, IViewFor where TViewModel : class where TProp : ICommand => _binderImplementation.BindCommand(viewModel, view, propertyName, controlName, withParameter, toEvent); @@ -79,7 +79,7 @@ static CommandBinder() Expression> propertyName, Expression> controlName, string? toEvent = null) - where TView : class, IViewFor + where TView : class, IViewFor where TViewModel : class where TProp : ICommand => _binderImplementation.BindCommand(viewModel, view, propertyName, controlName, toEvent); @@ -112,7 +112,7 @@ static CommandBinder() Expression> controlName, Expression> withParameter, string? toEvent = null) - where TView : class, IViewFor + where TView : class, IViewFor where TViewModel : class where TProp : ICommand { diff --git a/src/ReactiveUI/Bindings/Command/CommandBinderImplementation.cs b/src/ReactiveUI/Bindings/Command/CommandBinderImplementation.cs index 2cf6e67b8d..43ab0692bc 100644 --- a/src/ReactiveUI/Bindings/Command/CommandBinderImplementation.cs +++ b/src/ReactiveUI/Bindings/Command/CommandBinderImplementation.cs @@ -45,7 +45,7 @@ public class CommandBinderImplementation : ICommandBinderImplementation Expression> controlProperty, Expression> withParameter, string? toEvent = null) - where TView : class, IViewFor + where TView : class, IViewFor where TViewModel : class where TProp : ICommand { @@ -102,7 +102,7 @@ public class CommandBinderImplementation : ICommandBinderImplementation Expression> controlProperty, IObservable withParameter, string? toEvent = null) - where TView : class, IViewFor + where TView : class, IViewFor where TViewModel : class where TProp : ICommand { diff --git a/src/ReactiveUI/Bindings/Command/CommandBinderImplementationMixins.cs b/src/ReactiveUI/Bindings/Command/CommandBinderImplementationMixins.cs index 25a1e6b5d5..5223efea68 100644 --- a/src/ReactiveUI/Bindings/Command/CommandBinderImplementationMixins.cs +++ b/src/ReactiveUI/Bindings/Command/CommandBinderImplementationMixins.cs @@ -19,7 +19,7 @@ internal static class CommandBinderImplementationMixins Expression> propertyName, Expression> controlName, string? toEvent = null) - where TView : class, IViewFor + where TView : class, IViewFor where TViewModel : class where TProp : ICommand => @this.BindCommand(viewModel, view, propertyName, controlName, Observable.Empty, toEvent); @@ -32,7 +32,7 @@ internal static class CommandBinderImplementationMixins Expression> controlName, Expression> withParameter, string? toEvent = null) - where TView : class, IViewFor + where TView : class, IViewFor where TViewModel : class where TProp : ICommand { @@ -46,4 +46,4 @@ internal static class CommandBinderImplementationMixins return @this.BindCommand(viewModel, view, propertyName, controlName, param, toEvent); } -} \ No newline at end of file +} diff --git a/src/ReactiveUI/Bindings/Command/CreatesCommandBinding.cs b/src/ReactiveUI/Bindings/Command/CreatesCommandBinding.cs index 33b2fe978d..15f7cb04b8 100644 --- a/src/ReactiveUI/Bindings/Command/CreatesCommandBinding.cs +++ b/src/ReactiveUI/Bindings/Command/CreatesCommandBinding.cs @@ -35,42 +35,20 @@ internal class CreatesCommandBinding public static IDisposable BindCommandToObject(ICommand? command, object? target, IObservable commandParameter) { var type = target!.GetType(); - var binder = _bindCommandCache.Get(type); - if (binder is null) - { - throw new Exception($"Couldn't find a Command Binder for {type.FullName}"); - } - - var ret = binder.BindCommandToObject(command, target, commandParameter); - if (ret is null) - { - throw new Exception($"Couldn't bind Command Binder for {type.FullName}"); - } - + var binder = _bindCommandCache.Get(type) ?? throw new Exception($"Couldn't find a Command Binder for {type.FullName}"); + var ret = binder.BindCommandToObject(command, target, commandParameter) ?? throw new Exception($"Couldn't bind Command Binder for {type.FullName}"); return ret; } public static IDisposable BindCommandToObject(ICommand? command, object? target, IObservable commandParameter, string? eventName) { var type = target!.GetType(); - var binder = _bindCommandEventCache.Get(type); - if (binder is null) - { - throw new Exception($"Couldn't find an Event Binder for {type.FullName} and event {eventName}"); - } - + var binder = _bindCommandEventCache.Get(type) ?? throw new Exception($"Couldn't find an Event Binder for {type.FullName} and event {eventName}"); var eventArgsType = Reflection.GetEventArgsTypeForEvent(type, eventName); var mi = binder.GetType().GetTypeInfo().DeclaredMethods.First(x => x.Name == "BindCommandToObject" && x.IsGenericMethod); mi = mi.MakeGenericMethod(eventArgsType); - var ret = (IDisposable)mi.Invoke(binder, [command, target, commandParameter, eventName])!; - - // If we made it this far then this will not fail. - if (ret is null) - { - throw new Exception($"Couldn't bind Command Binder for {type.FullName} and event {eventName}"); - } - + var ret = (IDisposable)mi.Invoke(binder, [command, target, commandParameter, eventName])! ?? throw new Exception($"Couldn't bind Command Binder for {type.FullName} and event {eventName}"); return ret; } } diff --git a/src/ReactiveUI/Bindings/Command/CreatesCommandBindingViaEvent.cs b/src/ReactiveUI/Bindings/Command/CreatesCommandBindingViaEvent.cs index 2b853c029d..9cbe49e38d 100644 --- a/src/ReactiveUI/Bindings/Command/CreatesCommandBindingViaEvent.cs +++ b/src/ReactiveUI/Bindings/Command/CreatesCommandBindingViaEvent.cs @@ -55,14 +55,8 @@ public int GetAffinityForObject(Type type, bool hasEventTarget) var type = target.GetType(); var eventInfo = _defaultEventsToBind .Select(x => new { EventInfo = type.GetRuntimeEvent(x.name), Args = x.type }) - .FirstOrDefault(x => x.EventInfo is not null); - - if (eventInfo is null) - { - throw new Exception( + .FirstOrDefault(x => x.EventInfo is not null) ?? throw new Exception( $"Couldn't find a default event to bind to on {target.GetType().FullName}, specify an event explicitly"); - } - var mi = GetType().GetRuntimeMethods().First(x => x.Name == "BindCommandToObject" && x.IsGenericMethod); mi = mi.MakeGenericMethod(eventInfo.Args); diff --git a/src/ReactiveUI/Bindings/Command/ICommandBinderImplementation.cs b/src/ReactiveUI/Bindings/Command/ICommandBinderImplementation.cs index 650c06eeb4..db1c8f074d 100644 --- a/src/ReactiveUI/Bindings/Command/ICommandBinderImplementation.cs +++ b/src/ReactiveUI/Bindings/Command/ICommandBinderImplementation.cs @@ -34,7 +34,7 @@ internal interface ICommandBinderImplementation : IEnableLogger Expression> controlProperty, Expression> withParameter, string? toEvent = null) - where TView : class, IViewFor + where TView : class, IViewFor where TViewModel : class where TProp : ICommand; @@ -60,7 +60,7 @@ internal interface ICommandBinderImplementation : IEnableLogger Expression> controlProperty, IObservable withParameter, string? toEvent = null) - where TView : class, IViewFor + where TView : class, IViewFor where TViewModel : class where TProp : ICommand; -} \ No newline at end of file +}