Skip to content
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

Blazor .NET 7 release work #27535

Merged
merged 1 commit into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions aspnetcore/blazor/advanced-scenarios.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: Learn how to incorporate manual logic for building Blazor render tr
monikerRange: '>= aspnetcore-3.1'
ms.author: riande
ms.custom: mvc
ms.date: 11/09/2021
ms.date: 11/08/2022
uid: blazor/advanced-scenarios
---
# ASP.NET Core Blazor advanced scenarios (render tree construction)
Expand All @@ -15,7 +15,7 @@ This article describes the advanced scenario for building Blazor render trees ma
> [!WARNING]
> Use of <xref:Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder> to create components is an *advanced scenario*. A malformed component (for example, an unclosed markup tag) can result in undefined behavior. Undefined behavior includes broken content rendering, loss of app features, and ***compromised security***.

:::moniker range=">= aspnetcore-6.0 < aspnetcore-7.0"
:::moniker range=">= aspnetcore-7.0"

## Manually build a render tree (`RenderTreeBuilder`)

Expand All @@ -25,15 +25,15 @@ Consider the following `PetDetails` component, which can be manually rendered in

`Shared/PetDetails.razor`:

:::code language="razor" source="~/../blazor-samples/6.0/BlazorSample_WebAssembly/Shared/advanced-scenarios/PetDetails.razor":::
:::code language="razor" source="~/../blazor-samples/7.0/BlazorSample_WebAssembly/Shared/advanced-scenarios/PetDetails.razor":::

In the following `BuiltContent` component, the loop in the `CreateComponent` method generates three `PetDetails` components.

