chore(AttributeTable): support inheritdoc xml node#7547
Conversation
Reviewer's GuideRefactors attribute discovery for component properties and extends XML documentation parsing to support in summary nodes, while keeping localized summaries and version extraction compatible with existing formats. Sequence diagram for GetSummary with inheritdoc resolutionsequenceDiagram
participant Caller
participant ComponentAttributeCacheService as CacheService
participant XmlDoc as XDocument
participant SummaryElement as XElement
Caller->>CacheService: GetSummary(xmlDoc, property)
CacheService->>CacheService: memberName = P:FullTypeName.Property
CacheService->>CacheService: FindSummaryElement(xmlDoc, memberName)
activate CacheService
CacheService->>XmlDoc: Descendants(member)
XmlDoc-->>CacheService: memberElement
CacheService->>CacheService: summaryElement = memberElement.Element(summary)
alt summary has inheritdoc with cref
CacheService->>CacheService: FindSummaryElement(xmlDoc, cref)
Note right of CacheService: Recursive resolution of inheritdoc
CacheService-->>CacheService: resolvedSummaryElement
else no inheritdoc
CacheService-->>CacheService: summaryElement
end
deactivate CacheService
CacheService->>CacheService: GetLocalizedSummary(summaryElement)
activate CacheService
CacheService->>SummaryElement: Elements(para) with lang = currentLanguage
SummaryElement-->>CacheService: langPara or null
alt langPara found
CacheService-->>Caller: langPara.Value.Trim()
else first para with any lang
CacheService-->>Caller: firstLangPara.Value.Trim()
else no lang on paras
CacheService-->>Caller: summaryElement.Value.Trim()
end
deactivate CacheService
Class diagram for ComponentAttributeCacheService XML documentation handlingclassDiagram
class ComponentAttributeCacheService {
+List~AttributeItem~ GetAttributes(Type componentType)
-List~AttributeItem~ GetAttributeCore(Type type)
-string GetSummary(XDocument xmlDoc, PropertyInfo property)
-XElement FindSummaryElement(XDocument xmlDoc, string memberName)
-string GetLocalizedSummary(XElement summaryElement)
-string GetVersion(XDocument xmlDoc, PropertyInfo property)
-string GetFriendlyTypeName(Type type)
-XDocument GetXmlDocumentation(Assembly assembly)
}
class AttributeItem {
+string Name
+string Type
+string Description
+string Version
}
class Type
class PropertyInfo
class XDocument
class XElement
class Assembly
ComponentAttributeCacheService "1" --> "*" AttributeItem : creates
ComponentAttributeCacheService --> Type
ComponentAttributeCacheService --> PropertyInfo
ComponentAttributeCacheService --> XDocument
ComponentAttributeCacheService --> XElement
ComponentAttributeCacheService --> Assembly
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7547 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 748 748
Lines 33000 33000
Branches 4588 4588
=========================================
Hits 33000 33000
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- Consider adding a recursion/visited guard in
FindSummaryElementwhen resolving<inheritdoc cref="...">chains to avoid potential infinite recursion if XML docs contain cyclic or self-referentialcrefvalues. - When resolving
<inheritdoc>viacref, you currently pass the rawcrefstring intoFindSummaryElement; if your XML uses short or type-relativecrefvalues, you may want to normalize or qualify them to match thenameformat used in the<member>elements.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider adding a recursion/visited guard in `FindSummaryElement` when resolving `<inheritdoc cref="...">` chains to avoid potential infinite recursion if XML docs contain cyclic or self-referential `cref` values.
- When resolving `<inheritdoc>` via `cref`, you currently pass the raw `cref` string into `FindSummaryElement`; if your XML uses short or type-relative `cref` values, you may want to normalize or qualify them to match the `name` format used in the `<member>` elements.
## Individual Comments
### Comment 1
<location> `src/BootstrapBlazor.Server/Services/ComponentAttributeCacheService.cs:79-81` </location>
<code_context>
- var summaryElement = memberElement.Element("summary");
- if (summaryElement == null) return null;
+ var inheritDoc = summaryElement.Element("inheritdoc");
+ var cref = inheritDoc?.Attribute("cref")?.Value;
+ return cref != null ? FindSummaryElement(xmlDoc, cref) : summaryElement;
+ }
</code_context>
<issue_to_address>
**issue (bug_risk):** Guard against potential infinite recursion in nested/looped <inheritdoc> chains.
`FindSummaryElement(xmlDoc, cref)` will follow `<inheritdoc cref="...">` chains indefinitely. With a malformed or cyclic `cref` (self-reference or mutual references), this can cause unbounded recursion and a stack overflow. Add a guard, e.g. a max recursion depth or a `HashSet<string>` of visited `memberName`s, and fall back to the original summary or `null` when a cycle/excessive depth is detected.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Pull request overview
This PR adds support for inheritdoc XML documentation nodes to enable documentation inheritance in the AttributeTable component. The changes refactor the XML documentation parsing logic to handle inheritance references.
Changes:
- Refactored
GetAttributeCoreto use LINQ Select instead of foreach loop - Split
GetSummaryintoFindSummaryElementandGetLocalizedSummaryhelper methods - Added support for resolving
inheritdocreferences withcrefattributes
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Link issues
fixes #7546
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Support resolving inherited XML documentation summaries for component attribute metadata and streamline attribute extraction.
New Features:
Bug Fixes:
Enhancements: