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

Mark IdentityModel and OidcClient AOT compatible and fix AOT trimming warning #71

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions foss.sln
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "workflow-gen", ".github\wor
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityModel.OidcClient.Extensions", "identity-model-oidc-client\src\IdentityModel.OidcClient.Extensions\IdentityModel.OidcClient.Extensions.csproj", "{71943026-C895-4C39-953E-3F02519EFDA7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrimmableAnalysis", "identity-model-oidc-client\src\TrimmableAnalysis\TrimmableAnalysis.csproj", "{DB959C7D-0C67-435A-A0DB-CE6ED94DC72A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -202,6 +204,10 @@ Global
{71943026-C895-4C39-953E-3F02519EFDA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{71943026-C895-4C39-953E-3F02519EFDA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{71943026-C895-4C39-953E-3F02519EFDA7}.Release|Any CPU.Build.0 = Release|Any CPU
{DB959C7D-0C67-435A-A0DB-CE6ED94DC72A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DB959C7D-0C67-435A-A0DB-CE6ED94DC72A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DB959C7D-0C67-435A-A0DB-CE6ED94DC72A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DB959C7D-0C67-435A-A0DB-CE6ED94DC72A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -239,6 +245,7 @@ Global
{DB9D419A-39BE-4AF0-8DF5-AC59DB218469} = {7FE03753-F6F7-48B3-B38B-52EC8C804998}
{79FA307B-8362-448B-8ED3-A8E60700B04C} = {F3E00123-AE97-4BF4-8868-E078B59691C8}
{71943026-C895-4C39-953E-3F02519EFDA7} = {93313B63-592B-41AA-B122-BE6DED75B198}
{DB959C7D-0C67-435A-A0DB-CE6ED94DC72A} = {93313B63-592B-41AA-B122-BE6DED75B198}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {198D25AC-7BC4-48D6-BF04-37AF59E0648D}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<PackageTags>OAuth2;OAuth 2.0;OpenID Connect;Security;Identity;IdentityServer;DPoP</PackageTags>
<Description>DPoP extensions for IdentityModel.OidcClient</Description>
<PackageReadmePath>README.md</PackageReadmePath>
<IsTrimmable Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">true</IsTrimmable>
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">true</IsAotCompatible>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<PackageId>Duende.IdentityModel.OidcClient</PackageId>
<PackageTags>OAuth2;OAuth 2.0;OpenID Connect;Security;Identity;IdentityServer</PackageTags>
<Description>RFC8252 compliant and certified OpenID Connect and OAuth 2.0 client library for native applications</Description>
<IsTrimmable Condition="'$(TargetFramework)' != 'netstandard2.0'">true</IsTrimmable>
<IsTrimmable Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">true</IsTrimmable>
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">true</IsAotCompatible>
<Nullable>disable</Nullable>
<PackageReadmePath>README.md</PackageReadmePath>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ public static class LogSerializer
WriteIndented = true
};


#if NET7_0_OR_GREATER
[UnconditionalSuppressMessage("AOT",
"IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.",
Justification = "Code using `JsonOptions` is guarded by `RequiresDynamicCodeAttribute`")]
#endif
static LogSerializer()
{
JsonOptions.Converters.Add(new JsonStringEnumConverter());
Expand All @@ -40,6 +46,9 @@ static LogSerializer()
/// <returns></returns>
#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("The log serializer uses reflection in a way that is incompatible with trimming")]
#endif
#if NET7_0_OR_GREATER
[RequiresDynamicCode("The log serializer uses reflection in a way that is incompatible with trimming")]
#endif
public static string Serialize(object logObject)
{
Expand All @@ -59,6 +68,6 @@ private static string Serialize<T>(T logObject)
return Enabled ?
JsonSerializer.Serialize(logObject, (JsonTypeInfo<T>)SourceGenerationContext.Default.GetTypeInfo(typeof(T))) :
"Logging has been disabled";
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<PublishTrimmed>true</PublishTrimmed>
<PublishAot>true</PublishAot>
<TrimmerSingleWarn>false</TrimmerSingleWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\OidcClient\OidcClient.csproj" />
<ProjectReference Include="..\..\src\OidcClient.IdentityTokenValidator\OidcClient.IdentityTokenValidator.csproj" />
<ProjectReference Include="..\..\src\OidcClient.DPoP\OidcClient.DPoP.csproj" />
<ProjectReference Include="..\IdentityModel.OidcClient\IdentityModel.OidcClient.csproj" />
<TrimmerRootAssembly Include="Duende.IdentityModel.OidcClient" />

<ProjectReference Include="..\IdentityModel.OidcClient.Extensions\IdentityModel.OidcClient.Extensions.csproj" />
<TrimmerRootAssembly Include="Duende.IdentityModel.OidcClient.Extensions" />
</ItemGroup>

</Project>
2 changes: 2 additions & 0 deletions identity-model/src/IdentityModel/IdentityModel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<Description>OpenID Connect &amp; OAuth 2.0 client library</Description>
<PackageId>Duende.IdentityModel</PackageId>
<PackageTags>OAuth2;OAuth 2.0;OpenID Connect;Security;Identity;IdentityServer</PackageTags>
<IsTrimmable Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">true</IsTrimmable>
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">true</IsAotCompatible>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<PublishTrimmed>true</PublishTrimmed>
<PublishAot>true</PublishAot>
<TrimmerSingleWarn>false</TrimmerSingleWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>$(NoWarn);NU1507</NoWarn>
Expand Down
Loading