Skip to content

feat(LLMsDocsGenerator): document service registration extensions - #1323

Merged
ArgoZhang merged 4 commits into
masterfrom
dev-tools
Nov 17, 2026
Merged

ArgoZhang merged 4 commits into
masterfrom
dev-tools

Conversation

@ArgoZhang

@ArgoZhang ArgoZhang commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Link issues

fixes #1322

Summary By Copilot

Document public, non-obsolete Add*/TryAdd* registration extensions on IServiceCollection, 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?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

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; $out was 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.ps1 is absent and was not run. Full runtime unit suites were not run.

Packaging changes reviewed?

  • Yes
  • No
  • N/A

Generator 11.0.4 packages successfully; component packages are unchanged.

☑️ 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

Add source-based documentation for public service registration extensions while keeping them distinct from injectable services.

New Features:

  • Document public, non-obsolete IServiceCollection Add* and TryAdd* registration extensions with their source signatures, defaults, and generic constraints.

Enhancements:

  • Separate service registration extensions from injectable services in generated indexes, counts, and documentation.

Build:

  • Bump the LLMs documentation generator version to 11.0.4.

Documentation:

  • Update the generator documentation in English and Chinese to describe registration-extension discovery and output.

@sourcery-ai

sourcery-ai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Data structures

Add model fields for identifying registration-extension classes and retaining their source method signatures for documentation.

  • tools/BootstrapBlazor.LLMsDocsGenerator/ComponentInfo.cs L71-72, L162-166

Implementation

Discover eligible IServiceCollection registration extensions, filter and format their methods, and keep them separate from injectable service registrations.

  • tools/BootstrapBlazor.LLMsDocsGenerator/ComponentAnalyzer.cs L267-274, L301-304, L798-808 (+7 small edits)

Count registration extensions separately and report them in generation logs and empty-project errors.

  • tools/BootstrapBlazor.LLMsDocsGenerator/DocsGenerator.cs L33-38, L68

Render registration-extension links and counts separately, explain their role, and display preserved source signatures in generated method listings.

  • tools/BootstrapBlazor.LLMsDocsGenerator/MarkdownBuilder.cs L177-189, L194-198, L257-262 (+3 small edits)

Configuration

Update the generator project version to 11.0.4.

  • tools/BootstrapBlazor.LLMsDocsGenerator/BootstrapBlazor.LLMsDocsGenerator.csproj L4

Documentation

Document registration-extension discovery, output, limitations, and support in the English and Chinese READMEs.

  • tools/BootstrapBlazor.LLMsDocsGenerator/README.md L61, L72, L80-81
  • tools/BootstrapBlazor.LLMsDocsGenerator/README.zh-CN.md L61, L72, L80-81

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

@bb-auto bb-auto Bot added the enhancement New feature or request label Nov 17, 2026
@bb-auto bb-auto Bot added this to the v11.0.0 milestone Nov 17, 2026

@bb-auto bb-auto Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Auto approved by bb-auto

@ArgoZhang
ArgoZhang merged commit 98eeebe into master Nov 17, 2026
3 checks passed
@ArgoZhang
ArgoZhang deleted the dev-tools branch November 17, 2026 02:51
@sourcery-ai

sourcery-ai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Linked issues

Checked at commit 02b9c54

#1322 feat(LLMsDocsGenerator): document service registration extensions · 4 of 4 met

# Requirement Status Notes
1 Document public, non-obsolete Add*/TryAdd* extensions on IServiceCollection, preserving source signatures, defaults, and generic constraints. ✅ Met The analyzer discovers matching registration methods and retains their source signatures; the generated method list uses those signatures.
2 Index registration extensions separately from injectable services. ✅ Met The index separates registration-extension links and counts from service types.
3 Update both READMEs. ✅ Met Both the English and Chinese READMEs describe discovery and generated documentation for registration extensions.
4 Release generator 11.0.4. ✅ Met The generator project file sets its version to 11.0.4.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

{
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})"}`");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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 ||

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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("## 服务注册扩展");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚪ 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.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(LLMsDocsGenerator): document service registration extensions

1 participant