Skip to content
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

[Mono.Android] Bind and enumify API-35 Beta 3. #9043

Merged
merged 2 commits into from
Jul 9, 2024
Merged

Conversation

jpobst
Copy link
Contributor

@jpobst jpobst commented Jun 19, 2024

Context: https://developer.android.com/about/versions/15
Context: https://android-developers.googleblog.com/2024/06/the-third-beta-of-android-15.html

Android 15 Developer Preview 3 has been released. The Android 15
Developer Preview Program Overview Timeline and updates section
suggests the following timeline:

  • Feb/Mar: Developer Previews
  • April/May: Unstable Betas
  • June/July: Stable Betas
  • ???: Final

Additionally, enumify and mark API-35 as "stable", which changes net9.0-android to default to net9.0-android35.

Notes:

  • The Xamarin component manifest has not been updated to contain API-35 components, thus our existing InstallAndroidDependenciesTest unit test fails. Update the test to have a xamarin_manifest_needs_updating toggle set to true. While true it asserts that the test fails. When the Xamarin manifest is updated, this test will fail and it will need to toggled to false so that the normal checks occur.
  • The MAUI tests fail because 2 API that it uses have been marked as [Obsolete] in API-35 (Path.ComputeBounds(RectF, bool) and Window.SetStatusBarColor(Color)). MAUI will need to change the API they use or suppress these "warnings as errors".
  • APICompat reports that there are several Android.Runtime.RequiresPermissionAttribute that have been removed. As we do not consume this attribute, it does not cause any API breakage.

@jpobst jpobst force-pushed the api-35-beta-3 branch 7 times, most recently from ec3f0df to 5e339cf Compare June 21, 2024 15:05
@jpobst jpobst force-pushed the api-35-beta-3 branch 2 times, most recently from e561d8f to 47ac8b7 Compare June 28, 2024 15:53
@jpobst jpobst changed the title [Mono.Android] Bind API-35 Beta 3. [Mono.Android] Bind and enumify API-35 Beta 3. Jun 28, 2024
@jpobst jpobst force-pushed the api-35-beta-3 branch 8 times, most recently from 62b9d5c to 2adf17e Compare July 2, 2024 18:54
jonpryor pushed a commit that referenced this pull request Jul 3, 2024
Context: #9043

