diff --git a/NuGet.config b/NuGet.config
index b8539443065853..240b4807a1aa17 100644
--- a/NuGet.config
+++ b/NuGet.config
@@ -19,6 +19,8 @@
+
+
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.cs
index 238b7b42c06dc4..83c3cd0698b55b 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.cs
@@ -4,6 +4,7 @@
using System.Diagnostics;
using System.Reflection;
using System.Runtime.InteropServices;
+using System.Runtime.Versioning;
using System.Threading;
using System.Threading.Tasks;
@@ -19,6 +20,7 @@ public static partial class AsyncHelpers
// It will not capture/restore any local state that is live across it.
[BypassReadyToRun]
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)]
+ [RequiresPreviewFeatures]
public static void AwaitAwaiter(TAwaiter awaiter) where TAwaiter : INotifyCompletion
{
ref AsyncHelpers.RuntimeAsyncAwaitState state = ref AsyncHelpers.t_runtimeAsyncAwaitState;
@@ -34,6 +36,7 @@ public static void AwaitAwaiter(TAwaiter awaiter) where TAwaiter : INo
// It will not capture/restore any local state that is live across it.
[BypassReadyToRun]
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)]
+ [RequiresPreviewFeatures]
public static void UnsafeAwaitAwaiter(TAwaiter awaiter) where TAwaiter : ICriticalNotifyCompletion
{
ref AsyncHelpers.RuntimeAsyncAwaitState state = ref AsyncHelpers.t_runtimeAsyncAwaitState;
@@ -48,6 +51,7 @@ public static void UnsafeAwaitAwaiter(TAwaiter awaiter) where TAwaiter
[Intrinsic]
[BypassReadyToRun]
[MethodImpl(MethodImplOptions.Async)]
+ [RequiresPreviewFeatures]
public static T Await(Task task)
{
TaskAwaiter awaiter = task.GetAwaiter();
@@ -62,6 +66,7 @@ public static T Await(Task task)
[Intrinsic]
[BypassReadyToRun]
[MethodImpl(MethodImplOptions.Async)]
+ [RequiresPreviewFeatures]
public static void Await(Task task)
{
TaskAwaiter awaiter = task.GetAwaiter();
@@ -76,6 +81,7 @@ public static void Await(Task task)
[Intrinsic]
[BypassReadyToRun]
[MethodImpl(MethodImplOptions.Async)]
+ [RequiresPreviewFeatures]
public static T Await(ValueTask task)
{
ValueTaskAwaiter awaiter = task.GetAwaiter();
@@ -90,6 +96,7 @@ public static T Await(ValueTask task)
[Intrinsic]
[BypassReadyToRun]
[MethodImpl(MethodImplOptions.Async)]
+ [RequiresPreviewFeatures]
public static void Await(ValueTask task)
{
ValueTaskAwaiter awaiter = task.GetAwaiter();
@@ -104,6 +111,7 @@ public static void Await(ValueTask task)
[Intrinsic]
[BypassReadyToRun]
[MethodImpl(MethodImplOptions.Async)]
+ [RequiresPreviewFeatures]
public static void Await(ConfiguredTaskAwaitable configuredAwaitable)
{
ConfiguredTaskAwaitable.ConfiguredTaskAwaiter awaiter = configuredAwaitable.GetAwaiter();
@@ -118,6 +126,7 @@ public static void Await(ConfiguredTaskAwaitable configuredAwaitable)
[Intrinsic]
[BypassReadyToRun]
[MethodImpl(MethodImplOptions.Async)]
+ [RequiresPreviewFeatures]
public static void Await(ConfiguredValueTaskAwaitable configuredAwaitable)
{
ConfiguredValueTaskAwaitable.ConfiguredValueTaskAwaiter awaiter = configuredAwaitable.GetAwaiter();
@@ -132,6 +141,7 @@ public static void Await(ConfiguredValueTaskAwaitable configuredAwaitable)
[Intrinsic]
[BypassReadyToRun]
[MethodImpl(MethodImplOptions.Async)]
+ [RequiresPreviewFeatures]
public static T Await(ConfiguredTaskAwaitable configuredAwaitable)
{
ConfiguredTaskAwaitable.ConfiguredTaskAwaiter awaiter = configuredAwaitable.GetAwaiter();
@@ -146,6 +156,7 @@ public static T Await(ConfiguredTaskAwaitable configuredAwaitable)
[Intrinsic]
[BypassReadyToRun]
[MethodImpl(MethodImplOptions.Async)]
+ [RequiresPreviewFeatures]
public static T Await(ConfiguredValueTaskAwaitable configuredAwaitable)
{
ConfiguredValueTaskAwaitable.ConfiguredValueTaskAwaiter awaiter = configuredAwaitable.GetAwaiter();
@@ -157,15 +168,25 @@ public static T Await(ConfiguredValueTaskAwaitable configuredAwaitable)
return awaiter.GetResult();
}
#else
+ [RequiresPreviewFeatures]
public static void UnsafeAwaitAwaiter(TAwaiter awaiter) where TAwaiter : ICriticalNotifyCompletion { throw new NotImplementedException(); }
+ [RequiresPreviewFeatures]
public static void AwaitAwaiter(TAwaiter awaiter) where TAwaiter : INotifyCompletion { throw new NotImplementedException(); }
+ [RequiresPreviewFeatures]
public static void Await(System.Threading.Tasks.Task task) { throw new NotImplementedException(); }
+ [RequiresPreviewFeatures]
public static T Await(System.Threading.Tasks.Task task) { throw new NotImplementedException(); }
+ [RequiresPreviewFeatures]
public static void Await(System.Threading.Tasks.ValueTask task) { throw new NotImplementedException(); }
+ [RequiresPreviewFeatures]
public static T Await(System.Threading.Tasks.ValueTask task) { throw new NotImplementedException(); }
+ [RequiresPreviewFeatures]
public static void Await(System.Runtime.CompilerServices.ConfiguredTaskAwaitable configuredAwaitable) { throw new NotImplementedException(); }
+ [RequiresPreviewFeatures]
public static void Await(System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable configuredAwaitable) { throw new NotImplementedException(); }
+ [RequiresPreviewFeatures]
public static T Await(System.Runtime.CompilerServices.ConfiguredTaskAwaitable configuredAwaitable) { throw new NotImplementedException(); }
+ [RequiresPreviewFeatures]
public static T Await(System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable configuredAwaitable) { throw new NotImplementedException(); }
#endif
}
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeFeature.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeFeature.cs
index c3c9e8a8fe191a..eb6afdf66d1512 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeFeature.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeFeature.cs
@@ -54,7 +54,15 @@ public static bool IsSupported(string feature)
{
return feature switch
{
- PortablePdb or CovariantReturnsOfClasses or ByRefFields or ByRefLikeGenerics or UnmanagedSignatureCallingConvention or DefaultImplementationsOfInterfaces or VirtualStaticsInInterfaces or NumericIntPtr => true,
+ PortablePdb or
+ CovariantReturnsOfClasses or
+ ByRefFields or
+ ByRefLikeGenerics or
+ UnmanagedSignatureCallingConvention or
+ DefaultImplementationsOfInterfaces or
+ VirtualStaticsInInterfaces or
+ NumericIntPtr => true,
+
nameof(IsDynamicCodeSupported) => IsDynamicCodeSupported,
nameof(IsDynamicCodeCompiled) => IsDynamicCodeCompiled,
_ => false,
diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs
index ddbfd6ae5682ae..89a5c81e868e40 100644
--- a/src/libraries/System.Runtime/ref/System.Runtime.cs
+++ b/src/libraries/System.Runtime/ref/System.Runtime.cs
@@ -13833,15 +13833,25 @@ public static void RunModuleConstructor(System.ModuleHandle module) { }
[System.Diagnostics.CodeAnalysis.ExperimentalAttribute("SYSLIB5007", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
public static partial class AsyncHelpers
{
+ [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
public static void UnsafeAwaitAwaiter(TAwaiter awaiter) where TAwaiter : ICriticalNotifyCompletion { }
+ [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
public static void AwaitAwaiter(TAwaiter awaiter) where TAwaiter : INotifyCompletion { }
+ [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
public static void Await(System.Threading.Tasks.Task task) { throw null; }
+ [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
public static T Await(System.Threading.Tasks.Task task) { throw null; }
+ [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
public static void Await(System.Threading.Tasks.ValueTask task) { throw null; }
+ [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
public static T Await(System.Threading.Tasks.ValueTask task) { throw null; }
+ [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
public static void Await(System.Runtime.CompilerServices.ConfiguredTaskAwaitable configuredAwaitable) { throw null; }
+ [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
public static void Await(System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable configuredAwaitable) { throw null; }
+ [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
public static T Await(System.Runtime.CompilerServices.ConfiguredTaskAwaitable configuredAwaitable) { throw null; }
+ [System.Runtime.Versioning.RequiresPreviewFeaturesAttribute]
public static T Await(System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable configuredAwaitable) { throw null; }
}
public sealed partial class RuntimeWrappedException : System.Exception
diff --git a/src/tests/Directory.Build.props b/src/tests/Directory.Build.props
index 136b5db5ae4eb0..fc6ebdb5ed7da6 100644
--- a/src/tests/Directory.Build.props
+++ b/src/tests/Directory.Build.props
@@ -8,6 +8,11 @@
+
+
+ 5.0.0-1.25259.6
+
+
true
diff --git a/src/tests/async/Directory.Build.props b/src/tests/async/Directory.Build.props
index 17e80030ca09de..dda1142e724781 100644
--- a/src/tests/async/Directory.Build.props
+++ b/src/tests/async/Directory.Build.props
@@ -7,5 +7,9 @@
true
$(NoWarn);xUnit1013
false
+ $(Features);runtime-async=on
+
+
+
diff --git a/src/tests/async/RuntimeAsyncMethodGenerationAttribute.cs b/src/tests/async/RuntimeAsyncMethodGenerationAttribute.cs
new file mode 100644
index 00000000000000..d12d961ebcf220
--- /dev/null
+++ b/src/tests/async/RuntimeAsyncMethodGenerationAttribute.cs
@@ -0,0 +1,10 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+namespace System.Runtime.CompilerServices;
+
+[AttributeUsage(AttributeTargets.Method)]
+public class RuntimeAsyncMethodGenerationAttribute(bool runtimeAsync) : Attribute
+{
+ public bool RuntimeAsync { get; } = runtimeAsync;
+}
\ No newline at end of file
diff --git a/src/tests/async/awaitingnotasync/awaitingnotasync.cs b/src/tests/async/awaitingnotasync/awaitingnotasync.cs
index 9f4b1732313ca1..bf8ad8c9cc12a0 100644
--- a/src/tests/async/awaitingnotasync/awaitingnotasync.cs
+++ b/src/tests/async/awaitingnotasync/awaitingnotasync.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Xunit;
@@ -14,6 +13,7 @@ public static void TestEntryPoint()
AsyncEntryPoint().Wait();
}
+ [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)]
private static async Task GetTask(T arg)
{
await Task.Yield();
@@ -21,6 +21,7 @@ private static async Task GetTask(T arg)
}
// TODO: switch every other scenario to use ValueTask
+ [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)]
private static async ValueTask GetValueTask(T arg)
{
await Task.Yield();
@@ -33,13 +34,13 @@ private static async ValueTask GetValueTask(T arg)
private static T sIdentity(T arg) => arg;
- private static async2 Task AsyncEntryPoint()
+ private static async Task AsyncEntryPoint()
{
// static field
sField = GetTask(5);
Assert.Equal(5, await sField);
- // property
+ // property
Assert.Equal(6, await sProp);
// generic identity
diff --git a/src/tests/async/collectible-alc/collectible-alc.cs b/src/tests/async/collectible-alc/collectible-alc.cs
index eb7e43309db26a..0feb988d4ac4a4 100644
--- a/src/tests/async/collectible-alc/collectible-alc.cs
+++ b/src/tests/async/collectible-alc/collectible-alc.cs
@@ -17,7 +17,7 @@ public static void TestEntryPoint()
AsyncEntryPoint().Wait();
}
- private static async2 Task AsyncEntryPoint()
+ private static async Task AsyncEntryPoint()
{
WeakReference wr = await CallFooAsyncAndUnload();
@@ -31,7 +31,7 @@ private static async2 Task AsyncEntryPoint()
}
[MethodImpl(MethodImplOptions.NoInlining)]
- private static async2 Task CallFooAsyncAndUnload()
+ private static async Task CallFooAsyncAndUnload()
{
TaskCompletionSource tcs = new();
(Task task, WeakReference wr) = CallFooAsyncInCollectibleALC(tcs.Task);
@@ -63,7 +63,7 @@ private static (Task, WeakReference) CallFooAsyncInCollectibleALC(Task t
}
// Task[] to work around a compiler bug
- private static async2 Task FooAsync(Task[] t)
+ private static async Task FooAsync(Task[] t)
{
await t[0];
return "done";
diff --git a/src/tests/async/cse-array-index-byref/cse-array-index-byref.cs b/src/tests/async/cse-array-index-byref/cse-array-index-byref.cs
index be99722a054bbb..d208c4e7a12c7c 100644
--- a/src/tests/async/cse-array-index-byref/cse-array-index-byref.cs
+++ b/src/tests/async/cse-array-index-byref/cse-array-index-byref.cs
@@ -16,13 +16,14 @@ public static void TestEntryPoint()
Assert.Equal(199_990_000, arr[0]);
}
+ [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)]
private static async Task AsyncTestEntryPoint(int[] arr, int index)
{
await HoistedByref(arr, index);
}
[MethodImpl(MethodImplOptions.NoInlining)]
- private static async2 Task HoistedByref(int[] arr, int index)
+ private static async Task HoistedByref(int[] arr, int index)
{
for (int i = 0; i < 20000; i++)
{
diff --git a/src/tests/async/eh-microbench/eh-microbench.cs b/src/tests/async/eh-microbench/eh-microbench.cs
index 994e443cf9e386..2eefa61570a837 100644
--- a/src/tests/async/eh-microbench/eh-microbench.cs
+++ b/src/tests/async/eh-microbench/eh-microbench.cs
@@ -24,6 +24,7 @@ public static int Main()
return 100;
}
+ [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)]
public static async Task AsyncEntry()
{
if (!GCSettings.IsServerGC)
@@ -68,6 +69,7 @@ public static async Task AsyncEntry()
await RunBench(yieldFrequency, depth, finallyRate, throwOrReturn, "ValueTask");
}
+ [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)]
private static async Task RunBench(int yieldCount, int depth, int finallyRate, bool throwOrReturn, string type)
{
@@ -104,7 +106,7 @@ public Benchmark(int yieldCount, int depth, int finallyRate, bool throwOrReturn)
_throwOrReturn = throwOrReturn;
}
- public async2 Task Run(string type)
+ public async Task Run(string type)
{
if (type == "Async2")
return await RunAsync2(_depth);
@@ -117,6 +119,7 @@ public async2 Task Run(string type)
return 0;
}
+ [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)]
public async Task RunTask(int depth)
{
int liveState1 = depth * 3 + _yieldCount;
@@ -182,6 +185,7 @@ public async Task RunTask(int depth)
return result;
}
+ [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)]
public async ValueTask RunValueTask(int depth)
{
int liveState1 = depth * 3 + _yieldCount;
@@ -267,7 +271,7 @@ public class FakeThread
// This case is used to test the impact of save/restore of the sync and execution context on performance
// The intent here is to measure what the performance impact of maintaining the current async semantics with
// the new implementation.
- public async2 Task RunAsync2WithContextSaveRestore(int depth)
+ public async Task RunAsync2WithContextSaveRestore(int depth)
{
FakeThread thread = CurrentThread;
if (thread == null)
@@ -361,7 +365,7 @@ public async2 Task RunAsync2WithContextSaveRestore(int depth)
}
}
- public async2 Task RunAsync2(int depth)
+ public async Task RunAsync2(int depth)
{
int liveState1 = depth * 3 + _yieldCount;
int liveState2 = depth;
diff --git a/src/tests/async/fibonacci-with-yields/fibonacci-with-yields.cs b/src/tests/async/fibonacci-with-yields/fibonacci-with-yields.cs
index a51a834fbdd773..814b96eda0b974 100644
--- a/src/tests/async/fibonacci-with-yields/fibonacci-with-yields.cs
+++ b/src/tests/async/fibonacci-with-yields/fibonacci-with-yields.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
+using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Diagnostics;
using Xunit;
@@ -22,7 +23,7 @@ public static void Test()
System.Console.WriteLine("allocated: " + allocated);
}
- public static async2 Task AsyncEntry()
+ public static async Task AsyncEntry()
{
for (int i = 0; i < iterations; i++)
{
@@ -34,7 +35,7 @@ public static async2 Task AsyncEntry()
}
}
- static async2 Task Fib(int i)
+ static async Task Fib(int i)
{
if (i <= 1)
{
diff --git a/src/tests/async/fibonacci-with-yields_struct_return/fibonacci-with-yields_struct_return.cs b/src/tests/async/fibonacci-with-yields_struct_return/fibonacci-with-yields_struct_return.cs
index eee23a2c16245b..c77caf9d912717 100644
--- a/src/tests/async/fibonacci-with-yields_struct_return/fibonacci-with-yields_struct_return.cs
+++ b/src/tests/async/fibonacci-with-yields_struct_return/fibonacci-with-yields_struct_return.cs
@@ -6,6 +6,7 @@
using System;
using System.Threading.Tasks;
using System.Diagnostics;
+using System.Runtime.CompilerServices;
using Xunit;
public class Async2FibonacceWithYields
@@ -34,7 +35,7 @@ public struct MyInt
public MyInt(int i) => this.i = i;
}
- public static async2 Task AsyncEntry()
+ public static async Task AsyncEntry()
{
for (int i = 0; i < iterations; i++)
{
@@ -46,7 +47,7 @@ public static async2 Task AsyncEntry()
}
}
- static async2 Task Fib(MyInt n)
+ static async Task Fib(MyInt n)
{
int i = n.i;
if (i <= 1)
diff --git a/src/tests/async/fibonacci-without-yields-config-await/fibonacci-without-yields-config-await.cs b/src/tests/async/fibonacci-without-yields-config-await/fibonacci-without-yields-config-await.cs
index 7abf3bac07de57..e3b411b5c3303c 100644
--- a/src/tests/async/fibonacci-without-yields-config-await/fibonacci-without-yields-config-await.cs
+++ b/src/tests/async/fibonacci-without-yields-config-await/fibonacci-without-yields-config-await.cs
@@ -26,7 +26,7 @@ public static void Test()
System.Console.WriteLine("allocated: " + allocated);
}
- public static async2 Task AsyncEntry()
+ public static async Task AsyncEntry()
{
for (int i = 0; i < iterations; i++)
{
@@ -38,7 +38,7 @@ public static async2 Task AsyncEntry()
}
}
- static async2 Task Fib(int i)
+ static async Task Fib(int i)
{
if (i <= 1)
{
diff --git a/src/tests/async/fibonacci-without-yields/fibonacci-without-yields.cs b/src/tests/async/fibonacci-without-yields/fibonacci-without-yields.cs
index 77ff71e8d1ee36..11dd3db5168e47 100644
--- a/src/tests/async/fibonacci-without-yields/fibonacci-without-yields.cs
+++ b/src/tests/async/fibonacci-without-yields/fibonacci-without-yields.cs
@@ -4,6 +4,7 @@
using System;
using System.Threading.Tasks;
using System.Diagnostics;
+using System.Runtime.CompilerServices;
using Xunit;
public class Async2FibonacciWithoutYields
@@ -22,7 +23,7 @@ public static void Test()
System.Console.WriteLine("allocated: " + allocated);
}
- public static async2 Task AsyncEntry()
+ public static async Task AsyncEntry()
{
for (int i = 0; i < iterations; i++)
{
@@ -34,7 +35,7 @@ public static async2 Task AsyncEntry()
}
}
- static async2 Task Fib(int i)
+ static async Task Fib(int i)
{
if (i <= 1)
{
diff --git a/src/tests/async/gc-roots-scan/gc-roots-scan.cs b/src/tests/async/gc-roots-scan/gc-roots-scan.cs
index fffe874af38e50..76d0dfb629fcdf 100644
--- a/src/tests/async/gc-roots-scan/gc-roots-scan.cs
+++ b/src/tests/async/gc-roots-scan/gc-roots-scan.cs
@@ -4,6 +4,7 @@
using System;
using System.Threading.Tasks;
using System.Diagnostics;
+using System.Runtime.CompilerServices;
using Xunit;
public class Async2RootReporting
@@ -11,6 +12,7 @@ public class Async2RootReporting
private static TaskCompletionSource cs;
+ [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)]
static async Task Recursive1(int n)
{
Task cTask = cs.Task;
@@ -50,7 +52,7 @@ static async Task Recursive1(int n)
return result;
}
- static async2 Task Recursive2(int n)
+ static async Task Recursive2(int n)
{
Task cTask = cs.Task;
diff --git a/src/tests/async/implement/implement.cs b/src/tests/async/implement/implement.cs
index bb8607541d1d49..ddd20d0570c391 100644
--- a/src/tests/async/implement/implement.cs
+++ b/src/tests/async/implement/implement.cs
@@ -10,11 +10,12 @@ public class Async2Implement
{
interface IBase1
{
- public async2 Task M1();
+ public Task M1();
}
class Derived1 : IBase1
{
+ [RuntimeAsyncMethodGeneration(false)]
public async Task M1()
{
await Task.Yield();
@@ -24,7 +25,7 @@ public async Task M1()
class Derived1a : IBase1
{
- public async2 Task M1()
+ public async Task M1()
{
await Task.Yield();
return 3;
@@ -38,7 +39,7 @@ interface IBase2
class Derived2 : IBase2
{
- public async2 Task M1()
+ public async Task M1()
{
await Task.Yield();
return 12;
@@ -47,6 +48,7 @@ public async2 Task M1()
class Derived2a : IBase2
{
+ [RuntimeAsyncMethodGeneration(false)]
public async Task M1()
{
await Task.Yield();
diff --git a/src/tests/async/mincallcost-microbench/mincallcost-microbench.cs b/src/tests/async/mincallcost-microbench/mincallcost-microbench.cs
index 122994d8061c37..900aad4ba45b0c 100644
--- a/src/tests/async/mincallcost-microbench/mincallcost-microbench.cs
+++ b/src/tests/async/mincallcost-microbench/mincallcost-microbench.cs
@@ -24,6 +24,7 @@ public static int Main()
return 100;
}
+ [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)]
public static async Task AsyncEntry()
{
if (!GCSettings.IsServerGC)
@@ -66,6 +67,7 @@ public static async Task AsyncEntry()
static double time = 10.0;
static bool printResult = false;
+ [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)]
private static async Task RunBench(string type)
{
if (printResult)
@@ -85,6 +87,7 @@ private static async Task RunBench(string type)
Console.WriteLine("Result = {0}", (long)avg);
}
+ [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)]
private static async Task Run(string type)
{
if (type == "AsyncCallingAsync")
@@ -114,6 +117,7 @@ private static async Task Run(string type)
}
#pragma warning disable CS1998
+ [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)]
private static async Task AsyncCallingAsync()
{
Stopwatch timer = Stopwatch.StartNew();
@@ -131,6 +135,7 @@ private static async Task AsyncCallingAsync()
return numIters * 10;
}
+ [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)]
private static async Task AsyncCallingValueTaskAsync()
{
Stopwatch timer = Stopwatch.StartNew();
@@ -148,6 +153,7 @@ private static async Task AsyncCallingValueTaskAsync()
return numIters * 10;
}
+ [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)]
private static async Task AsyncCallingAsync2()
{
Stopwatch timer = Stopwatch.StartNew();
@@ -165,7 +171,7 @@ private static async Task AsyncCallingAsync2()
return numIters * 10;
}
- private static async2 Task Async2CallingAsync()
+ private static async Task Async2CallingAsync()
{
Stopwatch timer = Stopwatch.StartNew();
@@ -182,7 +188,7 @@ private static async2 Task Async2CallingAsync()
return numIters * 10;
}
- private static async2 Task Async2CallingValueTaskAsync()
+ private static async Task Async2CallingValueTaskAsync()
{
Stopwatch timer = Stopwatch.StartNew();
@@ -199,7 +205,7 @@ private static async2 Task Async2CallingValueTaskAsync()
return numIters * 10;
}
- private static async2 Task Async2CallingAsync2()
+ private static async Task Async2CallingAsync2()
{
Stopwatch timer = Stopwatch.StartNew();
@@ -216,7 +222,7 @@ private static async2 Task Async2CallingAsync2()
return numIters * 10;
}
- private static async2 Task Async2CallingAsync2NoInlining()
+ private static async Task Async2CallingAsync2NoInlining()
{
Stopwatch timer = Stopwatch.StartNew();
@@ -233,7 +239,7 @@ private static async2 Task Async2CallingAsync2NoInlining()
return numIters * 10;
}
- private static async2 Task Async2CallingAsync2WithContextSave()
+ private static async Task Async2CallingAsync2WithContextSave()
{
FakeThread thread = CurrentThread;
if (thread == null)
@@ -274,6 +280,7 @@ public class FakeThread
public static FakeThread CurrentThread;
+ [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)]
private static async Task AsyncCallingYield()
{
Stopwatch timer = Stopwatch.StartNew();
@@ -291,7 +298,7 @@ private static async Task AsyncCallingYield()
return numIters * 10;
}
- private static async2 Task Async2CallingYield()
+ private static async Task Async2CallingYield()
{
Stopwatch timer = Stopwatch.StartNew();
@@ -325,6 +332,7 @@ private static long Sync2CallingSync()
return numIters * 10;
}
+ [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)]
private static async Task EmptyAsync()
{
// Add some work that forces the method to be a real async method
@@ -333,6 +341,7 @@ private static async Task EmptyAsync()
return;
}
+ [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)]
private static async ValueTask EmptyValueTaskAsync()
{
// Add some work that forces the method to be a real async method
@@ -341,7 +350,7 @@ private static async ValueTask EmptyValueTaskAsync()
return;
}
- private static async2 Task EmptyAsync2()
+ private static async Task EmptyAsync2()
{
// Add some work that forces the method to be a real async method
if (time == 0)
@@ -350,7 +359,7 @@ private static async2 Task EmptyAsync2()
}
[MethodImpl(MethodImplOptions.NoInlining)]
- private static async2 Task EmptyAsync2NoInlining()
+ private static async Task EmptyAsync2NoInlining()
{
// Add some work that forces the method to be a real async method
if (time == 0)
@@ -358,8 +367,8 @@ private static async2 Task EmptyAsync2NoInlining()
return;
}
- // This simulates async2 capturing the same amount of state that existing async needs to capture to handle the current semantics around async locals and synchronizationcontext
- private static async2 Task EmptyAsync2WithContextSave()
+ // This simulates async capturing the same amount of state that existing async needs to capture to handle the current semantics around async locals and synchronizationcontext
+ private static async Task EmptyAsync2WithContextSave()
{
FakeThread thread = CurrentThread;
FakeExecContext? previousExecutionCtx = thread._execContext;
diff --git a/src/tests/async/object/object.cs b/src/tests/async/object/object.cs
index fb62588652ae3f..7ebec6207edf91 100644
--- a/src/tests/async/object/object.cs
+++ b/src/tests/async/object/object.cs
@@ -14,13 +14,14 @@ public static int TestEntryPoint()
return (int)AsyncTestEntryPoint(100).Result;
}
+ [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)]
private static async Task