diff --git a/API/GenHTTP.Api.csproj b/API/GenHTTP.Api.csproj index e9962c5a9..8e4b6f985 100644 --- a/API/GenHTTP.Api.csproj +++ b/API/GenHTTP.Api.csproj @@ -16,7 +16,7 @@ - + diff --git a/Directory.Build.props b/Directory.Build.props index 5a497e182..b3f545ae3 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,6 +4,8 @@ net10.0;net11.0 + $(Features);runtime-async=on + 14.0 enable true @@ -28,7 +30,7 @@ true true - CS1591,CS1587,CS1572,CS1573,NU1510 + CS1591,CS1572,CS1573 @@ -40,7 +42,7 @@ - + diff --git a/Engine/Internal/GenHTTP.Engine.Internal.csproj b/Engine/Internal/GenHTTP.Engine.Internal.csproj index 6a3f0e0be..0661f82e9 100644 --- a/Engine/Internal/GenHTTP.Engine.Internal.csproj +++ b/Engine/Internal/GenHTTP.Engine.Internal.csproj @@ -16,9 +16,9 @@ - + - + diff --git a/Engine/Ioxide/GenHTTP.Engine.Ioxide.csproj b/Engine/Ioxide/GenHTTP.Engine.Ioxide.csproj index 596800623..4170201e0 100644 --- a/Engine/Ioxide/GenHTTP.Engine.Ioxide.csproj +++ b/Engine/Ioxide/GenHTTP.Engine.Ioxide.csproj @@ -12,7 +12,7 @@ - + diff --git a/Engine/Shared/GenHTTP.Engine.Shared.csproj b/Engine/Shared/GenHTTP.Engine.Shared.csproj index fc8377e53..e5e72df8b 100644 --- a/Engine/Shared/GenHTTP.Engine.Shared.csproj +++ b/Engine/Shared/GenHTTP.Engine.Shared.csproj @@ -14,9 +14,9 @@ - + - + diff --git a/Modules/Archives/GenHTTP.Modules.Archives.csproj b/Modules/Archives/GenHTTP.Modules.Archives.csproj index d7a4358b4..cf13ff371 100644 --- a/Modules/Archives/GenHTTP.Modules.Archives.csproj +++ b/Modules/Archives/GenHTTP.Modules.Archives.csproj @@ -14,7 +14,7 @@ - + diff --git a/Modules/DependencyInjection/GenHTTP.Modules.DependencyInjection.csproj b/Modules/DependencyInjection/GenHTTP.Modules.DependencyInjection.csproj index 86782664e..48cf11744 100644 --- a/Modules/DependencyInjection/GenHTTP.Modules.DependencyInjection.csproj +++ b/Modules/DependencyInjection/GenHTTP.Modules.DependencyInjection.csproj @@ -29,7 +29,7 @@ - + diff --git a/Modules/Protobuf/GenHTTP.Modules.Protobuf.csproj b/Modules/Protobuf/GenHTTP.Modules.Protobuf.csproj index cd18bdc75..d5c4a7274 100644 --- a/Modules/Protobuf/GenHTTP.Modules.Protobuf.csproj +++ b/Modules/Protobuf/GenHTTP.Modules.Protobuf.csproj @@ -16,7 +16,7 @@ - + diff --git a/Modules/Reflection/GenHTTP.Modules.Reflection.csproj b/Modules/Reflection/GenHTTP.Modules.Reflection.csproj index 81d533d59..7bb9c1cd5 100644 --- a/Modules/Reflection/GenHTTP.Modules.Reflection.csproj +++ b/Modules/Reflection/GenHTTP.Modules.Reflection.csproj @@ -18,7 +18,7 @@ - + diff --git a/Modules/Reflection/MethodHandler.cs b/Modules/Reflection/MethodHandler.cs index 435bd2a2a..e22956e8c 100644 --- a/Modules/Reflection/MethodHandler.cs +++ b/Modules/Reflection/MethodHandler.cs @@ -1,5 +1,6 @@ using System.Reflection; using System.Runtime.ExceptionServices; +using System.Runtime.CompilerServices; using Cottle; @@ -235,7 +236,8 @@ public ValueTask PrepareAsync(IServer server) throw; } } - + + [RuntimeAsyncMethodGenerationAttribute(false)] private static async ValueTask UnwrapAsync(object? result) { if (result == null) diff --git a/Modules/Reflection/RuntimeAsyncMethodGenerationAttribute.cs b/Modules/Reflection/RuntimeAsyncMethodGenerationAttribute.cs new file mode 100644 index 000000000..d4b0b2d75 --- /dev/null +++ b/Modules/Reflection/RuntimeAsyncMethodGenerationAttribute.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +// ReSharper disable once CheckNamespace +namespace System.Runtime.CompilerServices; + +/// +/// Controls whether runtime-generated async code is used for an async method. +/// +[AttributeUsage(AttributeTargets.Method, Inherited = false)] +public sealed class RuntimeAsyncMethodGenerationAttribute : Attribute +{ + + /// + /// Initializes a new instance of the class. + /// + /// + /// true to enable runtime async generation for the attributed method; + /// false to disable it. + /// + public RuntimeAsyncMethodGenerationAttribute(bool enabled) + { + Enabled = enabled; + } + + /// + /// Gets whether runtime async generation is enabled. + /// + public bool Enabled { get; } + +} diff --git a/Testing/Acceptance/GenHTTP.Testing.Acceptance.csproj b/Testing/Acceptance/GenHTTP.Testing.Acceptance.csproj index c0a97d632..4b9a2cff6 100644 --- a/Testing/Acceptance/GenHTTP.Testing.Acceptance.csproj +++ b/Testing/Acceptance/GenHTTP.Testing.Acceptance.csproj @@ -44,20 +44,20 @@ - + - + - + - + - - + + - + all @@ -66,7 +66,7 @@ - +