2 using System
.Reflection
;
3 using System
.Threading
.Tasks
;
4 using System
.Runtime
.CompilerServices
;
11 public static async Task
<int> AsyncMethod ()
17 public static async Task
NestedAsyncAnonymousMethod ()
19 Action a
= async delegate {
26 public static int Main ()
28 var m
= typeof (C
).GetMethod ("AsyncMethod");
29 var attr
= m
.GetCustomAttribute
<AsyncStateMachineAttribute
> ();
33 if (attr
.StateMachineType
== null)
36 Func
<Task
<int>> a
= async () => await AsyncMethod ();
38 var c
= typeof (C
).GetMethods (BindingFlags
.NonPublic
| BindingFlags
.Static
).Where (l
=>
39 l
.IsDefined (typeof (AsyncStateMachineAttribute
))).Count ();
45 m
= typeof (C
).GetMethod ("NestedAsyncAnonymousMethod");
46 attr
= m
.GetCustomAttribute
<AsyncStateMachineAttribute
> ();
50 if (attr
.StateMachineType
== null)
53 var n
= typeof (C
).GetNestedTypes (BindingFlags
.NonPublic
).Single (l
=> l
.Name
.Contains ("NestedAsyncAnonymousMethod"));
57 m
= n
.GetMethods (BindingFlags
.NonPublic
| BindingFlags
.Static
).Single (l
=> l
.Name
.Contains ("m__"));
59 attr
= m
.GetCustomAttribute
<AsyncStateMachineAttribute
> ();
63 if (attr
.StateMachineType
== null)