xamarin-android/tests
Jonathan Peppers 56875061ca
[Xamarin.Android.Build.Tasks] enable ForceInterpretedInvoke switch (#7972)
Fixes: https://github.com/dotnet/runtime/issues/83893

Context: https://github.com/dotnet/runtime/pull/72717

In .NET 8, `System.Reflection.{ConstructorInfo,MethodInfo}.Invoke()`
will use `System.Reflection.Emit` when called more than once.
This impacts startup in mobile applications, so it may not be a
desirable feature.

Unfortunately, this appears to happen quite easily in Android apps;
some examples (using a custom dotnet/runtime build for extra output):

  * https://gist.github.com/ivanpovazan/2563ea9d2fea320e6425cfcc58da3ee5
  * https://gist.github.com/ivanpovazan/d2546d4abad17900d4366cc29e1689b2

The primary situation in which this happens is that all Java-originated
`Java.Lang.Object` subclass constructor invocations always hit
`ConstructorInfo.Invoke()`; see `TypeManager.Activate()`.

To solve this problem, we can set:

	<ItemGroup>
	  <RuntimeHostConfigurationOption
	      Include="Switch.System.Reflection.ForceInterpretedInvoke"
	      Value="$(_SystemReflectionForceInterpretedInvoke)"
	      Trim="true"
	  />
	</ItemGroup>

Setting the `Switch.System.Reflection.ForceInterpretedInvoke` switch
to True causes the `System.Reflection.Emit` codepath to be *skipped*.

We can set `$(_SystemReflectionForceInterpretedInvoke)` to test
out the setting in various apps.

I added a test to verify the "private" switch is actually set.

I also updated the `.aotprofile` to verify that all
`System.Reflection.Emit` code paths disappear from
`dotnet new android` applications.
2023-04-21 14:24:34 -04:00
..
BCL-Tests [One .NET] select defaults for App Bundles (#6087) 2021-08-27 21:42:57 -04:00
CodeBehind Fix SuccessfulAndroidXApp Unit Test (#6958) 2022-04-27 15:01:53 +01:00
CodeGen-Binding [tests] Port 'Xamarin.Android.JcwGen-Tests.JcwGen-Tests' to .NET (#7949) 2023-04-13 13:33:04 -04:00
CodeGen-MkBundle/Xamarin.Android.MakeBundle-Tests [ci] Improve build and test result packaging (#6411) 2021-10-28 16:25:25 -04:00
EmbeddedDSOs/EmbeddedDSO [build-tools] Bump Test emulator to use API-31 (#5257) 2022-02-25 12:54:12 -05:00
MSBuildDeviceIntegration [Microsoft.Android.Sdk.ILLink] fix crash when TZ changes (#7956) 2023-04-13 13:43:21 -04:00
Mono.Android-Tests [Xamarin.Android.Build.Tasks] enable ForceInterpretedInvoke switch (#7972) 2023-04-21 14:24:34 -04:00
ResolveImports [Xamarin.Android.Build.Tasks] Fast Deployment v2.0 (#4690) 2020-10-12 19:37:59 -04:00
TestRunner.Core [build] Use variables for `net6.0` where possible (#6947) 2022-04-21 11:32:29 -04:00
TestRunner.NUnit [build] Use variables for `net6.0` where possible (#6947) 2022-04-21 11:32:29 -04:00
TestRunner.xUnit [xaprepare] Use global NuGet package cache instead of in-tree one (#5491) 2021-01-26 14:49:01 -05:00
Xamarin.Android.Tools.Aidl-Tests [ci] Parallelize and reduce overhead of MSBuild test stage. (#7850) 2023-03-10 12:12:46 -06:00
Xamarin.Forms-Performance-Integration [Xamarin.Android.Build.Tasks] Remove support for mkbundle (#7772) 2023-02-28 14:09:50 -05:00
api-compatibility [Mono.Android] Bind API-UpsideDownCake Developer Preview 1 (#7796) 2023-03-28 15:15:55 -04:00
apk-sizes-reference Bump to Android NDK r25 (#6764) 2022-07-26 17:07:59 -04:00
locales [Xamarin.Android.Build.Tasks] Fast Deployment v2.0 (#4690) 2020-10-12 19:37:59 -04:00
msbuild-times-reference [tests] update times in MSBuildDeviceIntegration.csv (#7347) 2022-09-07 12:23:04 -04:00
RunApkTests.targets [tests] multi-target MSBuildDeviceIntegration (#5035) 2020-11-19 16:42:04 -05:00