In <xref:Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder> methods with a sequence number, sequence numbers are source code line numbers. The Blazor difference algorithm relies on the sequence numbers corresponding to distinct lines of code, not distinct call invocations. When creating a component with <xref:Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder> methods, hardcode the arguments for sequence numbers. **Using a calculation or counter to generate the sequence number can lead to poor performance.** For more information, see the [Sequence numbers relate to code line numbers and not execution order](#sequence-numbers-relate-to-code-line-numbers-and-not-execution-order) section.

`Pages/BuiltContent.razor`:

:::code language="razor" source="~/../blazor-samples/6.0/BlazorSample_WebAssembly/Pages/advanced-scenarios/BuiltContent.razor" highlight="6,16-24,28":::
:::code language="razor" source="~/../blazor-samples/7.0/BlazorSample_WebAssembly/Pages/advanced-scenarios/BuiltContent.razor" highlight="6,16-24,28":::

> [!WARNING]
> The types in <xref:Microsoft.AspNetCore.Components.RenderTree> allow processing of the *results* of rendering operations. These are internal details of the Blazor framework implementation. These types should be considered *unstable* and subject to change in future releases.
Expand Down Expand Up @@ -130,7 +130,7 @@ This is a trivial example. In more realistic cases with complex and deeply neste

:::moniker-end

:::moniker range=">= aspnetcore-5.0 < aspnetcore-6.0"
:::moniker range=">= aspnetcore-6.0 < aspnetcore-7.0"

## Manually build a render tree (`RenderTreeBuilder`)

Expand All @@ -140,15 +140,15 @@ Consider the following `PetDetails` component, which can be manually rendered in

`Shared/PetDetails.razor`:

:::code language="razor" source="~/../blazor-samples/5.0/BlazorSample_WebAssembly/Shared/advanced-scenarios/PetDetails.razor":::
:::code language="razor" source="~/../blazor-samples/6.0/BlazorSample_WebAssembly/Shared/advanced-scenarios/PetDetails.razor":::

In the following `BuiltContent` component, the loop in the `CreateComponent` method generates three `PetDetails` components.

In <xref:Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder> methods with a sequence number, sequence numbers are source code line numbers. The Blazor difference algorithm relies on the sequence numbers corresponding to distinct lines of code, not distinct call invocations. When creating a component with <xref:Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder> methods, hardcode the arguments for sequence numbers. **Using a calculation or counter to generate the sequence number can lead to poor performance.** For more information, see the [Sequence numbers relate to code line numbers and not execution order](#sequence-numbers-relate-to-code-line-numbers-and-not-execution-order) section.

`Pages/BuiltContent.razor`:

:::code language="razor" source="~/../blazor-samples/5.0/BlazorSample_WebAssembly/Pages/advanced-scenarios/BuiltContent.razor" highlight="6,16-24,28":::
:::code language="razor" source="~/../blazor-samples/6.0/BlazorSample_WebAssembly/Pages/advanced-scenarios/BuiltContent.razor" highlight="6,16-24,28":::

> [!WARNING]
> The types in <xref:Microsoft.AspNetCore.Components.RenderTree> allow processing of the *results* of rendering operations. These are internal details of the Blazor framework implementation. These types should be considered *unstable* and subject to change in future releases.
Expand Down Expand Up @@ -213,7 +213,7 @@ if (someFlag)
builder.AddContent(seq++, "Second");
```

The first output is seen in the following table.
The first output is reflected in the following table.

| Sequence | Type | Data |
| :------: | --------- | :----: |
Expand Down Expand Up @@ -245,7 +245,7 @@ This is a trivial example. In more realistic cases with complex and deeply neste

:::moniker-end

:::moniker range="< aspnetcore-5.0"
:::moniker range=">= aspnetcore-5.0 < aspnetcore-6.0"

## Manually build a render tree (`RenderTreeBuilder`)

Expand All @@ -255,15 +255,15 @@ Consider the following `PetDetails` component, which can be manually rendered in

`Shared/PetDetails.razor`:

:::code language="razor" source="~/../blazor-samples/3.1/BlazorSample_WebAssembly/Shared/advanced-scenarios/PetDetails.razor":::
:::code language="razor" source="~/../blazor-samples/5.0/BlazorSample_WebAssembly/Shared/advanced-scenarios/PetDetails.razor":::

In the following `BuiltContent` component, the loop in the `CreateComponent` method generates three `PetDetails` components.

In <xref:Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder> methods with a sequence number, sequence numbers are source code line numbers. The Blazor difference algorithm relies on the sequence numbers corresponding to distinct lines of code, not distinct call invocations. When creating a component with <xref:Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder> methods, hardcode the arguments for sequence numbers. **Using a calculation or counter to generate the sequence number can lead to poor performance.** For more information, see the [Sequence numbers relate to code line numbers and not execution order](#sequence-numbers-relate-to-code-line-numbers-and-not-execution-order) section.

`Pages/BuiltContent.razor`:

:::code language="razor" source="~/../blazor-samples/3.1/BlazorSample_WebAssembly/Pages/advanced-scenarios/BuiltContent.razor" highlight="6,16-24,28":::
:::code language="razor" source="~/../blazor-samples/5.0/BlazorSample_WebAssembly/Pages/advanced-scenarios/BuiltContent.razor" highlight="6,16-24,28":::

> [!WARNING]
> The types in <xref:Microsoft.AspNetCore.Components.RenderTree> allow processing of the *results* of rendering operations. These are internal details of the Blazor framework implementation. These types should be considered *unstable* and subject to change in future releases.
Expand Down Expand Up @@ -360,7 +360,7 @@ This is a trivial example. In more realistic cases with complex and deeply neste

:::moniker-end

:::moniker range=">= aspnetcore-7.0"
:::moniker range="< aspnetcore-5.0"

## Manually build a render tree (`RenderTreeBuilder`)

Expand All @@ -370,15 +370,15 @@ Consider the following `PetDetails` component, which can be manually rendered in

`Shared/PetDetails.razor`:

:::code language="razor" source="~/../blazor-samples/7.0/BlazorSample_WebAssembly/Shared/advanced-scenarios/PetDetails.razor":::
:::code language="razor" source="~/../blazor-samples/3.1/BlazorSample_WebAssembly/Shared/advanced-scenarios/PetDetails.razor":::

In the following `BuiltContent` component, the loop in the `CreateComponent` method generates three `PetDetails` components.

In <xref:Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder> methods with a sequence number, sequence numbers are source code line numbers. The Blazor difference algorithm relies on the sequence numbers corresponding to distinct lines of code, not distinct call invocations. When creating a component with <xref:Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder> methods, hardcode the arguments for sequence numbers. **Using a calculation or counter to generate the sequence number can lead to poor performance.** For more information, see the [Sequence numbers relate to code line numbers and not execution order](#sequence-numbers-relate-to-code-line-numbers-and-not-execution-order) section.

`Pages/BuiltContent.razor`:

:::code language="razor" source="~/../blazor-samples/7.0/BlazorSample_WebAssembly/Pages/advanced-scenarios/BuiltContent.razor" highlight="6,16-24,28":::
:::code language="razor" source="~/../blazor-samples/3.1/BlazorSample_WebAssembly/Pages/advanced-scenarios/BuiltContent.razor" highlight="6,16-24,28":::

> [!WARNING]
> The types in <xref:Microsoft.AspNetCore.Components.RenderTree> allow processing of the *results* of rendering operations. These are internal details of the Blazor framework implementation. These types should be considered *unstable* and subject to change in future releases.
Expand Down Expand Up @@ -443,7 +443,7 @@ if (someFlag)
builder.AddContent(seq++, "Second");
```

The first output is reflected in the following table.
The first output is seen in the following table.

| Sequence | Type | Data |
| :------: | --------- | :----: |
Expand Down
Loading