Skip to content

Commit 6d78b6d

Browse files
authored
Blazor RC1 wrap-up 8.0 (#30339)
1 parent aef25ad commit 6d78b6d

File tree

7 files changed

+88
-3
lines changed

7 files changed

+88
-3
lines changed

aspnetcore/blazor/components/quickgrid.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ To use Entity Framework (EF) Core as the data source:
9696
builder.Services.AddQuickGridEntityFrameworkAdapter();
9797
```
9898

99+
QuickGrid supports passing custom attributes to the the rendered table element:
100+
101+
```razor
102+
<QuickGrid Items="..." custom-attribute="somevalue" class="custom-class">
103+
```
104+
99105
:::moniker-end
100106

101107
:::moniker range="< aspnetcore-8.0"

aspnetcore/blazor/components/render-modes.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,3 +458,14 @@ You also typically must set the same interactive render mode on the `HeadOutlet`
458458
> In an upcoming preview release, a template option for the Blazor Web App template to create the app with root-level interactivity.
459459
460460
<!-- UPDATE 8.0 The preceding is tracked by https://github.com/dotnet/aspnetcore/issues/50433 -->
461+
462+
## Discover components from additional assemblies for static server rendering
463+
464+
Configure additional assemblies to use for discovering routable Razor components for static server rendering using the `AddAdditionalAssemblies` method chained to <xref:Microsoft.AspNetCore.Builder.RazorComponentsEndpointRouteBuilderExtensions.MapRazorComponents%2A>.
465+
466+
The following example includes the assembly of the `DifferentAssemblyCounter` component:
467+
468+
```csharp
469+
app.MapRazorComponents<App>()
470+
.AddAdditionalAssemblies(typeof(DifferentAssemblyCounter).Assembly);
471+
```

aspnetcore/blazor/forms-and-input-components.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2744,6 +2744,31 @@ Control the style of validation messages in the app's stylesheet (`wwwroot/css/a
27442744
}
27452745
```
27462746

2747+
:::moniker range=">= aspnetcore-8.0"
2748+
2749+
## Determine if a form field is valid
2750+
2751+
<!-- UPDATE 8.0 API cross-link -->
2752+
2753+
Use `EditContext.IsValid(fieldIdentifier)` to determine if a field is valid without obtaining validation messages.
2754+
2755+
<span aria-hidden="true">❌</span> Supported, but not recommended:
2756+
2757+
```csharp
2758+
var isValid = !editContext.GetValidationMessages(fieldIdentifier).Any();
2759+
```
2760+
2761+
<span aria-hidden="true">✔️</span> Recommended:
2762+
2763+
```csharp
2764+
var isValid = editContext.IsValid(fieldIdentifier);
2765+
```
2766+
2767+
> [!NOTE]
2768+
> Custom validation examples in this article call <xref:Microsoft.AspNetCore.Components.Forms.EditContext.GetValidationMessages%2A> on the edit context to determine if a field is valid. An issue has been opened at [Update Blazor form custom validation examples 8.0 (dotnet/AspNetCore.Docs #30338)](https://github.com/dotnet/AspNetCore.Docs/issues/30338) to update the examples to use the new API. We recommend using the new `EditContext.IsValid` API in your own code, but the approach with <xref:Microsoft.AspNetCore.Components.Forms.EditContext.GetValidationMessages%2A> is still supported and doesn't result in a runtime error if testing the article's examples.
2769+
2770+
:::moniker-end
2771+
27472772
## Custom validation attributes
27482773

27492774
To ensure that a validation result is correctly associated with a field when using a [custom validation attribute](xref:mvc/models/validation#custom-attributes), pass the validation context's <xref:System.ComponentModel.DataAnnotations.ValidationContext.MemberName> when creating the <xref:System.ComponentModel.DataAnnotations.ValidationResult>.

aspnetcore/blazor/fundamentals/startup.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ In `wwwroot/index.html`, remove the default SVG round indicator in `<div id="app
462462

463463
## Configure the .NET WebAssembly runtime
464464

465-
To configure the .NET WebAssembly runtime, use the `configureRuntime` property with the `dotnet` runtime host builder.
465+
To configure the .NET WebAssembly runtime, use the `configureRuntime` function with the `dotnet` runtime host builder.
466466

467467
The following example sets an environment variable, `CONFIGURE_RUNTIME`, to `true`:
468468

