Skip to content

Commit a1f7171

Browse files
authored
Wrap-up 10.0 inline work items (#36495)
1 parent 4324c05 commit a1f7171

9 files changed

Lines changed: 78 additions & 85 deletions

File tree

aspnetcore/blazor/call-web-api.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@ Example:
5757

5858
In the app's `Program` file, call:
5959

60-
<!-- UPDATE 10.0 - Missing API doc for 'Microsoft.Identity.Web.DownstreamApiExtensions.AddDownstreamApi' -->
60+
<!-- UPDATE 11.0 - Awaiting API per https://github.com/dotnet/AspNetCore.Docs/issues/36373.
61+
Marking this for 11.0 because it's the last 10.0 item and inline tracking
62+
now adopts 11.0 or later work items. This ensures that this inline item
63+
isn't missed.
64+
65+
Missing API doc for 'Microsoft.Identity.Web.DownstreamApiExtensions.AddDownstreamApi' -->
6166

6267
* <xref:Microsoft.Identity.Web.MicrosoftIdentityWebApiAuthenticationBuilder.EnableTokenAcquisitionToCallDownstreamApi%2A>: Enables token acquisition to call web APIs.
6368
* `AddDownstreamApi`: Microsoft Identity Web packages provide API to create a named downstream web service for making web API calls. <xref:Microsoft.Identity.Abstractions.IDownstreamApi> is injected into a server-side class, which is used to call <xref:Microsoft.Identity.Abstractions.IDownstreamApi.CallApiForUserAsync%2A> to obtain weather data from an external web API (`MinimalApiJwt` project).

aspnetcore/blazor/components/quickgrid.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ With the **Add New Scaffold Item** dialog open to **Installed** > **Common** > *
477477

478478
Complete the **Add Razor Components using Entity Framework (CRUD)** dialog:
479479

480-
<!-- UPDATE 10.0 Keep an eye on https://github.com/dotnet/Scaffolding/issues/3131
480+
<!-- UPDATE 11.0 Keep an eye on https://github.com/dotnet/Scaffolding/issues/3131
481481
for a scaffolding update that makes the scaffolder a little
482482
smarter about suggesting an existing dB context that has a
483483
factory provider. If the scaffolder can do that, this instruction

aspnetcore/blazor/forms/validation.md

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,27 +1576,23 @@ The <xref:System.ComponentModel.DataAnnotations.CompareAttribute> doesn't work w
15761576

15771577
Blazor form validation includes support for validating properties of nested objects and collection items with the built-in <xref:Microsoft.AspNetCore.Components.Forms.DataAnnotationsValidator>.
15781578

1579-
To create a validated form, use a <xref:Microsoft.AspNetCore.Components.Forms.DataAnnotationsValidator> component inside an <xref:Microsoft.AspNetCore.Components.Forms.EditForm> component, just as before.
1579+
To create a validated form, use a <xref:Microsoft.AspNetCore.Components.Forms.DataAnnotationsValidator> component inside an <xref:Microsoft.AspNetCore.Components.Forms.EditForm> component.
15801580

15811581
To opt into the nested objects and collection types validation feature:
15821582

15831583
1. Call the <xref:Microsoft.Extensions.DependencyInjection.ValidationServiceCollectionExtensions.AddValidation%2A> extension method in the `Program` file where services are registered.
15841584
2. Declare the form model types in a C# class file, not in a Razor component (`.razor`).
15851585
3. Annotate the root form model type with the [`[ValidatableType]` attribute](xref:Microsoft.Extensions.Validation.ValidatableTypeAttribute).
15861586

1587-
Without following the preceding steps, form validation behavior doesn't include nested model and collection type validation.
1588-
1589-
<!-- UPDATE 10.0 - Replace with a fully working, cut-'n-paste example -->
1590-
1591-
The following example demonstrates customer orders with the improved form validation (details omitted for brevity):
1587+
The following example demonstrates customer orders with nested collection form validation.
15921588

15931589
In `Program.cs`, call <xref:Microsoft.Extensions.DependencyInjection.ValidationServiceCollectionExtensions.AddValidation%2A> on the service collection:
15941590

15951591
```csharp
15961592
builder.Services.AddValidation();
15971593
```
15981594

1599-
In the following `Order` class, the `[ValidatableType]` attribute is required on the top-level model type. The other types are discovered automatically. `OrderItem` and `ShippingAddress` aren't shown for brevity, but nested and collection validation works the same way in those types if they were shown.
1595+
In the following `Order` class, the `[ValidatableType]` attribute is required on the top-level model type. The other types are discovered automatically.
16001596

16011597
`Order.cs`:
16021598

@@ -1622,6 +1618,41 @@ public class Customer
16221618
}
16231619
```
16241620

1621+
`OrderItem.cs`:
1622+
1623+
```csharp
1624+
public class OrderItem
1625+
{
1626+
[Required(ErrorMessage = "Id is required.")]
1627+
public int Id { get; set; }
1628+
1629+
[Required(ErrorMessage = "Description is required.")]
1630+
public string? Description { get; set; }
1631+
1632+
[Required(ErrorMessage = "Price is required.")]
1633+
public decimal Price { get; set; }
1634+
}
1635+
```
1636+
1637+
`ShippingAddress.cs`:
1638+
1639+
```csharp
1640+
public class ShippingAddress
1641+
{
1642+
[Required(ErrorMessage = "Street is required.")]
1643+
public string? Street { get; set; }
1644+
1645+
[Required(ErrorMessage = "City is required.")]
1646+
public string? City { get; set; }
1647+
1648+
[Required(ErrorMessage = "State/Province is required.")]
1649+
public string? StateProvince { get; set; }
1650+
1651+
[Required(ErrorMessage = "PostalCode is required.")]
1652+
public string? PostalCode { get; set; }
1653+
}
1654+
```
1655+
16251656
In the following `OrderPage` component, the <xref:Microsoft.AspNetCore.Components.Forms.DataAnnotationsValidator> component is present in the <xref:Microsoft.AspNetCore.Components.Forms.EditForm> component.
16261657

16271658
`OrderPage.razor`:
@@ -1649,7 +1680,7 @@ In the following `OrderPage` component, the <xref:Microsoft.AspNetCore.Component
16491680
}
16501681
```
16511682

1652-
The requirement to declare the model types outside of Razor components (`.razor` files) is due to the fact that both the new validation feature and the Razor compiler itself are using a source generator. Currently, output of one source generator can't be used as an input for another source generator.
1683+
The requirement to declare the model types outside of Razor components (`.razor` files) is due to the fact that both the nested collection validation feature and the Razor compiler itself are using a source generator. Currently, output of one source generator can't be used as an input for another source generator.
16531684

16541685
For guidance on using validation models from a different assembly, see the [Use validation models from a different assembly](#use-validation-models-from-a-different-assembly) section.
16551686

0 commit comments

Comments
 (0)