Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / test-async-83.cs
1 using System;
2 using System.Threading.Tasks;
3
4 class MainClass
5 {
6         public static int Main ()
7         {
8                 var t = GetSomeStrings (null);
9                 try {
10                         var s = t.Result;
11                         return 1;
12                 } catch (AggregateException e) {
13                         if (e.InnerException is NullReferenceException)
14                                 return 0;
15
16                         return 2;
17                 }
18         }
19
20         public static async Task<string> GetSomeStrings (AsyncStringFactory myFactory)
21         {
22                 var res = await myFactory?.GetSomeStringAsync ();
23                 return res;
24         }
25 }
26
27 public class AsyncStringFactory
28 {
29         public async Task<string> GetSomeStringAsync ()
30         {
31                 await Task.Yield();
32                 return "foo";
33         }
34 }