Default JsonSerializerIsReflectionEnabledByDefault to true on Blazor WASM.#31909
Default JsonSerializerIsReflectionEnabledByDefault to true on Blazor WASM.#31909lewing merged 2 commits intodotnet:mainfrom
Conversation
|
Thanks for your PR, @eerhardt. |
src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.Current.targets
Outdated
Show resolved
Hide resolved
| <SuppressTrimAnalysisWarnings Condition="'$(SuppressTrimAnalysisWarnings)' == '' And '$(TrimmerDefaultAction)' != 'link'">true</SuppressTrimAnalysisWarnings> | ||
|
|
||
| <!-- Similarly these feature switches must be configured before they are initialized in imported SDKs --> | ||
| <JsonSerializerIsReflectionEnabledByDefault Condition="'$(JsonSerializerIsReflectionEnabledByDefault)' == ''">true</JsonSerializerIsReflectionEnabledByDefault> |
There was a problem hiding this comment.
Does this need any testing?
There was a problem hiding this comment.
See the note in the top comment.
NOTE: I don't know how to test this at this layer. If anyone has a good recommendation for how to test it, I am open to suggestions.
There was a problem hiding this comment.
AFAIK blazor apps don't run here. So best way to test it is to locally run blazor app with the built SDK.
There was a problem hiding this comment.
This can't be disabled for blazor apps, if the user disables this, we should emit an error instead in the context of blazor webassembly apps or simply ignore the user choice.
The framework is dependent on this feature for basic functionality (JS interop)
maraf
left a comment
There was a problem hiding this comment.
It's ok to leave this change affecting only blazor, not vanilla wasm SDK, since that doesn't have an existing user base expecting it to work this way.
Since #31626, the Web SDK is defaulting
JsonSerializerIsReflectionEnabledByDefault=falsewhenever PublishTrimmed or PublishAot is set totrue. However, this also affects Blazor WASM since it is importing the Web SDK. For Blazor WASM, we need to keep the normal default ofJsonSerializerIsReflectionEnabledByDefault=true, so it doesn't break existing Blazor WASM apps that are relying on JsonSerializer using Reflection.See discussion in dotnet/runtime#84378.
NOTE: I don't know how to test this at this layer. If anyone has a good recommendation for how to test it, I am open to suggestions.