Skip to content
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

Add support for assembly trimming and AOT #132

Open
Tyrrrz opened this issue May 30, 2024 · 2 comments
Open

Add support for assembly trimming and AOT #132

Tyrrrz opened this issue May 30, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@Tyrrrz
Copy link
Contributor

Tyrrrz commented May 30, 2024

#130 added annotations for APIs that dynamically reference code (usually through reflection). These methods are, in essence, in compatible with trimming/AOT.

This means that the only available way to set up the raw Passwordless.dev SDK is by using this overload, which requires configuring the options manually:

public static IServiceCollection AddPasswordlessSdk(
        this IServiceCollection services,
        Action<PasswordlessOptions> configureOptions)

For the Identity integration package, we currently offer no way to add Passwordless.dev in a way that works with trimming/AOT.

Some of it may be a side-effect of the nature of ASP.NET Core as the foundation, but Microsoft is already rolling out certain alternative APIs to help support trimming/AOT scenarios. For example, for the configuration binding, we can use this approach to avoid reflection.

@Tyrrrz Tyrrrz added the enhancement New feature or request label May 30, 2024
@abergs
Copy link
Member

abergs commented May 30, 2024

While this issue is informative, are there any clear steps of action? While intriguing, I don't see AOT & trimming highly prioritised by users (since they run on top of asp.net)

@Tyrrrz
Copy link
Contributor Author

Tyrrrz commented May 30, 2024

ASP.NET Core does support AOT as of .NET 8 (at least the docs claim so): https://learn.microsoft.com/en-us/aspnet/core/fundamentals/native-aot?view=aspnetcore-8.0

The benefits are mostly: smaller disk footprint (extra useful for docker images) and faster execution.

As you can see from this table, not every aspect of ASP.NET is fully supported:

image

When it comes to actionable steps, I think we should look into providing overloads that are compatible with source-generated configuration binding. Most of the trim warnings that are triggered in our code are due to IConiguration.Bind(...) or similar calls. We should instead accept an IOptions<...> directly as a parameter.

Ideally, we should refactor our code so that the only trim warnings we have are those that bubble up from our dependencies, specifically those from ASP.NET Core and Identity that don't have trim-compatible alternatives. Currently, this is not the case.

I agree that AOT/trimming is a relatively low priority issue for web apps, but it's not unlikely that it will not remain such indefinitely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants