|
1 | 1 | # API Baselines
|
2 | 2 |
|
3 |
| -This document contains information regarding API baseline files and how to work with them. |
| 3 | +This document contains information regarding API baseline files and how to work with them. For additional details on how these files works, consult: |
| 4 | +- https://github.com/dotnet/roslyn-analyzers/blob/master/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md |
| 5 | +- https://github.com/dotnet/roslyn-analyzers/blob/master/src/PublicApiAnalyzers/Microsoft.CodeAnalysis.PublicApiAnalyzers.md |
4 | 6 |
|
5 | 7 | ## Add baseline files for new projects
|
6 | 8 |
|
7 | 9 | When creating a new implementation (i.e. src) project, it's necessary to manually add API baseline files since API baseline are enabled by default. If the project is a non-shipping or test only project, add `<AddPublicApiAnalyzers>false</AddPublicApiAnalyzers>` to the project to disable these checks. To add baseline files to the project:
|
8 | 10 |
|
9 |
| -1. Copy eng\PublicAPI.empty.txt to the project directory and rename it to PublicAPI.Shipped.txt |
10 |
| -1. Copy eng\PublicAPI.empty.txt to the project directory and rename it to PublicAPI.Unshipped.txt |
| 11 | +1. `cp .\eng\PublicAPI.empty.txt {new folder}\PublicAPI.Shipped.txt` |
| 12 | +1. `cp .\eng\PublicAPI.empty.txt {new folder}\PublicAPI.Unshipped.txt` |
| 13 | + |
| 14 | +See [Steps for adding and updating APIs](#steps-for-adding-and-updating-apis) for steps on how to add APIs to the Unshipped.txt files |
11 | 15 |
|
12 | 16 | ## PublicAPI.Shipped.txt
|
13 | 17 |
|
14 | 18 | This file contains APIs that were released in the last major version. This file should only be modified after a major release by the build team and should never be modified otherwise.
|
15 | 19 |
|
16 | 20 | ## PublicAPI.Unshipped.txt
|
17 | 21 |
|
18 |
| -This file contains new APIs since the last major version. |
| 22 | +This file contains new APIs since the last major version. Steps for working with changes in APIs and updating this file are found in [Steps for adding and updating APIs](#steps-for-adding-and-updating-apis). |
19 | 23 |
|
20 | 24 | ### New APIs
|
21 | 25 |
|
@@ -45,6 +49,21 @@ Two new entry needs to be added to the PublicAPI.Unshipped.txt file for an updat
|
45 | 49 | Microsoft.AspNetCore.DataProtection.Infrastructure.IApplicationDiscriminator.Discriminator.get -> string?
|
46 | 50 | ```
|
47 | 51 |
|
| 52 | +### Steps for adding and updating APIs |
| 53 | + |
| 54 | +1. Update AspNetCore.sln and relevant `*.slnf` file to include the new project if needed |
| 55 | +1. `{directory containing relevant *.slnf}\startvs.cmd` |
| 56 | +1. F6 *or whatever your favourite build gesture is* |
| 57 | +1. Click on a RS0016 (or whatever) error |
| 58 | +1. Right click in editor on underscored symbol or go straight to the “quick fix” icon to its left. Control-. also works. |
| 59 | +1. Choose “Add Blah to public API” / “Fix all occurrences in … Solution” |
| 60 | +1. Click Apply |
| 61 | +1. F6 *again to see if the fixer missed anything or if other RS00xx errors show up (not uncommon)* |
| 62 | +1. Suppress or fix other problems as needed but please suppress (if suppressing) using attributes and not globally or with `#pragma`s because attributes make the justification obvious e.g. for common errors that can't be fixed |
| 63 | + `[SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Required to maintain compatibility")]` |
| 64 | + or |
| 65 | + `[SuppressMessage("ApiDesign", "RS0027:Public API with optional parameter(s) should have the most parameters amongst its public overloads.", Justification = "Required to maintain compatibility")]` |
| 66 | + |
48 | 67 | ## Updating baselines after major releases
|
49 | 68 |
|
50 |
| -TODO |
| 69 | +This will be performed by the build team using scripts at https://github.com/dotnet/roslyn/tree/master/scripts/PublicApi (or an Arcade successor). The process moves the content of PublicAPI.Unshipped.txt into PublicAPI.Shipped.txt |
0 commit comments