@@ -19,17 +19,17 @@ public sealed class AsyncRelayCommand<T> : ObservableObject, IAsyncRelayCommand<
1919 /// <summary>
2020 /// The <see cref="Func{TResult}"/> to invoke when <see cref="Execute(T)"/> is used.
2121 /// </summary>
22- private readonly Func < T , Task > ? execute ;
22+ private readonly Func < T ? , Task > ? execute ;
2323
2424 /// <summary>
2525 /// The cancelable <see cref="Func{T1,T2,TResult}"/> to invoke when <see cref="Execute(object?)"/> is used.
2626 /// </summary>
27- private readonly Func < T , CancellationToken , Task > ? cancelableExecute ;
27+ private readonly Func < T ? , CancellationToken , Task > ? cancelableExecute ;
2828
2929 /// <summary>
3030 /// The optional action to invoke when <see cref="CanExecute(T)"/> is used.
3131 /// </summary>
32- private readonly Predicate < T > ? canExecute ;
32+ private readonly Predicate < T ? > ? canExecute ;
3333
3434 /// <summary>
3535 /// The <see cref="CancellationTokenSource"/> instance to use to cancel <see cref="cancelableExecute"/>.
@@ -44,7 +44,7 @@ public sealed class AsyncRelayCommand<T> : ObservableObject, IAsyncRelayCommand<
4444 /// </summary>
4545 /// <param name="execute">The execution logic.</param>
4646 /// <remarks>See notes in <see cref="RelayCommand{T}(Action{T})"/>.</remarks>
47- public AsyncRelayCommand ( Func < T , Task > execute )
47+ public AsyncRelayCommand ( Func < T ? , Task > execute )
4848 {
4949 this . execute = execute ;
5050 }
@@ -54,7 +54,7 @@ public AsyncRelayCommand(Func<T, Task> execute)
5454 /// </summary>
5555 /// <param name="cancelableExecute">The cancelable execution logic.</param>
5656 /// <remarks>See notes in <see cref="RelayCommand{T}(Action{T})"/>.</remarks>
57- public AsyncRelayCommand ( Func < T , CancellationToken , Task > cancelableExecute )
57+ public AsyncRelayCommand ( Func < T ? , CancellationToken , Task > cancelableExecute )
5858 {
5959 this . cancelableExecute = cancelableExecute ;
6060 }
@@ -65,7 +65,7 @@ public AsyncRelayCommand(Func<T, CancellationToken, Task> cancelableExecute)
6565 /// <param name="execute">The execution logic.</param>
6666 /// <param name="canExecute">The execution status logic.</param>
6767 /// <remarks>See notes in <see cref="RelayCommand{T}(Action{T})"/>.</remarks>
68- public AsyncRelayCommand ( Func < T , Task > execute , Predicate < T > canExecute )
68+ public AsyncRelayCommand ( Func < T ? , Task > execute , Predicate < T ? > canExecute )
6969 {
7070 this . execute = execute ;
7171 this . canExecute = canExecute ;
@@ -77,7 +77,7 @@ public AsyncRelayCommand(Func<T, Task> execute, Predicate<T> canExecute)
7777 /// <param name="cancelableExecute">The cancelable execution logic.</param>
7878 /// <param name="canExecute">The execution status logic.</param>
7979 /// <remarks>See notes in <see cref="RelayCommand{T}(Action{T})"/>.</remarks>
80- public AsyncRelayCommand ( Func < T , CancellationToken , Task > cancelableExecute , Predicate < T > canExecute )
80+ public AsyncRelayCommand ( Func < T ? , CancellationToken , Task > cancelableExecute , Predicate < T ? > canExecute )
8181 {
8282 this . cancelableExecute = cancelableExecute ;
8383 this . canExecute = canExecute ;
@@ -106,7 +106,7 @@ private set
106106 }
107107
108108 /// <inheritdoc/>
109- public bool CanBeCanceled => ! ( this . cancelableExecute is null ) && IsRunning ;
109+ public bool CanBeCanceled => this . cancelableExecute is not null && IsRunning ;
110110
111111 /// <inheritdoc/>
112112 public bool IsCancellationRequested => this . cancellationTokenSource ? . IsCancellationRequested == true ;
@@ -122,7 +122,7 @@ public void NotifyCanExecuteChanged()
122122
123123 /// <inheritdoc/>
124124 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
125- public bool CanExecute ( T parameter )
125+ public bool CanExecute ( T ? parameter )
126126 {
127127 return this . canExecute ? . Invoke ( parameter ) != false ;
128128 }
@@ -138,29 +138,29 @@ parameter is null &&
138138 return true ;
139139 }
140140
141- return CanExecute ( ( T ) parameter ! ) ;
141+ return CanExecute ( ( T ? ) parameter ) ;
142142 }
143143
144144 /// <inheritdoc/>
145145 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
146- public void Execute ( T parameter )
146+ public void Execute ( T ? parameter )
147147 {
148148 ExecuteAsync ( parameter ) ;
149149 }
150150
151151 /// <inheritdoc/>
152152 public void Execute ( object ? parameter )
153153 {
154- ExecuteAsync ( ( T ) parameter ! ) ;
154+ ExecuteAsync ( ( T ? ) parameter ) ;
155155 }
156156
157157 /// <inheritdoc/>
158- public Task ExecuteAsync ( T parameter )
158+ public Task ExecuteAsync ( T ? parameter )
159159 {
160160 if ( CanExecute ( parameter ) )
161161 {
162162 // Non cancelable command delegate
163- if ( ! ( this . execute is null ) )
163+ if ( this . execute is not null )
164164 {
165165 return ExecutionTask = this . execute ( parameter ) ;
166166 }
@@ -182,7 +182,7 @@ public Task ExecuteAsync(T parameter)
182182 /// <inheritdoc/>
183183 public Task ExecuteAsync ( object ? parameter )
184184 {
185- return ExecuteAsync ( ( T ) parameter ! ) ;
185+ return ExecuteAsync ( ( T ? ) parameter ) ;
186186 }
187187
188188 /// <inheritdoc/>
0 commit comments