-
Notifications
You must be signed in to change notification settings - Fork 562
Adding new api break workflow that uses Microsoft.DotNet.ApiCompat.dll #3884
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
Conversation
...n.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/CheckApiCompatibility.cs
Outdated
Show resolved
Hide resolved
...n.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/CheckApiCompatibility.cs
Outdated
Show resolved
Hide resolved
3b6154f
to
fa3d164
Compare
@gugavaro to fix the NuGet restore issue on the test jobs I think we'll need to update this YAML template to include - task: NuGetCommand@2
displayName: nuget restore Xamarin.Android solutions
inputs:
restoreSolution: '**/Xamarin.Android*.sln'
feedsToUse: config
nugetConfigPath: $(System.DefaultWorkingDirectory)/NuGet.config |
Thanks @pjcollins, I have updated the yaml file. |
...n.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/CheckApiCompatibility.cs
Outdated
Show resolved
Hide resolved
Given a previously stated intention of "merging" the xamarin-android and xamarin-android-api-compatibility repos -- because the new "reference Why not place them into |
...n.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/CheckApiCompatibility.cs
Outdated
Show resolved
Hide resolved
We should review the App Bundle crash: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=3223480&view=ms.vss-test-web.build-test-results-tab&runId=9669612&resultId=100000&paneView=debug See if it's fixed by PR #3888, which fixes:
|
The PR message mentions an error that doesn't appear to be fixed in the PR itself, and also doesn't error on a PR build:
Am I misunderstanding something? |
DotNet.ApiCompat does not use .cs, we will not be able to get rid of xamarin-android-api-compatibility repos yet. Microsoft.DotNet.ApiCompat is the tool .net and azure uses and it does a lot of further checks that is not possible to do with a simple text comparison. |
I am not sure I understand the question. This message is an example of what we will see if there is a breakage. The check happens when we build Mono.Android, and if a break happens the build will fail with similar message. The error does not happen on this PR because that error is an acceptable one based on the rules added on xamarin-android-api-compatibility repo |
cb26368
to
3c80c5b
Compare
Ah. Which specific rule disables the warnings that were mentioned? |
We may not be able to remove them yet, but if the intention is to eventually remove them, why increase our use of them, via these new Additionally, Thus, let's look at usage:
In context, these appear to be "contracts". Thus, instead of Though looking at the file contents: xamarin/xamarin-android-api-compatibility@a61271e...a9247ed#diff-3cc026f88bf794495bd1a9ddb20a6643R1
Thus, instead of e.g. |
for this specific error, this line will allow that specific breakage |
I agree with all your points and will fix all of them. �Thanks!!! |
315ba11
to
2e1532f
Compare
...n.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/CheckApiCompatibility.cs
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,40 @@ | |||
Compat issues with assembly Mono.Android: | |||
MembersMustExist : Member 'Android.Media.AudioRecord.add_RoutingChanged(System.EventHandler<Android.Media.AudioRecord.RoutingChangedEventArgs>)' does not exist in the implementation but it does exist in the contract. |
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.
...and I find this both horrifying and confusing: this sounds like a breaking change, yet it's not listed in https://github.com/xamarin/xamarin-android-api-compatibility/blob/master/inter-api-extra-v9.0-v10.0.txt nor in xamarin/xamarin-android-api-compatibility@336eeda (which must be viewed locally, as it's too big for GitHub to display), and I don't remember it coming up in the context of breaking changes previously.
$ git show 336eedaa51883d90100e30c95a007d8922ab19f0 | grep -i RoutingChanged
# no output
Yet, when I diff, it's there:
$ diff -u src/Mono.Android/obj/Debug/android-28/mcw/Android.Media.AudioRecord.cs src/Mono.Android/obj/Debug/android-29/mcw/Android.Media.AudioRecord.cs
- public event EventHandler<Android.Media.AudioRecord.RoutingChangedEventArgs> RoutingChanged {
+ public event EventHandler<Android.Media.AudioRoutingOnRoutingChangedEventArgs> RoutingChanged {
Why didn't our previous tooling find this?
For that matter, this finds nothing within the xamarin-android-api-compat repo:
$ grep '<event.*RoutingChanged' reference/Mono.Android.xml
# no matches
(Feeling of horror increases...)
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.
It took me quite a bit to remember this, but that's expected!
We were wrongly not generating that event, so that's why previous tool never complained about it.
see this: bcae941#diff-14048fd4cb6595cd0ad8cf1b41175ef5L1301
After my fix, we started generating that but only until api 28
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.
We were wrongly not generating that event
OK, so it didn't previously exist
After my fix, we started generating that but only until api 28
...and this is where we made a mistake. If we weren't previously emitting it, we should have continued not emitting it, so that when we "introduced" it in API-29, it wouldn't be incompatible with previous versions.
😞
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.
I gave you a wrong explanation, we are not adding it, we are actually only removing it from api 24 to api 28
we replace lines like:
<remove-node path="/api/package[@name='android.media']/interface[@name='AudioRouting']" />
to
<remove-node path="/api/package[@name='android.media']/interface[@name='AudioRouting']" api-since="24" api-until="28"/>
the issue was introduced when we fixed: dotnet/java-interop@7a31216
2e1532f
to
0ffb294
Compare
This PR now can only be merged after PR: #3997 be merged. |
Context: #3884 Commit 91467bb updated the build system so that instead of trying to do "everthing" within a single `.sln` file -- which would result in various file share exceptions when attempting to build `Xamarin.Android.sln` within Visual Studio on Windows -- the build tree would instead become "stateful": 1. Build `Xamarin.Android.BootstrapTasks.sln`. 2. Then `Xamarin.Android.sln` can be built. 3. Then `Xamarin.Android-Tests.sln` can be built. (1) was handled "internally" via `msbuild /t:Prepare`. A result of 91467bb is that if e.g. `build-tools/Xamarin.Android.Tools.BootstrapTasks` were changed, building `src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj` would no longer cause `Xamarin.Android.Tools.BootstrapTasks` to be rebuilt. (This was the point, as rebuilding `Xamarin.Android.Tools.BootstrapTasks`/etc. is what caused the file sharing issues that we wanted fixed.) Overlooked in 91467bb is that `xaprepare` (invoked by `msbuild /t:Prepare`) is responsible for restoring NuGet packages on `.sln` files, but it would only restore packages for `Xamarin.Android.sln`. This restriction caused problems in PR #3884, which attempted to add NuGet packages to `build-tools/Xamarin.Android.BootstrapTasks`, but because that solution never had its NuGet packages restored, attempting to use the expected *outputs* of NuGet restore would fail: $ cat build-tools/Xamarin.Android.BootstrapTasks/packages.config <?xml version="1.0" encoding="utf-8"?> <packages> <package id="Microsoft.DotNet.ApiCompat" version="5.0.0-beta.19602.1" targetFramework="net472" /> <package id="Microsoft.DotNet.GenAPI" version="5.0.0-beta.19602.1" targetFramework="net472" /> <package id="Mono.Posix.NETStandard" version="1.0.0" targetFramework="net472" /> <package id="Xamarin.LibZipSharp" version="1.0.6" targetFramework="net472" /> </packages> $ msbuild -t:restore build-tools/Xamarin.Android.BootstrapTasks/Xamarin.Android.Tools.BootstrapTask.csproj … $ ls packages/Microsoft.D* ls: cannot access 'packages/Microsoft.D*': No such file or directory Improve build system sanity: when `xaprepare` restores NuGet packages, it should restore the following solutions: * `Xamarin.Android.BootstrapTasks.sln` * `Xamarin.Android.Build.Tasks.sln` * `Xamarin.Android.sln` This will allow PR #3884 to work as intended.
0ffb294
to
3fa2d8b
Compare
Update the changes with mono.android.dll from Release 10.1.1 |
3fa2d8b
to
8ba6bfa
Compare
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Commit message for squash-and-merge:
|
Our current api check workflow is not able to detect some api breaks or is flagging api breaks that actually should not be raised.
examples are:
If we change Attributes current check is unable to validate that.
Also, if we add abstract methods to an abstract class, it also does not flag as break
Some instances of false positives are:
When a base class change.
from: ClassA : Object, ClassB: Object, ClassC: ClassA
to: ClassA : Object, ClassB: ClassA, ClassC: ClassB
this should not be considered a break, but our current check flags this as a break.
Also, using Microsoft.DotNet.ApiCompat.dll in our workflow makes sure we are following the same workflow .net team and azure team are using.
Another change is related to make the check as part of the project build step, so we can catch breakages much earlier and without any extra step.
original issue: #1118
here is an example of how the build would report the breakage:
AfterBuild:
CheckApiCompatibility for ApiLevel: v10.0
Compat issues with assembly Mono.Android:
CannotRemoveBaseTypeOrInterface : Type 'Java.Util.Concurrent.Atomic.LongAdder' does not inherit from base type 'Java.Util.Concurrent.Atomic.Striped64' in the implementation but it does in the contract.
Total Issues: 1
/home/gugavaro/Work/microsoft/Xamarin/xamarin-android-1/src/Mono.Android/Mono.Android.csproj(384,5): error : CheckApiCompatibility found nonacceptable Api breakages for ApiLevel: v10.0.
Done Building Project "/home/gugavaro/Work/microsoft/Xamarin/xamarin-android-1/src/Mono.Android/Mono.Android.csproj" (default targets) -- FAILED.
Build FAILED.
"/home/gugavaro/Work/microsoft/Xamarin/xamarin-android-1/src/Mono.Android/Mono.Android.csproj" (default target) (1) ->
(AfterBuild target) ->
/home/gugavaro/Work/microsoft/Xamarin/xamarin-android-1/src/Mono.Android/Mono.Android.csproj(384,5): error : CheckApiCompatibility found nonacceptable Api breakages for ApiLevel: v10.0.