diff --git a/.gitignore b/.gitignore index 44bf84f..2f6bc29 100644 --- a/.gitignore +++ b/.gitignore @@ -417,3 +417,6 @@ FodyWeavers.xsd *.msm *.msp .claude/ + +# ApiCompat baseline assemblies +!**/LastMajorVersionBinary/*.dll diff --git a/README.md b/README.md index bbc095f..16e0ef5 100644 --- a/README.md +++ b/README.md @@ -220,5 +220,22 @@ Pull requests are welcome. For major changes, please open an issue first to disc Please make sure to update tests as appropriate. +## Breaking Changes +The generated API surface is validated against a baseline using [ApiCompat](https://learn.microsoft.com/en-us/dotnet/fundamentals/apicompat/overview). Each `Example.OpenApi*` project has a `LastMajorVersionBinary/` directory containing the baseline reference assembly. + +### Introduce Breaking Change +Build will fail when a breaking change is detected. Generate a suppression file for the breaking changes, and commit it to accept the breaking changes: +```Shell +dotnet build -p:ApiCompatGenerateSuppressionFile=true +``` + +### Update Baseline +The baseline doesn't need to be updated when using suppression files, but if it for some reason should, run: +```Shell +dotnet build -p:_ApiCompatGenerateContractAssembly=true -p:ApiCompatValidateAssemblies=false +``` + +This copies the current reference assemblies to `LastMajorVersionBinary/` for each example project. Commit the updated DLLs. The suppression files should also be purged at this point. + # License [MIT](LICENSE) \ No newline at end of file diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props new file mode 100644 index 0000000..4b680a5 --- /dev/null +++ b/tests/Directory.Build.props @@ -0,0 +1,16 @@ + + + <_ApiCompatGenerateContractAssembly>false + <_ApiCompatCaptureGroupPattern>.+%5C$([System.IO.Path]::DirectorySeparatorChar)(.+)%5C$([System.IO.Path]::DirectorySeparatorChar)(.+) + + + + + + + + + + + \ No newline at end of file diff --git a/tests/Example.OpenApi20/Example.OpenApi20.csproj b/tests/Example.OpenApi20/Example.OpenApi20.csproj index f332436..46a091d 100644 --- a/tests/Example.OpenApi20/Example.OpenApi20.csproj +++ b/tests/Example.OpenApi20/Example.OpenApi20.csproj @@ -5,11 +5,17 @@ enable enable Example.OpenApi20 + + true + LastMajorVersionBinary/$(AssemblyName).dll + + false + diff --git a/tests/Example.OpenApi20/LastMajorVersionBinary/Example.OpenApi20.dll b/tests/Example.OpenApi20/LastMajorVersionBinary/Example.OpenApi20.dll new file mode 100644 index 0000000..b48ee90 Binary files /dev/null and b/tests/Example.OpenApi20/LastMajorVersionBinary/Example.OpenApi20.dll differ diff --git a/tests/Example.OpenApi30/Example.OpenApi30.csproj b/tests/Example.OpenApi30/Example.OpenApi30.csproj index fef665a..5d3b717 100644 --- a/tests/Example.OpenApi30/Example.OpenApi30.csproj +++ b/tests/Example.OpenApi30/Example.OpenApi30.csproj @@ -5,10 +5,16 @@ enable enable Example.OpenApi30 + + true + LastMajorVersionBinary/$(AssemblyName).dll + + false + diff --git a/tests/Example.OpenApi30/LastMajorVersionBinary/Example.OpenApi30.dll b/tests/Example.OpenApi30/LastMajorVersionBinary/Example.OpenApi30.dll new file mode 100644 index 0000000..868ee6c Binary files /dev/null and b/tests/Example.OpenApi30/LastMajorVersionBinary/Example.OpenApi30.dll differ diff --git a/tests/Example.OpenApi31/Example.OpenApi31.csproj b/tests/Example.OpenApi31/Example.OpenApi31.csproj index 76ae79d..93cacae 100644 --- a/tests/Example.OpenApi31/Example.OpenApi31.csproj +++ b/tests/Example.OpenApi31/Example.OpenApi31.csproj @@ -5,10 +5,16 @@ enable enable Example.OpenApi31 + + true + LastMajorVersionBinary/$(AssemblyName).dll + + false + diff --git a/tests/Example.OpenApi31/LastMajorVersionBinary/Example.OpenApi31.dll b/tests/Example.OpenApi31/LastMajorVersionBinary/Example.OpenApi31.dll new file mode 100644 index 0000000..31a2d6b Binary files /dev/null and b/tests/Example.OpenApi31/LastMajorVersionBinary/Example.OpenApi31.dll differ diff --git a/tests/Example.OpenApi32/Example.OpenApi32.csproj b/tests/Example.OpenApi32/Example.OpenApi32.csproj index 0c77fc8..227883b 100644 --- a/tests/Example.OpenApi32/Example.OpenApi32.csproj +++ b/tests/Example.OpenApi32/Example.OpenApi32.csproj @@ -5,10 +5,16 @@ enable enable Example.OpenApi32 + + true + LastMajorVersionBinary/$(AssemblyName).dll + + false + diff --git a/tests/Example.OpenApi32/LastMajorVersionBinary/Example.OpenApi32.dll b/tests/Example.OpenApi32/LastMajorVersionBinary/Example.OpenApi32.dll new file mode 100644 index 0000000..9b64f52 Binary files /dev/null and b/tests/Example.OpenApi32/LastMajorVersionBinary/Example.OpenApi32.dll differ