Vixen
02b45cc4
csharp
public static class ApiBaseline

The committed record of what an assembly's public surface is allowed to be, and the comparison of a reading against it.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Two files per project, both beside its .csproj: PublicAPI.Shipped.txt is what a released package published and is never edited by this tool; PublicAPI.Unshipped.txt is everything approved since, including *REMOVED* lines for shipped API that has been taken away. At release the second is folded into the first.

The split is the point rather than bookkeeping: it is what makes "this release removed something a consumer was using" a visible line in a reviewed file instead of an absence nobody looked for. Until the first release, Shipped is empty and honest — everything in this repository is unshipped, and writing it into Shipped would claim a compatibility promise that has not been made.

Fields and properties (3)

  • public const string ShippedFileName
  • public const string UnshippedFileName
  • public const string RemovedPrefix

    Marks a shipped entry that has since been removed.

Methods (6)

  • public static string DirectoryFor(string assemblyPath)

    Where the baselines for an assembly live: the directory of the project that produced it, found by walking up from the build output until a .csproj appears.

  • public static IReadOnlyList<string> Read(string path)

    Reads a baseline file, or an empty list when there is none. Blank lines and comments are not entries.

  • public static void Write(string path, IEnumerable<string> entries)

    Writes a baseline file, sorted, with the header and Unix line endings.

  • public static IReadOnlySet<string> Approved(IEnumerable<string> shipped, IEnumerable<string> unshipped)

    The surface a consumer has been promised: everything shipped, plus everything approved since, minus everything a *REMOVED* line has withdrawn.

  • public static ApiDifference Compare(IReadOnlyList<string> surface, IEnumerable<string> shipped, IEnumerable<string> unshipped)

    Compares a reading of the surface against the baseline that approves it.

  • public static IReadOnlyList<string> Rebase(IReadOnlyList<string> surface, IEnumerable<string> shipped)

    The contents PublicAPI.Unshipped.txt should have for this surface: everything not already shipped, and a *REMOVED* line for everything shipped that is gone.

Used by (1)

  • ApiBaselineTestsVixen.ApiCheck.Tests