The generate-publicapi tool regenerates the PublicAPI baseline files used by Microsoft.CodeAnalysis.PublicApiAnalyzers (diagnostics RS0016, RS0017, RS0037). These files track the public surface of each shipped library per target framework (TFM) in:
src/<Project>/PublicAPI/<tfm>/PublicAPI.Shipped.txt
src/<Project>/PublicAPI/<tfm>/PublicAPI.Unshipped.txt
You must run this tool whenever you add, remove, or change public API, or add a new target framework to a tracked library.
Process:
- Resets baseline files to
#nullable enable. - Runs
dotnet format analyzers to populate PublicAPI.Unshipped.txt with the current surface. - Folds the surface into
PublicAPI.Shipped.txt (sorted and deduped) and resets PublicAPI.Unshipped.txt to the bare header.
Note: Always review the diff in PublicAPI.Unshipped.txt before committing, as it represents your public API changes.
### Linux / macOS
```bash
tools/generate-publicapi.sh # all tracked libraries, all buildable TFMs
tools/generate-publicapi.sh Async # only projects whose path contains 'Async'
tools/generate-publicapi.sh ReactiveUI.Wpf
Windows (PowerShell)
./tools/generate-publicapi.ps1 # all tracked libraries
./tools/generate-publicapi.ps1 -Filter Async # path filter