-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
MAUI sdk should default the JsonSerializerIsReflectionEnabledByDefault property to true #16038
Comments
I wonder if this should be set at the iOS/Android SDK level rather than MAUI since it'll affect those projects as well. /cc @Redth |
Just noticed that we probably don't want this for the NativeAOT iOS scenario since it should disable reflection there, like for desktop NativeAOT. |
Is this on track for .NET 8 completion? We just received a bug report which seems to suggest that a basic scenario is broken at the moment. |
@rolfbjarne can you do the xamarin-macios side of this? We should also add a runtime/on-device test that does something like |
Sure, tracked here: xamarin/xamarin-macios#18057 |
…er settings Fixes: dotnet/maui#16038 Changes to trimmer defaults in .NET 8 require a new `$(JsonSerializerIsReflectionEnabledByDefault)` MSBuild property to be set by default for project types that use `$(TrimMode)=partial` like when running on mobile (iOS/Android). I added a very basic System.Text.Json test, which fails with the exception: System.InvalidOperationException : JsonSerializerIsReflectionDisabled at System.Text.Json.JsonSerializerOptions.ConfigureForJsonSerializer() at System.Text.Json.JsonSerializer.GetTypeInfo(JsonSerializerOptions , Type ) at System.Text.Json.JsonSerializer.Deserialize(String , Type , JsonSerializerOptions ) at System.Text.JsonTests.JsonSerializerTest.Deserialize() at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args) at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object , BindingFlags ) Simply running the test again with the MSBuild property set allows the test to pass. This will be a good smoke test for System.Text.Json going forward. The iOS side of this is tracked here: xamarin/xamarin-macios#18057
…er settings (#8266) Fixes: dotnet/maui#16038 Changes to trimmer defaults in .NET 8 require a new `$(JsonSerializerIsReflectionEnabledByDefault)` MSBuild property to be set by default for project types that use `$(TrimMode)=partial` like when running on mobile (iOS/Android). I added a very basic System.Text.Json test, which fails with the exception: System.InvalidOperationException : JsonSerializerIsReflectionDisabled at System.Text.Json.JsonSerializerOptions.ConfigureForJsonSerializer() at System.Text.Json.JsonSerializer.GetTypeInfo(JsonSerializerOptions , Type ) at System.Text.Json.JsonSerializer.Deserialize(String , Type , JsonSerializerOptions ) at System.Text.JsonTests.JsonSerializerTest.Deserialize() at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args) at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object , BindingFlags ) Simply running the test again with the MSBuild property set allows the test to pass. This will be a good smoke test for System.Text.Json going forward. The iOS side of this is tracked here: xamarin/xamarin-macios#18057
We are about to merge dotnet/runtime#88480 which once active will turn off System.Text.Json reflection-based serialization for projects with
PublishTrimmed=true
. Projects that use both trimming and reflection serialization will need to explicitly set theJsonSerializerIsReflectionEnabledByDefault
property totrue
. For reference, here's the PR enabling this for blazor wasm targets.The text was updated successfully, but these errors were encountered: