ApiCompat does not show all breaking changes for --respect-internals option
See original GitHub issueI have a scenario where the contract has an abstract
class with an internal
ctor. For example:
public abstract class Utility
{
internal Utility(){ } //internal ctor
public abstract Add(int a, int b);
}
In the implementation, I have marked the ctor as protected
and also added a new abstract
method.
public abstract class Utility
{
protected Utility(){ } //protected ctor
public abstract Add(int a, int b);
public abstract Subtract(int a, int b);
}
When I run ApiCompat, I provide the --respect-internals
option.
Expectation:
ApiCompat fails with the error CannotAddAbstractMembers
as I have added a new abstract method
Actual Behavior:
ApiCompat only reports this error CannotMakeMoreVisible
for the class
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Check for Breaking Changes with ApiCompat - Stuart Lang
If our public API changes in a way that is considered a breaking change, wouldn't it be great if we were notified so...
Read more >APICompat - Identifying breaking changes to an API
This identifies all breaking changes to an API at build time, with the option to ignore the breaking changes and append them to...
Read more >GenAPI issues generate invalid C# for internal types #4488
Anonymous classes are generated when the --all option is specified and the code is not compilable. We have to manually remove the anonymous ......
Read more >GenApi shouldn't add _dummy and _dummyObject if there ...
For example in the following struct object _dummy is not required because RenderTreeFrame has public ref fields which should be sufficient ...
Read more >A definitive guide to API-breaking changes in .NET
The ultimate goal is to catalogize as many breaking and quiet semantics API changes as possible, and describe exact effect of breakage, and ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As @Anipik mentions it’s treating internal constructors as “effectively sealed” https://github.com/dotnet/arcade/blob/cde36344adbc1c9808b1c3e7419f0ce3c3e5cd04/src/Microsoft.Cci.Extensions/Extensions/CSharp/CSharpCciExtensions.cs#L669-L686
So perhaps that needs to change to catch this specific case. It’s not effectively sealed if we’re considering internal API as part of the compatibility contract.
we pass
--respect-internals
as apicompat option to catch breaking changes in internaltypes as well https://github.com/dotnet/arcade/blob/main/src/Microsoft.DotNet.ApiCompat/src/ApiCompatRunner.cs#L80