tmenier / Flurl

Fluent URL builder and testable HTTP client for .NET
https://flurl.dev
MIT License
4.23k stars 387 forks source link

Trimming unused code causes the exception - Response could not be deserialized to JSON #827

Closed KB4MDD closed 5 months ago

KB4MDD commented 6 months ago

I am compiling my .NET 8 application for linux-arm, I have enabled the produce single file and trim unused code options. Flurl raises the exception "Response could not be deserialized to JSON". When I uncheck the "trim unused code" option, there is no exception.

It is clear that the compiler and linker are discarding something that Flurl needs to deserialize the JSON data. This may be addressed by changes asked for in #777.

I am moving my application from .NET 6 to .NET 8. I did not have an issue with .NET 6.

tranb3r commented 6 months ago

Did you try setting JsonSerializerIsReflectionEnabledByDefault to false ?

KB4MDD commented 6 months ago

I tried setting that property to false and it still fails. I also tried setting to true and it still fails.

tmenier commented 6 months ago

Thanks for reporting. I'm not very well equipped to troubleshoot support for less-common platforms, so I try and lean on the community to help with things like this.

KB4MDD commented 5 months ago

I have worked around the problem using the source generation capabilities in system.text.json.

It would be nice to have Issue #777 implemented so that a context could be passed to Flurl.

I am closing this issue.