Open
Description
openedon Feb 19, 2022
Right now, the PublicAPI analyzer is integrated into the project that is going to be monitored by the analyzer.
I have a library for which I would like to "freeze" the API and I would create a unit test project that tests whether the monitored
project has breaking changes relative to the baseline API.
I would like to know if it's possible to consume the PublicAPI analyzer as an actual reference in a test project, and call methods of the analyzer to manually generate the API of another project, so I can diff it with a previously stored one, something like this:
[Test]
void TestApiBreakingChanges()
{
string shippedAPI = System.IO.File.ReadAllText("BaselineAPI.txt");
string UnshippedAPI = Microsoft.CodeAnalysis.PublicApiAnalyzers.CreateApiFromProject("..\SomeProject\SomeProject.csproj");
Assert.AreEqual(shippedAPI , UnshippedAPI);
}
Is this case scenario supported?
Additional context
This way of monitoring the API changes has a number of advantages:
- It gives developers a programatic way of testing when and what is considered a breaking change.
- It gives fine grain control over the API changes, so you can do specific tests over a subset of the API.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment