Utilize .NET 8.0 trimming-safe EventSourcePrimitives for logging#352
Utilize .NET 8.0 trimming-safe EventSourcePrimitives for logging#352zeroskyx wants to merge 1 commit into
Conversation
|
@microsoft-github-policy-service agree |
maxkatz6
left a comment
There was a problem hiding this comment.
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.
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.