IdentityModel / IdentityModel.OidcClient

Certified C#/NetStandard OpenID Connect Client Library for native mobile/desktop Applications (RFC 8252)
Apache License 2.0
599 stars 175 forks source link

Fix trimming warnings when publishing with Native AOT #451

Open rabuckley opened 3 days ago

rabuckley commented 3 days ago

This fixes the two AOT analysis warnings in this project

IdentityModel.OidcClient/src/OidcClient/Infrastructure/LogSerializer.cs(52): AOT analysis warning IL3050: IdentityModel.OidcClient.Infrastructure.LogSerializer.Serialize(Object): Using member 'System.Text.Json.JsonSerializer.Serialize<Object>(Object,JsonSerializerOptions)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.
IdentityModel.OidcClient/src/OidcClient/Infrastructure/LogSerializer.cs(36): AOT analysis warning IL3050: IdentityModel.OidcClient.Infrastructure.LogSerializer..cctor(): Using member 'System.Text.Json.Serialization.JsonStringEnumConverter.JsonStringEnumConverter()' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. JsonStringEnumConverter cannot be statically analyzed and requires runtime code generation. Applications should use the generic JsonStringEnumConverter<TEnum> instead.

When targetting net9.0 there are no errors. When targeting net8.0, there is one remaining error, which is tracked in the dotnet runtime by https://github.com/dotnet/runtime/issues/109958.