@@ -441,6 +441,27 @@ public async Task Test_ICommandAttribute_CancelCommands()
441
441
Assert . IsTrue ( model . Result2 is OperationCanceledException ) ;
442
442
}
443
443
444
+ [ TestMethod ]
445
+ public async Task Test_ICommandAttribute_TaskOfTReturns ( )
446
+ {
447
+ GenericTaskCommands model = new ( ) ;
448
+
449
+ Task greetCommandTask = model . GreetCommand . ExecuteAsync ( null ) ;
450
+ Task greetWithTokenTask = model . GreetWithTokenCommand . ExecuteAsync ( null ) ;
451
+ Task greetWithParamTask = model . GreetWithParamCommand . ExecuteAsync ( null ) ;
452
+ Task greetWithParamAndCommandTask = model . GreetWithParamAndTokenCommand . ExecuteAsync ( null ) ;
453
+
454
+ Assert . IsInstanceOfType ( greetCommandTask , typeof ( Task < string > ) ) ;
455
+ Assert . IsInstanceOfType ( greetWithTokenTask , typeof ( Task < string > ) ) ;
456
+ Assert . IsInstanceOfType ( greetWithParamTask , typeof ( Task < string > ) ) ;
457
+ Assert . IsInstanceOfType ( greetWithParamAndCommandTask , typeof ( Task < string > ) ) ;
458
+
459
+ Assert . AreEqual ( "Hello world" , await ( Task < string > ) greetCommandTask ) ;
460
+ Assert . AreEqual ( "Hello world" , await ( Task < string > ) greetWithTokenTask ) ;
461
+ Assert . AreEqual ( "Hello world" , await ( Task < string > ) greetWithParamTask ) ;
462
+ Assert . AreEqual ( "Hello world" , await ( Task < string > ) greetWithParamAndCommandTask ) ;
463
+ }
464
+
444
465
#region Region
445
466
public class Region
446
467
{
@@ -731,4 +752,39 @@ private async Task DoWorkWithParameterAsync(int number, CancellationToken token)
731
752
}
732
753
}
733
754
}
755
+
756
+ public partial class GenericTaskCommands
757
+ {
758
+ [ ICommand ]
759
+ private async Task < string > GreetAsync ( )
760
+ {
761
+ await Task . Yield ( ) ;
762
+
763
+ return "Hello world" ;
764
+ }
765
+
766
+ [ ICommand ]
767
+ private async Task < string > GreetWithTokenAsync ( CancellationToken token )
768
+ {
769
+ await Task . Yield ( ) ;
770
+
771
+ return "Hello world" ;
772
+ }
773
+
774
+ [ ICommand ]
775
+ private async Task < string > GreetWithParamAsync ( object _ )
776
+ {
777
+ await Task . Yield ( ) ;
778
+
779
+ return "Hello world" ;
780
+ }
781
+
782
+ [ ICommand ]
783
+ private async Task < string > GreetWithParamAndTokenAsync ( object _ , CancellationToken token )
784
+ {
785
+ await Task . Yield ( ) ;
786
+
787
+ return "Hello world" ;
788
+ }
789
+ }
734
790
}
0 commit comments