Skip to content

feat: Make common sdk AOT safe#169

Open
justindbaur wants to merge 3 commits intolaunchdarkly:mainfrom
justindbaur:main
Open

feat: Make common sdk AOT safe#169
justindbaur wants to merge 3 commits intolaunchdarkly:mainfrom
justindbaur:main

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

Medium Risk
Touches core JSON serialization paths for Context and LdValue, which could change runtime serialization/deserialization behavior on newer TFMs and impact AOT/trim scenarios if the generated context is incomplete.

Overview
Improves AOT/trim compatibility by introducing a System.Text.Json source-generated LdJsonSerializerContext (net7+) and switching Context.ToString(), LdValue.Parse(), and LdValue.ToJsonString() to use the generated JsonTypeInfo when available.

Updates JSON helpers to add net7+ trim/AOT warning annotations on LdJsonSerialization APIs, adjusts enum converter implementations to use generic Enum.GetValues<T>() where supported, and fixes EvaluationReasonKindConverter.FromIdentifier to iterate the correct enum type.

Written by Cursor Bugbot for commit 7523b20. 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