This document contains information regarding API baseline files and how to work with them. For additional details on how these files work, consult:
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:
cp .\eng\PublicAPI.empty.txt {new folder}\PublicAPI.Shipped.txtcp .\eng\PublicAPI.empty.txt {new folder}\PublicAPI.Unshipped.txtSee Steps for adding and updating APIs for steps on how to add APIs to the Unshipped.txt files
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.
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.
A new entry needs to be added to the PublicAPI.Unshipped.txt file for a new API. For example:
#nullable enable
Microsoft.AspNetCore.Builder.NewApplicationBuilder.New() -> Microsoft.AspNetCore.Builder.IApplicationBuilder!
A new entry needs to be added to the PublicAPI.Unshipped.txt file for a removed API. For example:
#nullable enable
*REMOVED*Microsoft.Builder.OldApplicationBuilder.New() -> Microsoft.AspNetCore.Builder.IApplicationBuilder!
Two new entry needs to be added to the PublicAPI.Unshipped.txt file for an updated API, one to remove the old API and one for the new API. This also applies to APIs that are now nullable aware. For example:
#nullable enable
*REMOVED*Microsoft.AspNetCore.DataProtection.Infrastructure.IApplicationDiscriminator.Discriminator.get -> string!
Microsoft.AspNetCore.DataProtection.Infrastructure.IApplicationDiscriminator.Discriminator.get -> string?
*.slnf file to include the new project if needed{directory containing relevant *.slnf}\startvs.cmd#pragmas because attributes make the justification obvious e.g. for common errors that can't be fixed
[SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Required to maintain compatibility")]
or
[SuppressMessage("ApiDesign", "RS0027:Public API with optional parameter(s) should have the most parameters amongst its public overloads.", Justification = "Required to maintain compatibility")]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