Closed
Description
Today we use expression tree compilation to create the thunks for minimal APIs invocations it fails to work when used with NativeAOT compilation. We need to provide an alterative implementation that doesn't use dynamic code generation in order to make this work. The options are source generators or a reflection based fallback.
Turns out expression tree compilation is interpreted with NativeAOT and that's a fine fallback (though not the most optimized for high throughput). Where it does fail is the TryParse reflection:
Unhandled Exception: System.TypeInitializationException: A type initializer threw an exception. To determine which type, inspect the InnerException's StackTrace property.
---> System.TypeInitializationException: A type initializer threw an exception. To determine which type, inspect the InnerException's StackTrace property.
---> System.Exception: static bool System.Enum.TryParse<TEnum>(string? value, out TEnum result) not found.
at Microsoft.AspNetCore.Http.TryParseMethodCache.GetEnumTryParseMethod() + 0x2b9
at Microsoft.AspNetCore.Http.TryParseMethodCache..cctor() + 0x20
at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext*) + 0x17c
--- End of inner exception stack trace ---
at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext*) + 0x27e
at System.Runtime.CompilerServices.ClassConstructorRunner.CheckStaticClassConstructionReturnGCStaticBase(StaticClassConstructionContext*, Object) + 0x1b
at Microsoft.AspNetCore.Http.RequestDelegateFactory..cctor() + 0xe3d
at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext*) + 0x17c
--- End of inner exception stack trace ---
at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext*) + 0x27e
at System.Runtime.CompilerServices.ClassConstructorRunner.CheckStaticClassConstructionReturnGCStaticBase(StaticClassConstructionContext*, Object) + 0x1b
at Microsoft.AspNetCore.Http.RequestDelegateFactory.Create(Delegate, RequestDelegateFactoryOptions) + 0xc2
at Microsoft.AspNetCore.Builder.MinimalActionEndpointRouteBuilderExtensions.Map(IEndpointRouteBuilder, RoutePattern, Delegate) + 0x253
at Microsoft.AspNetCore.Builder.MinimalActionEndpointRouteBuilderExtensions.MapMethods(IEndpointRouteBuilder, String, IEnumerable`1, Delegate) + 0xa1
at Microsoft.AspNetCore.Builder.MinimalActionEndpointRouteBuilderExtensions.MapGet(IEndpointRouteBuilder, String, Delegate) + 0x42
at Program.<Main>$(String[]) + 0xe1
at WebApplication520!<BaseAddress>+0x10b0897
at WebApplication520!<BaseAddress>+0x10b0920
Metadata
Metadata
Assignees
Labels
Work that is nice to haveIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcThis issue represents an ask for new feature or an enhancement to an existing oneController-like actions for endpoint routing*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels