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

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

Merged
merged 1 commit into from
Aug 24, 2024

Conversation

normj
Copy link
Member

@normj normj commented Aug 20, 2024

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.

…gging.

The serialization is done as a best attempt with a fallback to using "ToString" if the reflection fails for NativeAOT.
@normj normj merged commit f3c8087 into feature/structured-logging Aug 24, 2024
3 of 4 checks passed
@normj normj deleted the normj/fix-structuredlogging-aot branch August 24, 2024 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants