Skip to content

Commit a1321f4

Browse files
Fix trimming issue (#51665)
# [release/8.0] Fix trimming issue affecting Blazor apps with WebAssembly interactivity Fixes an issue where the Blazor WebAssembly runtime would fail on startup for published Blazor apps utilizing WebAssembly interactivity. ## Description The problem was caused by the members of `RootComponentOperationBatch` getting trimmed away. This fix explicitly preserves its members to prevent this from happening. Fixes dotnet/AspNetCore-ManualTests#2420 ## Customer Impact Without this fix, WebAssembly interactivity won't work in any published Blazor Web app. Today, customers could work around the issue by defining a `<TrimmerRootDescriptor>` in their client project's `.csproj` file. For example: ```csproj <!-- Client.csproj --> <ItemGroup> <TrimmerRootDescriptor Include="Roots.xml" /> </ItemGroup> ``` ```xml <!-- Roots.xml --> <linker> <assembly fullname="Microsoft.AspNetCore.Components.WebAssembly"> <type fullname="Microsoft.AspNetCore.Components.RootComponentOperationBatch" preserve="all"> </type> </assembly> </linker> ``` ## Regression? - [X] Yes - [ ] No Regressed from .NET 8 RC2. ## Risk - [ ] High - [ ] Medium - [X] Low The fix does nothing more than mark the members of `RootComponentOperationBatch` to be preserved for JSON serialization. ## Verification - [X] Manual (required) - [ ] Automated ## Packaging changes reviewed? - [ ] Yes - [ ] No - [X] N/A
1 parent 34a9589 commit a1321f4

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/Components/WebAssembly/WebAssembly/src/Services/DefaultWebAssemblyJSRuntime.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public static void UpdateRootComponentsCore(string operationsJson)
105105
}
106106

107107
[DynamicDependency(JsonSerialized, typeof(RootComponentOperation))]
108+
[DynamicDependency(JsonSerialized, typeof(RootComponentOperationBatch))]
108109
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "The correct members will be preserved by the above DynamicDependency")]
109110
internal static RootComponentOperationBatch DeserializeOperations(string operationsJson)
110111
{

0 commit comments

Comments
 (0)