Skip to content

Utilize .NET 8.0 trimming-safe EventSourcePrimitives for logging#352

Open
zeroskyx wants to merge 1 commit into
microsoft:masterfrom
zeroskyx:master
Open

Utilize .NET 8.0 trimming-safe EventSourcePrimitives for logging#352
zeroskyx wants to merge 1 commit into
microsoft:masterfrom
zeroskyx:master

Conversation

@zeroskyx

Copy link
Copy Markdown

This PR fixes #349 by utilizing .NET 8.0 trimming-safe EventSourcePrimitives for logging.

Please note that this requires .NET 8.0 which might need to be added to the build pipeline.

@zeroskyx

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@maxkatz6 maxkatz6 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR fixes the trimming warning.

Previously, this code was using WriteEvent(int eventId, params object[] args) overload, which was involving potentially trimmer unsafe object serialization and is marked RequiresUnreferencedCode because of that.
Unsafe object serialization is not really the case in this code, every argument is a primitive. But compiler only sees that RequiresUnreferencedCode method is used and emits warning.

With this PR, new WriteEvent(int eventId, params EventSourcePrimitive[] args) overload is used. It is safe and is not marked with RequiresUnreferencedCode attribute, because each EventSourcePrimitive can only be created from the primitive by implicit cast.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing [RequiresUnreferencedCodeAttribute] annotation for trimming

3 participants