Skip to content

doc(AttributeTable): support base type parameter#7554

Merged
ArgoZhang merged 4 commits intomainfrom
doc-comments
Jan 21, 2026
Merged

doc(AttributeTable): support base type parameter#7554
ArgoZhang merged 4 commits intomainfrom
doc-comments

Conversation

@ArgoZhang
Copy link
Copy Markdown
Member

@ArgoZhang ArgoZhang commented Jan 21, 2026

Link issues

fixes #7553

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Improve component metadata display and documentation for attribute tables and validation components.

Enhancements:

  • Refine XML documentation lookup for component attributes to better handle base or related types when resolving property summaries.
  • Polish bilingual XML documentation comments for display and validation base components for clearer API descriptions.
  • Adjust attribute table marker styling to use a smaller font and success color for better visual emphasis.

Copilot AI review requested due to automatic review settings January 21, 2026 03:09
@bb-auto bb-auto Bot added the documentation Improvements or additions to documentation label Jan 21, 2026
@bb-auto bb-auto Bot added this to the v10.2.0 milestone Jan 21, 2026
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Jan 21, 2026

Reviewer's Guide

Refines component XML documentation for display/validation components and enhances the AttributeTable documentation resolution to support base-type/property-type XML doc lookups, along with a small styling adjustment for attribute markers.

Class diagram for ComponentAttributeCacheService documentation resolution

classDiagram
    class ComponentAttributeCacheService {
        - static ConcurrentDictionary<Type, List<AttributeItem>> Cache
        + static List<AttributeItem> GetAttributes(Type type)
        - static List<AttributeItem> GetAttributeCore(Type type)
        - static string GetPropertySummary(XmlDocument xmlDoc, PropertyInfo property)
        - static XElement FindSummaryElement(XmlDocument xmlDoc, string memberName)
        - static string GetLocalizedSummary(XElement summaryElement)
    }

    class AttributeItem {
        + string Name
        + string Description
        + string Type
        + string DefaultValue
    }

    ComponentAttributeCacheService --> AttributeItem : creates
Loading

Flow diagram for updated XML doc lookup in ComponentAttributeCacheService

flowchart TD
    A[Start: resolve property XML doc] --> B[Get property.DeclaringType]
    B --> C{DeclaringType is null?}
    C -- No --> D[Set type = property.DeclaringType]
    C -- Yes --> E[Set type = property.PropertyType]

    D --> F[Get type.FullName]
    E --> F

    F --> G{type.FullName is null?}
    G -- No --> H[Set typeName = type.FullName]
    G -- Yes --> I[Set typeName = BootstrapBlazor.Components. + type.Name]

    H --> J[Build memberName = P: + typeName + . + property.Name]
    I --> J

    J --> K[FindSummaryElement xmlDoc memberName]
    K --> L{summaryElement is null?}
    L -- Yes --> M[Return null]
    L -- No --> N[Return GetLocalizedSummary summaryElement]
Loading

File-Level Changes

Change Details Files
Improve XML documentation comments on core display and validation component base classes for better generated docs and localization.
  • Clarified and corrected Chinese XML doc strings for label, tooltip, binding, and cascading parameter descriptions in DisplayBase.
  • Replaced custom method summaries for lifecycle methods with inheritdoc to pull base-class documentation.
  • Adjusted ValidateBase XML docs to better describe validation CSS and required marker behavior.
src/BootstrapBlazor/Components/Display/DisplayBase.cs
src/BootstrapBlazor/Components/Validate/ValidateBase.cs
Update attribute documentation lookup to better resolve XML comments, including support for base or component types when building the AttributeTable.
  • Changed XML member name generation to derive the type from the declaring type or property type as a fallback.
  • Ensured a reasonable default namespace/type name is used when FullName is null, improving resilience of XML doc lookup for properties.
src/BootstrapBlazor.Server/Services/ComponentAttributeCacheService.cs
Tweak AttributeTable attribute marker styling to improve visual emphasis.
  • Reduced font size slightly for the attribute marker.
  • Applied a success theme color to the attribute marker text.
src/BootstrapBlazor.Server/Components/Components/AttributeTable.razor.css

Assessment against linked issues

