amwx / FluentAvalonia

Control library focused on fluent design and bringing more WinUI controls into Avalonia
MIT License
1.05k stars 97 forks source link

Localization crash due to reflection on net 8 #481

Closed emmauss closed 8 months ago

emmauss commented 1 year ago

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):

Additional context Using dotnet 8.0 RC1

crackedmind commented 1 year ago

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

zcsizmadia commented 1 year ago

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