[CORRUPTED] Synthetic Benchmark PR #64636 - Blazor supports DisplayName for models
#4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Benchmark PR dotnet#64636
Type: Corrupted (contains bugs)
Original PR Title: Blazor supports
DisplayNamefor modelsOriginal PR Description: # Summary
This PR adds the
DisplayName<TValue>component to enable displaying property display names from[Display]and[DisplayName]attributes in Blazor applications, addressing the feature gap identified in issue dotnet#49147.Background
Blazor currently lacks a built-in mechanism to display property names from metadata attributes like MVC's
@Html.DisplayNameFor()helper. This forces developers to either:The new
DisplayName<TValue>component provides an attribute-based solution that follows the same familiar pattern as other Blazor form components likeValidationMessage<TValue>.Fixes dotnet#49147
Changes
Public API
Implementation Details
The component extracts the property name from the expression and reads display metadata:
DisplayAttribute.Name(System.ComponentModel.DataAnnotations)DisplayNameAttribute.DisplayName(System.ComponentModel)Tests
Unit tests in
src/Components/Web/test/Forms/DisplayNameTest.cs:Forparameter is missingDisplayAttribute.NamecorrectlyDisplayNameAttribute.DisplayNamecorrectlyDisplayAttributetakes precedence overDisplayNameAttributeE2E test in
src/Components/test/E2ETest/Tests/FormsTest.cs:DisplayNamelReadsAttributesCorrectly()- Verifies the component renders correctly in a browser with all attribute scenariosAPI usage
Basic form usage:
renders e.g. as:
Table headers:
renders e.g. as:
Model example:
Original PR URL: dotnet#64636