@@ -479,6 +479,8 @@ The following example sets an environment variable, `CONFIGURE_RUNTIME`, to `tru
479479

480480
In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name.
481481

482+
The .NET runtime instance can be accessed from `Blazor.runtime`.
483+
482484
:::moniker-end
483485

484486
## Additional resources

aspnetcore/blazor/host-and-deploy/webassembly.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,33 @@ The size of an AOT-compiled Blazor WebAssembly app is generally larger than the
103103
> [!NOTE]
104104
> For [Mono](https://github.com/mono/mono)/WebAssembly MSBuild properties and targets, see [`WasmApp.targets` (dotnet/runtime GitHub repository)](https://github.com/dotnet/runtime/blob/main/src/mono/wasm/build/WasmApp.targets). Official documentation for common MSBuild properties is planned per [Document blazor msbuild configuration options (dotnet/docs #27395)](https://github.com/dotnet/docs/issues/27395).
105105
106+
:::moniker-end
107+
108+
:::moniker range=">= aspnetcore-8.0"
109+
110+
## Trim .NET IL after ahead-of-time (AOT) compilation
111+
112+
The `WasmStripILAfterAOT` MSBuild option enables removing the .NET Intermediate Language (IL) for compiled methods after performing AOT compilation to WebAssembly, which reduces the size of the `_framework` folder.
113+
114+
In the app's project file:
115+
116+
```xml
117+
<PropertyGroup>
118+
<RunAOTCompilation>true</RunAOTCompilation>
119+
<WasmStripILAfterAOT>true</WasmStripILAfterAOT>
120+
</PropertyGroup>
121+
```
122+
123+
This setting trims away the IL code for most compiled methods, including methods from libraries and methods in the app. Not all compiled methods can be trimmed, as some are still required by the .NET interpreter at runtime.
124+
125+
<!-- UPDATE 8.0 Remove the next line after some time has passed -->
126+
127+
If you hit any issues using this trimming option, [open an issue on the `dotnet/runtime` GitHub repository](https://github.com/dotnet/runtime/issues).
128+
129+
:::moniker-end
130+
131+
:::moniker range=">= aspnetcore-6.0"
132+
106133
## Runtime relinking
107134

108135
One of the largest parts of a Blazor WebAssembly app is the WebAssembly-based .NET runtime (`dotnet.wasm`) that the browser must download when the app is first accessed by a user's browser. Relinking the .NET WebAssembly runtime trims unused runtime code and thus improves download speed.

aspnetcore/blazor/project-structure.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ Blazor Web App project template: `blazor`
2222

2323
Project structure:
2424

25+
If both the WebAssembly and Server render modes are selected on app creation, the project template uses the Auto render mode. The Auto render mode initially uses the Server mode while the .NET app bundle and runtime are download to the browser. After the .NET WebAssembly runtime is activated, Auto switches to the WebAssembly render mode.
26+
27+
By default, the Blazor Web App template enables both static and interactive server rendering using a single project. If you also enable the WebAssembly render mode, the project includes an additional client project (`.Client`) for your WebAssembly-based components. The built output from the client project is downloaded to the browser and executed on the client. Any components using the WebAssembly or Auto render modes must be built from the client project.
28+
29+
For more information, see <xref:blazor/components/render-modes>.
30+
2531
<!-- UPDATE 8.0 Check on Error page setup per
2632
https://github.com/dotnet/aspnetcore/issues/49853 -->
2733

@@ -57,7 +63,7 @@ Project structure:
5763

5864
* App settings files (`appsettings.Development.json`, `appsettings.json`): Provide [configuration settings](xref:blazor/fundamentals/configuration) for the server project.
5965

60-
* Client project: `.Client`
66+
* Client project (`.Client`):
6167

6268
* `Pages` folder: Contains the app's routable client-side Razor components (`.razor`). The route for each page is specified using the [`@page`](xref:mvc/views/razor#page) directive. The template includes `Counter` component (`Counter.razor`) that implements the *Counter* page.
6369

aspnetcore/blazor/tooling.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,16 @@ To create a Blazor app on Windows, use the following guidance:
6161
<!-- UPDATE 8.0 Cross-link SSR -->
6262

6363
* For a Blazor Web App in the **Additional information** dialog:
64+
6465
* Interactivity with server rendering is enabled by default with the **Use interactive server components** checkbox.
65-
* To enable interactivity with client rendering, select the **Use interactive client components** checkbox.
66+
* To enable interactivity with client rendering, select the **Use interactive WebAssembly components** checkbox.
67+
* To include sample pages and a layout based on Bootstrap styling, select the **Include sample pages** checkbox. Disable this option for an empty project without Bootstrap styling.
68+
69+
If both the WebAssembly and Server render modes are selected, the template uses the Auto render mode. The Auto render mode initially uses the Server mode while the .NET app bundle and runtime are download to the browser. After the .NET WebAssembly runtime is activated, Auto switches to the WebAssembly render mode.
70+
71+
By default, the Blazor Web App template enables both static and interactive server rendering using a single project. If you also enable the WebAssembly render mode, the project includes an additional client project (`.Client`) for your WebAssembly-based components. The built output from the client project is downloaded to the browser and executed on the client. Any components using the WebAssembly or Auto render modes must be built from the client project.
72+
73+
For more information, see <xref:blazor/components/render-modes>.
6674

6775
<!-- UPDATE 8.0 I think the interactive root component checkbox
6876
will appear at RC2. -->

0 commit comments

Comments
 (0)