[release/8.0.1xx] Validate this extension methods and member types in APICompat #34999
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.
Backport of d0a4bf1 and 6fad359
Customer Impact
Customers use APICompat / PackageValidation to validate their public API changes. While we already have a large set of compatibility rules, we were missing two major cases: a) member type validation (i.e.
public string a
->public bool a
which is a breaking change) and b) the "this" modifier for extension methods (public static void ExtMethod(this string a)
->public static void ExtMethod(string a)
which also is a breaking change).By taking this change, we increase our customer's confidence in our shipping tooling by validating these two common scenarios. This was reported by a customer and by dotnet/runtime folks.
Testing
Tests were added for both scenarios and they are running in CI. I also tested the changes in dotnet/runtime manually and its main branch already uses an APICompat version with these changes.
Risk
Low to Medium. Existing scenarios are validated by tests. In general, new validation in APICompat is considered a breaking change as customers need to react to those. But that's exactly the reason why customers use APICompat as they want their API changes to be validated and APICompat to error out for incompatible changes.