Skip to content

Blazor supports DisplayName for models#17

Open
tomerqodo wants to merge 17 commits intocopilot_combined_20260121_qodo_grep_cursor_copilot_1_base_blazor_supports_displayname_for_models_pr84from
copilot_combined_20260121_qodo_grep_cursor_copilot_1_head_blazor_supports_displayname_for_models_pr84
Open

Blazor supports DisplayName for models#17
tomerqodo wants to merge 17 commits intocopilot_combined_20260121_qodo_grep_cursor_copilot_1_base_blazor_supports_displayname_for_models_pr84from
copilot_combined_20260121_qodo_grep_cursor_copilot_1_head_blazor_supports_displayname_for_models_pr84

Conversation

@tomerqodo
Copy link
Copy Markdown

Benchmark PR from qodo-benchmark#84

Copilot AI review requested due to automatic review settings January 21, 2026 18:10
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds a new DisplayName component to Blazor that automatically renders display names for model properties by reading from DisplayAttribute, DisplayNameAttribute, or falling back to the property name. The PR updates project templates to use this component for form labels and includes comprehensive test coverage.

Changes:

  • Introduces new DisplayName<TValue> component for automatic label rendering
  • Adds ExpressionMemberAccessor utility class to extract display names from model properties
  • Updates project templates (Login, Register, ResetPassword, etc.) to use DisplayName component instead of hardcoded labels
  • Includes unit tests, E2E tests, and localization support

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/Components/Web/src/Forms/DisplayName.cs New component that renders display names for model properties
src/Components/Web/src/Forms/ExpressionMemberAccessor.cs Utility class for extracting member metadata and display names from expressions
src/Components/Web/test/Forms/DisplayNameTest.cs Comprehensive unit tests for DisplayName component
src/Components/test/E2ETest/Tests/FormsTest.cs E2E test for DisplayName component behavior
src/Components/test/testassets/BasicTestApp/FormsTest/DisplayNameComponent.razor Test component demonstrating various DisplayName usage patterns
src/Components/test/testassets/BasicTestApp/TestResources.cs Wrapper for resource localization testing
src/Components/test/testassets/BasicTestApp/Resources.resx Resource file with test data for localization
src/Components/test/testassets/BasicTestApp/Resources.fr.resx French resource file for localization testing
src/Components/test/testassets/BasicTestApp/Index.razor Added DisplayName component to test component list
src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWebCSharp.1/Components/Account/Pages/ResetPassword.razor Updated to use DisplayName component for form labels
src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWebCSharp.1/Components/Account/Pages/Register.razor Updated to use DisplayName component for form labels
src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWebCSharp.1/Components/Account/Pages/Manage/Email.razor Updated to use DisplayName component for form labels
src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWebCSharp.1/Components/Account/Pages/Manage/ChangePassword.razor Updated to use DisplayName component for form labels
src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWebCSharp.1/Components/Account/Pages/Login.razor Updated to use DisplayName component for form labels
src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWebCSharp.1/Components/Account/Pages/ForgotPassword.razor Updated to use DisplayName component for form labels
src/Components/Web/src/PublicAPI.Unshipped.txt Added public API surface for DisplayName component

internal static class ExpressionMemberAccessor
{
private static readonly ConcurrentDictionary<Expression, MemberInfo> _memberInfoCache = new();
private static readonly ConcurrentDictionary<MemberInfo, string> _displayNameCache = new();
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _displayNameCache field is declared but never used in the code. Consider removing it if it's not needed, or implement caching for display names in the GetDisplayName method to improve performance.

Copilot uses AI. Check for mistakes.
Comment on lines +34 to +38
<InputText type="password" @bind-Value="Input.Password" id="Input.Password" class="form-control" autocomplete="current-password" aria-required="true" placeholder="password" />
<label for="Input.Password" class="form-label">
<DisplayName For="() => Input.Password" />
</label>
<ValidationMessage For="() => Input.Password" class="text-danger" />
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The InputText element has inconsistent indentation. It should be indented to align with other elements in the same div block (should have 4 more spaces at the beginning).

Suggested change
<InputText type="password" @bind-Value="Input.Password" id="Input.Password" class="form-control" autocomplete="current-password" aria-required="true" placeholder="password" />
<label for="Input.Password" class="form-label">
<DisplayName For="() => Input.Password" />
</label>
<ValidationMessage For="() => Input.Password" class="text-danger" />
<InputText type="password" @bind-Value="Input.Password" id="Input.Password" class="form-control" autocomplete="current-password" aria-required="true" placeholder="password" />
<label for="Input.Password" class="form-label">
<DisplayName For="() => Input.Password" />
</label>
<ValidationMessage For="() => Input.Password" class="text-danger" />

Copilot uses AI. Check for mistakes.

private static void ClearCache()
{
_memberInfoCache.Clear();
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ClearCache method clears _memberInfoCache but does not clear _displayNameCache. If _displayNameCache is intended to be used in the future, it should also be cleared here to maintain consistency during hot reload scenarios.

Suggested change
_memberInfoCache.Clear();
_memberInfoCache.Clear();
_displayNameCache.Clear();

Copilot uses AI. Check for mistakes.
Comment on lines +32 to +41
<label for="Input.Email">
<DisplayName For="() => Input.Email" />
</label>
<ValidationMessage For="() => Input.Email" class="text-danger" />
</div>
<div class="form-floating mb-3">
<InputText type="password" @bind-Value="Input.Password" id="Input.Password" class="form-control" autocomplete="new-password" aria-required="true" placeholder="password" />
<label for="Input.Password">Password</label>
<label for="Input.Password">
<DisplayName For="() => Input.Password" />
</label>
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The label elements are inconsistent with the form-label CSS class. Labels on lines 32 and 39 are missing class="form-label" while the label on line 46 has it. For consistency across the form and with other similar pages (ResetPassword, Login, etc.), all labels should have class="form-label".

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants