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

Replace System.Text.Json dependency in AsmResolver.DotNet with internal light-weight JSON parser #450

Closed
Washi1337 opened this issue Jun 13, 2023 · 2 comments · Fixed by #538
Labels
dotnet Issues related to AsmResolver.DotNet enhancement
Milestone

Comments

@Washi1337
Copy link
Owner

Washi1337 commented Jun 13, 2023

Problem Description

The DotNet package uses System.Text.Json to interpret the runtimeconfig.json files associated to input binaries. System.Text.Json was introduced in .NET Core 3.0 or later, and we are currently targeting the latest LTS version of .NET 6.0. As a result, projects using AsmResolver.DotNet that target legacy .NET framework require pulling in many dependencies, including polyfill packages such as System.Buffers. For such a small (non-crucial) portion of the library, this seems excessive.

Proposal

Replace the System.Text.Json serializer/deserializer code with a small, lightweight JSON parser that we can embed into the library directly, effectively removing dependencies to System.Text.Json and other polyfill dependencies for consumers targeting legacy frameworks.

Alternatives

We can consider using compiler preprocessor directives to switch between implementations of the JSON parser (e.g., using a direcvtive like#if NETSTANDARD). This way, for builds targeting recent runtime versions, we can keep usingSystem.Text.Json and keep leveraging the simplicity and performance of this library, while for for older more generic builds, we use a light-weight JSON parser instead. The downside of this is that it requires maintaining two versions of the same functionality.

Additional Context

No response

@Washi1337 Washi1337 added enhancement dotnet Issues related to AsmResolver.DotNet labels Jun 13, 2023
@Washi1337 Washi1337 added this to the 6.0.0 milestone Jun 13, 2023
@caesay
Copy link

caesay commented Jan 23, 2024

I did this exact thing in my dotnet installer/auto-updater with preprocessor directives to use System.Text.Json on dotnet and Newtonsoft.Json on full framework. Feel free to steal it if it's helpful. https://github.com/velopack/velopack/blob/master/src/Velopack/Internal/SimpleJson.cs

@Washi1337 Washi1337 mentioned this issue Mar 15, 2024
4 tasks
@Washi1337
Copy link
Owner Author

Potential candidates for embeddable JSON parsers:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet Issues related to AsmResolver.DotNet enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants