Repository navigation
Description
Describe the bug
Amazon.Lambda.Serialization.SystemTextJson 3.0.0 produces NativeAOT analysis warnings when using SourceGeneratorLambdaJsonSerializer, even though the Lambda serialization boundary is fully source-generated.
The same NativeAOT project publishes cleanly with Amazon.Lambda.Serialization.SystemTextJson 2.4.5.
With 3.0.0, the default NativeAOT publish reports IL3053 for Amazon.Lambda.Serialization.SystemTextJson. Expanding the AOT diagnostics shows IL3050 warnings originating from reflection-oriented serialization methods in DefaultLambdaJsonSerializer/LambdaJsonSerializer.
This is reproducible without any third-party Lambda framework or application library.
Regression Issue
- Select this option if this issue appears to be a regression.
Expected Behavior
A Lambda using LambdaBootstrapBuilder together with SourceGeneratorLambdaJsonSerializer should publish with NativeAOT without IL3050/IL3053 diagnostics from Amazon.Lambda.Serialization.SystemTextJson.
This was the behavior with Amazon.Lambda.Serialization.SystemTextJson 2.4.5.
Current Behavior
With Amazon.Lambda.Serialization.SystemTextJson 3.0.0, NativeAOT publish emits an assembly-level warning similar to:
IL3053: Assembly 'Amazon.Lambda.Serialization.SystemTextJson' produced AOT analysis warnings.
When the diagnostics are expanded, the underlying IL3050 warnings point to reflection-oriented JSON serialization paths, including methods in:
- DefaultLambdaJsonSerializer.InternalSerialize
- DefaultLambdaJsonSerializer.InternalDeserialize
- LambdaJsonSerializer.Serialize
- LambdaJsonSerializer.Deserialize
These ultimately use System.Text.Json APIs marked RequiresDynamicCode.
Changing only Amazon.Lambda.Serialization.SystemTextJson from 3.0.0 back to 2.4.5 makes the NativeAOT publish clean again.
Reproduction Steps
Create a .NET 10 executable Lambda project with NativeAOT enabled.
Project file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<OutputType>Exe</OutputType>
<PublishAot>true</PublishAot>
<StripSymbols>true</StripSymbols>
<TrimMode>partial</TrimMode>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Amazon.Lambda.Core" Version="3.3.0" />
<PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="2.1.2" />
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="3.0.0" />
</ItemGroup>
</Project>Use LambdaBootstrapBuilder with SourceGeneratorLambdaJsonSerializer:
using System.Text.Json.Serialization;
using Amazon.Lambda.Core;
using Amazon.Lambda.RuntimeSupport;
using Amazon.Lambda.Serialization.SystemTextJson;
var handler = (string value, ILambdaContext context) => value.ToUpperInvariant();
await LambdaBootstrapBuilder
.Create(
handler,
new SourceGeneratorLambdaJsonSerializer<LambdaJsonSerializerContext>())
.Build()
.RunAsync();
[JsonSerializable(typeof(string))]
internal partial class LambdaJsonSerializerContext : JsonSerializerContext;Publish it:
dotnet restore --runtime linux-x64
dotnet publish \
--configuration Release \
--runtime linux-x64 \
--self-contained true \
--no-restore \
--warnaserrorWith Amazon.Lambda.Serialization.SystemTextJson 3.0.0 the NativeAOT analysis reports IL3053 (and, when expanded, IL3050 warnings inside the serializer package).
Then change only:
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.5" />The publish completes cleanly without the AOT analysis warnings.
Possible Solution
The 3.0.0 implementation appears to cause NativeAOT analysis to reach reflection-oriented serialization methods even when SourceGeneratorLambdaJsonSerializer is used.
Ideally the source-generated serializer path should remain analyzable without reaching APIs marked RequiresDynamicCode, as it did in 2.4.5.
It may be worth comparing the implementation changes between 2.4.5 and 3.0.0 around LambdaJsonSerializer and DefaultLambdaJsonSerializer.
Additional Information/Context
I originally encountered this while adding NativeAOT support to a Lambda template library, but reduced it to the AWS-only project shown above.
I also compared the behavior with the official dotnet new lambda.NativeAOT project shape.
The official shape publishes cleanly with its older Amazon.Lambda.Serialization.SystemTextJson dependency. Keeping the same NativeAOT hosting model and normalizing the other Lambda packages to:
- Amazon.Lambda.Core 3.3.0
- Amazon.Lambda.RuntimeSupport 2.1.2
still publishes cleanly when Amazon.Lambda.Serialization.SystemTextJson is 2.4.5.
Changing only Amazon.Lambda.Serialization.SystemTextJson to 3.0.0 reproduces the warning.
I found PR #2340 ("Update .NET Targets and Fix warnings") while investigating the change history. It may be relevant to the regression, but I have not established that it is the cause.
AWS .NET SDK and/or Package version used
Amazon.Lambda.Serialization.SystemTextJson 3.0.0 (regression)
Amazon.Lambda.Serialization.SystemTextJson 2.4.5 (works)
Amazon.Lambda.RuntimeSupport 2.1.2
Amazon.Lambda.Core 3.3.0
Targeted .NET Platform
.NET 10 / NativeAOT
Operating System and version
Linux, targeting linux-x64
Activity
Fix NativeAOT IL3050/IL3053 warnings from net10.0 assemblies (#2531)
dscpinheiro commentedon Aug 17, 2026
Hi @Kralizek we just published a new version of the serialization library fixing this issue: https://www.nuget.org/packages/Amazon.Lambda.Serialization.SystemTextJson/3.0.1
As you had noticed, it was related to that PR (we unintentionally removed the AOT properties when targeting .NET 10). With the newer version I do not see any warnings with your reproduction code anymore, but let us know if you see any other issues.
github-actions commentedon Aug 17, 2026
Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.