Skip to content

Commit 053365f

Browse files
authored
Blazor API doc crosslinks (#18486)
1 parent 2078340 commit 053365f

44 files changed

Lines changed: 428 additions & 423 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

aspnetcore/blazor/advanced-scenarios.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ When a circuit ends because a user has disconnected and the framework is cleanin
6363

6464
## Manual RenderTreeBuilder logic
6565

66-
`Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder` provides methods for manipulating components and elements, including building components manually in C# code.
66+
<xref:Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder> provides methods for manipulating components and elements, including building components manually in C# code.
6767

6868
> [!NOTE]
69-
> Use of `RenderTreeBuilder` to create components is an advanced scenario. A malformed component (for example, an unclosed markup tag) can result in undefined behavior.
69+
> 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.
7070
7171
Consider the following `PetDetails` component, which can be manually built into another component:
7272

@@ -82,7 +82,7 @@ Consider the following `PetDetails` component, which can be manually built into
8282
}
8383
```
8484

85-
In the following example, the loop in the `CreateComponent` method generates three `PetDetails` components. When calling `RenderTreeBuilder` methods to create the components (`OpenComponent` and `AddAttribute`), 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 `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.
85+
In the following example, the loop in the `CreateComponent` method generates three `PetDetails` components. When calling <xref:Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder> methods to create the components (`OpenComponent` and `AddAttribute`), 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.
8686

8787
`BuiltContent` component:
8888

@@ -118,7 +118,7 @@ In the following example, the loop in the `CreateComponent` method generates thr
118118
```
119119

120120
> [!WARNING]
121-
> The types in `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.
121+
> 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.
122122
123123
### Sequence numbers relate to code line numbers and not execution order
124124

@@ -206,7 +206,7 @@ This is a trivial example. In more realistic cases with complex and deeply neste
206206

207207
* App performance suffers if sequence numbers are generated dynamically.
208208
* The framework can't create its own sequence numbers automatically at runtime because the necessary information doesn't exist unless it's captured at compile time.
209-
* Don't write long blocks of manually-implemented `RenderTreeBuilder` logic. Prefer *.razor* files and allow the compiler to deal with the sequence numbers. If you're unable to avoid manual `RenderTreeBuilder` logic, split long blocks of code into smaller pieces wrapped in `OpenRegion`/`CloseRegion` calls. Each region has its own separate space of sequence numbers, so you can restart from zero (or any other arbitrary number) inside each region.
209+
* Don't write long blocks of manually-implemented <xref:Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder> logic. Prefer *.razor* files and allow the compiler to deal with the sequence numbers. If you're unable to avoid manual <xref:Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder> logic, split long blocks of code into smaller pieces wrapped in <xref:Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.OpenRegion%2A>/<xref:Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.CloseRegion%2A> calls. Each region has its own separate space of sequence numbers, so you can restart from zero (or any other arbitrary number) inside each region.
210210
* If sequence numbers are hardcoded, the diff algorithm only requires that sequence numbers increase in value. The initial value and gaps are irrelevant. One legitimate option is to use the code line number as the sequence number, or start from zero and increase by ones or hundreds (or any preferred interval).
211211
* Blazor uses sequence numbers, while other tree-diffing UI frameworks don't use them. Diffing is far faster when sequence numbers are used, and Blazor has the advantage of a compile step that deals with sequence numbers automatically for developers authoring *.razor* files.
212212

aspnetcore/blazor/call-dotnet-from-javascript.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ This article covers invoking .NET methods from JavaScript. For information on ho
2121

2222
## Static .NET method call
2323

24-
To invoke a static .NET method from JavaScript, use the `DotNet.invokeMethod` or `DotNet.invokeMethodAsync` functions. Pass in the identifier of the static method you wish to call, the name of the assembly containing the function, and any arguments. The asynchronous version is preferred to support Blazor Server scenarios. The .NET method must be public, static, and have the `[JSInvokable]` attribute. Calling open generic methods isn't currently supported.
24+
To invoke a static .NET method from JavaScript, use the `DotNet.invokeMethod` or `DotNet.invokeMethodAsync` functions. Pass in the identifier of the static method you wish to call, the name of the assembly containing the function, and any arguments. The asynchronous version is preferred to support Blazor Server scenarios. The .NET method must be public, static, and have the [`[JSInvokable]`](xref:Microsoft.JSInterop.JSInvokableAttribute) attribute. Calling open generic methods isn't currently supported.
2525

26-
The sample app includes a C# method to return an `int` array. The `JSInvokable` attribute is applied to the method.
26+
The sample app includes a C# method to return an `int` array. The [`[JSInvokable]`](xref:Microsoft.JSInterop.JSInvokableAttribute) attribute is applied to the method.
2727

