Overview
Sometimes we are forced to put a name to a method (for repeated name with other methods) that it is not "ideal" to put as the generated command name. It will be preferrable to be able to set the name of the command manually.
This brings more control to the developer even to name the methods as they want.
API breakdown
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public sealed class RelayCommandAttribute : Attribute
{
public string? Name { get; init; } //--> If null or whitespace, default behaviour
public string? CanExecute { get; init; }
public bool AllowConcurrentExecutions { get; init; }
public bool FlowExceptionsToTaskScheduler { get; init; }
public bool IncludeCancelCommand { get; init; }
}
Usage example
[RelayCommand(Name = "SaveProject", CanExecute = nameof(CanSaveProject), IncludeCancelCommand = true)]
private async Task SaveProjectPrivateAsync(T? projectViewModel, CancellationToken cancellationToken = default);
protected virtual bool CanSaveProject(T? projectViewModel);
Breaking change?
No
Alternatives
Nothing.
Additional context
No response
Help us help you
No, just wanted to propose this