44using System . Diagnostics ;
55using System . Reflection ;
66using System . Runtime . InteropServices ;
7+ using System . Runtime . Versioning ;
78using System . Threading ;
89using System . Threading . Tasks ;
910
@@ -19,6 +20,7 @@ public static partial class AsyncHelpers
1920 // It will not capture/restore any local state that is live across it.
2021 [ BypassReadyToRun ]
2122 [ MethodImpl ( MethodImplOptions . NoInlining | MethodImplOptions . Async ) ]
23+ [ RequiresPreviewFeatures ]
2224 public static void AwaitAwaiter < TAwaiter > ( TAwaiter awaiter ) where TAwaiter : INotifyCompletion
2325 {
2426 ref AsyncHelpers . RuntimeAsyncAwaitState state = ref AsyncHelpers . t_runtimeAsyncAwaitState ;
@@ -34,6 +36,7 @@ public static void AwaitAwaiter<TAwaiter>(TAwaiter awaiter) where TAwaiter : INo
3436 // It will not capture/restore any local state that is live across it.
3537 [ BypassReadyToRun ]
3638 [ MethodImpl ( MethodImplOptions . NoInlining | MethodImplOptions . Async ) ]
39+ [ RequiresPreviewFeatures ]
3740 public static void UnsafeAwaitAwaiter < TAwaiter > ( TAwaiter awaiter ) where TAwaiter : ICriticalNotifyCompletion
3841 {
3942 ref AsyncHelpers . RuntimeAsyncAwaitState state = ref AsyncHelpers . t_runtimeAsyncAwaitState ;
@@ -48,6 +51,7 @@ public static void UnsafeAwaitAwaiter<TAwaiter>(TAwaiter awaiter) where TAwaiter
4851 [ Intrinsic ]
4952 [ BypassReadyToRun ]
5053 [ MethodImpl ( MethodImplOptions . Async ) ]
54+ [ RequiresPreviewFeatures ]
5155 public static T Await < T > ( Task < T > task )
5256 {
5357 TaskAwaiter < T > awaiter = task . GetAwaiter ( ) ;
@@ -62,6 +66,7 @@ public static T Await<T>(Task<T> task)
6266 [ Intrinsic ]
6367 [ BypassReadyToRun ]
6468 [ MethodImpl ( MethodImplOptions . Async ) ]
69+ [ RequiresPreviewFeatures ]
6570 public static void Await ( Task task )
6671 {
6772 TaskAwaiter awaiter = task . GetAwaiter ( ) ;
@@ -76,6 +81,7 @@ public static void Await(Task task)
7681 [ Intrinsic ]
7782 [ BypassReadyToRun ]
7883 [ MethodImpl ( MethodImplOptions . Async ) ]
84+ [ RequiresPreviewFeatures ]
7985 public static T Await < T > ( ValueTask < T > task )
8086 {
8187 ValueTaskAwaiter < T > awaiter = task . GetAwaiter ( ) ;
@@ -90,6 +96,7 @@ public static T Await<T>(ValueTask<T> task)
9096 [ Intrinsic ]
9197 [ BypassReadyToRun ]
9298 [ MethodImpl ( MethodImplOptions . Async ) ]
99+ [ RequiresPreviewFeatures ]
93100 public static void Await ( ValueTask task )
94101 {
95102 ValueTaskAwaiter awaiter = task . GetAwaiter ( ) ;
@@ -104,6 +111,7 @@ public static void Await(ValueTask task)
104111 [ Intrinsic ]
105112 [ BypassReadyToRun ]
106113 [ MethodImpl ( MethodImplOptions . Async ) ]
114+ [ RequiresPreviewFeatures ]
107115 public static void Await ( ConfiguredTaskAwaitable configuredAwaitable )
108116 {
109117 ConfiguredTaskAwaitable . ConfiguredTaskAwaiter awaiter = configuredAwaitable . GetAwaiter ( ) ;
@@ -118,6 +126,7 @@ public static void Await(ConfiguredTaskAwaitable configuredAwaitable)
118126 [ Intrinsic ]
119127 [ BypassReadyToRun ]
120128 [ MethodImpl ( MethodImplOptions . Async ) ]
129+ [ RequiresPreviewFeatures ]
121130 public static void Await ( ConfiguredValueTaskAwaitable configuredAwaitable )
122131 {
123132 ConfiguredValueTaskAwaitable . ConfiguredValueTaskAwaiter awaiter = configuredAwaitable . GetAwaiter ( ) ;
@@ -132,6 +141,7 @@ public static void Await(ConfiguredValueTaskAwaitable configuredAwaitable)
132141 [ Intrinsic ]
133142 [ BypassReadyToRun ]
134143 [ MethodImpl ( MethodImplOptions . Async ) ]
144+ [ RequiresPreviewFeatures ]
135145 public static T Await < T > ( ConfiguredTaskAwaitable < T > configuredAwaitable )
136146 {
137147 ConfiguredTaskAwaitable < T > . ConfiguredTaskAwaiter awaiter = configuredAwaitable . GetAwaiter ( ) ;
@@ -146,6 +156,7 @@ public static T Await<T>(ConfiguredTaskAwaitable<T> configuredAwaitable)
146156 [ Intrinsic ]
147157 [ BypassReadyToRun ]
148158 [ MethodImpl ( MethodImplOptions . Async ) ]
159+ [ RequiresPreviewFeatures ]
149160 public static T Await < T > ( ConfiguredValueTaskAwaitable < T > configuredAwaitable )
150161 {
151162 ConfiguredValueTaskAwaitable < T > . ConfiguredValueTaskAwaiter awaiter = configuredAwaitable . GetAwaiter ( ) ;
@@ -157,15 +168,25 @@ public static T Await<T>(ConfiguredValueTaskAwaitable<T> configuredAwaitable)
157168 return awaiter . GetResult ( ) ;
158169 }
159170#else
171+ [ RequiresPreviewFeatures ]
160172 public static void UnsafeAwaitAwaiter < TAwaiter > ( TAwaiter awaiter ) where TAwaiter : ICriticalNotifyCompletion { throw new NotImplementedException ( ) ; }
173+ [ RequiresPreviewFeatures ]
161174 public static void AwaitAwaiter < TAwaiter > ( TAwaiter awaiter ) where TAwaiter : INotifyCompletion { throw new NotImplementedException ( ) ; }
175+ [ RequiresPreviewFeatures ]
162176 public static void Await ( System . Threading . Tasks . Task task ) { throw new NotImplementedException ( ) ; }
177+ [ RequiresPreviewFeatures ]
163178 public static T Await < T > ( System . Threading . Tasks . Task < T > task ) { throw new NotImplementedException ( ) ; }
179+ [ RequiresPreviewFeatures ]
164180 public static void Await ( System . Threading . Tasks . ValueTask task ) { throw new NotImplementedException ( ) ; }
181+ [ RequiresPreviewFeatures ]
165182 public static T Await < T > ( System . Threading . Tasks . ValueTask < T > task ) { throw new NotImplementedException ( ) ; }
183+ [ RequiresPreviewFeatures ]
166184 public static void Await ( System . Runtime . CompilerServices . ConfiguredTaskAwaitable configuredAwaitable ) { throw new NotImplementedException ( ) ; }
185+ [ RequiresPreviewFeatures ]
167186 public static void Await ( System . Runtime . CompilerServices . ConfiguredValueTaskAwaitable configuredAwaitable ) { throw new NotImplementedException ( ) ; }
187+ [ RequiresPreviewFeatures ]
168188 public static T Await < T > ( System . Runtime . CompilerServices . ConfiguredTaskAwaitable < T > configuredAwaitable ) { throw new NotImplementedException ( ) ; }
189+ [ RequiresPreviewFeatures ]
169190 public static T Await < T > ( System . Runtime . CompilerServices . ConfiguredValueTaskAwaitable < T > configuredAwaitable ) { throw new NotImplementedException ( ) ; }
170191#endif
171192 }
0 commit comments