Skip to content

Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions without reflection ? #31561

@LLT21

Description

@LLT21

I have tried to compile my .NET 5 bare http server project with Native AOT without reflection. This is possible for a normal http connection, but not for a https connection because in Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions the line of code:

var loggerFactory = listenOptions.KestrelServerOptions?.ApplicationServices.GetRequiredService<ILoggerFactory>() ?? NullLoggerFactory.Instance;

that appears twice in this class requires reflection. Could it be changed to:

var loggerFactory = listenOptions.KestrelServerOptions?.ApplicationServices?.GetRequiredService<ILoggerFactory>() ?? NullLoggerFactory.Instance;

so that it has the ? after ApplicationServices. In this way I believe the reflection can be avoided.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NativeAOTarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsfeature-kestrel

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions