-
-
Notifications
You must be signed in to change notification settings - Fork 382
doc(Comments): support auto generate attribute table component in extensions #7524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
09b5adf
9c9d507
c40f270
70bc212
913a09a
b054ce7
9abb421
955be17
8f69aae
1323205
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,6 +18,8 @@ public static class ComponentAttributeCacheService | |||||||||
| { | ||||||||||
| private static readonly ConcurrentDictionary<string, List<AttributeItem>> _cache = new(); | ||||||||||
|
|
||||||||||
| private static XDocument? _xmlDoc; | ||||||||||
|
|
||||||||||
| /// <summary> | ||||||||||
| /// 通过组件类型获取组件的 AttributeItem 列表 | ||||||||||
| /// </summary> | ||||||||||
|
|
@@ -43,13 +45,21 @@ private static List<AttributeItem> GetAttributeCore(Type type) | |||||||||
| .ToArray(); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| var xmlDoc = GetXmlDocumentation(type.Assembly); | ||||||||||
| // 获得 BootstrapBlazor 程序集 xml 文档 | ||||||||||
| _xmlDoc ??= GetXmlDocumentation(typeof(BootstrapBlazorRoot).Assembly); | ||||||||||
| XDocument? xmlDoc = null; | ||||||||||
| if (type.Assembly.GetName().Name != "BootstrapBlazor") | ||||||||||
| { | ||||||||||
| // 扩展组件包 | ||||||||||
| xmlDoc = GetXmlDocumentation(type.Assembly); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| return properties.Select(property => new AttributeItem | ||||||||||
| { | ||||||||||
| Name = property.Name, | ||||||||||
| Type = GetFriendlyTypeName(property.PropertyType), | ||||||||||
| Description = GetSummary(xmlDoc, property) ?? "", | ||||||||||
| Version = GetVersion(xmlDoc, property) ?? "10.0.0", | ||||||||||
| Version = GetVersion(xmlDoc, property), | ||||||||||
|
||||||||||
| Version = GetVersion(xmlDoc, property), | |
| Version = GetVersion(xmlDoc, property) ?? "10.0.0", |
Copilot
AI
Jan 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 73 hardcodes the namespace as "BootstrapBlazor.Components" but this assumes all types are in this namespace. The previous code used type.FullName ?? $"BootstrapBlazor.Components.{type.Name}" which was more flexible. For extension assemblies or types in different namespaces, this hardcoded approach could fail to find the correct XML documentation member name.
| var typeName = $"BootstrapBlazor.Components.{type.Name}"; | |
| var typeName = type.FullName ?? $"BootstrapBlazor.Components.{type.Name}"; |
Copilot
AI
Jan 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable name 'v' is not descriptive. It's used to store the inheritdoc reference value. Consider renaming to something more meaningful like 'inheritdocRef' or 'cref' to improve code readability.
| var v = summaryElement.Element("inheritdoc")?.Attribute("cref")?.Value; | |
| return v != null ? FindSummaryElement(xmlDoc, v) : summaryElement; | |
| var inheritdocRef = summaryElement.Element("inheritdoc")?.Attribute("cref")?.Value; | |
| return inheritdocRef != null ? FindSummaryElement(xmlDoc, inheritdocRef) : summaryElement; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AttributeItem properties changed from non-nullable strings with default values to nullable strings. This is a breaking change if any code relies on these properties never being null. Consumers of AttributeItem may now need to handle null values, which could lead to NullReferenceExceptions if not properly handled in UI rendering code.