From 2601e59713e448d70ea5d2a6774492a5b529fc13 Mon Sep 17 00:00:00 2001 From: Maksym Koshovyi Date: Fri, 29 Jan 2021 15:24:23 +0200 Subject: [PATCH 1/2] Make Create overloads for Command consistent with overloads for other command types --- .../CommandFactory_Command_Tests.cs | 37 +++++-- .../CommandFactory.Command.shared.cs | 99 ++++++++++++++++--- .../CommandFactory.IAsyncCommand.shared.cs | 80 +++++++-------- ...ommandFactory.IAsyncValueCommand.shared.cs | 32 +++--- 4 files changed, 168 insertions(+), 80 deletions(-) diff --git a/src/CommunityToolkit/Xamarin.CommunityToolkit.UnitTests/ObjectModel/ICommandTests/CommandFactoryTests/CommandFactory_Command_Tests.cs b/src/CommunityToolkit/Xamarin.CommunityToolkit.UnitTests/ObjectModel/ICommandTests/CommandFactoryTests/CommandFactory_Command_Tests.cs index b6e4f48d4..4d98c5e89 100644 --- a/src/CommunityToolkit/Xamarin.CommunityToolkit.UnitTests/ObjectModel/ICommandTests/CommandFactoryTests/CommandFactory_Command_Tests.cs +++ b/src/CommunityToolkit/Xamarin.CommunityToolkit.UnitTests/ObjectModel/ICommandTests/CommandFactoryTests/CommandFactory_Command_Tests.cs @@ -42,18 +42,19 @@ public void Action_ValidExecuteParameter() public void Action_NullCanExecuteParameter() { // Arrange + Func canExecute = null; // Act // Assert - Assert.Throws(() => CommandFactory.Create(NoParameterAction, null)); + Assert.Throws(() => CommandFactory.Create(NoParameterAction, canExecute)); } [Fact] public void Action_ValidCanExecuteParameter() { // Arrange - var command = CommandFactory.Create(NoParameterAction, CanExecuteTrue); + var command = CommandFactory.Create(NoParameterAction, () => true); // Act command.Execute(null); @@ -83,7 +84,7 @@ public void ActionObject_NullExecuteParameter() public void ActionObject_ValidExecuteParameter() { // Arrange - var command = CommandFactory.Create(ObjectParameterAction); + var command = CommandFactory.Create(ObjectParameterAction); // Act command.Execute(null); @@ -105,14 +106,14 @@ public void ActionObject_NullCanExecuteParameter() // Act // Assert - Assert.Throws(() => CommandFactory.Create(ObjectParameterAction, null)); + Assert.Throws(() => CommandFactory.Create(ObjectParameterAction, null)); } [Fact] public void ActionObject_ValidCanExecuteParameter() { // Arrange - var command = CommandFactory.Create(ObjectParameterAction, _ => true); + var command = CommandFactory.Create(ObjectParameterAction, _ => true); // Act command.Execute(1); @@ -137,25 +138,26 @@ public void ActionInt_NullExecuteParameter() // Act // Assert - Assert.Throws(() => CommandFactory.Create(execute, CanExecuteTrue)); + Assert.Throws(() => CommandFactory.Create(execute, () => true)); } [Fact] public void ActionInt_NullCanExecuteParameter() { // Arrange + Func canExecute = null; // Act // Assert - Assert.Throws(() => CommandFactory.Create(IntParameterAction, null)); + Assert.Throws(() => CommandFactory.Create(IntParameterAction, canExecute)); } [Fact] public void ActionInt_ValidCanExecuteParameter() { // Arrange - var command = CommandFactory.Create(IntParameterAction, CanExecuteTrue); + var command = CommandFactory.Create(IntParameterAction, CanExecuteTrue); // Act @@ -164,8 +166,25 @@ public void ActionInt_ValidCanExecuteParameter() Assert.False(command.CanExecute(null)); Assert.False(command.CanExecute(string.Empty)); - Assert.IsType>(command); + Assert.IsType(command); Assert.IsAssignableFrom(command); } + + [Fact] + public void ActionInt_ValidExecuteParameter() + { + // Arrange + var executeResult = -1; + var executeParameter = 0; + var command = CommandFactory.Create(parameter => executeResult = parameter); + + // Act + command.Execute(executeParameter); + command.Execute(null); + command.Execute(string.Empty); + + // Assert + Assert.Equal(executeParameter, executeResult); + } } } \ No newline at end of file diff --git a/src/CommunityToolkit/Xamarin.CommunityToolkit/ObjectModel/CommandFactory.Command.shared.cs b/src/CommunityToolkit/Xamarin.CommunityToolkit/ObjectModel/CommandFactory.Command.shared.cs index 1d3ac9f22..d33e90947 100644 --- a/src/CommunityToolkit/Xamarin.CommunityToolkit/ObjectModel/CommandFactory.Command.shared.cs +++ b/src/CommunityToolkit/Xamarin.CommunityToolkit/ObjectModel/CommandFactory.Command.shared.cs @@ -1,4 +1,5 @@ using System; +using System.Reflection; using Xamarin.Forms; namespace Xamarin.CommunityToolkit.ObjectModel @@ -20,6 +21,16 @@ public static Command Create(Action execute) => /// Initializes Xamarin.Forms.Command /// /// The Function executed when Execute is called. This does not check canExecute before executing and will execute even if canExecute is false + /// The Function that verifies whether or not Command should execute. + /// Xamarin.Forms.Command + public static Command Create(Action execute, Func canExecute) => + new Command(ConvertExecute(execute), canExecute); + + /// + /// Initializes Xamarin.Forms.Command + /// + /// The Function executed when Execute is called. This does not check canExecute before executing and will execute even if canExecute is false + /// The Function that verifies whether or not Command should execute. /// Xamarin.Forms.Command public static Command Create(Action execute, Func canExecute) => new Command(execute, canExecute); @@ -29,31 +40,95 @@ public static Command Create(Action execute, Func canExecute) => /// /// The Function executed when Execute is called. This does not check canExecute before executing and will execute even if canExecute is false /// Xamarin.Forms.Command - public static Command Create(Action execute) => - new Command(execute); + public static Command Create(Action execute) => + new Command(ConvertExecute(execute)); /// /// Initializes Xamarin.Forms.Command /// /// The Function executed when Execute is called. This does not check canExecute before executing and will execute even if canExecute is false + /// The Function that verifies whether or not Command should execute. /// Xamarin.Forms.Command - public static Command Create(Action execute, Func canExecute) => - new Command(execute, canExecute); + public static Command Create(Action execute, Func canExecute) => + new Command(ConvertExecute(execute), canExecute); /// - /// Initializes Xamarin.Forms.Command + /// Initializes Xamarin.Forms.Command /// /// The Function executed when Execute is called. This does not check canExecute before executing and will execute even if canExecute is false - /// Xamarin.Forms.Command - public static Command Create(Action execute) => - new Command(execute); + /// The Function that verifies whether or not Command should execute. + /// Xamarin.Forms.Command + public static Command Create(Action execute, Func canExecute) => + new Command(ConvertExecute(execute), ConvertCanExecute(canExecute)); /// - /// Initializes Xamarin.Forms.Command + /// Initializes Xamarin.Forms.Command /// /// The Function executed when Execute is called. This does not check canExecute before executing and will execute even if canExecute is false - /// Xamarin.Forms.Command - public static Command Create(Action execute, Func canExecute) => - new Command(execute, canExecute); + /// The Function that verifies whether or not Command should execute. + /// Xamarin.Forms.Command + public static Command Create(Action execute, Func canExecute) => + new Command(ConvertExecute(execute), ConvertCanExecute(canExecute)); + + #region Helper methods to ensure Command behaviour is consistent with other commands + + static Action ConvertExecute(Action execute) + { + if (execute == null) + return null; + + return p => execute(); + } + + static Action ConvertExecute(Action execute) + { + if (execute == null) + return null; + + return p => Execute(execute, p); + } + + static void Execute(Action execute, object parameter) + { + switch (parameter) + { + case T validParameter: + execute(validParameter); + break; + + case null when !typeof(T).GetTypeInfo().IsValueType: + execute((T)parameter); + break; + + case null: + default: + return; + } + } + + static Func ConvertCanExecute(Func canExecute) + { + if (canExecute == null) + return null; + + return _ => canExecute(); + } + + static Func ConvertCanExecute(Func canExecute) + { + if (canExecute == null) + return null; + + return p => CanExecute(canExecute, p); + } + + static bool CanExecute(Func canExecute, object parameter) => parameter switch + { + T validParameter => canExecute(validParameter), + null when !typeof(T).GetTypeInfo().IsValueType => canExecute((T)parameter), + _ => false, + }; + + #endregion } } diff --git a/src/CommunityToolkit/Xamarin.CommunityToolkit/ObjectModel/CommandFactory.IAsyncCommand.shared.cs b/src/CommunityToolkit/Xamarin.CommunityToolkit/ObjectModel/CommandFactory.IAsyncCommand.shared.cs index 40276897c..307b8c826 100644 --- a/src/CommunityToolkit/Xamarin.CommunityToolkit/ObjectModel/CommandFactory.IAsyncCommand.shared.cs +++ b/src/CommunityToolkit/Xamarin.CommunityToolkit/ObjectModel/CommandFactory.IAsyncCommand.shared.cs @@ -11,151 +11,145 @@ public partial class CommandFactory /// /// Initializes a new instance of IAsyncCommand /// - /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false + /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false /// The Function that verifies whether or not AsyncCommand should execute. /// If an exception is thrown in the Task, onException will execute. If onException is null, the exception will be re-thrown /// If set to true continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to false continue on a different context; this will allow the Synchronization Context to continue on a different thread /// IAsyncCommand public static IAsyncCommand Create( - Func execute, + Func executeTask, Func canExecute = null, Action onException = null, bool continueOnCapturedContext = false, bool allowsMultipleExecutions = true) => - new AsyncCommand(execute, canExecute, onException, continueOnCapturedContext, allowsMultipleExecutions); + new AsyncCommand(executeTask, canExecute, onException, continueOnCapturedContext, allowsMultipleExecutions); /// /// Initializes a new instance of IAsyncCommand /// - /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false + /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false /// The Function that verifies whether or not AsyncCommand should execute. /// If an exception is thrown in the Task, onException will execute. If onException is null, the exception will be re-thrown /// If set to true continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to false continue on a different context; this will allow the Synchronization Context to continue on a different thread /// IAsyncCommand public static IAsyncCommand Create( - Func execute, + Func executeTask, Func canExecute, Action onException = null, bool continueOnCapturedContext = false, bool allowsMultipleExecutions = true) => - new AsyncCommand(execute, canExecute, onException, continueOnCapturedContext, allowsMultipleExecutions); + new AsyncCommand(executeTask, canExecute, onException, continueOnCapturedContext, allowsMultipleExecutions); /// /// Initializes a new instance of IAsyncCommand /// - /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false + /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false /// The Function that verifies whether or not AsyncCommand should execute. /// If an exception is thrown in the Task, onException will execute. If onException is null, the exception will be re-thrown /// If set to true continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to false continue on a different context; this will allow the Synchronization Context to continue on a different thread /// IAsyncCommand public static IAsyncCommand Create( - Func execute, + Func executeTask, Func canExecute = null, Action onException = null, bool continueOnCapturedContext = false, bool allowsMultipleExecutions = true) => - new AsyncCommand(execute, canExecute, onException, continueOnCapturedContext, allowsMultipleExecutions); + new AsyncCommand(executeTask, canExecute, onException, continueOnCapturedContext, allowsMultipleExecutions); /// /// Initializes a new instance of IAsyncCommand /// - /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false + /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false /// The Function that verifies whether or not AsyncCommand should execute. /// If an exception is thrown in the Task, onException will execute. If onException is null, the exception will be re-thrown /// If set to true continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to false continue on a different context; this will allow the Synchronization Context to continue on a different thread /// IAsyncCommand public static IAsyncCommand Create( - Func execute, + Func executeTask, Func canExecute, Action onException = null, bool continueOnCapturedContext = false, bool allowsMultipleExecutions = true) => - new AsyncCommand(execute, canExecute, onException, continueOnCapturedContext, allowsMultipleExecutions); + new AsyncCommand(executeTask, canExecute, onException, continueOnCapturedContext, allowsMultipleExecutions); /// /// Initializes a new instance of IAsyncCommand /// - /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false + /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false /// The Function that verifies whether or not AsyncCommand should execute. /// If an exception is thrown in the Task, onException will execute. If onException is null, the exception will be re-thrown /// If set to true continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to false continue on a different context; this will allow the Synchronization Context to continue on a different thread /// IAsyncCommand public static IAsyncCommand Create( - Func execute, - Func canExecute = null, + Func executeTask, + Func canExecute, Action onException = null, bool continueOnCapturedContext = false, bool allowsMultipleExecutions = true) => - new AsyncCommand(execute, canExecute, onException, continueOnCapturedContext, allowsMultipleExecutions); + new AsyncCommand(executeTask, canExecute, onException, continueOnCapturedContext, allowsMultipleExecutions); #region Helper Methods to Prevent Ambiguous Method Error When Using Anonymous Async Methods /// /// Initializes a new instance of IAsyncCommand /// - /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false + /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false /// IAsyncCommand - public static IAsyncCommand Create(Func execute) - { - Func canExecute = null; - return Create(execute, canExecute, null, false, true); - } + public static IAsyncCommand Create(Func executeTask) => + Create(executeTask, (Func)null, null, false, true); /// /// Initializes a new instance of IAsyncCommand /// - /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false + /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false /// The Function that verifies whether or not AsyncCommand should execute. /// IAsyncCommand - public static IAsyncCommand Create(Func execute, Func canExecute) => - Create(execute, canExecute, null, false, true); + public static IAsyncCommand Create(Func executeTask, Func canExecute) => + Create(executeTask, canExecute, null, false, true); /// /// Initializes a new instance of IAsyncCommand /// - /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false + /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false /// The Function that verifies whether or not AsyncCommand should execute. /// IAsyncCommand - public static IAsyncCommand Create(Func execute, Func canExecute) => - Create(execute, canExecute, null, false, true); + public static IAsyncCommand Create(Func executeTask, Func canExecute) => + Create(executeTask, canExecute, null, false, true); /// /// Initializes a new instance of IAsyncCommand /// - /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false + /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false /// IAsyncCommand - public static IAsyncCommand Create(Func execute) - { - Func canExecute = null; - return Create(execute, canExecute, null, false, true); - } + public static IAsyncCommand Create(Func executeTask) => + Create(executeTask, (Func)null, null, false, true); /// /// Initializes a new instance of IAsyncCommand /// - /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false + /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false /// The Function that verifies whether or not AsyncCommand should execute. /// IAsyncCommand - public static IAsyncCommand Create(Func execute, Func canExecute) => - Create(execute, canExecute, null, false, true); + public static IAsyncCommand Create(Func executeTask, Func canExecute) => + Create(executeTask, canExecute, null, false, true); /// /// Initializes a new instance of IAsyncCommand /// - /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false + /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false /// The Function that verifies whether or not AsyncCommand should execute. /// IAsyncCommand - public static IAsyncCommand Create(Func execute, Func canExecute) => - Create(execute, canExecute, null, false, true); + public static IAsyncCommand Create(Func executeTask, Func canExecute) => + Create(executeTask, canExecute, null, false, true); /// /// Initializes a new instance of IAsyncCommand /// - /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false + /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false /// The Function that verifies whether or not AsyncCommand should execute. /// IAsyncCommand - public static IAsyncCommand Create(Func execute, Func canExecute) => - Create(execute, canExecute, null, false, true); + public static IAsyncCommand Create(Func executeTask, Func canExecute) => + Create(executeTask, canExecute, null, false, true); #endregion } } diff --git a/src/CommunityToolkit/Xamarin.CommunityToolkit/ObjectModel/CommandFactory.IAsyncValueCommand.shared.cs b/src/CommunityToolkit/Xamarin.CommunityToolkit/ObjectModel/CommandFactory.IAsyncValueCommand.shared.cs index b237836cf..852e9d83d 100644 --- a/src/CommunityToolkit/Xamarin.CommunityToolkit/ObjectModel/CommandFactory.IAsyncValueCommand.shared.cs +++ b/src/CommunityToolkit/Xamarin.CommunityToolkit/ObjectModel/CommandFactory.IAsyncValueCommand.shared.cs @@ -11,81 +11,81 @@ public partial class CommandFactory /// /// Initializes a new instance of AsyncValueCommand /// - /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false + /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false /// The Function that verifies whether or not AsyncCommand should execute. /// If an exception is thrown in the Task, onException will execute. If onException is null, the exception will be re-thrown /// If set to true continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to false continue on a different context; this will allow the Synchronization Context to continue on a different thread /// IAsyncValueCommand public static IAsyncValueCommand Create( - Func execute, + Func executeValueTask, Func canExecute = null, Action onException = null, bool continueOnCapturedContext = false, bool allowsMultipleExecutions = true) => - new AsyncValueCommand(execute, canExecute, onException, continueOnCapturedContext, allowsMultipleExecutions); + new AsyncValueCommand(executeValueTask, canExecute, onException, continueOnCapturedContext, allowsMultipleExecutions); /// /// Initializes a new instance of AsyncValueCommand /// - /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false + /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false /// The Function that verifies whether or not AsyncCommand should execute. /// If an exception is thrown in the Task, onException will execute. If onException is null, the exception will be re-thrown /// If set to true continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to false continue on a different context; this will allow the Synchronization Context to continue on a different thread /// IAsyncValueCommand public static IAsyncValueCommand Create( - Func execute, + Func executeValueTask, Func canExecute, Action onException = null, bool continueOnCapturedContext = false, bool allowsMultipleExecutions = true) => - new AsyncValueCommand(execute, canExecute, onException, continueOnCapturedContext, allowsMultipleExecutions); + new AsyncValueCommand(executeValueTask, canExecute, onException, continueOnCapturedContext, allowsMultipleExecutions); /// /// Initializes a new instance of AsyncValueCommand /// - /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false + /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false /// The Function that verifies whether or not AsyncCommand should execute. /// If an exception is thrown in the Task, onException will execute. If onException is null, the exception will be re-thrown /// If set to true continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to false continue on a different context; this will allow the Synchronization Context to continue on a different thread /// IAsyncValueCommand public static IAsyncValueCommand Create( - Func execute, + Func executeValueTask, Func canExecute = null, Action onException = null, bool continueOnCapturedContext = false, bool allowsMultipleExecutions = true) => - new AsyncValueCommand(execute, canExecute, onException, continueOnCapturedContext, allowsMultipleExecutions); + new AsyncValueCommand(executeValueTask, canExecute, onException, continueOnCapturedContext, allowsMultipleExecutions); /// /// Initializes a new instance of AsyncValueCommand /// - /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false + /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false /// The Function that verifies whether or not AsyncCommand should execute. /// If an exception is thrown in the Task, onException will execute. If onException is null, the exception will be re-thrown /// If set to true continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to false continue on a different context; this will allow the Synchronization Context to continue on a different thread /// IAsyncValueCommand public static IAsyncValueCommand Create( - Func execute, + Func executeValueTask, Func canExecute, Action onException = null, bool continueOnCapturedContext = false, bool allowsMultipleExecutions = true) => - new AsyncValueCommand(execute, canExecute, onException, continueOnCapturedContext, allowsMultipleExecutions); + new AsyncValueCommand(executeValueTask, canExecute, onException, continueOnCapturedContext, allowsMultipleExecutions); /// /// Initializes a new instance of AsyncValueCommand /// - /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false + /// The Function executed when Execute or ExecuteAsync is called. This does not check canExecute before executing and will execute even if canExecute is false /// The Function that verifies whether or not AsyncCommand should execute. /// If an exception is thrown in the Task, onException will execute. If onException is null, the exception will be re-thrown /// If set to true continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to false continue on a different context; this will allow the Synchronization Context to continue on a different thread /// IAsyncValueCommand> public static IAsyncValueCommand Create( - Func execute, - Func canExecute = null, + Func executeValueTask, + Func canExecute, Action onException = null, bool continueOnCapturedContext = false, bool allowsMultipleExecutions = true) => - new AsyncValueCommand(execute, canExecute, onException, continueOnCapturedContext, allowsMultipleExecutions); + new AsyncValueCommand(executeValueTask, canExecute, onException, continueOnCapturedContext, allowsMultipleExecutions); } } From ef2ce7030d9427fb8badc69e49e109dac059b15f Mon Sep 17 00:00:00 2001 From: Maksym Koshovyi Date: Fri, 29 Jan 2021 15:56:39 +0200 Subject: [PATCH 2/2] Return Command in one case --- .../CommandFactoryTests/CommandFactory_Command_Tests.cs | 2 +- .../ObjectModel/CommandFactory.Command.shared.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/CommunityToolkit/Xamarin.CommunityToolkit.UnitTests/ObjectModel/ICommandTests/CommandFactoryTests/CommandFactory_Command_Tests.cs b/src/CommunityToolkit/Xamarin.CommunityToolkit.UnitTests/ObjectModel/ICommandTests/CommandFactoryTests/CommandFactory_Command_Tests.cs index 4d98c5e89..499ef8826 100644 --- a/src/CommunityToolkit/Xamarin.CommunityToolkit.UnitTests/ObjectModel/ICommandTests/CommandFactoryTests/CommandFactory_Command_Tests.cs +++ b/src/CommunityToolkit/Xamarin.CommunityToolkit.UnitTests/ObjectModel/ICommandTests/CommandFactoryTests/CommandFactory_Command_Tests.cs @@ -94,7 +94,7 @@ public void ActionObject_ValidExecuteParameter() Assert.True(command.CanExecute(string.Empty)); Assert.True(command.CanExecute(0)); - Assert.IsType(command); + Assert.IsType>(command); Assert.IsAssignableFrom(command); } diff --git a/src/CommunityToolkit/Xamarin.CommunityToolkit/ObjectModel/CommandFactory.Command.shared.cs b/src/CommunityToolkit/Xamarin.CommunityToolkit/ObjectModel/CommandFactory.Command.shared.cs index d33e90947..20f0b0b58 100644 --- a/src/CommunityToolkit/Xamarin.CommunityToolkit/ObjectModel/CommandFactory.Command.shared.cs +++ b/src/CommunityToolkit/Xamarin.CommunityToolkit/ObjectModel/CommandFactory.Command.shared.cs @@ -36,12 +36,12 @@ public static Command Create(Action execute, Func canExecute) => new Command(execute, canExecute); /// - /// Initializes Xamarin.Forms.Command + /// Initializes Xamarin.Forms.Command /// /// The Function executed when Execute is called. This does not check canExecute before executing and will execute even if canExecute is false - /// Xamarin.Forms.Command - public static Command Create(Action execute) => - new Command(ConvertExecute(execute)); + /// Xamarin.Forms.Command + public static Command Create(Action execute) => + new Command(execute); /// /// Initializes Xamarin.Forms.Command