Open dualtagh opened 1 month ago
This sounds right. Only question I have is how many of the other interfaces should we patch in the same release.
@keegan-caruso
These are the other interfaces that have AOT warnings for Json serialization. I could use some help understanding if these should be patched too?
The fix would be the same as above - providing an overload with JsonTypeInfo.
DownstreamApi.cs
CallApiForAppAsync<TInput, TOutput>
CallApiForUserAsync
DownstreamApi.HttpMethods.cs
GetForUserAsync
DownstreamWebApiGenericExtensions.cs
GetForUserAsync
Microsoft.Identity.Web.TokenAcquisition\TokenAcquisition.cs AddAccountToCacheFromAuthorizationCodeAsync
Microsoft.Identity.Web\WebAppExtensions\MicrosoftIdentityWebAppAuthenticationBuilder.cs WebAppCallsWebApiImplementation
the ones in DownstreamApi.cs and DownstreamApi.HttpMethods.cs should be if we can patch for DownstreamWebApiGenericExtensions.cs this would be great.
I would not do it for the last two:
Just curious how this was fixed? I see a draft PR still open for this topic.
This is still open - the prerequisite PR in abstractions has been merged and release but this PR implements the changes in microsoft-identity-web https://github.com/AzureAD/microsoft-identity-web/pull/2959
Is your feature request related to a problem? Please describe. microsoft-identity-web emits NativeAOT trim warnings when GetForUserAsync is called from a NativeAOT compiled library. This is caused by using generics for JSON serialization/deserialization in DownstreamApi.cs.
Describe the solution you'd like Public interfaces (particularly GetForUserAsync) should accept a JsonTypeInfo so that source generation can be used for Json serialization in a NativeAOT context.
Existing interfaces should be marked with the [RequiresUnreferencedCode] attribute. New interfaces that accept JsonTypeInfo should be made available only for net8+.
Example change for IDownstreamApi:
Describe alternatives you've considered Open to suggestions
Additional context There is a short term need for GetForUserAsync to be NativeAOT compliant - but there are other interfaces with AOT warnings that could require similar changes. Will follow up with more details on this