2828
*Pages/JsInterop.razor*:
2929

@@ -58,7 +58,7 @@ Array(4) [ 1, 2, 3, 4 ]
5858

5959
The fourth array value is pushed to the array (`data.push(4);`) returned by `ReturnArrayAsync`.
6060

61-
By default, the method identifier is the method name, but you can specify a different identifier using the `JSInvokableAttribute` constructor:
61+
By default, the method identifier is the method name, but you can specify a different identifier using the [`[JSInvokable]`](xref:Microsoft.JSInterop.JSInvokableAttribute) attribute constructor:
6262

6363
```csharp
6464
@code {
@@ -87,8 +87,8 @@ returnArrayAsyncJs: function () {
8787
You can also call .NET instance methods from JavaScript. To invoke a .NET instance method from JavaScript:
8888

8989
* Pass the .NET instance by reference to JavaScript:
90-
* Make a static call to `DotNetObjectReference.Create`.
91-
* Wrap the instance in a `DotNetObjectReference` instance and call `Create` on the `DotNetObjectReference` instance. Dispose of `DotNetObjectReference` objects (an example appears later in this section).
90+
* Make a static call to <xref:Microsoft.JSInterop.DotNetObjectReference.Create%2A?displayProperty=nameWithType>.
91+
* Wrap the instance in a <xref:Microsoft.JSInterop.DotNetObjectReference> instance and call <xref:Microsoft.JSInterop.DotNetObjectReference.Create%2A> on the <xref:Microsoft.JSInterop.DotNetObjectReference> instance. Dispose of <xref:Microsoft.JSInterop.DotNetObjectReference> objects (an example appears later in this section).
9292
* Invoke .NET instance methods on the instance using the `invokeMethod` or `invokeMethodAsync` functions. The .NET instance can also be passed as an argument when invoking other .NET methods from JavaScript.
9393

9494
> [!NOTE]
@@ -134,9 +134,9 @@ Console output in the browser's web developer tools:
134134
Hello, Blazor!
135135
```
136136

137-
To avoid a memory leak and allow garbage collection on a component that creates a `DotNetObjectReference`, adopt one of the following approaches:
137+
To avoid a memory leak and allow garbage collection on a component that creates a <xref:Microsoft.JSInterop.DotNetObjectReference>, adopt one of the following approaches:
138138

139-
* Dispose of the object in the class that created the `DotNetObjectReference` instance:
139+
* Dispose of the object in the class that created the <xref:Microsoft.JSInterop.DotNetObjectReference> instance:
140140

141141
```csharp
142142
public class ExampleJsInterop : IDisposable
@@ -198,7 +198,7 @@ To avoid a memory leak and allow garbage collection on a component that creates
198198
}
199199
```
200200

201-
* When the component or class doesn't dispose of the `DotNetObjectReference`, dispose of the object on the client by calling `.dispose()`:
201+
* When the component or class doesn't dispose of the <xref:Microsoft.JSInterop.DotNetObjectReference>, dispose of the object on the client by calling `.dispose()`:
202202

203203
```javascript
204204
window.myFunction = (dotnetHelper) => {
@@ -212,7 +212,7 @@ To avoid a memory leak and allow garbage collection on a component that creates
212212
To invoke a component's .NET methods:
213213

214214
* Use the `invokeMethod` or `invokeMethodAsync` function to make a static method call to the component.
215-
* The component's static method wraps the call to its instance method as an invoked `Action`.
215+
* The component's static method wraps the call to its instance method as an invoked <xref:System.Action>.
216216

217217
In the client-side JavaScript:
218218

@@ -258,11 +258,11 @@ function updateMessageCallerJS() {
258258
}
259259
```
260260

261-
When there are several components, each with instance methods to call, use a helper class to invoke the instance methods (as `Action`s) of each component.
261+
When there are several components, each with instance methods to call, use a helper class to invoke the instance methods (as <xref:System.Action>s) of each component.
262262

263263
In the following example:
264264

265-
* The `JSInterop` component contains several `ListItem` components.
265+
* The `JSInteropExample` component contains several `ListItem` components.
266266
* Each `ListItem` component is composed of a message and a button.
267267
* When a `ListItem` component button is selected, that `ListItem`'s `UpdateMessage` method changes the list item text and hides the button.
268268

@@ -333,10 +333,10 @@ window.updateMessageCallerJS = (dotnetHelper) => {
333333
}
334334
```
335335

336-
*Pages/JSInterop.razor*:
336+
*Pages/JSInteropExample.razor*:
337337

338338
```razor
339-
@page "/JSInterop"
339+
@page "/JSInteropExample"
340340
341341
<h1>List of components</h1>
342342

0 commit comments

Comments
 (0)