Skip to content

Commit 180b6c7

Browse files
authored
[Blazor] Clarify trimming behavior for custom types (#36094)
1 parent 365db75 commit 180b6c7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

aspnetcore/blazor/host-and-deploy/configure-trimmer.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,20 @@ Consider the following example that performs JSON deserialization into a <xref:S
8383

8484
The preceding component executes normally when the app is run locally and produces the following rendered list:
8585

86-
> • 1:T1, 1:T2
86+
> • 1:T1, 1:T2
8787
> • 2:T2, 2:T2
8888
8989
When the app is published, <xref:System.Tuple%602> is trimmed from the app, even in spite of setting the `<PublishTrimmed>` property to `false` in the project file. Accessing the component throws the following exception:
9090

91-
> :::no-loc text="crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]":::
92-
> :::no-loc text="Unhandled exception rendering component: ConstructorContainsNullParameterNames, System.Tuple`2[System.String,System.String]":::
91+
> :::no-loc text="crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]":::
92+
> :::no-loc text="Unhandled exception rendering component: ConstructorContainsNullParameterNames, System.Tuple`2[System.String,System.String]":::
9393
> :::no-loc text="System.NotSupportedException: ConstructorContainsNullParameterNames, System.Tuple`2[System.String,System.String]":::
9494
9595
To address lost types, consider adopting one of the following approaches.
9696

9797
### Custom types
9898

99-
Custom types aren't trimmed by Blazor when an app is published, so we recommend using custom types for JS interop, JSON serialization/deserialization, and other operations that rely on reflection.
99+
Custom types aren't trimmed by Blazor when an app is published (unless explicitly opted in), so we recommend using custom types for JS interop, JSON serialization/deserialization, and other operations that rely on reflection.
100100

101101
The following modifications create a `StringTuple` type for use by the component.
102102

@@ -123,7 +123,7 @@ The component is modified to use the `StringTuple` type:
123123
+ items = JsonSerializer.Deserialize<List<StringTuple>>(data, options)!;
124124
```
125125

126-
Because custom types are never trimmed by Blazor when an app is published, the component works as designed after the app is published.
126+
Because custom types aren't trimmed by Blazor when an app is published (unless explicitly opted in), the component works as designed after the app is published.
127127

128128
:::moniker range=">= aspnetcore-10.0"
129129

0 commit comments

Comments
 (0)