Skip to content

Commit bc05994

Browse files
committed
docs: adds information about promoting shipped APIs
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
1 parent fb40442 commit bc05994

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

CONTRIBUTING.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,34 @@ The recommended commit types used are:
7474
- __ci__ for CI configuration file changes e.g. updating a pipeline
7575
- __chore__ for miscallaneous non-sdk changesin the repo e.g. removing an unused file
7676

77-
Adding an exclamation mark after the commit type (`feat!`) or footer with the prefix __BREAKING CHANGE:__ will cause an increment of the _major_ version.
77+
Adding an exclamation mark after the commit type (`feat!`) or footer with the prefix __BREAKING CHANGE:__ will cause an increment of the _major_ version.
78+
79+
## Updates to public API surface
80+
81+
Because we need to maintain a compatible public API surface within a major version, this project is using the public API analyzers to ensure no prior public API is changed/removed inadvertently.
82+
83+
This means that:
84+
85+
- All entries in an __Unshipped__ document need to be moved to the __Shipped__ document before any public release.
86+
- All new APIs being added need to be __Unshipped__ document before the pull request can be merged, otherwise build will fail with a message like the example below.
87+
88+
```txt
89+
Error: /home/runner/work/OpenAPI.NET/OpenAPI.NET/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs(39,46): error RS0016: Symbol 'OAuth2MetadataUrl.set' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md) [/home/runner/work/OpenAPI.NET/OpenAPI.NET/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj::TargetFramework=net8.0]
90+
```
91+
92+
### Update the unshipped document
93+
94+
To update the unshipped document, simply run the following commands
95+
96+
```shell
97+
# add the missing public api entries
98+
dotnet format --diagnostics RS0016
99+
# discard changes to cs files to avoid creating conflicts
100+
git checkout *.cs
101+
```
102+
103+
### Move items from unshipped to unshipped document
104+
105+
```pwsh
106+
. ./scripts/promoteUnshipped.ps1
107+
```

scripts/promoteUnshipped.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
$nullableConstant = "#nullable enable"
2+
$unshippedDocuments = ls *.Unshipped* -R | Select-Object -ExpandProperty FullName
3+
foreach ($unshippedDocumentPath in $unshippedDocuments) {
4+
$shippedDocumentPath = $unshippedDocumentPath -replace '\.Unshipped', '.Shipped'
5+
$unshippedDocumentContent = Get-Content $unshippedDocumentPath -Raw
6+
$unshippedDocumentContent = ($unshippedDocumentContent -replace [regex]::Escape($nullableConstant), '').Trim()
7+
if ([string]::IsNullOrWhiteSpace($unshippedDocumentContent)) {
8+
Write-Host "No content to promote for $unshippedDocumentPath, skipping." -ForegroundColor Yellow
9+
continue
10+
}
11+
Add-Content -Path $shippedDocumentPath -Value $unshippedDocumentContent -Verbose
12+
Set-Content -Path $unshippedDocumentPath -Value $nullableConstant -Verbose
13+
}

0 commit comments

Comments
 (0)