File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -309,8 +309,9 @@ public static (string FieldName, string PropertyName) GetGeneratedFieldAndProper
309
309
{
310
310
string propertyName = methodSymbol . Name ;
311
311
312
- if ( methodSymbol . ReturnType . HasFullyQualifiedName ( "global::System.Threading.Tasks.Task" ) &&
313
- methodSymbol . Name . EndsWith ( "Async" ) )
312
+ if ( methodSymbol . Name . EndsWith ( "Async" ) &&
313
+ ( methodSymbol . ReturnType . HasFullyQualifiedName ( "global::System.Threading.Tasks.Task" ) ||
314
+ methodSymbol . ReturnType . InheritsFromFullyQualifiedName ( "global::System.Threading.Tasks.Task" ) ) )
314
315
{
315
316
propertyName = propertyName . Substring ( 0 , propertyName . Length - "Async" . Length ) ;
316
317
}
@@ -372,7 +373,9 @@ private static bool TryMapCommandTypesFromMethod(
372
373
return true ;
373
374
}
374
375
375
- if ( methodSymbol . ReturnType . HasFullyQualifiedName ( "global::System.Threading.Tasks.Task" ) )
376
+ // Map all Task-returning methods
377
+ if ( methodSymbol . ReturnType . HasFullyQualifiedName ( "global::System.Threading.Tasks.Task" ) ||
378
+ methodSymbol . ReturnType . InheritsFromFullyQualifiedName ( "global::System.Threading.Tasks.Task" ) )
376
379
{
377
380
// Map <void, Task> to IAsyncRelayCommand, AsyncRelayCommand, Func<Task>
378
381
if ( methodSymbol . Parameters . Length == 0 )
Original file line number Diff line number Diff line change @@ -51,11 +51,15 @@ namespace CommunityToolkit.Mvvm.Input;
51
51
/// <code>
52
52
/// Task Method();
53
53
/// Task Method(CancellationToken);
54
+ /// Task<T> Method();
55
+ /// Task<T> Method(CancellationToken);
54
56
/// </code>
55
57
/// Will both generate an <see cref="IAsyncRelayCommand"/> property (using an <see cref="AsyncRelayCommand{T}"/> instance).
56
58
/// <code>
57
59
/// Task Method(T?);
58
60
/// Task Method(T?, CancellationToken);
61
+ /// Task<T> Method(T?);
62
+ /// Task<T> Method(T?, CancellationToken);
59
63
/// </code>
60
64
/// Will both generate an <see cref="IAsyncRelayCommand{T}"/> property (using an <see cref="AsyncRelayCommand{T}"/> instance).
61
65
/// </para>
You can’t perform that action at this time.
0 commit comments