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 AsyncTestEntryPoint(int arg) { return await ObjMethod(arg); } [MethodImpl(MethodImplOptions.NoInlining)] - private static async2 Task ObjMethod(int arg) + private static async Task ObjMethod(int arg) { await Task.Yield(); return arg; diff --git a/src/tests/async/objects-captured/objects-captured.cs b/src/tests/async/objects-captured/objects-captured.cs index 197d29f0383d98..07c502b12ee61c 100644 --- a/src/tests/async/objects-captured/objects-captured.cs +++ b/src/tests/async/objects-captured/objects-captured.cs @@ -4,11 +4,12 @@ using System; using System.Threading.Tasks; using System.Diagnostics; +using System.Runtime.CompilerServices; using Xunit; public class Async2ObjectsWithYields { - internal static async2 Task A(object n) + internal static async Task A(object n) { // use string equality so that JIT would not think of hoisting "(int)n" // also to produce some amout of garbage @@ -21,6 +22,7 @@ internal static async2 Task A(object n) return 0; } + [RuntimeAsyncMethodGeneration(false)] private static async Task AsyncEntry() { object result = 0; diff --git a/src/tests/async/override/override.cs b/src/tests/async/override/override.cs index 4ee5d1446b831a..d55d961880ad30 100644 --- a/src/tests/async/override/override.cs +++ b/src/tests/async/override/override.cs @@ -10,7 +10,7 @@ public class Async2Override { class Base { - public virtual async2 Task M1() + public virtual async Task M1() { await Task.Yield(); return 1; @@ -19,6 +19,7 @@ public virtual async2 Task M1() class Derived1 : Base { + [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] public override async Task M1() { await Task.Yield(); @@ -28,7 +29,7 @@ public override async Task M1() class Derived2 : Derived1 { - public override async2 Task M1() + public override async Task M1() { await Task.Yield(); return 3; @@ -38,6 +39,7 @@ public override async2 Task M1() class Base1 { + [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] public virtual async Task M1() { await Task.Yield(); @@ -47,7 +49,7 @@ public virtual async Task M1() class Derived11 : Base1 { - public override async2 Task M1() + public override async Task M1() { await Task.Yield(); return 12; @@ -56,6 +58,7 @@ public override async2 Task M1() class Derived12 : Derived11 { + [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] public override async Task M1() { await Task.Yield(); diff --git a/src/tests/async/pgo/pgo.cs b/src/tests/async/pgo/pgo.cs index 6e3f14caa7bae1..ba5589c07d9117 100644 --- a/src/tests/async/pgo/pgo.cs +++ b/src/tests/async/pgo/pgo.cs @@ -17,7 +17,7 @@ public static void EntryPoint() AsyncEntryPoint().Wait(); } - internal static async2 Task AsyncEntryPoint() + internal static async Task AsyncEntryPoint() { int[] arr = Enumerable.Range(0, 100_000).ToArray(); @@ -36,20 +36,20 @@ internal static async2 Task AsyncEntryPoint() private class AggregateSum : I { #pragma warning disable CS1998 - public async2 Task Aggregate(int a, int b) => a + b; + public async Task Aggregate(int a, int b) => a + b; } - + public interface I { public Task Aggregate(T seed, T val); } - + [MethodImpl(MethodImplOptions.NoInlining)] - public static async2 Task AggregateDelegateAsync(T[] arr, I aggregate, T seed) + public static async Task AggregateDelegateAsync(T[] arr, I aggregate, T seed) { foreach (T val in arr) seed = await aggregate.Aggregate(seed, val); - + return seed; } } diff --git a/src/tests/async/pinvoke/pinvoke.cs b/src/tests/async/pinvoke/pinvoke.cs index df04091cbaf2ff..bbe9e939ad7f8f 100644 --- a/src/tests/async/pinvoke/pinvoke.cs +++ b/src/tests/async/pinvoke/pinvoke.cs @@ -14,7 +14,7 @@ public static void TestEntryPoint() AsyncEntryPoint().Wait(); } - private static async2 Task AsyncEntryPoint() + private static async Task AsyncEntryPoint() { unsafe { diff --git a/src/tests/async/returns/returns.cs b/src/tests/async/returns/returns.cs index 174a66c479a14c..3df7a8a65899bd 100644 --- a/src/tests/async/returns/returns.cs +++ b/src/tests/async/returns/returns.cs @@ -15,7 +15,7 @@ public static void TestEntryPoint() } [MethodImpl(MethodImplOptions.NoInlining)] - private static async2 Task Returns(C c) + private static async Task Returns(C c) { for (int i = 0; i < 20000; i++) { @@ -58,28 +58,28 @@ private static void AssertEqual(T expected, T actual) } [MethodImpl(MethodImplOptions.NoInlining)] - private static async2 Task> ReturnsStruct() + private static async Task> ReturnsStruct() { await Task.Yield(); return new S { A = 42, B = 4242, C = 424242, D = 42424242 }; } [MethodImpl(MethodImplOptions.NoInlining)] - private static async2 Task> ReturnsStructGC() + private static async Task> ReturnsStructGC() { await Task.Yield(); return new S { A = "A", B = "B", C = "C", D = "D" }; } [MethodImpl(MethodImplOptions.NoInlining)] - private static async2 Task> ReturnsBytes() + private static async Task> ReturnsBytes() { await Task.Yield(); return new S { A = 4, B = 40, C = 42, D = 45 }; } [MethodImpl(MethodImplOptions.NoInlining)] - private static async2 Task ReturnsString() + private static async Task ReturnsString() { await Task.Yield(); return "a string!"; diff --git a/src/tests/async/shared-generic/shared-generic.cs b/src/tests/async/shared-generic/shared-generic.cs index e53ce961680450..c75abab84bb410 100644 --- a/src/tests/async/shared-generic/shared-generic.cs +++ b/src/tests/async/shared-generic/shared-generic.cs @@ -51,6 +51,7 @@ public static void TestEntryPoint() Async2EntryPoint?>(typeof(S1?), null).Wait(); } + [RuntimeAsyncMethodGeneration(false)] private static async Task Async1EntryPoint(Type t, T value) { await new GenericClass().InstanceMethod(t); @@ -65,7 +66,7 @@ private static async Task Async1EntryPoint(Type t, T value) Assert.Equal(value, await GenericClass.StaticReturnMethodTypeAsync1(value)); } - private static async2 Task Async2EntryPoint(Type t, T value) + private static async Task Async2EntryPoint(Type t, T value) { await new GenericClass().InstanceMethod(t); await GenericClass.StaticMethod(t); @@ -84,7 +85,7 @@ public class GenericClass { // 'this' is context [MethodImpl(MethodImplOptions.NoInlining)] - public async2 Task InstanceMethod(Type t) + public async Task InstanceMethod(Type t) { Assert.Equal(typeof(T), t); await Task.Yield(); @@ -93,7 +94,7 @@ public async2 Task InstanceMethod(Type t) // Class context [MethodImpl(MethodImplOptions.NoInlining)] - public static async2 Task StaticMethod(Type t) + public static async Task StaticMethod(Type t) { Assert.Equal(typeof(T), t); await Task.Yield(); @@ -102,7 +103,7 @@ public static async2 Task StaticMethod(Type t) // Method context [MethodImpl(MethodImplOptions.NoInlining)] - public static async2 Task StaticMethod(Type t, Type tm) + public static async Task StaticMethod(Type t, Type tm) { Assert.Equal(typeof(T), t); Assert.Equal(typeof(TM), tm); @@ -113,6 +114,7 @@ public static async2 Task StaticMethod(Type t, Type tm) // Class context [MethodImpl(MethodImplOptions.NoInlining)] + [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] public static async Task StaticMethodAsync1(Type t) { Assert.Equal(typeof(T), t); @@ -122,6 +124,7 @@ public static async Task StaticMethodAsync1(Type t) // Method context [MethodImpl(MethodImplOptions.NoInlining)] + [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] public static async Task StaticMethodAsync1(Type t, Type tm) { Assert.Equal(typeof(T), t); @@ -131,24 +134,26 @@ public static async Task StaticMethodAsync1(Type t, Type tm) Assert.Equal(typeof(TM), tm); } - public static async2 Task StaticReturnClassType(T value) + public static async Task StaticReturnClassType(T value) { await Task.Yield(); return value; } - public static async2 Task StaticReturnMethodType(TM value) + public static async Task StaticReturnMethodType(TM value) { await Task.Yield(); return value; } + [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] public static async Task StaticReturnClassTypeAsync1(T value) { await Task.Yield(); return value; } + [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] public static async Task StaticReturnMethodTypeAsync1(TM value) { await Task.Yield(); diff --git a/src/tests/async/simple-eh/simple-eh.cs b/src/tests/async/simple-eh/simple-eh.cs index 8d70af66efc5b4..04b19f132c4208 100644 --- a/src/tests/async/simple-eh/simple-eh.cs +++ b/src/tests/async/simple-eh/simple-eh.cs @@ -18,13 +18,14 @@ public static void Test() Task.Run(AsyncEntry).Wait(); } + [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] public static async Task AsyncEntry() { int result = await Handler(); Assert.Equal(42, result); } - public static async2 Task Handler() + public static async Task Handler() { try { @@ -37,7 +38,7 @@ public static async2 Task Handler() } [MethodImpl(MethodImplOptions.NoInlining)] - public static async2 Task Throw(int value) + public static async Task Throw(int value) { await Task.Yield(); throw new IntegerException(value); diff --git a/src/tests/async/simple-eh/simple-eh.csproj b/src/tests/async/simple-eh/simple-eh.csproj index de6d5e08882e86..7df4a08ec02b24 100644 --- a/src/tests/async/simple-eh/simple-eh.csproj +++ b/src/tests/async/simple-eh/simple-eh.csproj @@ -1,6 +1,7 @@ True + true diff --git a/src/tests/async/small/small.cs b/src/tests/async/small/small.cs index 5afbbe7bc31ece..bdce432c39b869 100644 --- a/src/tests/async/small/small.cs +++ b/src/tests/async/small/small.cs @@ -15,7 +15,7 @@ public static void TestEntryPoint() } [MethodImpl(MethodImplOptions.NoInlining)] - private static async2 Task SmallType(byte arg) + private static async Task SmallType(byte arg) { await Task.Yield(); Assert.Equal(123, arg); diff --git a/src/tests/async/strength-reduction/strength-reduction.cs b/src/tests/async/strength-reduction/strength-reduction.cs index e9e6aef7fd6b83..175a01f09a5af0 100644 --- a/src/tests/async/strength-reduction/strength-reduction.cs +++ b/src/tests/async/strength-reduction/strength-reduction.cs @@ -16,7 +16,7 @@ public static int TestEntryPoint() } [MethodImpl(MethodImplOptions.NoInlining)] - private static async2 Task StrengthReduction(int[] arr) + private static async Task StrengthReduction(int[] arr) { int sum = 0; foreach (int x in arr) diff --git a/src/tests/async/struct/struct.cs b/src/tests/async/struct/struct.cs index 76bd0fd35e8fa5..7c5062d499cb42 100644 --- a/src/tests/async/struct/struct.cs +++ b/src/tests/async/struct/struct.cs @@ -17,6 +17,7 @@ public static void TestEntryPoint() Async2().Wait(); } + [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] private static async Task Async() { S s = new S(100); @@ -24,13 +25,14 @@ private static async Task Async() AssertEqual(100, s.Value); } - private static async2 Task Async2() + private static async Task Async2() { S s = new S(100); await s.Test(); AssertEqual(100, s.Value); } + [MethodImpl(MethodImplOptions.NoInlining)] private static void AssertEqual(int expected, int val) { @@ -43,7 +45,7 @@ private struct S public S(int value) => Value = value; - public async2 Task Test() + public async Task Test() { // TODO: C# compiler is expected to do this, but not in the prototype. S @this = this; @@ -57,7 +59,7 @@ public async2 Task Test() AssertEqual(102, @this.Value); } - private async2 Task InstanceCall() + private async Task InstanceCall() { // TODO: C# compiler is expected to do this, but not in the prototype. S @this = this; diff --git a/src/tests/async/taskbased-asyncfibonacci-with-yields/taskbased-asyncfibonacci-with-yields.cs b/src/tests/async/taskbased-asyncfibonacci-with-yields/taskbased-asyncfibonacci-with-yields.cs index 4829e029636da6..2465903d710a81 100644 --- a/src/tests/async/taskbased-asyncfibonacci-with-yields/taskbased-asyncfibonacci-with-yields.cs +++ b/src/tests/async/taskbased-asyncfibonacci-with-yields/taskbased-asyncfibonacci-with-yields.cs @@ -23,6 +23,7 @@ public static int Main() return 100; } + [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] public static async Task AsyncEntry() { for (int i = 0; i < iterations; i++) @@ -35,6 +36,7 @@ public static async Task AsyncEntry() } } + [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] static async Task Fib(int i) { if (i <= 1) diff --git a/src/tests/async/taskbased-asyncfibonacci-without-yields/taskbased-asyncfibonacci-without-yields.cs b/src/tests/async/taskbased-asyncfibonacci-without-yields/taskbased-asyncfibonacci-without-yields.cs index e3e9c7ff21f8f1..2f8ddb5f06658e 100644 --- a/src/tests/async/taskbased-asyncfibonacci-without-yields/taskbased-asyncfibonacci-without-yields.cs +++ b/src/tests/async/taskbased-asyncfibonacci-without-yields/taskbased-asyncfibonacci-without-yields.cs @@ -23,6 +23,7 @@ public static int Main() return 100; } + [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] public static async Task AsyncEntry() { for (int i = 0; i < iterations; i++) @@ -35,6 +36,7 @@ public static async Task AsyncEntry() } } + [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] static async Task Fib(int i) { if (i <= 1) diff --git a/src/tests/async/valuetask/valuetask.cs b/src/tests/async/valuetask/valuetask.cs index deff530e9f5d4d..4740181e27394f 100644 --- a/src/tests/async/valuetask/valuetask.cs +++ b/src/tests/async/valuetask/valuetask.cs @@ -19,7 +19,7 @@ private static ValueTask AsyncTestEntryPoint(int arg) return M1(arg); } - private static async2 ValueTask M1(int arg) + private static async ValueTask M1(int arg) { await Task.Yield(); return arg; diff --git a/src/tests/async/valuetaskbased-asyncfibonacci-with-yields/valuetaskbased-asyncfibonacci-with-yields.cs b/src/tests/async/valuetaskbased-asyncfibonacci-with-yields/valuetaskbased-asyncfibonacci-with-yields.cs index ac48372814efb6..f34cc93b1d6bb2 100644 --- a/src/tests/async/valuetaskbased-asyncfibonacci-with-yields/valuetaskbased-asyncfibonacci-with-yields.cs +++ b/src/tests/async/valuetaskbased-asyncfibonacci-with-yields/valuetaskbased-asyncfibonacci-with-yields.cs @@ -23,6 +23,7 @@ public static int Main() return 100; } + [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] public static async ValueTask AsyncEntry() { for (int i = 0; i < iterations; i++) @@ -35,6 +36,7 @@ public static async ValueTask AsyncEntry() } } + [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] static async ValueTask Fib(int i) { if (i <= 1) diff --git a/src/tests/async/valuetaskbased-asyncfibonacci-without-yields/valuetaskbased-asyncfibonacci-without-yields.cs b/src/tests/async/valuetaskbased-asyncfibonacci-without-yields/valuetaskbased-asyncfibonacci-without-yields.cs index 1e3aab57ec7da5..64d57c46f8ee56 100644 --- a/src/tests/async/valuetaskbased-asyncfibonacci-without-yields/valuetaskbased-asyncfibonacci-without-yields.cs +++ b/src/tests/async/valuetaskbased-asyncfibonacci-without-yields/valuetaskbased-asyncfibonacci-without-yields.cs @@ -23,6 +23,7 @@ public static int Main() return 100; } + [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] public static async ValueTask AsyncEntry() { for (int i = 0; i < iterations; i++) @@ -35,6 +36,7 @@ public static async ValueTask AsyncEntry() } } + [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] static async ValueTask Fib(int i) { if (i <= 1) diff --git a/src/tests/async/varying-yields/varying-yields.cs b/src/tests/async/varying-yields/varying-yields.cs index 6edc30e8118dd7..6194d1890d838a 100644 --- a/src/tests/async/varying-yields/varying-yields.cs +++ b/src/tests/async/varying-yields/varying-yields.cs @@ -22,6 +22,7 @@ public static void TestEntryPoint() Task.Run(AsyncEntry).Wait(); } + [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] public static async Task AsyncEntry() { if (!GCSettings.IsServerGC) @@ -76,13 +77,14 @@ private class Benchmark public Benchmark(double yieldProbability) => _yieldProbability = yieldProbability; -public #if ASYNC1_TASK - async Task + [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] + public async Task #elif ASYNC1_VALUETASK - async ValueTask + [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] + public async ValueTask #else - async2 Task + public async Task #endif Run(int depth) { @@ -98,13 +100,14 @@ async2 Task return result; } -private #if ASYNC1_TASK - async Task + [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] + private async Task #elif ASYNC1_VALUETASK - async ValueTask + [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] + private async ValueTask #else - async2 Task + private async Task #endif Loop() { @@ -124,13 +127,14 @@ async2 Task return numIters; } -private #if ASYNC1_TASK - async Task + [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] + private async Task #elif ASYNC1_VALUETASK - async ValueTask + [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] + private async ValueTask #else - async2 Task + private async Task #endif DoYields() { diff --git a/src/tests/async/void/void.cs b/src/tests/async/void/void.cs index 8271887731a110..566dbd8e7ccc77 100644 --- a/src/tests/async/void/void.cs +++ b/src/tests/async/void/void.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/with-yields/with-yields.cs b/src/tests/async/with-yields/with-yields.cs index 2f53a60f7c4fc5..7c382b671092d7 100644 --- a/src/tests/async/with-yields/with-yields.cs +++ b/src/tests/async/with-yields/with-yields.cs @@ -8,7 +8,7 @@ public class Async2FibonacceWithYields { - internal static async2 Task B(int n) + internal static async Task B(int n) { int num = 1; await Task.Yield(); @@ -22,7 +22,7 @@ internal static async2 Task B(int n) return num; } - internal static async2 Task A(int n) + internal static async Task A(int n) { int num = n; for (int num2 = 0; num2 < n; num2++) @@ -33,6 +33,7 @@ internal static async2 Task A(int n) return num; } + [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] private static async Task AsyncEntry() { int result = 0; diff --git a/src/tests/async/without-yields/without-yields.cs b/src/tests/async/without-yields/without-yields.cs index ba1f2aeff0df1f..b0866fda6a79b3 100644 --- a/src/tests/async/without-yields/without-yields.cs +++ b/src/tests/async/without-yields/without-yields.cs @@ -11,12 +11,12 @@ public class Async2FibonacceWithoutYields //This async method lacks 'await' #pragma warning disable 1998 - internal static async2 Task B(int n) + internal static async Task B(int n) { return 100; } - internal static async2 Task A(int n) + internal static async Task A(int n) { int num = n; for (int num2 = 0; num2 < n; num2++) @@ -27,6 +27,7 @@ internal static async2 Task A(int n) return num; } + [System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)] private static async Task AsyncEntry() { int result = 0;