aws / aws-lambda-dotnet

Libraries, samples and tools to help .NET Core developers develop AWS Lambda functions.
Apache License 2.0
1.58k stars 477 forks source link

Add suppression for IL3050 when serializing objects for structured logging. #1795

Closed normj closed 3 months ago

normj commented 3 months ago

With structured logging the "@" directive can be used to indicate the POCO used for a logging parameter should be json serialized. With structured logging in Native AOT we do a best attempt to serialize. If the serialization fails then fallback to the regular ToString method. Previously the code had a suppression for IL2026 calling out the serialization was a best attempt. For some reason when actually publishing for NativeAOT it also triggers the IL3050 warning that doesn't show up in the normal build despite EnableTrimAnalyzer being enabled.

This PR adds the suppression for IL3050 as well as add a new unit tests that compiles a function with NativeAOT enabled. If any AOT trim warnings are produced during the publish the test fails.