From f202e3b6cfa64627407006d1f84badfeb9fca4dd Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Fri, 15 Sep 2023 13:26:16 -0400 Subject: [PATCH 1/3] Bump to xamarin/java.interop/main@1adb7964 Fixes: https://github.com/xamarin/java.interop/issues/910 Fixes: https://github.com/xamarin/java.interop/issues/1139 Changes: https://github.com/xamarin/Java.Interop/compare/3c83179668cf8b6848626be14ddccc3f742a92d3...1adb7964a2033c83c298c070f2d1ab896d92671b * xamarin/Java.Interop@1adb7964: [generator] `generator --lang-features=emit-legacy-interface-invokers` (xamarin/Java.Interop#1145) * xamarin/Java.Interop@6bd7ae48: [Xamarin.Android.Tools.Bytecode] Kotlin internal prop visibility (xamarin/Java.Interop#1151) Updates `class-parse` to better support parsing the visibility of Kotlin properties. Updates `generator` to emit optimized interface Invokers. Add support for a new `$(AndroidEmitLegacyInterfaceInvokers)` MSBuild property; when `true`, causes `generator` to emit legacy interface Invokers. The default value is `false`. --- .../guides/building-apps/build-properties.md | 10 ++++++ external/Java.Interop | 2 +- .../Xamarin.Android.Bindings.Core.targets | 1 + ...soft.Android.Sdk.DefaultProperties.targets | 1 + .../Tasks/Generator.cs | 6 ++++ .../BuildReleaseArm64SimpleDotNet.apkdesc | 32 +++++++++---------- .../BuildReleaseArm64XFormsDotNet.apkdesc | 14 ++++---- 7 files changed, 42 insertions(+), 24 deletions(-) diff --git a/Documentation/guides/building-apps/build-properties.md b/Documentation/guides/building-apps/build-properties.md index be7378f3c1a..2538c5e5903 100644 --- a/Documentation/guides/building-apps/build-properties.md +++ b/Documentation/guides/building-apps/build-properties.md @@ -430,6 +430,16 @@ documentation on [D8 and R8][d8-r8]. [dex]: https://source.android.com/devices/tech/dalvik/dalvik-bytecode [d8-r8]: https://github.com/xamarin/xamarin-android/blob/main/Documentation/guides/D8andR8.md +## AndroidEmitLegacyInterfaceInvokers + +A boolean property that determines whether or not "legacy" interface invokers are generated. +This should only be done if using the new optimizerd interface invoker infrastructure results +in build failures. + +The default value is `False`, and more optimized interface invokers are generated. + +Added in .NET 9.0. + ## AndroidEnableDesugar A boolean property that diff --git a/external/Java.Interop b/external/Java.Interop index 3c83179668c..1adb7964a20 160000 --- a/external/Java.Interop +++ b/external/Java.Interop @@ -1 +1 @@ -Subproject commit 3c83179668cf8b6848626be14ddccc3f742a92d3 +Subproject commit 1adb7964a2033c83c298c070f2d1ab896d92671b diff --git a/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.Core.targets b/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.Core.targets index d023fe0acc2..21988813abd 100644 --- a/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.Core.targets +++ b/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.Core.targets @@ -108,6 +108,7 @@ It is shared between "legacy" binding projects and .NET 5 projects. ToolPath="$(_BindingsToolsLocation)" ToolExe="$(BindingsGeneratorToolExe)" LangVersion="$(LangVersion)" + EmitLegacyInterfaceInvokers="$(AndroidEmitLegacyInterfaceInvokers)" EnableBindingStaticAndDefaultInterfaceMethods="$(AndroidBoundInterfacesContainStaticAndDefaultInterfaceMethods)" EnableBindingNestedInterfaceTypes="$(AndroidBoundInterfacesContainTypes)" EnableBindingInterfaceConstants="$(AndroidBoundInterfacesContainConstants)" diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets index 46a750a585b..a86b35e642a 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets @@ -39,6 +39,7 @@ true true true + false true obsolete diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/Generator.cs b/src/Xamarin.Android.Build.Tasks/Tasks/Generator.cs index 9744f864c4c..bb76b585a1d 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/Generator.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/Generator.cs @@ -48,6 +48,8 @@ public class BindingsGenerator : AndroidDotnetToolTask public string LangVersion { get; set; } + public bool EmitLegacyInterfaceInvokers { get; set; } + public bool EnableBindingStaticAndDefaultInterfaceMethods { get; set; } public bool EnableBindingNestedInterfaceTypes { get; set; } public bool EnableBindingInterfaceConstants { get; set; } @@ -209,6 +211,10 @@ protected override string GenerateCommandLineCommands () if (SupportsCSharp8) { var features = new List (); + if (EmitLegacyInterfaceInvokers) { + features.Add ("emit-legacy-interface-invokers"); + } + if (EnableBindingInterfaceConstants) features.Add ("interface-constants"); diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64SimpleDotNet.apkdesc b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64SimpleDotNet.apkdesc index 18b995352c6..1dbc7d0c32b 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64SimpleDotNet.apkdesc +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64SimpleDotNet.apkdesc @@ -8,61 +8,61 @@ "Size": 1024 }, "assemblies/Java.Interop.dll": { - "Size": 61886 + "Size": 61350 }, "assemblies/Mono.Android.dll": { - "Size": 88044 + "Size": 90818 }, "assemblies/Mono.Android.Runtime.dll": { - "Size": 5509 + "Size": 5514 }, "assemblies/rc.bin": { - "Size": 1395 + "Size": 1512 }, "assemblies/System.Console.dll": { - "Size": 6400 + "Size": 6536 }, "assemblies/System.Linq.dll": { - "Size": 9199 + "Size": 7118 }, "assemblies/System.Private.CoreLib.dll": { - "Size": 550507 + "Size": 550324 }, "assemblies/System.Runtime.dll": { - "Size": 2621 + "Size": 2614 }, "assemblies/System.Runtime.InteropServices.dll": { - "Size": 3858 + "Size": 3851 }, "assemblies/UnnamedProject.dll": { - "Size": 2933 + "Size": 2932 }, "classes.dex": { - "Size": 377064 + "Size": 377956 }, "lib/arm64-v8a/libmono-component-marshal-ilgen.so": { "Size": 97080 }, "lib/arm64-v8a/libmonodroid.so": { - "Size": 325320 + "Size": 334784 }, "lib/arm64-v8a/libmonosgen-2.0.so": { - "Size": 3189360 + "Size": 3193200 }, "lib/arm64-v8a/libSystem.IO.Compression.Native.so": { "Size": 723560 }, "lib/arm64-v8a/libSystem.Native.so": { - "Size": 93920 + "Size": 93952 }, "lib/arm64-v8a/libSystem.Security.Cryptography.Native.Android.so": { "Size": 154904 }, "lib/arm64-v8a/libxamarin-app.so": { - "Size": 11576 + "Size": 11648 }, "META-INF/BNDLTOOL.RSA": { - "Size": 1213 + "Size": 1221 }, "META-INF/BNDLTOOL.SF": { "Size": 3037 diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64XFormsDotNet.apkdesc b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64XFormsDotNet.apkdesc index 1a0ecbe1e38..25f7dfca7a9 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64XFormsDotNet.apkdesc +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64XFormsDotNet.apkdesc @@ -11,13 +11,13 @@ "Size": 7112 }, "assemblies/Java.Interop.dll": { - "Size": 70036 + "Size": 69472 }, "assemblies/Mono.Android.dll": { - "Size": 471216 + "Size": 447387 }, "assemblies/Mono.Android.Runtime.dll": { - "Size": 5506 + "Size": 5514 }, "assemblies/mscorlib.dll": { "Size": 3852 @@ -206,13 +206,13 @@ "Size": 42282 }, "classes.dex": { - "Size": 3513140 + "Size": 3514468 }, "lib/arm64-v8a/libmono-component-marshal-ilgen.so": { "Size": 97080 }, "lib/arm64-v8a/libmonodroid.so": { - "Size": 325320 + "Size": 334784 }, "lib/arm64-v8a/libmonosgen-2.0.so": { "Size": 3193200 @@ -227,7 +227,7 @@ "Size": 154904 }, "lib/arm64-v8a/libxamarin-app.so": { - "Size": 102840 + "Size": 102888 }, "META-INF/android.support.design_material.version": { "Size": 12 @@ -1916,5 +1916,5 @@ "Size": 325240 } }, - "PackageSize": 7973902 + "PackageSize": 7949326 } \ No newline at end of file From 57337eda1f0d6b8533b3e3a98eb015b037f8ac5c Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Thu, 26 Oct 2023 14:52:29 -0400 Subject: [PATCH 2/3] Make AndroidEmitLegacyInterfaceInvokers private As per discussion. --- Documentation/guides/building-apps/build-properties.md | 9 --------- .../Android/Xamarin.Android.Bindings.Core.targets | 2 +- .../Microsoft.Android.Sdk.DefaultProperties.targets | 2 +- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/Documentation/guides/building-apps/build-properties.md b/Documentation/guides/building-apps/build-properties.md index 2538c5e5903..cf3b5100649 100644 --- a/Documentation/guides/building-apps/build-properties.md +++ b/Documentation/guides/building-apps/build-properties.md @@ -430,15 +430,6 @@ documentation on [D8 and R8][d8-r8]. [dex]: https://source.android.com/devices/tech/dalvik/dalvik-bytecode [d8-r8]: https://github.com/xamarin/xamarin-android/blob/main/Documentation/guides/D8andR8.md -## AndroidEmitLegacyInterfaceInvokers - -A boolean property that determines whether or not "legacy" interface invokers are generated. -This should only be done if using the new optimizerd interface invoker infrastructure results -in build failures. - -The default value is `False`, and more optimized interface invokers are generated. - -Added in .NET 9.0. ## AndroidEnableDesugar diff --git a/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.Core.targets b/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.Core.targets index 21988813abd..e4fd97abeea 100644 --- a/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.Core.targets +++ b/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.Core.targets @@ -108,7 +108,7 @@ It is shared between "legacy" binding projects and .NET 5 projects. ToolPath="$(_BindingsToolsLocation)" ToolExe="$(BindingsGeneratorToolExe)" LangVersion="$(LangVersion)" - EmitLegacyInterfaceInvokers="$(AndroidEmitLegacyInterfaceInvokers)" + EmitLegacyInterfaceInvokers="$(_AndroidEmitLegacyInterfaceInvokers)" EnableBindingStaticAndDefaultInterfaceMethods="$(AndroidBoundInterfacesContainStaticAndDefaultInterfaceMethods)" EnableBindingNestedInterfaceTypes="$(AndroidBoundInterfacesContainTypes)" EnableBindingInterfaceConstants="$(AndroidBoundInterfacesContainConstants)" diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets index a86b35e642a..3aeea8cf67b 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets @@ -39,7 +39,7 @@ true true true - false + <_AndroidEmitLegacyInterfaceInvokers Condition=" '$(AndroidEmitLegacyInterfaceInvokers)' == '' ">false true obsolete From 4301223fc44f7183c0c49d30180460718df98d8b Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Fri, 3 Nov 2023 15:21:30 -0400 Subject: [PATCH 3/3] Bump to xamarin/java.interop/main@38c8a827e78ffe9c80ad2313a9e0e0d4f8215184 --- external/Java.Interop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/Java.Interop b/external/Java.Interop index 1adb7964a20..38c8a827e78 160000 --- a/external/Java.Interop +++ b/external/Java.Interop @@ -1 +1 @@ -Subproject commit 1adb7964a2033c83c298c070f2d1ab896d92671b +Subproject commit 38c8a827e78ffe9c80ad2313a9e0e0d4f8215184