Repository navigation
Conversation
This reverts commit 24ab7a8.
Reviewer's GuideData structuresAdd model fields for identifying registration-extension classes and retaining their source method signatures for documentation.
ImplementationDiscover eligible IServiceCollection registration extensions, filter and format their methods, and keep them separate from injectable service registrations.
Count registration extensions separately and report them in generation logs and empty-project errors.
Render registration-extension links and counts separately, explain their role, and display preserved source signatures in generated method listings.
ConfigurationUpdate the generator project version to 11.0.4.
DocumentationDocument registration-extension discovery, output, limitations, and support in the English and Chinese READMEs.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Linked issuesChecked at commit 02b9c54 #1322 feat(LLMsDocsGenerator): document service registration extensions · 4 of 4 met
|
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="tools/BootstrapBlazor.LLMsDocsGenerator/MarkdownBuilder.cs" line_range="376" />
<code_context>
{
var paramStr = string.Join(", ", method.Parameters.Select(p => $"{p.Item1} {p.Item2}"));
- _sb.AppendLine($"- `{method.ReturnType} {method.Name}({paramStr})`");
+ _sb.AppendLine($"- `{method.Signature ?? $"{method.ReturnType} {method.Name}({paramStr})"}`");
var methodDescription = Localize(method.Description, lang);
if (!string.IsNullOrEmpty(methodDescription))
</code_context>
<issue_to_address>
**Generated docs accept injected Markdown**
When an attacker contributes a registration extension with an optional raw-string default containing Markdown or HTML delimiters, `BuildComponentSection` writes the source signature inside a single-backtick code span without escaping it, so embedded backticks or raw-string newlines break out of the span and inject Markdown or HTML into generated documentation consumed by renderers or agents.
Escape the signature for Markdown or render it in a format that safely handles embedded backticks and newlines.
</issue_to_address>
### Comment 2
<location path="tools/BootstrapBlazor.LLMsDocsGenerator/ComponentAnalyzer.cs" line_range="258" />
<code_context>
{
if (model.GetDeclaredSymbol(declaration) is not INamedTypeSymbol symbol ||
- symbol.DeclaredAccessibility != Accessibility.Public || symbol.ContainingType != null || symbol.IsStatic ||
+ symbol.DeclaredAccessibility != Accessibility.Public || symbol.ContainingType != null ||
symbol.DeclaringSyntaxReferences.Select(reference => reference.GetSyntax())
.OfType<TypeDeclarationSyntax>().SelectMany(type => type.AttributeLists)
</code_context>
<issue_to_address>
**Obsolete APIs appear supported**
When an obsolete type or registration method uses a using alias for System.ObsoleteAttribute, `ComponentAnalyzer` compares attribute syntax names in both type and method checks, so it includes the obsolete declaration in the generated index and documentation as supported.
Resolve each attribute to its symbol and exclude declarations whose attribute symbol is `System.ObsoleteAttribute`.
Also at `tools/BootstrapBlazor.LLMsDocsGenerator/ComponentAnalyzer.cs:798-806`.
</issue_to_address>
### Comment 3
<location path="tools/BootstrapBlazor.LLMsDocsGenerator/MarkdownBuilder.cs" line_range="179" />
<code_context>
+ if (registrationExtensions.Count > 0)
+ {
+ _sb.AppendLine("## 服务注册扩展");
+ _sb.AppendLine();
+ _sb.AppendLine("公开的 IServiceCollection 注册扩展方法;扩展类本身不是可注入的服务。");
</code_context>
<issue_to_address>
**Extensions get the wrong category**
When the generated index is read by the CLI, `LlmsDocsClient.ParseIndex` recognizes only `###` headings, so it leaves the category unchanged when it reaches this `##` section and assigns that stale (or empty) category to the extension entries. Callers of `ListAsync` receive misleading category values.
Teach the index parser to assign a category to the service-registration section, or emit a heading level the parser recognizes.
</issue_to_address>| { | ||
| var paramStr = string.Join(", ", method.Parameters.Select(p => $"{p.Item1} {p.Item2}")); | ||
| _sb.AppendLine($"- `{method.ReturnType} {method.Name}({paramStr})`"); | ||
| _sb.AppendLine($"- `{method.Signature ?? $"{method.ReturnType} {method.Name}({paramStr})"}`"); |
There was a problem hiding this comment.
🟡 Medium · Generated docs accept injected Markdown
When an attacker contributes a registration extension with an optional raw-string default containing Markdown or HTML delimiters, BuildComponentSection writes the source signature inside a single-backtick code span without escaping it, so embedded backticks or raw-string newlines break out of the span and inject Markdown or HTML into generated documentation consumed by renderers or agents.
Escape the signature for Markdown or render it in a format that safely handles embedded backticks and newlines.
Prompt for AI agents
In `tools/BootstrapBlazor.LLMsDocsGenerator/MarkdownBuilder.cs` at line 376:
**Generated docs accept injected Markdown**
When an attacker contributes a registration extension with an optional raw-string default containing Markdown or HTML delimiters, `BuildComponentSection` writes the source signature inside a single-backtick code span without escaping it, so embedded backticks or raw-string newlines break out of the span and inject Markdown or HTML into generated documentation consumed by renderers or agents.
Escape the signature for Markdown or render it in a format that safely handles embedded backticks and newlines.| { | ||
| if (model.GetDeclaredSymbol(declaration) is not INamedTypeSymbol symbol || | ||
| symbol.DeclaredAccessibility != Accessibility.Public || symbol.ContainingType != null || symbol.IsStatic || | ||
| symbol.DeclaredAccessibility != Accessibility.Public || symbol.ContainingType != null || |
There was a problem hiding this comment.
🟡 Medium · Obsolete APIs appear supported
When an obsolete type or registration method uses a using alias for System.ObsoleteAttribute, ComponentAnalyzer compares attribute syntax names in both type and method checks, so it includes the obsolete declaration in the generated index and documentation as supported.
Resolve each attribute to its symbol and exclude declarations whose attribute symbol is System.ObsoleteAttribute.
Also at tools/BootstrapBlazor.LLMsDocsGenerator/ComponentAnalyzer.cs:798-806.
Prompt for AI agents
In `tools/BootstrapBlazor.LLMsDocsGenerator/ComponentAnalyzer.cs` at line 258:
**Obsolete APIs appear supported**
When an obsolete type or registration method uses a using alias for System.ObsoleteAttribute, `ComponentAnalyzer` compares attribute syntax names in both type and method checks, so it includes the obsolete declaration in the generated index and documentation as supported.
Resolve each attribute to its symbol and exclude declarations whose attribute symbol is `System.ObsoleteAttribute`.
Also at `tools/BootstrapBlazor.LLMsDocsGenerator/ComponentAnalyzer.cs:798-806`.|
|
||
| if (registrationExtensions.Count > 0) | ||
| { | ||
| _sb.AppendLine("## 服务注册扩展"); |
There was a problem hiding this comment.
⚪ Low · Extensions get the wrong category
When the generated index is read by the CLI, LlmsDocsClient.ParseIndex recognizes only ### headings, so it leaves the category unchanged when it reaches this ## section and assigns that stale (or empty) category to the extension entries. Callers of ListAsync receive misleading category values.
Teach the index parser to assign a category to the service-registration section, or emit a heading level the parser recognizes.
Prompt for AI agents
In `tools/BootstrapBlazor.LLMsDocsGenerator/MarkdownBuilder.cs` at line 179:
**Extensions get the wrong category**
When the generated index is read by the CLI, `LlmsDocsClient.ParseIndex` recognizes only `###` headings, so it leaves the category unchanged when it reaches this `##` section and assigns that stale (or empty) category to the extension entries. Callers of `ListAsync` receive misleading category values.
Teach the index parser to assign a category to the service-registration section, or emit a heading level the parser recognizes.
Link issues
fixes #1322
Summary By Copilot
Document public, non-obsolete
Add*/TryAdd*registration extensions onIServiceCollection, preserving source signatures, defaults, and generic constraints. Separate registration extensions from injectable services in the index and counts. Update both READMEs and bump the generator to 11.0.4.Tool-only change: seven files, no package skill definitions or packaging targets. These changes also exist in #1321; this independent PR was explicitly requested, and #1321 is unchanged.
Regression?
Risk
Source-analysis only. Receiver types are matched by name without loading dependency metadata; external service/configuration APIs are not included.
Verification
Manual (required)
Automated
git diff --check origin/master...HEAD— passed.dotnet build .\tools\BootstrapBlazor.LLMsDocsGenerator -c Release --no-restore— passed, zero warnings/errors.dotnet pack .\tools\BootstrapBlazor.LLMsDocsGenerator -c Release --no-build --no-restore— passed.dotnet run --project .\tools\BootstrapBlazor.LLMsDocsGenerator -c Release --no-build -- --project .\src\components\BootstrapBlazor.Holiday --output $out— passed;$outwas a session-only output directory. Verified one registration extension, no components/services, an index link, and the complete registration signature.The documented
tests\Verify-SingleProject.ps1is absent and was not run. Full runtime unit suites were not run.Packaging changes reviewed?
Generator 11.0.4 packages successfully; component packages are unchanged.
☑️ Self Check before Merge
Summary by Sourcery
Add source-based documentation for public service registration extensions while keeping them distinct from injectable services.
New Features:
Enhancements:
Build:
Documentation: