Skip to content

Conversation

@jpobst
Copy link
Contributor

@jpobst jpobst commented Jul 6, 2023

Fixes #7421

Enable Microsoft's PublicApiAnalyzers for Mono.Android.dll.

We currently have ApiCompat, which ensures that we do not break backwards compatibility between Android API levels, but now that we are in the .NET TargetFramework world we also need to ensure we do not add any new API to a TF once it has shipped. A TargetFramework is essentially a contract that we cannot change. (Imagine if you had different minor versions of .NET on your local machine and CI machine, what works on one should work on the other.)

Running the PublicApiAnalyzer adds about 25 seconds to a local build. One can use our existing $(DisableApiCompatibilityCheck) property we have to also disable them to facilitate faster local build if desired.

Additionally, disable RS0041 ("Public members should not use oblivious types"). We should look at getting Android.Runtime.JniEnv.g.cs properly annotated with NRT and then we could enable this analyzer.

@jpobst jpobst force-pushed the api-analyzer branch 2 times, most recently from 0ff8261 to 5c21133 Compare July 7, 2023 04:55
@jpobst jpobst marked this pull request as ready for review July 10, 2023 20:32
@jonpryor
Copy link
Contributor

I want to point out that PublicAPI.Shipped.txt cannot be the only thing we use to maintain API, because we have had historical instances where the C# API did not break, but the implementation did break; see also #1118 and 07e7477.

This PR (#8171) does not fundamentally change things vs. 07e7477. I just want to point this out so that we don't remove tests/api-compatibility/reference/Mono.Android.zip without remembering #1118.

@jonpryor jonpryor merged commit 76ab8b2 into main Jul 13, 2023
@jonpryor jonpryor deleted the api-analyzer branch July 13, 2023 21:11
grendello added a commit to grendello/xamarin-android that referenced this pull request Jul 14, 2023
* main:
  [ci] XA.PublishAllLogs publishes all build logs to build artifacts (dotnet#8189)
  Bump to xamarin/Java.Interop/main@151b03e (dotnet#8188)
  [Mono.Android] Use PublicApiAnalyzers to ensure we do not break API. (dotnet#8171)
grendello added a commit to grendello/xamarin-android that referenced this pull request Jul 14, 2023
* main:
  [ci] XA.PublishAllLogs publishes all build logs to build artifacts (dotnet#8189)
  Bump to xamarin/Java.Interop/main@151b03e (dotnet#8188)
  [Mono.Android] Use PublicApiAnalyzers to ensure we do not break API. (dotnet#8171)
  [Xamarin.Android.Build.Tasks] per-RID assemblies & typemaps (dotnet#8164)
  [AndroidDependenciesTests] Test both manifest types (dotnet#8186)
  [AndroidDependenciesTests] Use platform-tools 34.0.4 (dotnet#8184)
grendello added a commit to grendello/xamarin-android that referenced this pull request Jul 14, 2023
* main:
  [ci] XA.PublishAllLogs publishes all build logs to build artifacts (dotnet#8189)
  Bump to xamarin/Java.Interop/main@151b03e (dotnet#8188)
  [Mono.Android] Use PublicApiAnalyzers to ensure we do not break API. (dotnet#8171)
grendello added a commit to grendello/xamarin-android that referenced this pull request Jul 17, 2023
* main:
  LLVM IR code generator refactoring and updates (dotnet#8140)
  [ci] XA.PublishAllLogs publishes all build logs to build artifacts (dotnet#8189)
  Bump to xamarin/Java.Interop/main@151b03e (dotnet#8188)
  [Mono.Android] Use PublicApiAnalyzers to ensure we do not break API. (dotnet#8171)
  [Xamarin.Android.Build.Tasks] per-RID assemblies & typemaps (dotnet#8164)
  [AndroidDependenciesTests] Test both manifest types (dotnet#8186)
  [AndroidDependenciesTests] Use platform-tools 34.0.4 (dotnet#8184)
@github-actions github-actions bot locked and limited conversation to collaborators Jan 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use PublicApiAnalyzers?

4 participants