Skip to content

Commit 3f965b2

Browse files
committed
Fixed NRE when calling CanExecute(null) over value types
1 parent 3773226 commit 3f965b2

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

Microsoft.Toolkit.Mvvm/Input/AsyncRelayCommand{T}.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,9 @@ public bool CanExecute(T? parameter)
132132
public bool CanExecute(object? parameter)
133133
{
134134
if (default(T) is not null &&
135-
parameter is null &&
136-
this.canExecute is null)
135+
parameter is null)
137136
{
138-
return true;
137+
return false;
139138
}
140139

141140
return CanExecute((T?)parameter);

Microsoft.Toolkit.Mvvm/Input/RelayCommand{T}.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,9 @@ public bool CanExecute(T? parameter)
7777
public bool CanExecute(object? parameter)
7878
{
7979
if (default(T) is not null &&
80-
parameter is null &&
81-
this.canExecute is null)
80+
parameter is null)
8281
{
83-
return true;
82+
return false;
8483
}
8584

8685
return CanExecute((T?)parameter);

0 commit comments

Comments
 (0)