Issue Objective Addressed Explanation
#7553 Ensure the AttributeTable documentation system correctly resolves and displays XML documentation for properties defined on base types (i.e., support base type parameters).

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@ArgoZhang ArgoZhang merged commit 2e4d93f into main Jan 21, 2026
7 of 8 checks passed
@ArgoZhang ArgoZhang deleted the doc-comments branch January 21, 2026 03:09
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • The new XML-doc lookup in ComponentAttributeCacheService.GetPropertySummary uses property.DeclaringType ?? property.PropertyType and then guesses a namespace when FullName is null; this can produce incorrect member names (properties are defined on the declaring type, not the value type) and brittle lookups—consider defaulting only to DeclaringType and handling FullName == null more conservatively (e.g., skipping or logging).
  • Replacing explicit bilingual summaries on overriding lifecycle methods in DisplayBase with <inheritdoc/> may drop the localized XML docs if the base methods are not similarly documented; verify that consumers still get the intended Chinese/English descriptions or keep the explicit summaries where needed.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new XML-doc lookup in `ComponentAttributeCacheService.GetPropertySummary` uses `property.DeclaringType ?? property.PropertyType` and then guesses a namespace when `FullName` is null; this can produce incorrect member names (properties are defined on the declaring type, not the value type) and brittle lookups—consider defaulting only to `DeclaringType` and handling `FullName == null` more conservatively (e.g., skipping or logging).
- Replacing explicit bilingual summaries on overriding lifecycle methods in `DisplayBase` with `<inheritdoc/>` may drop the localized XML docs if the base methods are not similarly documented; verify that consumers still get the intended Chinese/English descriptions or keep the explicit summaries where needed.

## Individual Comments

### Comment 1
<location> `src/BootstrapBlazor.Server/Services/ComponentAttributeCacheService.cs:63-64` </location>
<code_context>
         if (xmlDoc == null) return null;

-        var memberName = $"P:{property.DeclaringType?.FullName}.{property.Name}";
+        var type = property.DeclaringType ?? property.PropertyType;
+        var typeName = type.FullName ?? $"BootstrapBlazor.Components.{type.Name}";
+        var memberName = $"P:{typeName}.{property.Name}";
</code_context>

<issue_to_address>
**suggestion:** Avoid shadowing the method parameter `type` with a local variable of the same name.

This shadows the `GetAttributeCore` parameter and hurts readability. Please rename the local (e.g., `declaringTypeOrPropertyType`) to make its purpose clear and avoid confusion with the outer `type` parameter.

