-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Public api analyzer [API-1573] #730
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
zpqrtbnk
force-pushed
the
public-api-analyzer
branch
from
October 5, 2022 11:04
7e7f56f
to
cb53a7a
Compare
Codecov Report
@@ Coverage Diff @@
## master #730 +/- ##
==========================================
+ Coverage 83.41% 83.60% +0.18%
==========================================
Files 862 872 +10
Lines 20113 20418 +305
==========================================
+ Hits 16777 17070 +293
- Misses 3336 3348 +12
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
zpqrtbnk
force-pushed
the
public-api-analyzer
branch
9 times, most recently
from
November 4, 2022 09:14
e800298
to
c0f4ded
Compare
zpqrtbnk
force-pushed
the
public-api-analyzer
branch
4 times, most recently
from
November 17, 2022 16:43
1bcecda
to
2e711eb
Compare
zpqrtbnk
force-pushed
the
public-api-analyzer
branch
3 times, most recently
from
November 22, 2022 18:25
18f59c1
to
92864d7
Compare
zpqrtbnk
force-pushed
the
public-api-analyzer
branch
from
November 23, 2022 14:08
92864d7
to
fc5eca9
Compare
zpqrtbnk
force-pushed
the
public-api-analyzer
branch
2 times, most recently
from
November 29, 2022 11:17
05c93b6
to
f05d290
Compare
zpqrtbnk
force-pushed
the
public-api-analyzer
branch
from
December 2, 2022 15:36
f05d290
to
362f7d1
Compare
zpqrtbnk
force-pushed
the
public-api-analyzer
branch
from
December 7, 2022 18:47
bc533bd
to
ade657c
Compare
emreyigit
approved these changes
Dec 8, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks nice.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the Microsoft.CodeAnalysis.PublicApiAnalyzers analyzer to the
Hazelcast.Net
project. These analyzers maintain a signature of the complete public API exposed by the project, in a set of text files, and issue warnings whenever the current signature does not match the files.This means that... if a public method or property or class or anything is changed, added, removed, anything - a warning will be logged in the build. This is used by the Roslyn team to monitor their API changes, and it willbe greatly beneficial to us to ensure compatibility between versions and track changes.
Note that the PR relies on a beta version of the analyzers that support merging multiple definition files (see PR#5422) and this is considered acceptable since it is a development-time dependency, and does not impact the production code in any ways.
How it works
Development
Covered projects (
Hazelcast.Net
at the moment) have an extrasrc/Hazelcast.Net/PublicAPI
directory that contains a set of files. ThePublicAPI.Shipped.txt
files define the signature of the public API. Whenever that public API is modified, i.e. whenever the code does not match that signature anymore,RS0016
and other warnings appear during the build.Whenever a change is made that is not a mistake, it should be added to
PublicAPI.Unshipped.txt
files. This will get rid of the warnings, but the change is still considered "proposed" and not "shipped" (see Release section below). Beware of conditional code (code within#if
blocks) and their correspondingPublicAPI.Unshipped.txt
files.At one point of time, and before entering the release phase, the
PublicAPI.Unshipped.txt
should be carefully reviewed and merged into thePublicAPI.Shipped.txt
files. Ideally these reviews should be independent PRs.Release
When building a
release/*
branch,RS0016
and other warnings are escalated to errors (rule inAnalysisRules.prop
) and therefore fail the build. In addition thehz.ps1
script looks forPublicAPI.Unshipped.txt
files and fails the build in case some are detected.A release build can therefore succeed only if changes to the public API have been reviewed, merged, etc.
Review
Open any public options file such as
MetricsOptions
and add a public property such aspublic int Whatever { get; set; }
. Rebuild, ensure you see a new warning. Name the current branchrelease/foo
and rebuild withhz.ps1 build
, ensure the build fails.Modify the
PublicAPI.Unshipped.txt
file to declare the new option. Rebuild, ensure the warning is one. Switch torelease/foo
and rebuild withhz.ps1
, ensure the buid fails.Merge the
PublicAPI.Unshipped.txt
changes intoPublicAPI.Shipped.txt
. Rebuild, ensure you see no warnings. Switch torelease/foo
and rebuild withhz.ps1
, ensure the buid succeeds.References