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

Fix trimming warnings when publishing with Native AOT #451

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
5 changes: 3 additions & 2 deletions src/DPoP/DPoP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
<DebugType>embedded</DebugType>

<!-- Enable Trimming Warnings to allow consumers to publish as trimmed -->
<IsTrimmable Condition="'$(TargetFramework)' == 'net6.0'">true</IsTrimmable>

<IsTrimmable Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">true</IsTrimmable>
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">true</IsAotCompatible>

<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true'">True</ContinuousIntegrationBuild>

<AssemblyOriginatorKeyFile>../../key.snk</AssemblyOriginatorKeyFile>
Expand Down
7 changes: 4 additions & 3 deletions src/IdentityTokenValidator/IdentityTokenValidator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<RootNamespace>IdentityModel.OidcClient</RootNamespace>
<AssemblyName>IdentityModel.OidcClient.IdentityTokenValidator</AssemblyName>

<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>

<PackageTags>OAuth2;OAuth 2.0;OpenID Connect;Security;Identity;IdentityServer</PackageTags>
<Description>Identity token validator for IdentityModeo.OidcClient based on the Microsoft JWT handler</Description>
Expand All @@ -24,8 +24,9 @@
<DebugType>embedded</DebugType>

<!-- Enable Trimming Warnings to allow consumers to publish as trimmed -->
<IsTrimmable Condition="'$(TargetFramework)' == 'net6.0'">true</IsTrimmable>

<IsTrimmable Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">true</IsTrimmable>
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">true</IsAotCompatible>

<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true'">True</ContinuousIntegrationBuild>

<AssemblyOriginatorKeyFile>../../key.snk</AssemblyOriginatorKeyFile>
Expand Down
10 changes: 9 additions & 1 deletion src/OidcClient/Infrastructure/LogSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ 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 @@ -39,7 +44,10 @@ static LogSerializer()
/// <param name="logObject">The object.</param>
/// <returns></returns>
#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("The log serializer uses reflection in a way that is incompatible with trimming")]
[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 Down
9 changes: 5 additions & 4 deletions src/OidcClient/OidcClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<RootNamespace>IdentityModel.OidcClient</RootNamespace>
<AssemblyName>IdentityModel.OidcClient</AssemblyName>

<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
<LangVersion>latest</LangVersion>

<PackageId>IdentityModel.OidcClient</PackageId>
Expand All @@ -27,8 +27,9 @@
<DebugType>embedded</DebugType>

<!-- Enable Trimming Warnings to allow consumers to publish as trimmed -->
<IsTrimmable Condition="'$(TargetFramework)' == 'net6.0'">true</IsTrimmable>

<IsTrimmable Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">true</IsTrimmable>
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">true</IsAotCompatible>

<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true'">True</ContinuousIntegrationBuild>

<AssemblyOriginatorKeyFile>../../key.snk</AssemblyOriginatorKeyFile>
Expand All @@ -50,7 +51,7 @@
</ItemGroup>

<!--Conditional Package references -->
<ItemGroup Condition="'$(TargetFramework)' != 'net6.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.Text.Json" Version="8.0.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion test/TrimmableAnalysis/TrimmableAnalysis.csproj
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>
<IsPackable>false</IsPackable>
Expand Down