question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ApiCompat does not show all breaking changes for --respect-internals option

See original GitHub issue

I 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:open
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ericstjcommented, Jun 8, 2021

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.

1reaction
Anipikcommented, Jun 8, 2021

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found