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

AoT support #815

Merged
merged 1 commit into from
Nov 9, 2023
Merged

Conversation

martincostello
Copy link
Member

Add support for native AoT for the libraries.

After my adventures getting this working for Polly, I thought I'd give it a try here, and it seemed to be relatively simple.

The only changes required were for the Trovo and Yammer providers to use AoT-friendly JSON serialization. Everything else appears to Just Work™️.

Tested by:

  1. Adding the following to the Mvc.Sample project file:
    <PropertyGroup>
      <PublishAot>true</PublishAot>
      <SelfContained>true</SelfContained>
      <TrimmerSingleWarn>false</TrimmerSingleWarn>
    </PropertyGroup>
    <ItemGroup>
      <TrimmerRootAssembly Include="@(ProjectReference->'%(Filename)')" />
    </ItemGroup>
  2. Commenting out services.AddMvc() (because it's not supported)
  3. Running dotnet publish for the Mvc.Sample project.

Only one warning is output, and that's from MVC's own lack of support.

ILC : Trim analysis warning IL2026: Microsoft.AspNetCore.Mvc.Routing.ConventionalRouteEntry.ConventionalRouteEntry(String,String,RouteValueDictionary,IDictionary`2<String,Object>,RouteValueDictionary,Int32,List`1<Acion`1<EndpointBuilder>>,List`1<Action`1<EndpointBuilder>>): Using member 'Microsoft.AspNetCore.Routing.Patterns.RoutePatternFactory.Parse(String,Object,Object)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. This API may perform reflection on supplied parameters which may be trimmed if not referenced directly. Initialize a RouteValueDictionary with route values to avoid this issue. [C:\Coding\aspnet-contrib\AspNet.Security.OAuth.Providers\samples\Mvc.Client\Mvc.Client.csproj]

Thoughts?

Add support for native AoT for the libraries.
@kevinchalet
Copy link
Member

Everything else appears to Just Work™️.

Looks almost too easy to be true 🤣

Copy link
Member

@kevinchalet kevinchalet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do it 👍🏻

@martincostello
Copy link
Member Author

Cool - I'll just do a double-check locally that I haven't messed up the serialization format and then I'll merge this in for the v8 release.

@martincostello
Copy link
Member Author

Yep, it works as expected. The payloads before and after are:

Trovo

{"redirect_uri":"http://localhost/signin-trovo","code":"a6ed8e7f-471f-44f1-903b-65946475f351","client_secret":"my-client-secret","grant_type":"authorization_code"}

Yammer

{"access_token":"ajsdfiasd7f6asdf8o","token_type":"","refresh_token":"","expires_in":""}

@martincostello martincostello marked this pull request as ready for review November 9, 2023 17:06
@martincostello martincostello merged commit cedd813 into aspnet-contrib:dev-v8 Nov 9, 2023
8 checks passed
@martincostello martincostello deleted the aot-support branch November 9, 2023 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants