FluentAvalonia icon indicating copy to clipboard operation
FluentAvalonia copied to clipboard

Localization crash due to reflection on net 8

Open emmauss opened this issue 1 year ago • 2 comments

Describe the bug The following crash occurs on net 8-rc 1.

 ---> 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 System.Text.Json.ThrowHelper.ThrowInvalidOperationException_JsonSerializerIsReflectionDisabled()
   at System.Text.Json.JsonSerializerOptions.ConfigureForJsonSerializer()
   at System.Text.Json.JsonSerializer.GetTypeInfo(JsonSerializerOptions options, Type inputType)
   at System.Text.Json.JsonSerializer.GetTypeInfo[T](JsonSerializerOptions options)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](Stream utf8Json, JsonSerializerOptions options)
   at FluentAvalonia.UI.FALocalizationHelper..ctor()
   at FluentAvalonia.UI.FALocalizationHelper..cctor()
   --- End of inner exception stack trace ---

This can be triggered on loading a NavigationView.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop/Platform (please complete the following information):

  • OS: Windows 11
  • FluentAvalonia Version 2.0.1
  • Avalonia Version 11.0.0

Additional context Using dotnet 8.0 RC1

emmauss avatar Sep 14 '23 23:09 emmauss

Workaround for now is set <JsonSerializerIsReflectionEnabledByDefault>true</JsonSerializerIsReflectionEnabledByDefault>

crackedmind avatar Oct 20 '23 12:10 crackedmind

It looks like as soon as .NET 8 is released, adding net8.0 to the TargetFrameworks would solve this problem. The other workaround might if the app explicitly PackageReference System.Text.Json and force explicitly to use the newer STJ instead of using STJ 6.0.x

zcsizmadia avatar Nov 07 '23 14:11 zcsizmadia