Skip to content

Add docs on authoring and using generator plugins for the C# emitter#10907

Open
Copilot wants to merge 6 commits into
mainfrom
copilot/add-doc-usage-plugins-property
Open

Add docs on authoring and using generator plugins for the C# emitter#10907
Copilot wants to merge 6 commits into
mainfrom
copilot/add-doc-usage-plugins-property

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 5, 2026

The plugins emitter option (added in #10249) lets emitter authors load custom generator plugins, but there was no documentation describing how to author or use them. This adds a guide to the existing packages/http-client-csharp/docs.

Changes

  • New docs/plugins.md covering:
    • Plugin discovery: automatic (via node_modules dist) vs. explicit (via the plugins option).
    • Authoring a GeneratorPlugin subclass and the CodeModelGenerator extension points (AddVisitor, AddRewriter, AddMetadataReference, AddSharedSourceDirectory), plus a LibraryVisitor example.
    • A minimal plugin .csproj that references the generator via a NuGet PackageReference to the published Microsoft.TypeSpec.Generator.ClientModel package (which transitively brings in Microsoft.TypeSpec.Generator).
    • tspconfig.yaml usage and path-resolution behavior (paths absolute or relative to the resolved emitter-output-dir, auto-build of .csproj, DLL scanning).
  • emitter.mdplugins option now links to the new guide and includes the inline path-resolution example.
  • index.mdx — adds a "Generator plugins" section linking to the doc.
  • emitter/src/options.ts — expanded the plugins option description to document path resolution (absolute or relative to the resolved emitter-output-dir) with an inline YAML example, applying the inline examples from docs(http-client-csharp): document plugins option path resolution with examples #10908.
  • readme.md and website reference emitter.md — regenerated to reflect the updated option description.

Plugin authoring example:

using Microsoft.TypeSpec.Generator;

public class MyPlugin : GeneratorPlugin
{
    public override void Apply(CodeModelGenerator generator)
    {
        generator.AddVisitor(new MyLibraryVisitor());
    }
}
options:
  "@typespec/http-client-csharp":
    plugins:
      - "codegen/MyPlugin.dll" # file relative to emitter-output-dir
      - "codegen" # directory containing plugin assemblies
      - "/abs/path/to/MyPlugin.dll" # absolute path used as-is

Content was cross-checked against GeneratorPlugin.cs, GeneratorHandler.cs, CodeModelGenerator.cs, and the emitter options.ts/emitter.ts.

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Jun 5, 2026
Copilot AI changed the title [WIP] Add documentation for using plugins property in emitter Add docs on authoring and using generator plugins for the C# emitter Jun 5, 2026
Copilot AI requested a review from jorgerangel-msft June 5, 2026 19:54
Copy link
Copy Markdown
Contributor

@jorgerangel-msft jorgerangel-msft left a comment

Choose a reason for hiding this comment

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

@copilot apply the inline examples from #10908

Comment thread packages/http-client-csharp/docs/plugins.md Outdated
Comment thread packages/http-client-csharp/docs/plugins.md Outdated
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 5, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-csharp@10907

commit: 9121f26

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 2026

No changes needing a change description found.

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jun 5, 2026

@copilot apply the inline examples from #10908

Applied the inline plugins option examples from #10908 in 4302df0. Updated the option description in emitter/src/options.ts (path resolution + YAML example), propagated to readme.md, the website reference emitter.md, and docs/emitter.md, and reflected the same path-resolution behavior and example in docs/plugins.md. Also added a changeset for the option description change.

@copilot apply the inline examples from #10908

Correction: the change is in commit 201b792.

Comment thread .chronus/changes/copilot-document-plugins-option-examples-2026-6-5-20-0-0.md Outdated
Copilot AI and others added 2 commits June 5, 2026 20:17
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
@jorgerangel-msft jorgerangel-msft marked this pull request as ready for review June 5, 2026 20:22
@azure-sdk-automation
Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

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

Labels

emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp meta:website TypeSpec.io updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Doc On How to Use Plugins Property for Emitter

3 participants