Skip to content
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

Built-in JSON serialization without reflection #221

Closed
gastonfournier opened this issue May 15, 2024 · 8 comments
Closed

Built-in JSON serialization without reflection #221

gastonfournier opened this issue May 15, 2024 · 8 comments

Comments

@gastonfournier
Copy link

Is your feature request related to a problem? Please describe.
Depending on a Json serialization library that requires a custom implementation, can lead to errors. In particular, when defining a custom serialization with system.text if we forget to do stream.Position = 0; the payload will not be serialized properly, leading to errors downstream.

Describe the solution you'd like
Serialization should be provided by the SDK, it's not something users should override, as there's only 1 correct way of serializing the payload. The downside is that the actual users, that are using a custom serializer might cause a crash at runtime.

Describe alternatives you've considered
None, but open to suggestions

Additional context
As a sample test, I wrote a test for System.text as serializer. It's currently not working because the test compares strings to strings and the only difference is the sort order of fields. So it's the test that needs to change. On top of that, the test is not covering serialization of metrics, so it's incomplete. But it's a good enough to prove the point that serialization is dangerous if left in the hands of users and it should be handled by the SDK without giving users the ability to override it:

https://github.com/Unleash/unleash-client-dotnet/compare/system-text-serialization-test?expand=1

@gastonfournier
Copy link
Author

We're making this issue visible after some issues caused by custom serializers, but it's not gonna be prioritized soon. We'd like to collect some feedback from the community (you), and why not some contribution.

@ivarconr ivarconr moved this from New to For later in Issues and PRs May 16, 2024
Copy link

stale bot commented Jun 14, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 14, 2024
@daveleek daveleek removed the stale label Jun 17, 2024
@daveleek daveleek pinned this issue Jun 17, 2024
Copy link

stale bot commented Jul 18, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 18, 2024
@stale stale bot closed this as completed Jul 28, 2024
@github-project-automation github-project-automation bot moved this from For later to Done in Issues and PRs Jul 28, 2024
@daveleek daveleek reopened this Aug 12, 2024
@stale stale bot removed the stale label Aug 12, 2024
Copy link

stale bot commented Sep 11, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 11, 2024
@PhbsSmn
Copy link

PhbsSmn commented Oct 8, 2024

Why not opting for System.Text.Json rather than still using the Newtonsoft implementation?
Did not glance too deeply in the code base but for the things I needed it wasn't such a hard thing, and by doing so you could tap into the power of source generated serialization as well for the newer .NET versions.

Not sure how backwards compatible this is though since it's been a long time now that I used .NET framework.

@sighphyre
Copy link
Member

sighphyre commented Oct 25, 2024

Why not opting for System.Text.Json rather than still using the Newtonsoft implementation? Did not glance too deeply in the code base but for the things I needed it wasn't such a hard thing, and by doing so you could tap into the power of source generated serialization as well for the newer .NET versions.

Not sure how backwards compatible this is though since it's been a long time now that I used .NET framework.

Yeah I think this makes sense. Backwards compatibility should be okay

@sighphyre
Copy link
Member

Handled by #249

@sighphyre
Copy link
Member

This should be out in the next major release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants