-
Notifications
You must be signed in to change notification settings - Fork 10.3k
RDG throws at startup when combined with PublishAot and AuthorizationMiddleware #49855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I should note this is using the latest rc1 SDK and you can work around this with the following: builder.Services.ConfigureHttpJsonOptions(options =>
{
options.SerializerOptions.TypeInfoResolver = JsonTypeInfoResolver.Combine();
}); Or by not adding the |
@captainsafia - I thought we fixed these issues with #49393. Is that not the case? Or is it because the source generator uses different code than RDF does? Kind of similar to #47973? |
Yep, the code is not shared here. :/ It's super fishy to me that the middleware registration is the triggering factor here. Looking into that now.... EDIT: I suspect this might be related to the fact that the authorization middleware resolves |
To follow-up, the The real problem is that RDG doesn't play nice if you're running with PublishAoT enabled but don't have the JSON source generator enabled (that's what the NSE warns about anyway). We could make the failure mode a little nicer at runtime ("hey you're running with aot enabled but don't have JSON source gen setup"). That would also make the RDG more useful when people want to enable it outside the context of AoT. Thoughts? |
RequestDelegateGenerator
throws at startup when theAuthorizationMiddleware
constructor resolves itsAuthorizationPolicyCache
andPublishAot
is enabled. The throwing call toGetTypeInfo
is in the generated code'sRequestDelegateFactoryFunc createRequestDelegate
in lines generated for the filter pipeline to handle possible object returns withobjectJsonTypeInfo
.aspnetcore/src/Http/Http.Extensions/gen/StaticRouteHandlerModel/Emitters/EndpointJsonPreparationEmitter.cs
Lines 9 to 14 in dbd6a51
I'm not exactly sure why adding the
AuthorizationMiddleware
triggers it, but here's the repro app:Hand here's the unhandled startup exception:
@eerhardt @captainsafia
The text was updated successfully, but these errors were encountered: