Skip to content

Trim analysis warnings #49

@justindbaur

Description

@justindbaur

Hi, when trying to use the LaunchDarkly.ServerSdk library, which brings in code from this repository and trying to publish my app using ahead of time compilation I am running into some trim analysis warnings from this repo. The following are the errors that I believe pertain to code in this repo:

Trim analysis warning IL2026: LaunchDarkly.Sdk.Internal.Events.EventProcessorInternal.<SendDiagnosticEventAsync>d__32.MoveNext(): Using member 'System.Text.Json.JsonSerializer.SerializeToUtf8Bytes<LdValue>(LdValue,JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.
AOT analysis warning IL3050: LaunchDarkly.Sdk.Internal.Events.EventProcessorInternal.<SendDiagnosticEventAsync>d__32.MoveNext(): Using member 'System.Text.Json.JsonSerializer.SerializeToUtf8Bytes<LdValue>(LdValue,JsonSerializerOptions)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.

These are basically the same error pointing at this code:

var jsonDiagnostic = JsonSerializer.SerializeToUtf8Bytes(diagnostic.JsonValue);

Would a PR to help fix these warnings and a test suite to help ensure no future issues be welcomed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions