8000 LaunchDarkly.ClientSDK 5.3.0 fails in trimmed applications · Issue #90 · launchdarkly/dotnet-core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

LaunchDarkly.ClientSDK 5.3.0 fails in trimmed applications #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
GaryHughes opened this issue Apr 4, 2025 · 2 comments
Open

LaunchDarkly.ClientSDK 5.3.0 fails in trimmed applications #90

GaryHughes opened this issue Apr 4, 2025 · 2 comments
Labels
bug Something isn't working package: sdk/server

Comments

@GaryHughes
Copy link

Describe the bug
If I create a trimmed application the SDK fails due to the use of reflection based JSON serialisation.

To reproduce
Create a new .NET project and enable trimming in the project file.

true

Integrate the LaunchDarkly API as per your sample applications, when LDClient.Init() is called the following exception will be raised.

2025-04-04 11:22:48.981 +11:00 [LaunchDarkly.Sdk] INFO: Starting LaunchDarkly Client 5.3.0.0 built with target framework net7.0
2025-04-04 11:22:49.034 +11:00 [LaunchDarkly.Sdk] INFO: Network availability is now True
Unhandled exception. System.InvalidOperationException: Reflection-based serialization has been disabled for this application. Either use the source generator APIs or explicitly configure the 'JsonSerializerOptions.TypeInfoResolver' property.
at LaunchDarkly.Sdk.Internal.Concurrent.AsyncUtils.WaitSafely(Func`1 taskFn, TimeSpan timeout)
at LaunchDarkly.Sdk.Client.LdClient.Start(TimeSpan maxWaitTime)
at LaunchDarkly.Sdk.Client.LdClient.Init(Configuration config, Context initialContext, TimeSpan maxWaitTime)
at Program.

$(String[] args) in /Users/ghughes/Developer/CurlAgents/LaunchDarkly/Program.cs:line 6

Expected behavior
The LDClient.Init() method returns without throwing this exception.

Logs
See above.

SDK version
Client 5.3.0

Language version, developer tools
.NET 8.0.

OS/platform
Tested on macOS but exception is not platform specific.

@GaryHughes GaryHughes added bug Something isn't working package: sdk/server labels Apr 4, 2025
@tanderson-ld
Copy link
Contributor

Hi @GaryHughes. We see this sometimes in other ecosystems that use reflection around the communication protocol. Is there a way for you to disable trimming for a subset of packages/classes? That may be faster and more guaranteed to get you unblocked. I am not familiar with the flexibility of the trimming configuration for .NET.

@GaryHughes
Copy link
Author

Hi @tanderson-ld disabling trimming in general is not possible, our software has tight size constraints that preclude this. I'll look at the options for excluding your code but our experience with that technique has not been great. Replacing reflection based serialisation with source generators is quite straight forward, there is a good explainer here if you haven't seen it https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/source-generation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
L 3F77 abels
bug Something isn't working package: sdk/server
Projects
None yet
Development

No branches or pull requests

2 participants
0