Changes: jbevain/cecil@0.11.4...0.11.5

  * jbevain/cecil@8c123e1: Bump to 0.11.5
  * jbevain/cecil@870ce3e: Fix RVA field alignment (jbevain/cecil#888)
  * jbevain/cecil@4ad9c0f: Fix that method resolution would consider all function-pointers to be the same (jbevain/cecil#885)
  * jbevain/cecil@cc48622: Fix a StackOverflowException reading windows runtime assemblies. (jbevain/cecil#879)
  * jbevain/cecil@341fb14: Treat instance and static methods as different methods during resolution (jbevain/cecil#882)
  * jbevain/cecil@e052ab5: Address issue #873 (jbevain/cecil#874)
  * jbevain/cecil@92f32da: Add `MethodImplAttributes.AggressiveOptimization` (jbevain/cecil#855)
  * jbevain/cecil@c4cfe16: Fix a race condition between certain Has properties and their collection property. (jbevain/cecil#843)
  * jbevain/cecil@65a2912: Add more style configuration (jbevain/cecil#854)
  * jbevain/cecil@9eb00e4: ILProcessor should also update custom debug info (jbevain/cecil#867)
  * jbevain/cecil@7d36386: Fix corrupted debug header directory entry when writing multiple such entries. (jbevain/cecil#869)
  * jbevain/cecil@6f94613: InvariantCulture for operand to string conversion in Instruction.ToString() (jbevain/cecil#870)
  * jbevain/cecil@42b9ef1: Add support for generic attributes (jbevain/cecil#871)
  * jbevain/cecil@49b1c52: Add `Unmanaged` calling convention (jbevain/cecil#852)
  * jbevain/cecil@2c68927: Fix mixed module ReadSymbols() (jbevain/cecil#851)
  * jbevain/cecil@f7b64f7: Fix custom attribute with enum on generic type (jbevain/cecil#827)
  * jbevain/cecil@79b43e8: Fix deterministic MVID and add PdbChecksum (jbevain/cecil#810)
  * jbevain/cecil@8b593d5: Harden debug scope update logic (jbevain/cecil#824)
  * jbevain/cecil@a56b5bd: FieldRVA alignment (jbevain/cecil#817)
  * jbevain/cecil@75372c7: Switch to netcoreapp3.1 for tests (jbevain/cecil#823)
  * jbevain/cecil@5f69faa: Add support for generating the method and generic method comment signature with nested types (jbevain/cecil#801)
  * jbevain/cecil@a0a6ce4: Addressing issue #781 (jbevain/cecil#782)
  * jbevain/cecil@2f1077d: Update the version of Microsoft.NETFramework.ReferenceAssemblies.net40 (jbevain/cecil#787)
  * jbevain/cecil@ede17f9: Fix handling of empty string constants (jbevain/cecil#776)

#9043 stops building API-34 and makes API-35 stable,
and in attempting to do so encounters this error when running
all of the in-tree Windows smoke tests on CI:

	D:\a\_work\1\s\bin\Release\dotnet\packs\Microsoft.Android.Sdk.Windows\35.0.0-ci.pr.gh9043.6\tools\Xamarin.Android.Bindings.JavaDependencyVerification.targets(22,5):
	error MSB4062: The "Xamarin.Android.Tasks.GetMicrosoftNuGetPackagesMap" task could not be loaded from the assembly 
	D:\a\_work\1\s\bin\Release\dotnet\packs\Microsoft.Android.Sdk.Windows\35.0.0-ci.pr.gh9043.6\tools\Xamarin.Android.Build.Tasks.dll.
	Could not load file or assembly 'Mono.Cecil, Version=0.11.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e'.
	The system cannot find the file specified.
	Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available,
	  and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
	[D:\a\_work\1\a\TestRelease\07-02_16.40.15\temp\DotNetBuildandroid-armFalseFalseFalse\UnnamedProject.csproj]

This appears to be caused by the fact that previously we:

 1. Build `Microsoft.Android.Sdk.ILLink.csproj`, which pulls in
    [Microsoft.NET.ILLink/9.0.0-preview.6.24319.11][0], which pulls
    in [Microsoft.DotNet.Cecil/0.11.4-alpha.24313.1][1], which
    contains `Mono.Cecil.dll` versioned as 0.11.5.0.

    (Yes, it's "odd" that `Microsoft.DotNet.Cecil/0.11.4*` would
    contain a Cecil versioned as 0.11.5, but that's what it has!)

 2. Build the rest of dotnet/android with the
    [Mono.Cecil/0.11.4][2] package.

 3. The Mono.Cecil/0.11.4 package "wins" and ends up in the output
    directory and the sdk pack.

So long as the `ILLink*`-related assemblies don't use any
Mono.Cecil/0.11.5 APIs, this works, however it is risky because we
don't know exactly what API `ILLink*` uses.

#9043 appears to change the build order such that
Mono.Cecil/0.11.5 now "wins" and is in the output directory.
This causes the above MSB4062 assembly load error.

We could try to fix the ordering and make Mono.Cecil/0.11.4 "win",
but this leaves us vulnerable to missing some API that `ILLink*`
needs.  As such, it's better that we update the rest of dotnet/android
to use the `0.11.5` version of `Mono.Cecil`.

This update breaks the `LinkerTests.FixAbstractMethodsStep_Explicit()`
unit test.  Specifically, this logic now returns `null` instead of
being able to be resolved:

	new MethodReference (iface_method.Name, void_type, iface)
	    .Resolve ();

It feels like this makes sense: a method name and return type doesn't
seem like it would be enough to resolve, as parameters are not
considered.

The fix is simply to use the existing `MethodDefinition` as the
`MethodReference`, there is no reason to create a new one.
This change fixes the test.

[0]: https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet9-transport/NuGet/Microsoft.NET.ILLink/overview/9.0.0-preview.7.24328.10
[1]: https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet9-transport/NuGet/Microsoft.DotNet.Cecil/overview/0.11.4-alpha.24313.1
[2]: https://www.nuget.org/packages/Mono.Cecil/0.11.4
@jpobst jpobst force-pushed the api-35-beta-3 branch 2 times, most recently from 1557b90 to 6e3d907 Compare July 3, 2024 20:50
@jpobst jpobst marked this pull request as ready for review July 8, 2024 17:37
@jonathanpeppers
Copy link
Member

I guess MAUI will require a couple code changes:

D:\a\_work\1\s\maui\src\Compatibility\Core\src\Android\Shapes\ShapeRenderer.cs(483,6): error CA1422: This call site is reachable on: 'Android' 21.0 and later. 'Path.ComputeBounds(RectF, bool)' is obsoleted on: 'Android' 35.0 and later. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1422) [D:\a\_work\1\s\maui\src\Compatibility\Core\src\Compatibility.csproj::TargetFramework=net9.0-android]
D:\a\_work\1\s\maui\src\Compatibility\Core\src\Android\Shapes\ShapeRenderer.cs(426,6): error CA1422: This call site is reachable on: 'Android' 21.0 and later. 'Path.ComputeBounds(RectF, bool)' is obsoleted on: 'Android' 35.0 and later. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1422) [D:\a\_work\1\s\maui\src\Compatibility\Core\src\Compatibility.csproj::TargetFramework=net9.0-android]
D:\a\_work\1\s\maui\src\Compatibility\Core\src\Android\AppCompat\FormsAppCompatActivity.cs(105,4): error CA1422: This call site is reachable on: 'Android' 21.0 and later. 'Window.SetStatusBarColor(Color)' is obsoleted on: 'Android' 35.0 and later. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1422) [D:\a\_work\1\s\maui\src\Compatibility\Core\src\Compatibility.csproj::TargetFramework=net9.0-android]

Maybe they should just disable TreatWarningsAsErrors for the Compatibility project.

@jonpryor jonpryor merged commit c57ca14 into main Jul 9, 2024
56 of 58 checks passed
@jonpryor jonpryor deleted the api-35-beta-3 branch July 9, 2024 19:36
grendello added a commit that referenced this pull request Jul 23, 2024
* main: (23 commits)
  Localized file check-in by OneLocBuild Task (#9129)
  [ci] Disable CodeQL on CI/PR pipelines (#9128)
  Refine 16k page alignment support (#9075)
  [build] fix `ConfigureLocalWorkload` target (#9124)
  Bump to NDK r27 (#9020)
  [ci] Use drop service for SDK insertion artifacts  (#9116)
  Fix up all mapping paths (#9121)
  [ci] Fix maestro publishing for stable packages (#9118)
  Bump to dotnet/sdk@2f14fea98b 9.0.100-preview.7.24367.21 (#9108)
  Missing androidx.window.[extensions|sidecar] warnings (#9085)
  [ci] Use sign-artifacts template for macOS signing (#9091)
  [ci] Use DotNetCoreCLI to sign macOS files (#9102)
  [ci] Disable CodeQL on macOS, Linux, non-main jobs (#9111)
  [tests] re-enable `JavaAbstractMethodTest` (#9097)
  [Microsoft.Android.Sdk.ILLink] preserve types with `IJniNameProviderAttribute` (#9099)
  [Mono.Android] Data sharing and Close() overrides (#9103)
  [AndroidManifest] Add `Android.App.PropertyAttribute` (#9016)
  [Mono.Android] Add support for AndroidMessageHandler ClientCertificates (#8961)
  [Mono.Android] Bind and enumify API-35 (#9043)
  Bump to dotnet/java-interop@7a058c0e (#9066)
  ...
@github-actions github-actions bot locked and limited conversation to collaborators Aug 9, 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.

6 participants