Summary
The .NET projects currently do not appear to use Microsoft.CodeAnalysis.PublicApiAnalyzers or PublicAPI.Shipped.txt / PublicAPI.Unshipped.txt baselines. We should consider setting them up for released packages so public API changes are explicitly reviewed, tracked, and promoted as part of the release process.
Proposal
-
Add Public API Analyzer support to released .NET packages.
- Add the analyzer package/configuration needed to enforce public API baselines.
- Add
PublicAPI.Shipped.txt and PublicAPI.Unshipped.txt files for packages that publish public APIs.
- Establish guidance for contributors: new public APIs go into
PublicAPI.Unshipped.txt; breaking/removal changes are intentional and reviewed.
-
Add an automatic shipped API promotion workflow.
-
Update release workflows to fail when unshipped public API entries remain.
- Before publishing packages, validate that
PublicAPI.Unshipped.txt files are empty or absent.
- This prevents releasing packages with APIs that were added but never promoted into the shipped baseline.
Benefits
- Makes public API changes visible in PRs instead of relying on reviewers to notice new public types, members, constants, or accessibility changes.
- Helps distinguish intentional API additions from accidental public surface area exposure.
- Creates an auditable history of shipped APIs for released packages.
- Makes release readiness clearer by separating unshipped API work from APIs that have been accepted into the shipped contract.
- Reduces reviewer burden when public APIs are added across multiple projects or target frameworks.
Risks addressed
- Accidentally shipping new public APIs without design/API review.
- Accidentally changing or removing public APIs in ways that may break consumers.
- Forgetting to promote accepted APIs before release.
- Inconsistent API baseline practices across packages.
- Discovering API-surface problems late in the release pipeline instead of during PR validation.
Notes
This is especially useful for released packages where even small additions, such as public constants used as metadata keys, become part of the supported surface area once published.
Summary
The .NET projects currently do not appear to use
Microsoft.CodeAnalysis.PublicApiAnalyzersorPublicAPI.Shipped.txt/PublicAPI.Unshipped.txtbaselines. We should consider setting them up for released packages so public API changes are explicitly reviewed, tracked, and promoted as part of the release process.Proposal
Add Public API Analyzer support to released .NET packages.
PublicAPI.Shipped.txtandPublicAPI.Unshipped.txtfiles for packages that publish public APIs.PublicAPI.Unshipped.txt; breaking/removal changes are intentional and reviewed.Add an automatic shipped API promotion workflow.
promote-shipped-apis.yml: https://github.com/microsoft/OpenAPI.NET/blob/main/.github/workflows/promote-shipped-apis.ymlPublicAPI.Unshipped.txttoPublicAPI.Shipped.txtand open/update a PR.Update release workflows to fail when unshipped public API entries remain.
PublicAPI.Unshipped.txtfiles are empty or absent.Benefits
Risks addressed
Notes
This is especially useful for released packages where even small additions, such as public constants used as metadata keys, become part of the supported surface area once published.