```suggestion
        var declaringTypeOrPropertyType = property.DeclaringType ?? property.PropertyType;
        var typeName = declaringTypeOrPropertyType.FullName ?? $"BootstrapBlazor.Components.{declaringTypeOrPropertyType.Name}";
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
Contributor

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 aims to improve the AttributeTable component's ability to handle base type parameters when generating documentation. The changes include documentation improvements, XML documentation lookup logic modifications, and build configuration updates.

Changes:

  • Enhanced XML documentation member name resolution to handle properties from base types
  • Improved Chinese documentation quality with spelling corrections and better formatting
  • Modified build targets to ensure XML documentation files are properly copied
  • Minor styling adjustments to the attribute table markers

Reviewed changes

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

Show a summary per file
File Description
src/BootstrapBlazor/Components/Validate/ValidateBase.cs Updated XML documentation comments to be more accurate (changed "获得/设置" to "获得" for read-only property ValidCss, and added "获得/设置" for Required property)
src/BootstrapBlazor/Components/Display/DisplayBase.cs Improved Chinese documentation with spelling corrections (裁减→裁剪), removed extra spaces, added proper <see cref> tags, and replaced method documentation with <inheritdoc/>
src/BootstrapBlazor.Server/Services/ComponentAttributeCacheService.cs Modified GetSummary method to support base type parameters by adding fallback logic for type resolution
src/BootstrapBlazor.Server/Directory.Build.targets Removed file existence condition and skip unchanged files optimization from XML copy task
src/BootstrapBlazor.Server/Components/Components/AttributeTable.razor.css Adjusted marker styling (font-size: 85%, added color)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (xmlDoc == null) return null;

var memberName = $"P:{property.DeclaringType?.FullName}.{property.Name}";
var type = property.DeclaringType ?? property.PropertyType;
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 fallback logic when property.DeclaringType is null appears incorrect. Using property.PropertyType as a fallback doesn't make semantic sense - the declaring type (which class the property is declared in) and the property type (the type of the value) are completely different concepts.

For XML documentation lookup, we need the type where the property is declared, not the type of the property's value. If DeclaringType is null, this would typically indicate a reflection issue, and falling back to PropertyType would likely result in looking up documentation in the wrong location.

Consider either:

  1. Removing the fallback to PropertyType if it's not a valid scenario
  2. If this is intended to handle a specific edge case, add a comment explaining when and why DeclaringType would be null and why PropertyType is the correct fallback
Suggested change
var type = property.DeclaringType ?? property.PropertyType;
// DeclaringType is required to build the correct XML documentation member name.
// If it is null, we cannot reliably locate the summary, so return null instead
// of falling back to PropertyType (which represents the value type, not the owner).
var type = property.DeclaringType;
if (type == null)
{
return null;
}

Copilot uses AI. Check for mistakes.

var memberName = $"P:{property.DeclaringType?.FullName}.{property.Name}";
var type = property.DeclaringType ?? property.PropertyType;
var typeName = type.FullName ?? $"BootstrapBlazor.Components.{type.Name}";
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 fallback construction $"BootstrapBlazor.Components.{type.Name}" when type.FullName is null may not produce accurate member names for XML documentation lookup. This assumes all types without a FullName belong to the BootstrapBlazor.Components namespace, which may not always be true.

FullName can be null for generic type parameters and some special types. For generic types, you might want to handle them differently. Consider adding validation or a comment explaining which types are expected to have null FullName and why this fallback is appropriate for those specific cases.

Suggested change
var typeName = type.FullName ?? $"BootstrapBlazor.Components.{type.Name}";
var typeName = type.FullName;
// FullName can be null for generic type parameters and some special types.
// In such cases we skip XML documentation lookup instead of fabricating a namespace,
// as that may not produce an accurate member name.
if (string.IsNullOrEmpty(typeName))
{
return null;
}

Copilot uses AI. Check for mistakes.
@@ -185,7 +183,6 @@ protected override void OnParametersSet()
/// <para lang="en">Format Value to String Method</para>
/// </summary>
/// <param name="value">The value to format.</param>
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 removal of the <returns> tag from the XML documentation is inconsistent with standard C# documentation practices. Methods should document their return values, especially for public or protected virtual methods. The English comment "A string representation of the value" provided useful information about what the method returns.

Consider keeping the <returns> tag to maintain complete documentation.

Suggested change
/// <param name="value">The value to format.</param>
/// <param name="value">The value to format.</param>
/// <returns>
/// <para lang="zh">值的字符串表示形式。</para>
/// <para lang="en">A string representation of the value.</para>
/// </returns>

Copilot uses AI. Check for mistakes.
</ItemGroup>
<Message Text="Copying XML docs to output path: $(OutputPath)" Importance="High" />
<Copy SourceFiles="@(XmlDocsToCopy)" DestinationFolder="$(OutputPath)" SkipUnchangedFiles="true" Condition="Exists('%(RootDir)%(Directory)%(Filename)%(Extension)')" />
<Copy SourceFiles="@(XmlDocsToCopy)" DestinationFolder="$(OutputPath)" />
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 removal of SkipUnchangedFiles="true" and the Condition attribute from the Copy task may cause unnecessary file copying on every build, potentially slowing down build times. The original attributes were performance optimizations:

  • SkipUnchangedFiles="true" avoids copying files that haven't changed
  • The Condition prevents errors when files don't exist

Unless there's a specific reason these optimizations are causing issues (such as stale documentation not being updated), consider keeping them. If they must be removed to fix the issue mentioned in #7553, please add a comment explaining why.

Suggested change
<Copy SourceFiles="@(XmlDocsToCopy)" DestinationFolder="$(OutputPath)" />
<Copy SourceFiles="@(XmlDocsToCopy)" DestinationFolder="$(OutputPath)" SkipUnchangedFiles="true" Condition="Exists('%(RootDir)%(Directory)%(Filename)%(Extension)')" />

Copilot uses AI. Check for mistakes.
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (0ee1538) to head (8bb4fb3).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #7554   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          748       748           
  Lines        33000     33000           
  Branches      4588      4588           
=========================================
  Hits         33000     33000           
Flag Coverage Δ
BB 100.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doc(AttributeTable): support base type parameter

2 participants