Skip to content

Conversation

@justindbaur
Copy link

@justindbaur justindbaur commented Oct 13, 2025

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

Part of #90
Prerequisite for launchdarkly/dotnet-sdk-internal#49

Describe the solution you've provided

I made all targets of the common SDK trim safe using the built in system text json source generators.

Describe alternatives you've considered

The already written converters could be called directly in the places where LdValue and Context need to be serialized.

Additional context

I do have a test console app that can be published with AOT and then ran to make sure that these items can be serialized properly but wasn't totally sure where I should put it. If that is desired I can add it, just need to know where to put it.


Note

Adopts System.Text.Json source generation for Context/LdValue and updates serializers, converters, and project settings to be AOT/trim friendly.

  • Serialization (NET7+):
    • Use generated context LdJsonSerializerContext for Context.ToString, LdValue.Parse, and LdValue.ToJsonString.
    • Add LdJsonSerializerContext with [JsonSerializable] for LdValue and Context.
    • Annotate LdJsonSerialization methods with RequiresUnreferencedCode/RequiresDynamicCode warnings and messages.
  • JSON Converters:
    • Use Enum.GetValues<T>() on NET5+ for BigSegmentsStatus, EvaluationErrorKind, and EvaluationReasonKind identifier mapping.
    • Correct enum iteration in EvaluationReasonKindConverter to use the proper enum type.
  • Project Configuration:
    • Conditionally set LangVersion to 9.0 and IsAotCompatible true for NET7+ targets.
  • Behavior:
    • Maintain existing paths for older frameworks via #if guards.

Written by Cursor Bugbot for commit 67e2603. This will update automatically on new commits. Configure here.

@justindbaur justindbaur changed the title Make common sdk AOT safe feat: Make common sdk AOT safe Oct 13, 2025
@justindbaur justindbaur marked this pull request as ready for review October 13, 2025 00:54
@justindbaur justindbaur requested a review from a team as a code owner October 13, 2025 00:54
cursor[bot]

This comment was marked as outdated.

@jsonbailey
Copy link
Contributor

@justindbaur thanks for submitting the PR. I will review this as soon as I can.

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.

2 participants