Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #156
Hello there☺️
This PR is attempting to fix the crash/incompatibility with NativeAOT:
IZLoggerFormatter
which shouldn't be an issue. In all the call sites ofFormatLogEntry
,TEntry
is alwaysIZLoggerEntry
and not an actual value type, so forcingIZLoggerEntry
on the interface will avoid the crash at NativeAOT runtimeFailed to create generic virtual method implementation
(In general, it's better to avoid generic method with generic parameters in interfaces):[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)]
to generics mostly to help with the usage of Json behind the scene.[UnconditionalSuppressMessage]
forIL3050
andIL2026
due to the usage of several methods fromJsonSerializer.Serialize
which takes an object. The ones that are usingJsonSerializerOptions
should be fine as the user can set its own instance toSystemTextJsonZLoggerFormatter.JsonSerializerOptions
and initialize it with a NativeAOT/Source generator version. There are other places whereJsonSerializer.Serialize
is used, but without the options. I'm not sure exactly if it will be a problem (I'm not using JsonSerializer for now). Ideally the sameJsonSerializerOptions
should be propagated to all these places, but it looks likeJsonSerializer.Serialize
in these cases might be only used for primitives.