Skip to content

Add a generation best-practices guide for ClangSharpPInvokeGenerator#752

Merged
tannergooding merged 4 commits into
dotnet:mainfrom
tannergooding:tannergooding-generator-best-practices-doc
Jul 13, 2026
Merged

Add a generation best-practices guide for ClangSharpPInvokeGenerator#752
tannergooding merged 4 commits into
dotnet:mainfrom
tannergooding:tannergooding-generator-best-practices-doc

Conversation

@tannergooding

Copy link
Copy Markdown
Member

Adds an opinionated best-practices guide for driving ClangSharpPInvokeGenerator, and wires it into the docs so it's discoverable. This addresses the documentation gap raised in #532 — the underlying need there was guidance on how to drive the generator well, not more logging (the existing log-exclusions/log-potential-typedef-remappings/log-visited-files flags already cover the diagnostics, and the guide points at them).

Every recommendation is grounded in a real pattern from terrafx/terrafx.interop.windows or a real generator option — no invented features.


New docdocs/generating-bindings-best-practices.md, covering:

  • structuring a generation project (one folder per target; a thin driver that recursively discovers each generate.rsp and regenerates in parallel, shown in both PowerShell and bash)
  • response files and @-include composition (generate.rspsettings.rsp + remap.rsp → topical remap-*.rsp)
  • splitting shared settings from per-target settings
  • the key options grouped by intent, with when to use each
  • wildcards, incremental regeneration, and common pitfalls

Discoverability

  • README.md — Table-of-Contents entry + a link in the Generating Bindings section
  • sources/ClangSharpPInvokeGenerator/README.md — link under More information
  • --help now prints a More information: footer pointing at the guide

The help link and the tool-README link reference blob/main/docs/generating-bindings-best-practices.md (a stable branch URL rather than a commit permalink, which can't exist until this merges); happy to swap in a versioned/release permalink if preferred.

dotnet build -c Release stays green with 0 warnings.

tannergooding and others added 4 commits July 13, 2026 10:09
Documents how to structure a ClangSharpPInvokeGenerator project, compose
response files, choose options, regenerate incrementally, and avoid common
pitfalls, grounded in the terrafx.interop.windows patterns. Addresses the
documentation gap raised in dotnet#532.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Add a "More information:" footer to the tool help pointing at the guide so
users can discover it from the command line. Relates to dotnet#532.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Gives Linux/macOS users a find + xargs command matching the PowerShell
parallel-regeneration snippet. Relates to dotnet#532.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Replace a PowerShell-specific Push-Location reference in prose with a
platform-neutral description so it applies to the bash driver too.
Relates to dotnet#532.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@tannergooding tannergooding merged commit 93cb7b3 into dotnet:main Jul 13, 2026
14 checks passed
@tannergooding tannergooding deleted the tannergooding-generator-best-practices-doc branch July 13, 2026 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant