From 1ef92983672f022e8c93d23dc7482bb085118f19 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Thu, 11 Jun 2026 10:23:21 +0200 Subject: [PATCH 01/10] Update SDK workload pipeline configuration Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- build-tools/automation/azure-pipelines.yaml | 2 +- .../yaml-templates/stage-package-tests.yaml | 45 -------------- .../ConfigureLocalWorkload.targets | 61 +------------------ build-tools/scripts/DotNet.targets | 28 --------- .../xaprepare/Application/KnownProperties.cs | 2 - .../Application/Properties.Defaults.cs.in | 2 - .../xaprepare/ConfigAndData/Configurables.cs | 8 --- .../Steps/Step_InstallDotNetPreview.cs | 18 ------ .../xaprepare/xaprepare/package-download.proj | 10 --- .../xaprepare/xaprepare/xaprepare.targets | 2 - eng/Version.Details.xml | 9 --- eng/Versions.props | 3 - 12 files changed, 3 insertions(+), 187 deletions(-) diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index 9f9454386e3..9db14c71d95 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -102,7 +102,7 @@ extends: - stage: maui_tests displayName: MAUI Tests dependsOn: mac_build - condition: and(in(dependencies.mac_build.result, 'Succeeded', 'SucceededWithIssues'), eq(variables['RunMAUITestJob'], 'true')) + condition: false jobs: # Check - "Xamarin.Android (MAUI Tests MAUI Integration)" - job: maui_tests_integration diff --git a/build-tools/automation/yaml-templates/stage-package-tests.yaml b/build-tools/automation/yaml-templates/stage-package-tests.yaml index e6fd01de65f..63b298c741d 100644 --- a/build-tools/automation/yaml-templates/stage-package-tests.yaml +++ b/build-tools/automation/yaml-templates/stage-package-tests.yaml @@ -80,15 +80,6 @@ stages: artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.apk artifactFolder: $(DotNetTargetFramework)-NoAab - - template: /build-tools/automation/yaml-templates/apk-instrumentation.yaml - parameters: - configuration: $(XA.Build.Configuration) - testName: Mono.Android.NET_Tests-Interpreter - project: tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj - extraBuildArgs: -p:TestsFlavor=Interpreter -p:UseInterpreter=True -p:UseMonoRuntime=true - artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab - artifactFolder: $(DotNetTargetFramework)-Interpreter - - ${{ if ne(parameters.macTestAgentsUseCleanImages, true) }}: - template: /build-tools/automation/yaml-templates/start-stop-emulator.yaml parameters: @@ -151,42 +142,6 @@ stages: - template: /build-tools/automation/yaml-templates/start-stop-emulator.yaml - - template: /build-tools/automation/yaml-templates/apk-instrumentation.yaml - parameters: - configuration: $(XA.Build.Configuration) - testName: Mono.Android.NET_Tests-NoAot - project: tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj - extraBuildArgs: -p:TestsFlavor=NoAot -p:RunAOTCompilation=false -p:UseMonoRuntime=true - artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab - artifactFolder: $(DotNetTargetFramework)-NoAot - - - template: /build-tools/automation/yaml-templates/apk-instrumentation.yaml - parameters: - configuration: $(XA.Build.Configuration) - testName: Mono.Android.NET_Tests-TrimModePartial - project: tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj - extraBuildArgs: -p:TestsFlavor=TrimModePartial -p:TrimMode=partial -p:UseMonoRuntime=true - artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab - artifactFolder: $(DotNetTargetFramework)-TrimModePartial - - - template: /build-tools/automation/yaml-templates/apk-instrumentation.yaml - parameters: - configuration: $(XA.Build.Configuration) - testName: Mono.Android.NET_Tests-AotLlvm - project: tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj - extraBuildArgs: -p:TestsFlavor=AotLlvm -p:EnableLLVM=true -p:AndroidEnableProfiledAot=false -p:UseMonoRuntime=true - artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab - artifactFolder: $(DotNetTargetFramework)-AotLlvm - - - template: /build-tools/automation/yaml-templates/apk-instrumentation.yaml - parameters: - configuration: $(XA.Build.Configuration) - testName: Mono.Android.NET_Tests-IsAssignableFrom - project: tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj - extraBuildArgs: -p:TestsFlavor=IsAssignableFrom -p:IncludeCategories=Intune -p:_AndroidIsAssignableFromCheck=false -p:UseMonoRuntime=true - artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab - artifactFolder: $(DotNetTargetFramework)-IsAssignableFrom - - template: /build-tools/automation/yaml-templates/apk-instrumentation.yaml parameters: configuration: $(XA.Build.Configuration) diff --git a/build-tools/create-packs/ConfigureLocalWorkload.targets b/build-tools/create-packs/ConfigureLocalWorkload.targets index ea4c4f2c02d..e5d5df519b4 100644 --- a/build-tools/create-packs/ConfigureLocalWorkload.targets +++ b/build-tools/create-packs/ConfigureLocalWorkload.targets @@ -48,40 +48,11 @@ - - - - - - - - - - - - - - - <_LocalSdkManifestsFolder>$(BuildOutputDirectory)lib\sdk-manifests\$(DotNetSdkManifestsFolder)\ <_LocalAndroidManifestFolder>$(_LocalSdkManifestsFolder)microsoft.net.sdk.android\$(AndroidPackVersionLong)\ - <_EmptyWorkloadDir>$(_LocalSdkManifestsFolder)android.deps.workload\0.0.1\ @@ -91,38 +62,10 @@ Targets="_GenerateXAWorkloadContent" /> - - - - - - - "microsoft-net-runtime-android" - <_EmptyWorkloadJsonContent> - - - - - - - - - - - CreateLocalFrameworkLists;CreateLocalRuntimeLists;InstallManifestAndDependencies;DeleteExtractedWorkloadPacks;PackLocalTemplates + CreateLocalFrameworkLists;CreateLocalRuntimeLists;InstallManifest;DeleteExtractedWorkloadPacks;PackLocalTemplates diff --git a/build-tools/scripts/DotNet.targets b/build-tools/scripts/DotNet.targets index e3774c9c48d..b5ca7a80f10 100644 --- a/build-tools/scripts/DotNet.targets +++ b/build-tools/scripts/DotNet.targets @@ -6,7 +6,6 @@ $(_Root)..\maui $(MauiSourcePath)\artifacts\packages\$(Configuration)\Shipping - maui-android @@ -118,33 +117,6 @@ - - - - - - - - - - - <_NuGetSources Condition=" '$(MauiUseLocalPacks)' == 'true' " Include="$(MauiPackagePath.TrimEnd('\'))" /> - <_InstallArguments Include="--skip-manifest-update" /> - <_InstallArguments Include="--skip-sign-check" /> - <_InstallArguments Include="--verbosity diag" /> - <_InstallArguments Include="--source "%(_NuGetSources.Identity)"" /> - <_InstallArguments Include="--temp-dir "$(_TempDirectory)"" /> - - diff --git a/build-tools/xaprepare/xaprepare/Application/KnownProperties.cs b/build-tools/xaprepare/xaprepare/Application/KnownProperties.cs index e80df2d8537..877ae599e48 100644 --- a/build-tools/xaprepare/xaprepare/Application/KnownProperties.cs +++ b/build-tools/xaprepare/xaprepare/Application/KnownProperties.cs @@ -23,11 +23,9 @@ static class KnownProperties public const string DotNetPreviewPath = "DotNetPreviewPath"; public const string DotNetPreviewVersionBand = nameof (DotNetPreviewVersionBand); public const string DotNetSdkManifestsFolder = nameof (DotNetSdkManifestsFolder); - public const string DotNetMonoManifestVersionBand = nameof (DotNetMonoManifestVersionBand); public const string DotNetEmscriptenManifestVersionBand = nameof (DotNetEmscriptenManifestVersionBand); public const string MicrosoftDotnetSdkInternalPackageVersion = "MicrosoftDotnetSdkInternalPackageVersion"; public const string MicrosoftNETCoreAppRefPackageVersion = "MicrosoftNETCoreAppRefPackageVersion"; - public const string MicrosoftNETWorkloadMonoToolChainPackageVersion = "MicrosoftNETWorkloadMonoToolChainPackageVersion"; public const string MicrosoftNETWorkloadEmscriptenPackageVersion = "MicrosoftNETWorkloadEmscriptenPackageVersion"; public const string EmulatorVersion = "EmulatorVersion"; public const string EmulatorPkgRevision = "EmulatorPkgRevision"; diff --git a/build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in b/build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in index 83ce47017ab..800c79c6639 100644 --- a/build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in +++ b/build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in @@ -27,11 +27,9 @@ namespace Xamarin.Android.Prepare properties.Add (KnownProperties.DotNetPreviewPath, StripQuotes (@"@DotNetPreviewPath@")); properties.Add (KnownProperties.DotNetPreviewVersionBand, StripQuotes (@"@DotNetPreviewVersionBand@")); properties.Add (KnownProperties.DotNetSdkManifestsFolder, StripQuotes (@"@DotNetSdkManifestsFolder@")); - properties.Add (KnownProperties.DotNetMonoManifestVersionBand, StripQuotes (@"@DotNetMonoManifestVersionBand@")); properties.Add (KnownProperties.DotNetEmscriptenManifestVersionBand, StripQuotes (@"@DotNetEmscriptenManifestVersionBand@")); properties.Add (KnownProperties.MicrosoftDotnetSdkInternalPackageVersion, StripQuotes ("@MicrosoftDotnetSdkInternalPackageVersion@")); properties.Add (KnownProperties.MicrosoftNETCoreAppRefPackageVersion, StripQuotes ("@MicrosoftNETCoreAppRefPackageVersion@")); - properties.Add (KnownProperties.MicrosoftNETWorkloadMonoToolChainPackageVersion, StripQuotes ("@MicrosoftNETWorkloadMonoToolChainPackageVersion@")); properties.Add (KnownProperties.MicrosoftNETWorkloadEmscriptenPackageVersion, StripQuotes ("@MicrosoftNETWorkloadEmscriptenPackageVersion@")); properties.Add (KnownProperties.EmulatorVersion, StripQuotes ("@EmulatorVersion@")); properties.Add (KnownProperties.EmulatorPkgRevision, StripQuotes ("@EmulatorPkgRevision@")); diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs index b4d402c053c..b576b1b2c8d 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs @@ -178,14 +178,6 @@ public static partial class Paths public static string CoreClrAppRuntimeAndroidX86 => GetCachedPath (ref coreclrAppRuntimeAndroidX86, () => GetCoreClrAppRuntimePath (ctx, "x86")); public static string CoreClrAppRuntimeAndroidX86_64 => GetCachedPath (ref coreclrAppRuntimeAndroidX86_64, () => GetCoreClrAppRuntimePath (ctx, "x64")); - public static string MicrosoftNETWorkloadMonoPackageDir => Path.Combine ( - XAPackagesDir, - $"microsoft.net.workload.mono.toolchain.{{0}}.manifest-{ctx.Properties.GetRequiredValue (KnownProperties.DotNetMonoManifestVersionBand)}", - ctx.Properties.GetRequiredValue (KnownProperties.MicrosoftNETWorkloadMonoToolChainPackageVersion) - ); - - public static string MicrosoftNETWorkloadMonoToolChainDir => Path.Combine (MicrosoftNETWorkloadMonoPackageDir, "data"); - public static string MicrosoftNETWorkloadEmscriptenPackageDir => Path.Combine ( XAPackagesDir, $"microsoft.net.workload.emscripten.{{0}}.manifest-{ctx.Properties.GetRequiredValue (KnownProperties.DotNetEmscriptenManifestVersionBand)}", diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs b/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs index 7d53a9b5330..c294cf7d0c1 100644 --- a/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs +++ b/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs @@ -33,16 +33,6 @@ protected override async Task Execute (Context context) AddToInventory (); - // Delete all relevant NuGet package install directories, as we could possibly be using a new runtime commit with a previously installed version (6.0.0) - var runtimeDirs = Directory.GetDirectories (Configurables.Paths.XAPackagesDir, "microsoft.netcore.app.runtime.mono.android*"); - var packageDirsToRemove = new List (runtimeDirs); - packageDirsToRemove.Add (Configurables.Paths.MicrosoftNETWorkloadMonoPackageDir); - foreach (var packageDir in packageDirsToRemove) { - if (Directory.Exists (packageDir)) { - Utilities.DeleteDirectory (packageDir); - } - } - // Install runtime packs associated with the SDK previously installed. var packageDownloadProj = Path.Combine (BuildPaths.XamarinAndroidSourceRoot, "build-tools", "xaprepare", "xaprepare", "package-download.proj"); var logPathBase = Path.Combine (Configurables.Paths.BuildBinDir, $"msbuild-{context.BuildTimeStamp}-download-runtime-packs"); @@ -82,14 +72,6 @@ protected override async Task Execute (Context context) var dotnets = new [] { "net6", "net7", "net8", "net9", "net10", "current" }; foreach (var dotnet in dotnets) { var destination = Path.Combine (sdk_manifests, - context.Properties.GetRequiredValue (KnownProperties.DotNetMonoManifestVersionBand), - $"microsoft.net.workload.mono.toolchain.{dotnet}", - context.Properties.GetRequiredValue (KnownProperties.MicrosoftNETWorkloadMonoToolChainPackageVersion)); - Utilities.DeleteDirectory (destination, recurse: true); - foreach (var file in Directory.GetFiles (string.Format (Configurables.Paths.MicrosoftNETWorkloadMonoToolChainDir, dotnet), "*")) { - Utilities.CopyFileToDir (file, destination); - } - destination = Path.Combine (sdk_manifests, context.Properties.GetRequiredValue (KnownProperties.DotNetEmscriptenManifestVersionBand), $"microsoft.net.workload.emscripten.{dotnet}", context.Properties.GetRequiredValue (KnownProperties.MicrosoftNETWorkloadEmscriptenPackageVersion)); diff --git a/build-tools/xaprepare/xaprepare/package-download.proj b/build-tools/xaprepare/xaprepare/package-download.proj index dcf3c42420d..82631da49eb 100644 --- a/build-tools/xaprepare/xaprepare/package-download.proj +++ b/build-tools/xaprepare/xaprepare/package-download.proj @@ -16,18 +16,8 @@ Otherwise, $(MicrosoftNETCoreAppRefPackageVersion) from eng/Versions.props will - - - - - - - - - - diff --git a/build-tools/xaprepare/xaprepare/xaprepare.targets b/build-tools/xaprepare/xaprepare/xaprepare.targets index 50f9c290493..f3db8a8463e 100644 --- a/build-tools/xaprepare/xaprepare/xaprepare.targets +++ b/build-tools/xaprepare/xaprepare/xaprepare.targets @@ -62,11 +62,9 @@ - - diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 72e9aa98ae5..ad3e832b728 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -16,19 +16,10 @@ https://github.com/dotnet/dotnet c5d1f734662eb718e7431a4e679a29e47c380f04 - - https://github.com/dotnet/dotnet - ab01524bbb2ef1eea0ffaef161b3ef5686e8f256 - https://github.com/dotnet/dotnet ab01524bbb2ef1eea0ffaef161b3ef5686e8f256 - - - https://github.com/dotnet/runtime - 2b2a06c8a4d45ec0781266ffa3f3852a052f0fbb - https://github.com/dotnet/android diff --git a/eng/Versions.props b/eng/Versions.props index 27a9e629150..07c597aae91 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -9,9 +9,7 @@ 11.0.0-beta.26060.102 11.0.0-beta.26268.112 - 11.0.100-preview.4.26215.121 11.0.100-preview.4.26215.121 - $(MicrosoftNETWorkloadMonoToolChainCurrentManifest110100preview4PackageVersion) $(MicrosoftNETWorkloadEmscriptenCurrentManifest110100preview4PackageVersion) 11.0.100-preview.5.26268.112 0.11.5-preview.26268.112 @@ -28,7 +26,6 @@ \-(preview|rc|alpha).\d+ $(VersionBand)$([System.Text.RegularExpressions.Regex]::Match($(MicrosoftDotnetSdkInternalPackageVersion), $(VersionSuffixRegex))) $(DotNetPreviewVersionBand) - $(VersionBand)$([System.Text.RegularExpressions.Regex]::Match($(MicrosoftNETWorkloadMonoToolChainPackageVersion), $(VersionSuffixRegex))) $(VersionBand)$([System.Text.RegularExpressions.Regex]::Match($(MicrosoftNETWorkloadEmscriptenPackageVersion), $(VersionSuffixRegex))) $(DotNetPreviewVersionBand) From 87b245475cb45592d85d1d3f69865a264242ba4b Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Wed, 10 Jun 2026 15:11:43 +0200 Subject: [PATCH 02/10] Update .NET 11 SDK to preview 6 (build 20260610.6) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- eng/Version.Details.xml | 24 ++++++++++++------------ eng/Versions.props | 14 +++++++------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index ad3e832b728..85d48309f30 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -1,24 +1,24 @@ - + https://github.com/dotnet/dotnet - c5d1f734662eb718e7431a4e679a29e47c380f04 + 8d5d82abe13ac88cf5b2343e77460243b5272a6b - + https://github.com/dotnet/dotnet - c5d1f734662eb718e7431a4e679a29e47c380f04 + 8d5d82abe13ac88cf5b2343e77460243b5272a6b - + https://github.com/dotnet/dotnet - c5d1f734662eb718e7431a4e679a29e47c380f04 + 8d5d82abe13ac88cf5b2343e77460243b5272a6b - + https://github.com/dotnet/dotnet - c5d1f734662eb718e7431a4e679a29e47c380f04 + 8d5d82abe13ac88cf5b2343e77460243b5272a6b - + https://github.com/dotnet/dotnet - ab01524bbb2ef1eea0ffaef161b3ef5686e8f256 + 8d5d82abe13ac88cf5b2343e77460243b5272a6b @@ -35,9 +35,9 @@ https://github.com/dotnet/dotnet c5d1f734662eb718e7431a4e679a29e47c380f04 - + https://github.com/dotnet/dotnet - c5d1f734662eb718e7431a4e679a29e47c380f04 + 8d5d82abe13ac88cf5b2343e77460243b5272a6b https://github.com/microsoft/testfx diff --git a/eng/Versions.props b/eng/Versions.props index 07c597aae91..ce8dcf4f8f4 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -1,18 +1,18 @@ - 11.0.100-preview.5.26268.112 + 11.0.100-preview.6.26310.106 $(MicrosoftNETSdkPackageVersion) - 11.0.0-preview.5.26268.112 - 11.0.0-preview.5.26268.112 + 11.0.0-preview.6.26310.106 + 11.0.0-preview.6.26310.106 7.0.0-beta.22103.1 11.0.0-beta.26060.102 11.0.0-beta.26268.112 - 11.0.100-preview.4.26215.121 - $(MicrosoftNETWorkloadEmscriptenCurrentManifest110100preview4PackageVersion) - 11.0.100-preview.5.26268.112 - 0.11.5-preview.26268.112 + 11.0.100-preview.6.26310.106 + $(MicrosoftNETWorkloadEmscriptenCurrentManifest110100preview6PackageVersion) + 11.0.100-preview.6.26310.106 + 0.11.5-preview.26310.106 4.3.0-preview.26314.12 10.0.9 11.0.0-preview.1.26104.118 From e69a75c1134517a1f47ceab35248fbbd12eeb5ad Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Wed, 10 Jun 2026 16:47:21 +0200 Subject: [PATCH 03/10] Use validation package feed for SDK packages Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- NuGet.config | 1 + 1 file changed, 1 insertion(+) diff --git a/NuGet.config b/NuGet.config index dec1baffe92..09802b3955c 100644 --- a/NuGet.config +++ b/NuGet.config @@ -2,6 +2,7 @@ + From 3f2b59601c87217cf0aff5b7fb1af2d8a563deda Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Fri, 12 Jun 2026 11:57:15 +0200 Subject: [PATCH 04/10] [mobile] Remove MAUI integration pipeline stage The MAUI integration stage installs the full maui workload, which pulls mobile runtime workloads that are no longer produced for .NET 11. Remove the stage from the public and internal pipelines and drop the now-unused RunMAUITestJob variable. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../automation/azure-pipelines-public.yaml | 188 ------------------ build-tools/automation/azure-pipelines.yaml | 139 ------------- .../automation/yaml-templates/variables.yaml | 2 - 3 files changed, 329 deletions(-) diff --git a/build-tools/automation/azure-pipelines-public.yaml b/build-tools/automation/azure-pipelines-public.yaml index a2f83418def..763d7b68511 100644 --- a/build-tools/automation/azure-pipelines-public.yaml +++ b/build-tools/automation/azure-pipelines-public.yaml @@ -412,191 +412,3 @@ stages: - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml parameters: condition: true - -# MAUI Tests Stage -- stage: maui_tests - displayName: MAUI Tests - dependsOn: mac_build - condition: and(succeeded(), ne(variables['SkipTestStages'], 'true')) - jobs: - - job: maui_tests_integration - displayName: MAUI Integration - pool: - name: $(NetCorePublicPoolName) - demands: - - ImageOverride -equals 1es-windows-2022-open - os: windows - timeoutInMinutes: 180 - workspace: - clean: all - variables: - BuildVersion: $(Build.BuildId) - # Ignore MAUI's public API analyzer errors (RS0016) - dotnet/android does not care about those - PublicApiType: Generate - steps: - - checkout: self - clean: true - submodules: recursive - path: s/android - persistCredentials: false - - - checkout: maui - clean: true - submodules: recursive - path: s/maui - persistCredentials: true - - # Restore ~/.gradle/caches between runs so MAUI's Gradle resolution - # for android-gradle-plugin/sdklib/ddmlib is not gated on the - # dotnet-public-maven Maven feed every build. The dnceng-public Maven - # feed periodically rate-limits ('exceeding usage of resource Concurrency - # in namespace IPAddress', HTTP 500), which deterministically fails - # MAUI's ./build.ps1 --target=dotnet-pack. - # Adapted from upstream dotnet/maui, which adopted the pattern from us: - # https://github.com/dotnet/maui/blob/net11.0/eng/pipelines/common/cache-gradle.yml - - template: /build-tools/automation/yaml-templates/cache-gradle.yaml - parameters: - xaSourcePath: $(Build.SourcesDirectory)/android - - - template: /build-tools/automation/yaml-templates/setup-test-environment-steps.yaml - parameters: - xaSourcePath: $(Build.SourcesDirectory)/android - androidSdkPlatforms: $(DefaultTestSdkPlatforms) - dotnetVersion: $(DotNetSdkVersion) - dotnetQuality: $(DotNetSdkQuality) - useAgentJdkPath: false - use1ESTemplate: false - - - task: DownloadPipelineArtifact@2 - inputs: - artifactName: $(NuGetArtifactName) - downloadPath: $(Build.StagingDirectory)/android-packs - - - pwsh: | - $searchPath = Join-Path $(Build.StagingDirectory) android-packs - $wlmanPack = Get-ChildItem $searchPath -Filter *Android*Manifest*.nupkg | Select-Object -First 1 - $dest = Join-Path $searchPath "tmp-wlman" "$($wlmanPack.BaseName)" - Expand-Archive -LiteralPath $wlmanPack -DestinationPath $dest - $wlmanJsonPath = Join-Path $dest "data" "WorkloadManifest.json" - $json = Get-Content $wlmanJsonPath | ConvertFrom-Json -AsHashtable - Write-Host "Setting variable ANDROID_PACK_VERSION = $($json["version"])" - Write-Host "##vso[task.setvariable variable=ANDROID_PACK_VERSION;]$($json["version"])" - displayName: Set ANDROID_PACK_VERSION - - - pwsh: >- - $(Build.SourcesDirectory)/maui/eng/scripts/update-version-props.ps1 - -xmlFileName "$(Build.SourcesDirectory)/maui/eng/Versions.props" - -androidVersion $(ANDROID_PACK_VERSION) - displayName: Update MAUI's Android dependency - - - task: DotNetCoreCLI@2 - displayName: Update Android SDK band in Workloads.csproj - inputs: - projects: $(Build.SourcesDirectory)/android/Xamarin.Android.sln - arguments: -t:UpdateMauiWorkloadsProj -c $(XA.Build.Configuration) --no-restore -v:n -bl:$(Build.StagingDirectory)/logs/update-maui-workloadsproj.binlog - - - pwsh: ./build.ps1 --target=dotnet --configuration="$(XA.Build.Configuration)" --nugetsource="$(Build.StagingDirectory)\android-packs" --verbosity=diagnostic - displayName: Install .NET - retryCountOnTaskFailure: 3 - workingDirectory: $(Build.SourcesDirectory)/maui - - - task: NodeTool@0 - displayName: Install Node.js - # MAUI's TypeScript build steps for the BlazorWebView project shell out - # to node.exe; the dnceng-public windows.vs2022.amd64.open image does - # not preinstall Node, so install it explicitly. - inputs: - versionSpec: '20.x' - - - pwsh: | - # Match Configuration.props: prefer ANDROID_SDK_ROOT if set+exists, - # else $(HOME)\android-toolchain\sdk, else $env:USERPROFILE fallback. - $candidates = @() - if ($env:ANDROID_SDK_ROOT) { $candidates += $env:ANDROID_SDK_ROOT } - if ($env:ANDROID_HOME) { $candidates += $env:ANDROID_HOME } - if ($env:HOME) { $candidates += "$env:HOME\android-toolchain\sdk" } - if ($env:USERPROFILE) { $candidates += "$env:USERPROFILE\android-toolchain\sdk" } - $sdk = $candidates | Where-Object { $_ -and (Test-Path (Join-Path $_ 'platforms')) } | Select-Object -First 1 - if (-not $sdk) { - Write-Error "Could not find an Android SDK install with a 'platforms' subdir. Tried:`n$($candidates -join "`n")" - exit 1 - } - Write-Host "Setting ANDROID_HOME / ANDROID_SDK_ROOT to '$sdk'" - Get-ChildItem (Join-Path $sdk 'platforms') | ForEach-Object { Write-Host " platforms\$($_.Name)" } - Write-Host "##vso[task.setvariable variable=ANDROID_HOME]$sdk" - Write-Host "##vso[task.setvariable variable=ANDROID_SDK_ROOT]$sdk" - displayName: Point ANDROID_HOME at xa-prepare SDK - # androidsdk.csproj's install path follows Configuration.props rules: - # ANDROID_SDK_ROOT if it exists, otherwise %HOME%\android-toolchain\sdk. - # On the 1es-windows-2022-open image, ANDROID_SDK_ROOT is preset to - # the agent's preinstalled SDK (e.g. C:\Program Files (x86)\Android\android-sdk), - # so xa-prepare ends up extending that location with the requested - # API levels. Whichever path it picked, MAUI's build needs the same - # ANDROID_HOME / ANDROID_SDK_ROOT so it sees API 37, etc. - - - pwsh: ./build.ps1 --target=dotnet-pack --configuration="$(XA.Build.Configuration)" --nugetsource="$(Build.StagingDirectory)\android-packs" --verbosity=diagnostic - displayName: Pack .NET Maui - workingDirectory: $(Build.SourcesDirectory)/maui - - - task: DotNetCoreCLI@2 - displayName: Install MAUI workload packs - retryCountOnTaskFailure: 3 - inputs: - projects: $(Build.SourcesDirectory)/android/Xamarin.Android.sln - arguments: -t:InstallMaui -p:MauiUseLocalPacks=true -p:MauiWorkloadToInstall=maui -p:MauiManifestDiagnosticsPath=$(Build.StagingDirectory)/logs/maui-manifest -c $(XA.Build.Configuration) --no-restore -v:n -bl:$(Build.StagingDirectory)/logs/install-maui.binlog - - - template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml - parameters: - command: new - arguments: maui -o $(Build.StagingDirectory)/MauiTestProj - xaSourcePath: $(Build.SourcesDirectory)/android - displayName: Create MAUI template - continueOnError: false - - - powershell: | - $project = '$(Build.StagingDirectory)/MauiTestProj/MauiTestProj.csproj' - [xml] $xml = Get-Content $project - $node = $xml.SelectSingleNode('/Project/PropertyGroup/TargetFrameworks') - $node.InnerText = '$(DotNetTargetFramework)-android' - $xml.Save($project) - displayName: set TargetFrameworks to Android-only - - - template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml - parameters: - project: $(Build.StagingDirectory)/MauiTestProj/MauiTestProj.csproj - arguments: >- - -f $(DotNetTargetFramework)-android -c Debug - --configfile $(Build.SourcesDirectory)/maui/NuGet.config - -bl:$(Build.StagingDirectory)/logs/MauiTestProj-Debug.binlog - xaSourcePath: $(Build.SourcesDirectory)/android - displayName: Build MAUI template - Debug - - - template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml - parameters: - project: $(Build.StagingDirectory)/MauiTestProj/MauiTestProj.csproj - arguments: >- - -f $(DotNetTargetFramework)-android -c Release - --configfile $(Build.SourcesDirectory)/maui/NuGet.config - -bl:$(Build.StagingDirectory)/logs/MauiTestProj-Release.binlog - xaSourcePath: $(Build.SourcesDirectory)/android - displayName: Build MAUI template - Release - - - task: CopyFiles@2 - displayName: copy build logs - condition: always() - inputs: - Contents: | - $(Build.SourcesDirectory)/android/bin/*$(XA.Build.Configuration)/*.*log - $(Build.SourcesDirectory)/maui/artifacts/logs/** - TargetFolder: $(Build.StagingDirectory)/logs - flattenFolders: true - - - template: /build-tools/automation/yaml-templates/publish-artifact.yaml - parameters: - displayName: upload build and test results - artifactName: Test Results - MAUI Integration - targetPath: $(Build.StagingDirectory)/logs - condition: or(ne(variables['Agent.JobStatus'], 'Succeeded'), eq(variables['XA.PublishAllLogs'], 'true')) - use1ESTemplate: false - - - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index 9db14c71d95..ceac0e5ae00 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -99,144 +99,6 @@ extends: parameters: usesCleanImages: ${{ parameters.macTestAgentsUseCleanImages }} - - stage: maui_tests - displayName: MAUI Tests - dependsOn: mac_build - condition: false - jobs: - # Check - "Xamarin.Android (MAUI Tests MAUI Integration)" - - job: maui_tests_integration - displayName: MAUI Integration - pool: - name: MAUI-1ESPT - image: $(WindowsPoolImage1ESPT) - os: windows - timeoutInMinutes: 180 - workspace: - clean: all - variables: - BuildVersion: $(Build.BuildId) - # Ignore MAUI's public API analyzer errors (RS0016) - dotnet/android does not care about those - PublicApiType: Generate - steps: - - checkout: maui - clean: true - submodules: recursive - path: s/maui - persistCredentials: true - - - template: /build-tools/automation/yaml-templates/setup-test-environment.yaml@self - parameters: - xaSourcePath: $(Build.SourcesDirectory)/android - androidSdkPlatforms: $(DefaultTestSdkPlatforms) - dotnetVersion: $(DotNetSdkVersion) - dotnetQuality: $(DotNetSdkQuality) - - - task: NuGetAuthenticate@1 - displayName: authenticate with azure artifacts - inputs: - forceReinstallCredentialProvider: true - - - task: DownloadPipelineArtifact@2 - inputs: - artifactName: $(NuGetArtifactName) - downloadPath: $(Build.StagingDirectory)/android-packs - - - pwsh: | - $searchPath = Join-Path $(Build.StagingDirectory) android-packs - $wlmanPack = Get-ChildItem $searchPath -Filter *Android*Manifest*.nupkg | Select-Object -First 1 - $dest = Join-Path $searchPath "tmp-wlman" "$($wlmanPack.BaseName)" - Expand-Archive -LiteralPath $wlmanPack -DestinationPath $dest - $wlmanJsonPath = Join-Path $dest "data" "WorkloadManifest.json" - $json = Get-Content $wlmanJsonPath | ConvertFrom-Json -AsHashtable - Write-Host "Setting variable ANDROID_PACK_VERSION = $($json["version"])" - Write-Host "##vso[task.setvariable variable=ANDROID_PACK_VERSION;]$($json["version"])" - displayName: Set ANDROID_PACK_VERSION - - - pwsh: >- - $(Build.SourcesDirectory)/maui/eng/scripts/update-version-props.ps1 - -xmlFileName "$(Build.SourcesDirectory)/maui/eng/Versions.props" - -androidVersion $(ANDROID_PACK_VERSION) - displayName: Update MAUI's Android dependency - - - task: DotNetCoreCLI@2 - displayName: Update Android SDK band in Workloads.csproj - inputs: - projects: $(Build.SourcesDirectory)/android/Xamarin.Android.sln - arguments: -t:UpdateMauiWorkloadsProj -c $(XA.Build.Configuration) --no-restore -v:n -bl:$(Build.StagingDirectory)/logs/update-maui-workloadsproj.binlog - - - pwsh: ./build.ps1 --target=dotnet --configuration="$(XA.Build.Configuration)" --nugetsource="$(Build.StagingDirectory)\android-packs" --verbosity=diagnostic - displayName: Install .NET - retryCountOnTaskFailure: 3 - workingDirectory: $(Build.SourcesDirectory)/maui - - - pwsh: ./build.ps1 --target=dotnet-pack --configuration="$(XA.Build.Configuration)" --nugetsource="$(Build.StagingDirectory)\android-packs" --verbosity=diagnostic - displayName: Pack .NET Maui - workingDirectory: $(Build.SourcesDirectory)/maui - - - task: DotNetCoreCLI@2 - displayName: Install MAUI workload packs - retryCountOnTaskFailure: 3 - inputs: - projects: $(Build.SourcesDirectory)/android/Xamarin.Android.sln - arguments: -t:InstallMaui -p:MauiUseLocalPacks=true -p:MauiWorkloadToInstall=maui -p:MauiManifestDiagnosticsPath=$(Build.StagingDirectory)/logs/maui-manifest -c $(XA.Build.Configuration) --no-restore -v:n -bl:$(Build.StagingDirectory)/logs/install-maui.binlog - - - template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml@self - parameters: - command: new - arguments: maui -o $(Build.StagingDirectory)/MauiTestProj - xaSourcePath: $(Build.SourcesDirectory)/android - displayName: Create MAUI template - continueOnError: false - - - powershell: | - $project = '$(Build.StagingDirectory)/MauiTestProj/MauiTestProj.csproj' - [xml] $xml = Get-Content $project - $node = $xml.SelectSingleNode('/Project/PropertyGroup/TargetFrameworks') - $node.InnerText = '$(DotNetTargetFramework)-android' - $xml.Save($project) - displayName: set TargetFrameworks to Android-only - - - template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml@self - parameters: - project: $(Build.StagingDirectory)/MauiTestProj/MauiTestProj.csproj - arguments: >- - -f $(DotNetTargetFramework)-android -c Debug - --configfile $(Build.SourcesDirectory)/maui/NuGet.config - -bl:$(Build.StagingDirectory)/logs/MauiTestProj-Debug.binlog - xaSourcePath: $(Build.SourcesDirectory)/android - displayName: Build MAUI template - Debug - - - template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml@self - parameters: - project: $(Build.StagingDirectory)/MauiTestProj/MauiTestProj.csproj - arguments: >- - -f $(DotNetTargetFramework)-android -c Release - --configfile $(Build.SourcesDirectory)/maui/NuGet.config - -bl:$(Build.StagingDirectory)/logs/MauiTestProj-Release.binlog - xaSourcePath: $(Build.SourcesDirectory)/android - displayName: Build MAUI template - Release - - - task: CopyFiles@2 - displayName: copy build logs - condition: always() - inputs: - Contents: | - $(Build.SourcesDirectory)/android/bin/*$(XA.Build.Configuration)/*.*log - $(Build.SourcesDirectory)/maui/artifacts/logs/** - TargetFolder: $(Build.StagingDirectory)/logs - flattenFolders: true - - - template: /build-tools/automation/yaml-templates/publish-artifact.yaml@self - parameters: - displayName: upload build and test results - artifactName: Test Results - MAUI Integration - targetPath: $(Build.StagingDirectory)/logs - condition: or(ne(variables['Agent.JobStatus'], 'Succeeded'), eq(variables['XA.PublishAllLogs'], 'true')) - - - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml@self - - - stage: dotnet_prepare_release displayName: Prepare .NET Release dependsOn: @@ -462,7 +324,6 @@ extends: - linux_tests - msbuild_dotnet - msbuilddevice_tests - - maui_tests condition: failed() jobs: - template: build-summary/v1.yml@yaml-templates diff --git a/build-tools/automation/yaml-templates/variables.yaml b/build-tools/automation/yaml-templates/variables.yaml index 8a9d45d11f7..ce07d3d24c0 100644 --- a/build-tools/automation/yaml-templates/variables.yaml +++ b/build-tools/automation/yaml-templates/variables.yaml @@ -66,8 +66,6 @@ variables: value: 21 - name: ExcludedNightlyNUnitCategories value: 'cat != SystemApplication & cat != TimeZoneInfo & cat != Localization' -- name: RunMAUITestJob - value: true - name: DOTNET_SYSTEM_NET_SECURITY_NOREVOCATIONCHECKBYDEFAULT value: true - name: DOTNET_CLI_TELEMETRY_OPTOUT From a5a80474e8f6814735ccccc032d2cdc47ef16c82 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Sun, 14 Jun 2026 17:44:41 +0200 Subject: [PATCH 05/10] Restore Mono build infrastructure; keep only Mono mobile test-leg disable Address review feedback: the native build and MAUI-on-local-build flow still require the Mono runtime pack downloads and workload-install targets, so restore package-download.proj, DotNet.targets, Step_InstallDotNetPreview, the xaprepare property plumbing, the maui_tests stage, and the RunMAUITestJob variable. The PR now changes only the Mono mobile instrumentation test legs in stage-package-tests.yaml plus the temporary validation pins. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../automation/azure-pipelines-public.yaml | 188 ++++++++++++++++++ build-tools/automation/azure-pipelines.yaml | 139 +++++++++++++ .../automation/yaml-templates/variables.yaml | 2 + .../ConfigureLocalWorkload.targets | 61 +++++- build-tools/scripts/DotNet.targets | 28 +++ .../xaprepare/Application/KnownProperties.cs | 2 + .../Application/Properties.Defaults.cs.in | 2 + .../xaprepare/ConfigAndData/Configurables.cs | 8 + .../Steps/Step_InstallDotNetPreview.cs | 18 ++ .../xaprepare/xaprepare/package-download.proj | 10 + .../xaprepare/xaprepare/xaprepare.targets | 2 + eng/Version.Details.xml | 4 + eng/Versions.props | 3 + 13 files changed, 465 insertions(+), 2 deletions(-) diff --git a/build-tools/automation/azure-pipelines-public.yaml b/build-tools/automation/azure-pipelines-public.yaml index 763d7b68511..a2f83418def 100644 --- a/build-tools/automation/azure-pipelines-public.yaml +++ b/build-tools/automation/azure-pipelines-public.yaml @@ -412,3 +412,191 @@ stages: - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml parameters: condition: true + +# MAUI Tests Stage +- stage: maui_tests + displayName: MAUI Tests + dependsOn: mac_build + condition: and(succeeded(), ne(variables['SkipTestStages'], 'true')) + jobs: + - job: maui_tests_integration + displayName: MAUI Integration + pool: + name: $(NetCorePublicPoolName) + demands: + - ImageOverride -equals 1es-windows-2022-open + os: windows + timeoutInMinutes: 180 + workspace: + clean: all + variables: + BuildVersion: $(Build.BuildId) + # Ignore MAUI's public API analyzer errors (RS0016) - dotnet/android does not care about those + PublicApiType: Generate + steps: + - checkout: self + clean: true + submodules: recursive + path: s/android + persistCredentials: false + + - checkout: maui + clean: true + submodules: recursive + path: s/maui + persistCredentials: true + + # Restore ~/.gradle/caches between runs so MAUI's Gradle resolution + # for android-gradle-plugin/sdklib/ddmlib is not gated on the + # dotnet-public-maven Maven feed every build. The dnceng-public Maven + # feed periodically rate-limits ('exceeding usage of resource Concurrency + # in namespace IPAddress', HTTP 500), which deterministically fails + # MAUI's ./build.ps1 --target=dotnet-pack. + # Adapted from upstream dotnet/maui, which adopted the pattern from us: + # https://github.com/dotnet/maui/blob/net11.0/eng/pipelines/common/cache-gradle.yml + - template: /build-tools/automation/yaml-templates/cache-gradle.yaml + parameters: + xaSourcePath: $(Build.SourcesDirectory)/android + + - template: /build-tools/automation/yaml-templates/setup-test-environment-steps.yaml + parameters: + xaSourcePath: $(Build.SourcesDirectory)/android + androidSdkPlatforms: $(DefaultTestSdkPlatforms) + dotnetVersion: $(DotNetSdkVersion) + dotnetQuality: $(DotNetSdkQuality) + useAgentJdkPath: false + use1ESTemplate: false + + - task: DownloadPipelineArtifact@2 + inputs: + artifactName: $(NuGetArtifactName) + downloadPath: $(Build.StagingDirectory)/android-packs + + - pwsh: | + $searchPath = Join-Path $(Build.StagingDirectory) android-packs + $wlmanPack = Get-ChildItem $searchPath -Filter *Android*Manifest*.nupkg | Select-Object -First 1 + $dest = Join-Path $searchPath "tmp-wlman" "$($wlmanPack.BaseName)" + Expand-Archive -LiteralPath $wlmanPack -DestinationPath $dest + $wlmanJsonPath = Join-Path $dest "data" "WorkloadManifest.json" + $json = Get-Content $wlmanJsonPath | ConvertFrom-Json -AsHashtable + Write-Host "Setting variable ANDROID_PACK_VERSION = $($json["version"])" + Write-Host "##vso[task.setvariable variable=ANDROID_PACK_VERSION;]$($json["version"])" + displayName: Set ANDROID_PACK_VERSION + + - pwsh: >- + $(Build.SourcesDirectory)/maui/eng/scripts/update-version-props.ps1 + -xmlFileName "$(Build.SourcesDirectory)/maui/eng/Versions.props" + -androidVersion $(ANDROID_PACK_VERSION) + displayName: Update MAUI's Android dependency + + - task: DotNetCoreCLI@2 + displayName: Update Android SDK band in Workloads.csproj + inputs: + projects: $(Build.SourcesDirectory)/android/Xamarin.Android.sln + arguments: -t:UpdateMauiWorkloadsProj -c $(XA.Build.Configuration) --no-restore -v:n -bl:$(Build.StagingDirectory)/logs/update-maui-workloadsproj.binlog + + - pwsh: ./build.ps1 --target=dotnet --configuration="$(XA.Build.Configuration)" --nugetsource="$(Build.StagingDirectory)\android-packs" --verbosity=diagnostic + displayName: Install .NET + retryCountOnTaskFailure: 3 + workingDirectory: $(Build.SourcesDirectory)/maui + + - task: NodeTool@0 + displayName: Install Node.js + # MAUI's TypeScript build steps for the BlazorWebView project shell out + # to node.exe; the dnceng-public windows.vs2022.amd64.open image does + # not preinstall Node, so install it explicitly. + inputs: + versionSpec: '20.x' + + - pwsh: | + # Match Configuration.props: prefer ANDROID_SDK_ROOT if set+exists, + # else $(HOME)\android-toolchain\sdk, else $env:USERPROFILE fallback. + $candidates = @() + if ($env:ANDROID_SDK_ROOT) { $candidates += $env:ANDROID_SDK_ROOT } + if ($env:ANDROID_HOME) { $candidates += $env:ANDROID_HOME } + if ($env:HOME) { $candidates += "$env:HOME\android-toolchain\sdk" } + if ($env:USERPROFILE) { $candidates += "$env:USERPROFILE\android-toolchain\sdk" } + $sdk = $candidates | Where-Object { $_ -and (Test-Path (Join-Path $_ 'platforms')) } | Select-Object -First 1 + if (-not $sdk) { + Write-Error "Could not find an Android SDK install with a 'platforms' subdir. Tried:`n$($candidates -join "`n")" + exit 1 + } + Write-Host "Setting ANDROID_HOME / ANDROID_SDK_ROOT to '$sdk'" + Get-ChildItem (Join-Path $sdk 'platforms') | ForEach-Object { Write-Host " platforms\$($_.Name)" } + Write-Host "##vso[task.setvariable variable=ANDROID_HOME]$sdk" + Write-Host "##vso[task.setvariable variable=ANDROID_SDK_ROOT]$sdk" + displayName: Point ANDROID_HOME at xa-prepare SDK + # androidsdk.csproj's install path follows Configuration.props rules: + # ANDROID_SDK_ROOT if it exists, otherwise %HOME%\android-toolchain\sdk. + # On the 1es-windows-2022-open image, ANDROID_SDK_ROOT is preset to + # the agent's preinstalled SDK (e.g. C:\Program Files (x86)\Android\android-sdk), + # so xa-prepare ends up extending that location with the requested + # API levels. Whichever path it picked, MAUI's build needs the same + # ANDROID_HOME / ANDROID_SDK_ROOT so it sees API 37, etc. + + - pwsh: ./build.ps1 --target=dotnet-pack --configuration="$(XA.Build.Configuration)" --nugetsource="$(Build.StagingDirectory)\android-packs" --verbosity=diagnostic + displayName: Pack .NET Maui + workingDirectory: $(Build.SourcesDirectory)/maui + + - task: DotNetCoreCLI@2 + displayName: Install MAUI workload packs + retryCountOnTaskFailure: 3 + inputs: + projects: $(Build.SourcesDirectory)/android/Xamarin.Android.sln + arguments: -t:InstallMaui -p:MauiUseLocalPacks=true -p:MauiWorkloadToInstall=maui -p:MauiManifestDiagnosticsPath=$(Build.StagingDirectory)/logs/maui-manifest -c $(XA.Build.Configuration) --no-restore -v:n -bl:$(Build.StagingDirectory)/logs/install-maui.binlog + + - template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml + parameters: + command: new + arguments: maui -o $(Build.StagingDirectory)/MauiTestProj + xaSourcePath: $(Build.SourcesDirectory)/android + displayName: Create MAUI template + continueOnError: false + + - powershell: | + $project = '$(Build.StagingDirectory)/MauiTestProj/MauiTestProj.csproj' + [xml] $xml = Get-Content $project + $node = $xml.SelectSingleNode('/Project/PropertyGroup/TargetFrameworks') + $node.InnerText = '$(DotNetTargetFramework)-android' + $xml.Save($project) + displayName: set TargetFrameworks to Android-only + + - template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml + parameters: + project: $(Build.StagingDirectory)/MauiTestProj/MauiTestProj.csproj + arguments: >- + -f $(DotNetTargetFramework)-android -c Debug + --configfile $(Build.SourcesDirectory)/maui/NuGet.config + -bl:$(Build.StagingDirectory)/logs/MauiTestProj-Debug.binlog + xaSourcePath: $(Build.SourcesDirectory)/android + displayName: Build MAUI template - Debug + + - template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml + parameters: + project: $(Build.StagingDirectory)/MauiTestProj/MauiTestProj.csproj + arguments: >- + -f $(DotNetTargetFramework)-android -c Release + --configfile $(Build.SourcesDirectory)/maui/NuGet.config + -bl:$(Build.StagingDirectory)/logs/MauiTestProj-Release.binlog + xaSourcePath: $(Build.SourcesDirectory)/android + displayName: Build MAUI template - Release + + - task: CopyFiles@2 + displayName: copy build logs + condition: always() + inputs: + Contents: | + $(Build.SourcesDirectory)/android/bin/*$(XA.Build.Configuration)/*.*log + $(Build.SourcesDirectory)/maui/artifacts/logs/** + TargetFolder: $(Build.StagingDirectory)/logs + flattenFolders: true + + - template: /build-tools/automation/yaml-templates/publish-artifact.yaml + parameters: + displayName: upload build and test results + artifactName: Test Results - MAUI Integration + targetPath: $(Build.StagingDirectory)/logs + condition: or(ne(variables['Agent.JobStatus'], 'Succeeded'), eq(variables['XA.PublishAllLogs'], 'true')) + use1ESTemplate: false + + - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index ceac0e5ae00..9f9454386e3 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -99,6 +99,144 @@ extends: parameters: usesCleanImages: ${{ parameters.macTestAgentsUseCleanImages }} + - stage: maui_tests + displayName: MAUI Tests + dependsOn: mac_build + condition: and(in(dependencies.mac_build.result, 'Succeeded', 'SucceededWithIssues'), eq(variables['RunMAUITestJob'], 'true')) + jobs: + # Check - "Xamarin.Android (MAUI Tests MAUI Integration)" + - job: maui_tests_integration + displayName: MAUI Integration + pool: + name: MAUI-1ESPT + image: $(WindowsPoolImage1ESPT) + os: windows + timeoutInMinutes: 180 + workspace: + clean: all + variables: + BuildVersion: $(Build.BuildId) + # Ignore MAUI's public API analyzer errors (RS0016) - dotnet/android does not care about those + PublicApiType: Generate + steps: + - checkout: maui + clean: true + submodules: recursive + path: s/maui + persistCredentials: true + + - template: /build-tools/automation/yaml-templates/setup-test-environment.yaml@self + parameters: + xaSourcePath: $(Build.SourcesDirectory)/android + androidSdkPlatforms: $(DefaultTestSdkPlatforms) + dotnetVersion: $(DotNetSdkVersion) + dotnetQuality: $(DotNetSdkQuality) + + - task: NuGetAuthenticate@1 + displayName: authenticate with azure artifacts + inputs: + forceReinstallCredentialProvider: true + + - task: DownloadPipelineArtifact@2 + inputs: + artifactName: $(NuGetArtifactName) + downloadPath: $(Build.StagingDirectory)/android-packs + + - pwsh: | + $searchPath = Join-Path $(Build.StagingDirectory) android-packs + $wlmanPack = Get-ChildItem $searchPath -Filter *Android*Manifest*.nupkg | Select-Object -First 1 + $dest = Join-Path $searchPath "tmp-wlman" "$($wlmanPack.BaseName)" + Expand-Archive -LiteralPath $wlmanPack -DestinationPath $dest + $wlmanJsonPath = Join-Path $dest "data" "WorkloadManifest.json" + $json = Get-Content $wlmanJsonPath | ConvertFrom-Json -AsHashtable + Write-Host "Setting variable ANDROID_PACK_VERSION = $($json["version"])" + Write-Host "##vso[task.setvariable variable=ANDROID_PACK_VERSION;]$($json["version"])" + displayName: Set ANDROID_PACK_VERSION + + - pwsh: >- + $(Build.SourcesDirectory)/maui/eng/scripts/update-version-props.ps1 + -xmlFileName "$(Build.SourcesDirectory)/maui/eng/Versions.props" + -androidVersion $(ANDROID_PACK_VERSION) + displayName: Update MAUI's Android dependency + + - task: DotNetCoreCLI@2 + displayName: Update Android SDK band in Workloads.csproj + inputs: + projects: $(Build.SourcesDirectory)/android/Xamarin.Android.sln + arguments: -t:UpdateMauiWorkloadsProj -c $(XA.Build.Configuration) --no-restore -v:n -bl:$(Build.StagingDirectory)/logs/update-maui-workloadsproj.binlog + + - pwsh: ./build.ps1 --target=dotnet --configuration="$(XA.Build.Configuration)" --nugetsource="$(Build.StagingDirectory)\android-packs" --verbosity=diagnostic + displayName: Install .NET + retryCountOnTaskFailure: 3 + workingDirectory: $(Build.SourcesDirectory)/maui + + - pwsh: ./build.ps1 --target=dotnet-pack --configuration="$(XA.Build.Configuration)" --nugetsource="$(Build.StagingDirectory)\android-packs" --verbosity=diagnostic + displayName: Pack .NET Maui + workingDirectory: $(Build.SourcesDirectory)/maui + + - task: DotNetCoreCLI@2 + displayName: Install MAUI workload packs + retryCountOnTaskFailure: 3 + inputs: + projects: $(Build.SourcesDirectory)/android/Xamarin.Android.sln + arguments: -t:InstallMaui -p:MauiUseLocalPacks=true -p:MauiWorkloadToInstall=maui -p:MauiManifestDiagnosticsPath=$(Build.StagingDirectory)/logs/maui-manifest -c $(XA.Build.Configuration) --no-restore -v:n -bl:$(Build.StagingDirectory)/logs/install-maui.binlog + + - template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml@self + parameters: + command: new + arguments: maui -o $(Build.StagingDirectory)/MauiTestProj + xaSourcePath: $(Build.SourcesDirectory)/android + displayName: Create MAUI template + continueOnError: false + + - powershell: | + $project = '$(Build.StagingDirectory)/MauiTestProj/MauiTestProj.csproj' + [xml] $xml = Get-Content $project + $node = $xml.SelectSingleNode('/Project/PropertyGroup/TargetFrameworks') + $node.InnerText = '$(DotNetTargetFramework)-android' + $xml.Save($project) + displayName: set TargetFrameworks to Android-only + + - template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml@self + parameters: + project: $(Build.StagingDirectory)/MauiTestProj/MauiTestProj.csproj + arguments: >- + -f $(DotNetTargetFramework)-android -c Debug + --configfile $(Build.SourcesDirectory)/maui/NuGet.config + -bl:$(Build.StagingDirectory)/logs/MauiTestProj-Debug.binlog + xaSourcePath: $(Build.SourcesDirectory)/android + displayName: Build MAUI template - Debug + + - template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml@self + parameters: + project: $(Build.StagingDirectory)/MauiTestProj/MauiTestProj.csproj + arguments: >- + -f $(DotNetTargetFramework)-android -c Release + --configfile $(Build.SourcesDirectory)/maui/NuGet.config + -bl:$(Build.StagingDirectory)/logs/MauiTestProj-Release.binlog + xaSourcePath: $(Build.SourcesDirectory)/android + displayName: Build MAUI template - Release + + - task: CopyFiles@2 + displayName: copy build logs + condition: always() + inputs: + Contents: | + $(Build.SourcesDirectory)/android/bin/*$(XA.Build.Configuration)/*.*log + $(Build.SourcesDirectory)/maui/artifacts/logs/** + TargetFolder: $(Build.StagingDirectory)/logs + flattenFolders: true + + - template: /build-tools/automation/yaml-templates/publish-artifact.yaml@self + parameters: + displayName: upload build and test results + artifactName: Test Results - MAUI Integration + targetPath: $(Build.StagingDirectory)/logs + condition: or(ne(variables['Agent.JobStatus'], 'Succeeded'), eq(variables['XA.PublishAllLogs'], 'true')) + + - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml@self + + - stage: dotnet_prepare_release displayName: Prepare .NET Release dependsOn: @@ -324,6 +462,7 @@ extends: - linux_tests - msbuild_dotnet - msbuilddevice_tests + - maui_tests condition: failed() jobs: - template: build-summary/v1.yml@yaml-templates diff --git a/build-tools/automation/yaml-templates/variables.yaml b/build-tools/automation/yaml-templates/variables.yaml index ce07d3d24c0..8a9d45d11f7 100644 --- a/build-tools/automation/yaml-templates/variables.yaml +++ b/build-tools/automation/yaml-templates/variables.yaml @@ -66,6 +66,8 @@ variables: value: 21 - name: ExcludedNightlyNUnitCategories value: 'cat != SystemApplication & cat != TimeZoneInfo & cat != Localization' +- name: RunMAUITestJob + value: true - name: DOTNET_SYSTEM_NET_SECURITY_NOREVOCATIONCHECKBYDEFAULT value: true - name: DOTNET_CLI_TELEMETRY_OPTOUT diff --git a/build-tools/create-packs/ConfigureLocalWorkload.targets b/build-tools/create-packs/ConfigureLocalWorkload.targets index e5d5df519b4..ea4c4f2c02d 100644 --- a/build-tools/create-packs/ConfigureLocalWorkload.targets +++ b/build-tools/create-packs/ConfigureLocalWorkload.targets @@ -48,11 +48,40 @@ - + + + + + + + + + + + + + + <_LocalSdkManifestsFolder>$(BuildOutputDirectory)lib\sdk-manifests\$(DotNetSdkManifestsFolder)\ <_LocalAndroidManifestFolder>$(_LocalSdkManifestsFolder)microsoft.net.sdk.android\$(AndroidPackVersionLong)\ + <_EmptyWorkloadDir>$(_LocalSdkManifestsFolder)android.deps.workload\0.0.1\ @@ -62,10 +91,38 @@ Targets="_GenerateXAWorkloadContent" /> + + + + + + + "microsoft-net-runtime-android" + <_EmptyWorkloadJsonContent> + + + + + + + + + + - CreateLocalFrameworkLists;CreateLocalRuntimeLists;InstallManifest;DeleteExtractedWorkloadPacks;PackLocalTemplates + CreateLocalFrameworkLists;CreateLocalRuntimeLists;InstallManifestAndDependencies;DeleteExtractedWorkloadPacks;PackLocalTemplates diff --git a/build-tools/scripts/DotNet.targets b/build-tools/scripts/DotNet.targets index b5ca7a80f10..e3774c9c48d 100644 --- a/build-tools/scripts/DotNet.targets +++ b/build-tools/scripts/DotNet.targets @@ -6,6 +6,7 @@ $(_Root)..\maui $(MauiSourcePath)\artifacts\packages\$(Configuration)\Shipping + maui-android @@ -117,6 +118,33 @@ + + + + + + + + + + + <_NuGetSources Condition=" '$(MauiUseLocalPacks)' == 'true' " Include="$(MauiPackagePath.TrimEnd('\'))" /> + <_InstallArguments Include="--skip-manifest-update" /> + <_InstallArguments Include="--skip-sign-check" /> + <_InstallArguments Include="--verbosity diag" /> + <_InstallArguments Include="--source "%(_NuGetSources.Identity)"" /> + <_InstallArguments Include="--temp-dir "$(_TempDirectory)"" /> + + diff --git a/build-tools/xaprepare/xaprepare/Application/KnownProperties.cs b/build-tools/xaprepare/xaprepare/Application/KnownProperties.cs index 877ae599e48..e80df2d8537 100644 --- a/build-tools/xaprepare/xaprepare/Application/KnownProperties.cs +++ b/build-tools/xaprepare/xaprepare/Application/KnownProperties.cs @@ -23,9 +23,11 @@ static class KnownProperties public const string DotNetPreviewPath = "DotNetPreviewPath"; public const string DotNetPreviewVersionBand = nameof (DotNetPreviewVersionBand); public const string DotNetSdkManifestsFolder = nameof (DotNetSdkManifestsFolder); + public const string DotNetMonoManifestVersionBand = nameof (DotNetMonoManifestVersionBand); public const string DotNetEmscriptenManifestVersionBand = nameof (DotNetEmscriptenManifestVersionBand); public const string MicrosoftDotnetSdkInternalPackageVersion = "MicrosoftDotnetSdkInternalPackageVersion"; public const string MicrosoftNETCoreAppRefPackageVersion = "MicrosoftNETCoreAppRefPackageVersion"; + public const string MicrosoftNETWorkloadMonoToolChainPackageVersion = "MicrosoftNETWorkloadMonoToolChainPackageVersion"; public const string MicrosoftNETWorkloadEmscriptenPackageVersion = "MicrosoftNETWorkloadEmscriptenPackageVersion"; public const string EmulatorVersion = "EmulatorVersion"; public const string EmulatorPkgRevision = "EmulatorPkgRevision"; diff --git a/build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in b/build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in index 800c79c6639..83ce47017ab 100644 --- a/build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in +++ b/build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in @@ -27,9 +27,11 @@ namespace Xamarin.Android.Prepare properties.Add (KnownProperties.DotNetPreviewPath, StripQuotes (@"@DotNetPreviewPath@")); properties.Add (KnownProperties.DotNetPreviewVersionBand, StripQuotes (@"@DotNetPreviewVersionBand@")); properties.Add (KnownProperties.DotNetSdkManifestsFolder, StripQuotes (@"@DotNetSdkManifestsFolder@")); + properties.Add (KnownProperties.DotNetMonoManifestVersionBand, StripQuotes (@"@DotNetMonoManifestVersionBand@")); properties.Add (KnownProperties.DotNetEmscriptenManifestVersionBand, StripQuotes (@"@DotNetEmscriptenManifestVersionBand@")); properties.Add (KnownProperties.MicrosoftDotnetSdkInternalPackageVersion, StripQuotes ("@MicrosoftDotnetSdkInternalPackageVersion@")); properties.Add (KnownProperties.MicrosoftNETCoreAppRefPackageVersion, StripQuotes ("@MicrosoftNETCoreAppRefPackageVersion@")); + properties.Add (KnownProperties.MicrosoftNETWorkloadMonoToolChainPackageVersion, StripQuotes ("@MicrosoftNETWorkloadMonoToolChainPackageVersion@")); properties.Add (KnownProperties.MicrosoftNETWorkloadEmscriptenPackageVersion, StripQuotes ("@MicrosoftNETWorkloadEmscriptenPackageVersion@")); properties.Add (KnownProperties.EmulatorVersion, StripQuotes ("@EmulatorVersion@")); properties.Add (KnownProperties.EmulatorPkgRevision, StripQuotes ("@EmulatorPkgRevision@")); diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs index b576b1b2c8d..b4d402c053c 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs @@ -178,6 +178,14 @@ public static partial class Paths public static string CoreClrAppRuntimeAndroidX86 => GetCachedPath (ref coreclrAppRuntimeAndroidX86, () => GetCoreClrAppRuntimePath (ctx, "x86")); public static string CoreClrAppRuntimeAndroidX86_64 => GetCachedPath (ref coreclrAppRuntimeAndroidX86_64, () => GetCoreClrAppRuntimePath (ctx, "x64")); + public static string MicrosoftNETWorkloadMonoPackageDir => Path.Combine ( + XAPackagesDir, + $"microsoft.net.workload.mono.toolchain.{{0}}.manifest-{ctx.Properties.GetRequiredValue (KnownProperties.DotNetMonoManifestVersionBand)}", + ctx.Properties.GetRequiredValue (KnownProperties.MicrosoftNETWorkloadMonoToolChainPackageVersion) + ); + + public static string MicrosoftNETWorkloadMonoToolChainDir => Path.Combine (MicrosoftNETWorkloadMonoPackageDir, "data"); + public static string MicrosoftNETWorkloadEmscriptenPackageDir => Path.Combine ( XAPackagesDir, $"microsoft.net.workload.emscripten.{{0}}.manifest-{ctx.Properties.GetRequiredValue (KnownProperties.DotNetEmscriptenManifestVersionBand)}", diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs b/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs index c294cf7d0c1..7d53a9b5330 100644 --- a/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs +++ b/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs @@ -33,6 +33,16 @@ protected override async Task Execute (Context context) AddToInventory (); + // Delete all relevant NuGet package install directories, as we could possibly be using a new runtime commit with a previously installed version (6.0.0) + var runtimeDirs = Directory.GetDirectories (Configurables.Paths.XAPackagesDir, "microsoft.netcore.app.runtime.mono.android*"); + var packageDirsToRemove = new List (runtimeDirs); + packageDirsToRemove.Add (Configurables.Paths.MicrosoftNETWorkloadMonoPackageDir); + foreach (var packageDir in packageDirsToRemove) { + if (Directory.Exists (packageDir)) { + Utilities.DeleteDirectory (packageDir); + } + } + // Install runtime packs associated with the SDK previously installed. var packageDownloadProj = Path.Combine (BuildPaths.XamarinAndroidSourceRoot, "build-tools", "xaprepare", "xaprepare", "package-download.proj"); var logPathBase = Path.Combine (Configurables.Paths.BuildBinDir, $"msbuild-{context.BuildTimeStamp}-download-runtime-packs"); @@ -72,6 +82,14 @@ protected override async Task Execute (Context context) var dotnets = new [] { "net6", "net7", "net8", "net9", "net10", "current" }; foreach (var dotnet in dotnets) { var destination = Path.Combine (sdk_manifests, + context.Properties.GetRequiredValue (KnownProperties.DotNetMonoManifestVersionBand), + $"microsoft.net.workload.mono.toolchain.{dotnet}", + context.Properties.GetRequiredValue (KnownProperties.MicrosoftNETWorkloadMonoToolChainPackageVersion)); + Utilities.DeleteDirectory (destination, recurse: true); + foreach (var file in Directory.GetFiles (string.Format (Configurables.Paths.MicrosoftNETWorkloadMonoToolChainDir, dotnet), "*")) { + Utilities.CopyFileToDir (file, destination); + } + destination = Path.Combine (sdk_manifests, context.Properties.GetRequiredValue (KnownProperties.DotNetEmscriptenManifestVersionBand), $"microsoft.net.workload.emscripten.{dotnet}", context.Properties.GetRequiredValue (KnownProperties.MicrosoftNETWorkloadEmscriptenPackageVersion)); diff --git a/build-tools/xaprepare/xaprepare/package-download.proj b/build-tools/xaprepare/xaprepare/package-download.proj index 82631da49eb..dcf3c42420d 100644 --- a/build-tools/xaprepare/xaprepare/package-download.proj +++ b/build-tools/xaprepare/xaprepare/package-download.proj @@ -16,8 +16,18 @@ Otherwise, $(MicrosoftNETCoreAppRefPackageVersion) from eng/Versions.props will + + + + + + + + + + diff --git a/build-tools/xaprepare/xaprepare/xaprepare.targets b/build-tools/xaprepare/xaprepare/xaprepare.targets index f3db8a8463e..50f9c290493 100644 --- a/build-tools/xaprepare/xaprepare/xaprepare.targets +++ b/build-tools/xaprepare/xaprepare/xaprepare.targets @@ -62,9 +62,11 @@ + + diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 85d48309f30..8ec8d8b6cdb 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -16,6 +16,10 @@ https://github.com/dotnet/dotnet 8d5d82abe13ac88cf5b2343e77460243b5272a6b + + https://github.com/dotnet/dotnet + 8d5d82abe13ac88cf5b2343e77460243b5272a6b + https://github.com/dotnet/dotnet 8d5d82abe13ac88cf5b2343e77460243b5272a6b diff --git a/eng/Versions.props b/eng/Versions.props index ce8dcf4f8f4..f5bce4643a9 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -9,7 +9,9 @@ 11.0.0-beta.26060.102 11.0.0-beta.26268.112 + 11.0.100-preview.6.26310.106 11.0.100-preview.6.26310.106 + $(MicrosoftNETWorkloadMonoToolchainCurrentManifest110100preview6PackageVersion) $(MicrosoftNETWorkloadEmscriptenCurrentManifest110100preview6PackageVersion) 11.0.100-preview.6.26310.106 0.11.5-preview.26310.106 @@ -26,6 +28,7 @@ \-(preview|rc|alpha).\d+ $(VersionBand)$([System.Text.RegularExpressions.Regex]::Match($(MicrosoftDotnetSdkInternalPackageVersion), $(VersionSuffixRegex))) $(DotNetPreviewVersionBand) + $(VersionBand)$([System.Text.RegularExpressions.Regex]::Match($(MicrosoftNETWorkloadMonoToolChainPackageVersion), $(VersionSuffixRegex))) $(VersionBand)$([System.Text.RegularExpressions.Regex]::Match($(MicrosoftNETWorkloadEmscriptenPackageVersion), $(VersionSuffixRegex))) $(DotNetPreviewVersionBand) From 8b2d263fda1c8bda351d93e20b6ffb349cc2c502 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Mon, 15 Jun 2026 20:03:03 +0200 Subject: [PATCH 06/10] Temporarily error when building with the Mono mobile runtime Surface the unsupported Mono mobile runtime build error directly in the workload to validate that no Mono mobile build paths remain in CI. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../targets/Microsoft.Android.Sdk.DefaultProperties.targets | 6 ++++++ 1 file changed, 6 insertions(+) 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 b7a35e2e08d..0d8f4616c73 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 @@ -1,5 +1,11 @@ + + + + System From 97993b43d78a63debf97024e3c8261cf555c28dd Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Mon, 15 Jun 2026 20:16:52 +0200 Subject: [PATCH 07/10] Drop validation SDK pin and feed Validation now happens through the temporary Mono mobile runtime build error in the workload, so the pinned SDK version and validation package feed are no longer needed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- NuGet.config | 1 - eng/Version.Details.xml | 33 +++++++++++++++++++-------------- eng/Versions.props | 18 +++++++++--------- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/NuGet.config b/NuGet.config index 09802b3955c..dec1baffe92 100644 --- a/NuGet.config +++ b/NuGet.config @@ -2,7 +2,6 @@ - diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 8ec8d8b6cdb..72e9aa98ae5 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -1,28 +1,33 @@ - + https://github.com/dotnet/dotnet - 8d5d82abe13ac88cf5b2343e77460243b5272a6b + c5d1f734662eb718e7431a4e679a29e47c380f04 - + https://github.com/dotnet/dotnet - 8d5d82abe13ac88cf5b2343e77460243b5272a6b + c5d1f734662eb718e7431a4e679a29e47c380f04 - + https://github.com/dotnet/dotnet - 8d5d82abe13ac88cf5b2343e77460243b5272a6b + c5d1f734662eb718e7431a4e679a29e47c380f04 - + https://github.com/dotnet/dotnet - 8d5d82abe13ac88cf5b2343e77460243b5272a6b + c5d1f734662eb718e7431a4e679a29e47c380f04 - + https://github.com/dotnet/dotnet - 8d5d82abe13ac88cf5b2343e77460243b5272a6b + ab01524bbb2ef1eea0ffaef161b3ef5686e8f256 - + https://github.com/dotnet/dotnet - 8d5d82abe13ac88cf5b2343e77460243b5272a6b + ab01524bbb2ef1eea0ffaef161b3ef5686e8f256 + + + + https://github.com/dotnet/runtime + 2b2a06c8a4d45ec0781266ffa3f3852a052f0fbb @@ -39,9 +44,9 @@ https://github.com/dotnet/dotnet c5d1f734662eb718e7431a4e679a29e47c380f04 - + https://github.com/dotnet/dotnet - 8d5d82abe13ac88cf5b2343e77460243b5272a6b + c5d1f734662eb718e7431a4e679a29e47c380f04 https://github.com/microsoft/testfx diff --git a/eng/Versions.props b/eng/Versions.props index f5bce4643a9..27a9e629150 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -1,20 +1,20 @@ - 11.0.100-preview.6.26310.106 + 11.0.100-preview.5.26268.112 $(MicrosoftNETSdkPackageVersion) - 11.0.0-preview.6.26310.106 - 11.0.0-preview.6.26310.106 + 11.0.0-preview.5.26268.112 + 11.0.0-preview.5.26268.112 7.0.0-beta.22103.1 11.0.0-beta.26060.102 11.0.0-beta.26268.112 - 11.0.100-preview.6.26310.106 - 11.0.100-preview.6.26310.106 - $(MicrosoftNETWorkloadMonoToolchainCurrentManifest110100preview6PackageVersion) - $(MicrosoftNETWorkloadEmscriptenCurrentManifest110100preview6PackageVersion) - 11.0.100-preview.6.26310.106 - 0.11.5-preview.26310.106 + 11.0.100-preview.4.26215.121 + 11.0.100-preview.4.26215.121 + $(MicrosoftNETWorkloadMonoToolChainCurrentManifest110100preview4PackageVersion) + $(MicrosoftNETWorkloadEmscriptenCurrentManifest110100preview4PackageVersion) + 11.0.100-preview.5.26268.112 + 0.11.5-preview.26268.112 4.3.0-preview.26314.12 10.0.9 11.0.0-preview.1.26104.118 From fbfabd9f5f58addd9db6d184c3b03b12af298146 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Tue, 16 Jun 2026 09:14:48 +0200 Subject: [PATCH 08/10] Skip Mono runtime test variants on .NET 11 and later Gate the MonoVM runtime parametrization in the build tests so the Mono variants are ignored on .NET 11 and later, where the Mono runtime is no longer supported for Android. CoreCLR and NativeAOT variants are unaffected. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Xamarin.Android.Build.Tests/Utilities/ProjectExtensions.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/ProjectExtensions.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/ProjectExtensions.cs index 41e701a39e2..fcaa4d86631 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/ProjectExtensions.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/ProjectExtensions.cs @@ -1,5 +1,7 @@ using System; +using NUnit.Framework; + using Xamarin.Android.Tasks; using Xamarin.ProjectTools; @@ -47,6 +49,7 @@ static void DoSetRuntime (XamarinProject project, AndroidRuntime runtime) project.SetProperty ("PublishAot", "true"); break; case AndroidRuntime.MonoVM: + Assert.Ignore ("The Mono runtime is not supported in .NET 11 and later. Use the .NET 10 SDK to build with the Mono runtime."); project.SetProperty ("UseMonoRuntime", "true"); break; From d115ab9cdb80fa182adec54240dbeb89d1d1bbb2 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Tue, 16 Jun 2026 09:42:40 +0200 Subject: [PATCH 09/10] Remove Mono runtime build tests for .NET 11 and later The Mono runtime is no longer supported for Android in .NET 11 and later. Remove the Mono runtime variants from the build tests: - Narrow the runtime parametrization ([Values], [TestCase], and the Enum.GetValues/TestCaseSource generators) to CoreCLR and NativeAOT. - Delete the Mono-only test methods and their now-unused TestCaseSource data generators. CoreCLR and NativeAOT coverage is unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Xamarin.Android.Build.Tests/AidlTest.cs | 6 +- .../AndroidDependenciesTests.cs | 8 +- .../AndroidGradleProjectTests.cs | 22 +- .../AndroidUpdateResourcesTest.cs | 64 ++-- .../Xamarin.Android.Build.Tests/AotTests.cs | 302 +----------------- .../AssetPackTests.cs | 10 +- .../BindingBuildTest.cs | 48 +-- .../BuildTest.TestCaseSource.cs | 151 --------- .../Xamarin.Android.Build.Tests/BuildTest.cs | 170 +++------- .../Xamarin.Android.Build.Tests/BuildTest2.cs | 144 +++------ .../Xamarin.Android.Build.Tests/BuildTest3.cs | 16 +- .../BuildWithLibraryTests.cs | 34 +- .../CodeBehindTests.cs | 30 +- .../DeferredBuildTest.cs | 4 +- .../EnvironmentContentTests.cs | 69 +--- .../IncrementalBuildTest.cs | 189 ++--------- .../InvalidConfigTests.cs | 34 -- .../ManifestTest.TestCaseSource.cs | 2 +- .../ManifestTest.cs | 103 ++---- .../MarshalMethodTests.cs | 148 --------- .../PackagingTest.cs | 126 ++------ .../SingleProjectTest.cs | 4 +- .../Tasks/AndroidResourceTests.cs | 2 +- .../Tasks/LinkerTests.cs | 20 +- .../Tasks/ManagedResourceParserTests.cs | 2 +- .../Tasks/NdkUtilTests.cs | 2 +- .../Tasks/ResolveMonoAndroidSdksTests.cs | 6 +- .../Utilities/ProjectExtensions.cs | 3 - .../Xamarin.Android.Build.Tests/WearTests.cs | 6 +- .../Xamarin.Android.Build.Tests/XASdkTests.cs | 8 +- 30 files changed, 313 insertions(+), 1420 deletions(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AidlTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AidlTest.cs index 44c3909df8b..f1984829d4e 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AidlTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AidlTest.cs @@ -26,7 +26,7 @@ void TestAidl (string testName, string aidl, AndroidRuntime runtime) } [Test] - public void ListAndMap ([Values] AndroidRuntime runtime) + public void ListAndMap ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: true)) { return; @@ -46,7 +46,7 @@ interface Test { } [Test] - public void NamespaceResolution ([Values] AndroidRuntime runtime) + public void NamespaceResolution ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: true)) { return; @@ -64,7 +64,7 @@ interface Test { } [Test] - public void PrimitiveTypes ([Values] AndroidRuntime runtime) + public void PrimitiveTypes ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: true)) { return; diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidDependenciesTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidDependenciesTests.cs index 38cd29612ac..baad82d7013 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidDependenciesTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidDependenciesTests.cs @@ -19,7 +19,7 @@ public class AndroidDependenciesTests : BaseTest { [Test] [NonParallelizable] // Do not run environment modifying tests in parallel. - public void InstallAndroidDependenciesTest ([Values ("GoogleV2", "Xamarin")] string manifestType, [Values] AndroidRuntime runtime) + public void InstallAndroidDependenciesTest ([Values ("GoogleV2", "Xamarin")] string manifestType, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -134,7 +134,7 @@ static IEnumerable Get_GetDependencyNdkRequiredConditionsData () { var ret = new List (); - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }) { AddTestData ("AotAssemblies", false, runtime); AddTestData ("AndroidEnableProfiledAot", false, runtime); AddTestData ("EnableLLVM", true, runtime); @@ -220,7 +220,7 @@ public void NativeAotRequiresNdk_WhenWorkloadLinkerDisabled () } [Test] - public void GetDependencyWhenBuildToolsAreMissingTest ([Values] AndroidRuntime runtime) + public void GetDependencyWhenBuildToolsAreMissingTest ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -260,7 +260,7 @@ public void GetDependencyWhenBuildToolsAreMissingTest ([Values] AndroidRuntime r } [Test] - public void GetDependencyWhenSDKIsMissingTest ([Values] bool createSdkDirectory, [Values] bool installJavaDeps, [Values] AndroidRuntime runtime) + public void GetDependencyWhenSDKIsMissingTest ([Values] bool createSdkDirectory, [Values] bool installJavaDeps, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidGradleProjectTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidGradleProjectTests.cs index 084b9f55ba6..9fa0060780b 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidGradleProjectTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidGradleProjectTests.cs @@ -41,7 +41,7 @@ public void GradleTestTearDown () } [Test] - public void BuildApp ([Values] AndroidRuntime runtime) + public void BuildApp ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -73,7 +73,7 @@ static IEnumerable Get_AGPMetadataTestSources () { var ret = new List (); - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }) { AddTestData ( bind: true, configuration: "Release", @@ -162,7 +162,7 @@ public void BindLibrary (bool bind, string configuration, bool refOutputs, Andro } [Test] - public void BindPackLibrary ([Values] bool packGradleRef, [Values] AndroidRuntime runtime) + public void BindPackLibrary ([Values] bool packGradleRef, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -208,7 +208,7 @@ public void BindPackLibrary ([Values] bool packGradleRef, [Values] AndroidRuntim } [Test] - public void BuildIncremental ([Values] AndroidRuntime runtime) + public void BuildIncremental ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -260,7 +260,7 @@ public void BuildIncremental ([Values] AndroidRuntime runtime) } [Test] - public void BuildCustomOutputPaths ([Values] AndroidRuntime runtime) + public void BuildCustomOutputPaths ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -294,7 +294,7 @@ public void BuildCustomOutputPaths ([Values] AndroidRuntime runtime) } [Test] - public void BuildArtifactsOutputPaths ([Values] AndroidRuntime runtime) + public void BuildArtifactsOutputPaths ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -344,7 +344,7 @@ public void BuildArtifactsOutputPaths ([Values] AndroidRuntime runtime) } [Test] - public void BuildMultipleModules ([Values] AndroidRuntime runtime) + public void BuildMultipleModules ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -387,7 +387,7 @@ public void BuildMultipleModules ([Values] AndroidRuntime runtime) } [Test] - public void BuildMultipleLibraries ([Values] AndroidRuntime runtime) + public void BuildMultipleLibraries ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -433,7 +433,7 @@ public void BuildMultipleLibraries ([Values] AndroidRuntime runtime) } [Test] - public void InvalidItemRefError ([Values] AndroidRuntime runtime) + public void InvalidItemRefError ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -457,7 +457,7 @@ public void InvalidItemRefError ([Values] AndroidRuntime runtime) } [Test] - public void InvalidModuleNameError ([Values] AndroidRuntime runtime) + public void InvalidModuleNameError ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -486,7 +486,7 @@ public void InvalidModuleNameError ([Values] AndroidRuntime runtime) } [Test] - public void BindFacebook ([Values] AndroidRuntime runtime) + public void BindFacebook ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidUpdateResourcesTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidUpdateResourcesTest.cs index 16b949b4be7..e206f1deb68 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidUpdateResourcesTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidUpdateResourcesTest.cs @@ -19,7 +19,7 @@ namespace Xamarin.Android.Build.Tests public class AndroidUpdateResourcesTest : BaseTest { [Test] - public void CheckMultipleLibraryProjectReferenceAlias ([Values] bool withGlobal, [Values] bool useDesignerAssembly, [Values] AndroidRuntime runtime) + public void CheckMultipleLibraryProjectReferenceAlias ([Values] bool withGlobal, [Values] bool useDesignerAssembly, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -76,7 +76,7 @@ public void CheckMultipleLibraryProjectReferenceAlias ([Values] bool withGlobal, } [Test] - public void BuildAppWithSystemNamespace ([Values] AndroidRuntime runtime) + public void BuildAppWithSystemNamespace ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -110,7 +110,7 @@ public void BuildAppWithSystemNamespace ([Values] AndroidRuntime runtime) } [Test] - public void DesignTimeBuild ([Values] bool isRelease, [Values] bool useManagedParser, [Values] AndroidRuntime runtime) + public void DesignTimeBuild ([Values] bool isRelease, [Values] bool useManagedParser, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -170,7 +170,7 @@ public void DesignTimeBuild ([Values] bool isRelease, [Values] bool useManagedPa } [Test] - public void CheckEmbeddedAndroidXResources ([Values] AndroidRuntime runtime) + public void CheckEmbeddedAndroidXResources ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -193,7 +193,7 @@ public void CheckEmbeddedAndroidXResources ([Values] AndroidRuntime runtime) } [Test] - public void MoveResource ([Values] AndroidRuntime runtime) + public void MoveResource ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -221,7 +221,7 @@ public void MoveResource ([Values] AndroidRuntime runtime) } [Test] - public void ReportAaptErrorsInOriginalFileName ([Values] AndroidRuntime runtime) + public void ReportAaptErrorsInOriginalFileName ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -245,7 +245,7 @@ public void ReportAaptErrorsInOriginalFileName ([Values] AndroidRuntime runtime) } [Test] - public void ReportAaptWarningsForBlankLevel ([Values] AndroidRuntime runtime) + public void ReportAaptWarningsForBlankLevel ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -271,7 +271,7 @@ public void ReportAaptWarningsForBlankLevel ([Values] AndroidRuntime runtime) } [Test] - public void RepetiviteBuildUpdateSingleResource ([Values] AndroidRuntime runtime) + public void RepetiviteBuildUpdateSingleResource ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -325,7 +325,7 @@ public void RepetiviteBuildUpdateSingleResource ([Values] AndroidRuntime runtime [Test] [Category ("XamarinBuildDownload")] [NonParallelizable] - public void Check9PatchFilesAreProcessed ([Values] AndroidRuntime runtime) + public void Check9PatchFilesAreProcessed ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -379,7 +379,7 @@ public void Check9PatchFilesAreProcessed ([Values] AndroidRuntime runtime) /// /// Based on https://bugzilla.xamarin.com/show_bug.cgi?id=29263 /// - public void CheckXmlResourcesFilesAreProcessed ([Values] AndroidRuntime runtime) + public void CheckXmlResourcesFilesAreProcessed ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -594,7 +594,7 @@ static IEnumerable Get_ReleaseLanguageData () { var ret = new List (); - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }) { AddTestData (isRelease: false, language: XamarinAndroidProjectLanguage.CSharp, runtime: runtime); AddTestData (isRelease: true, language: XamarinAndroidProjectLanguage.CSharp, runtime: runtime); AddTestData (isRelease: false, language: XamarinAndroidProjectLanguage.FSharp, runtime: runtime); @@ -685,7 +685,7 @@ public void CheckResourceDesignerIsUpdatedWhenReadOnly (bool isRelease, ProjectL } [Test] - public void CheckOldResourceDesignerIsNotUsed ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void CheckOldResourceDesignerIsNotUsed ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -715,7 +715,7 @@ public void CheckOldResourceDesignerIsNotUsed ([Values] bool isRelease, [Values] // ref https://bugzilla.xamarin.com/show_bug.cgi?id=30089 [Test] - public void CheckOldResourceDesignerWithWrongCasingIsRemoved ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void CheckOldResourceDesignerWithWrongCasingIsRemoved ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -745,7 +745,7 @@ public void CheckOldResourceDesignerWithWrongCasingIsRemoved ([Values] bool isRe } [Test] - public void GenerateResourceDesigner_false ([Values] bool useDesignerAssembly, [Values] AndroidRuntime runtime) + public void GenerateResourceDesigner_false ([Values] bool useDesignerAssembly, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -795,7 +795,7 @@ public void GenerateResourceDesigner_false ([Values] bool useDesignerAssembly, [ } [Test] - public void CheckThatXA1034IsRaisedForInvalidConfiguration ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void CheckThatXA1034IsRaisedForInvalidConfiguration ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -842,7 +842,7 @@ public static string GetFoo () { } [Test] - public void CheckAaptErrorRaisedForMissingResource ([Values] AndroidRuntime runtime) + public void CheckAaptErrorRaisedForMissingResource ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -876,7 +876,7 @@ public void CheckAaptErrorRaisedForMissingResource ([Values] AndroidRuntime runt } [Test] - public void CheckAaptErrorRaisedForInvalidDirectoryName ([Values] AndroidRuntime runtime) + public void CheckAaptErrorRaisedForInvalidDirectoryName ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -900,7 +900,7 @@ public void CheckAaptErrorRaisedForInvalidDirectoryName ([Values] AndroidRuntime } [Test] - public void CheckAaptErrorRaisedForInvalidFileName ([Values] AndroidRuntime runtime) + public void CheckAaptErrorRaisedForInvalidFileName ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -928,7 +928,7 @@ public void CheckAaptErrorRaisedForInvalidFileName ([Values] AndroidRuntime runt } [Test] - public void CheckAaptErrorNotRaisedForInvalidFileNameWithValidLogicalName ([Values] AndroidRuntime runtime) + public void CheckAaptErrorNotRaisedForInvalidFileNameWithValidLogicalName ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -958,7 +958,7 @@ public void CheckAaptErrorNotRaisedForInvalidFileNameWithValidLogicalName ([Valu } [Test] - public void CheckAaptErrorRaisedForDuplicateResourceinApp ([Values] AndroidRuntime runtime) + public void CheckAaptErrorRaisedForDuplicateResourceinApp ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -987,7 +987,7 @@ public void CheckAaptErrorRaisedForDuplicateResourceinApp ([Values] AndroidRunti } [Test] - public void CheckFilesAreRemoved ([Values] AndroidRuntime runtime) + public void CheckFilesAreRemoved ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1022,7 +1022,7 @@ public void CheckFilesAreRemoved ([Values] AndroidRuntime runtime) } [Test] - public void CheckDontUpdateResourceIfNotNeeded ([Values] bool useDesignerAssembly, [Values] AndroidRuntime runtime) + public void CheckDontUpdateResourceIfNotNeeded ([Values] bool useDesignerAssembly, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1137,7 +1137,7 @@ public string GetFoo () { } [Test] - public void BuildAppWithManagedResourceParser ([Values] AndroidRuntime runtime) + public void BuildAppWithManagedResourceParser ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1183,7 +1183,7 @@ public void BuildAppWithManagedResourceParser ([Values] AndroidRuntime runtime) [Test] [NonParallelizable] - public void BuildAppWithManagedResourceParserAndLibraries ([Values] AndroidRuntime runtime) + public void BuildAppWithManagedResourceParserAndLibraries ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1290,7 +1290,7 @@ public void BuildAppWithManagedResourceParserAndLibraries ([Values] AndroidRunti } [Test] - public void CheckMaxResWarningIsEmittedAsAWarning ([Values] AndroidRuntime runtime) + public void CheckMaxResWarningIsEmittedAsAWarning ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1318,7 +1318,7 @@ public void CheckMaxResWarningIsEmittedAsAWarning ([Values] AndroidRuntime runti } [Test] - public void CheckCodeBehindIsGenerated ([Values] AndroidRuntime runtime) + public void CheckCodeBehindIsGenerated ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1380,7 +1380,7 @@ protected override void OnCreate (Bundle bundle) } [Test] - public void CheckInvalidXmlInManagedResourceParser ([Values] AndroidRuntime runtime) + public void CheckInvalidXmlInManagedResourceParser ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1404,7 +1404,7 @@ public void CheckInvalidXmlInManagedResourceParser ([Values] AndroidRuntime runt //NOTE: This test was failing randomly before fixing a bug in `CopyIfChanged`. // Let's set it to run 3 times, it still completes in a reasonable time ~1.5 min. [Test, Repeat(3)] - public void LightlyModifyLayout ([Values] AndroidRuntime runtime) + public void LightlyModifyLayout ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1428,7 +1428,7 @@ public void LightlyModifyLayout ([Values] AndroidRuntime runtime) } [Test] - public void CustomViewAddResourceId ([Values] AndroidRuntime runtime) + public void CustomViewAddResourceId ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1466,7 +1466,7 @@ public void CustomViewAddResourceId ([Values] AndroidRuntime runtime) [Test] [Parallelizable (ParallelScope.Self)] - public void CheckNoVersionVectors ([Values] AndroidRuntime runtime) + public void CheckNoVersionVectors ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1493,7 +1493,7 @@ public void CheckNoVersionVectors ([Values] AndroidRuntime runtime) } [Test] - public void InvalidFilenames ([Values] AndroidRuntime runtime) + public void InvalidFilenames ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1520,7 +1520,7 @@ BuildItem CreateItem (string include) => } [Test] - public void SolutionBuildSeveralProjects ([Values] AndroidRuntime runtime) + public void SolutionBuildSeveralProjects ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AotTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AotTests.cs index 92ab6c1e846..05551929448 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AotTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AotTests.cs @@ -58,68 +58,11 @@ void AssertProfiledAotBuildMessages(ProjectBuilder b) StringAssertEx.ContainsRegex (@$"Method.*emitted at", b.LastBuildOutput, "Should contain verbose AOT compiler output", RegexOptions.IgnoreCase); } - [Test, Category ("ProfiledAOT")] - public void BuildBasicApplicationReleaseProfiledAot ([Values (true, false)] bool enableLLVM) - { - if (TestEnvironment.IsWindows && enableLLVM) { - Assert.Ignore("https://github.com/dotnet/runtime/issues/93788"); - } - - var proj = new XamarinAndroidApplicationProject () { - IsRelease = true, - AndroidEnableProfiledAot = true, - }; - // Mono-only test - proj.SetRuntime (AndroidRuntime.MonoVM); - proj.SetProperty ("EnableLLVM", enableLLVM.ToString ()); - proj.SetProperty (proj.ActiveConfigurationProperties, "AndroidExtraAotOptions", "--verbose"); - using var b = CreateApkBuilder (); - b.Verbosity = LoggerVerbosity.Detailed; - Assert.IsTrue (b.Build (proj), "Build should have succeeded."); - AssertProfiledAotBuildMessages (b); - } - - [Test, Category ("ProfiledAOT")] - public void BuildBasicApplicationReleaseWithCustomAotProfile () - { - var proj = new XamarinAndroidApplicationProject () { - IsRelease = true, - AndroidEnableProfiledAot = true, - }; - // A Mono-only test - proj.SetRuntime (AndroidRuntime.MonoVM); - proj.SetProperty (proj.ActiveConfigurationProperties, "AndroidExtraAotOptions", "--verbose"); - - byte [] custom_aot_profile = XamarinAndroidCommonProject.GetResourceContents ("Xamarin.ProjectTools.Resources.Base.custom.aotprofile"); - proj.OtherBuildItems.Add (new BuildItem ("AndroidAotProfile", "custom.aotprofile") { BinaryContent = () => custom_aot_profile }); - - using var b = CreateApkBuilder (); - b.Verbosity = LoggerVerbosity.Detailed; - Assert.IsTrue (b.Build (proj), "Build should have succeeded."); - AssertProfiledAotBuildMessages (b); - } - - [Test, Category ("ProfiledAOT")] - public void BuildBasicApplicationReleaseProfiledAotWithoutDefaultProfile () - { - var proj = new XamarinAndroidApplicationProject () { - IsRelease = true, - AndroidEnableProfiledAot = true, - }; - // Mono-only test - proj.SetRuntime (AndroidRuntime.MonoVM); - proj.SetProperty (proj.ActiveConfigurationProperties, "AndroidUseDefaultAotProfile", "false"); - using var b = CreateApkBuilder (); - b.Verbosity = LoggerVerbosity.Detailed; - Assert.IsTrue (b.Build (proj), "Build should have succeeded."); - StringAssertEx.DoesNotContainRegex (@$"Using profile data file.*dotnet\.aotprofile", b.LastBuildOutput, "Should not use default AOT profile", RegexOptions.IgnoreCase); - } - static IEnumerable Get_BuildAotApplicationWithSpecialCharactersInProjectData () { var ret = new List (); - foreach (AndroidRuntime runtime in new[] { AndroidRuntime.MonoVM, AndroidRuntime.CoreCLR }) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR }) { AddTestData ("テスト", false, false, runtime); AddTestData ("テスト", true, true, runtime); AddTestData ("テスト", true, false, runtime); @@ -165,139 +108,8 @@ public void BuildAotApplicationWithSpecialCharactersInProject (string testName, } } - static object [] AotChecks () => new object [] { - new object[] { - /* supportedAbis */ "arm64-v8a", - /* enableLLVM */ false, - /* usesAssemblyBlobs */ false, - }, - new object[] { - /* supportedAbis */ "armeabi-v7a;x86", - /* enableLLVM */ true, - /* usesAssemblyBlobs */ true, - }, - new object[] { - /* supportedAbis */ "armeabi-v7a;arm64-v8a;x86;x86_64", - /* enableLLVM */ false, - /* usesAssemblyBlobs */ true, - }, - new object[] { - /* supportedAbis */ "armeabi-v7a;arm64-v8a;x86;x86_64", - /* enableLLVM */ true, - /* usesAssemblyBlobs */ false, - }, - }; - - // TODO: possibly enable NativeAOT - [Test] - [TestCaseSource (nameof (AotChecks))] - public void BuildAotApplicationWithNdkAndBundleAndÜmläüts (string supportedAbis, bool enableLLVM, bool usesAssemblyBlobs) - { - if (IsWindows) - Assert.Ignore ("https://github.com/dotnet/runtime/issues/88625"); - - var abisSanitized = supportedAbis.Replace (";", "").Replace ("-", "").Replace ("_", ""); - var path = Path.Combine ("temp", string.Format ("BuildAotNdk AndÜmläüts_{0}_{1}_{2}", abisSanitized, enableLLVM, usesAssemblyBlobs)); - var proj = new XamarinAndroidApplicationProject () { - IsRelease = true, - AotAssemblies = true, - PackageName = "com.xamarin.buildaotappwithspecialchars", - }; - - // Mono-only test - proj.SetRuntime (AndroidRuntime.MonoVM); - proj.SetProperty ("AndroidNdkDirectory", AndroidNdkPath); - proj.SetRuntimeIdentifiers (supportedAbis.Split (';')); - proj.SetProperty ("EnableLLVM", enableLLVM.ToString ()); - proj.SetProperty ("AndroidUseAssemblyStore", usesAssemblyBlobs.ToString ()); - bool checkMinLlvmPath = enableLLVM && (supportedAbis == "armeabi-v7a" || supportedAbis == "x86"); - if (checkMinLlvmPath) { - // Set //uses-sdk/@android:minSdkVersion so that LLVM uses the right libc.so - proj.AndroidManifest = $@" - - - - -"; - } - using (var b = CreateApkBuilder (path)) { - b.ThrowOnBuildFailure = false; - Assert.IsTrue (b.Build (proj), "Build should have succeeded."); - foreach (var abi in supportedAbis.Split (new char [] { ';' })) { - var intermediate = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath); - var aotNativeLibrary = Path.Combine (intermediate, AbiUtils.AbiToRuntimeIdentifier (abi), "aot", "UnnamedProject.dll.so"); - FileAssert.Exists (aotNativeLibrary); - var apk = Path.Combine (Root, b.ProjectDirectory, - proj.OutputPath, $"{proj.PackageName}-Signed.apk"); - - var helper = new ArchiveAssemblyHelper (apk, usesAssemblyBlobs); - Assert.IsTrue (helper.Exists ($"assemblies/{abi}/UnnamedProject.dll"), $"{abi}/UnnamedProject.dll should be in {proj.PackageName}-Signed.apk"); - using (var zipFile = ZipHelper.OpenZip (apk)) { - Assert.IsNotNull (ZipHelper.ReadFileFromZip (zipFile, - string.Format ("lib/{0}/libaot-UnnamedProject.dll.so", abi)), - $"lib/{0}/libaot-UnnamedProject.dll.so should be in the {proj.PackageName}-Signed.apk", abi); - } - } - Assert.IsTrue (b.Build (proj), "Second Build should have succeeded."); - Assert.IsTrue ( - b.Output.IsTargetSkipped ("_CompileJava"), - "the _CompileJava target should be skipped"); - Assert.IsTrue ( - b.Output.IsTargetSkipped ("_BuildApkEmbed"), - "the _BuildApkEmbed target should be skipped"); - } - } - - [Test] - [TestCaseSource (nameof (AotChecks))] - public void BuildAotApplicationAndÜmläüts (string supportedAbis, bool enableLLVM, bool usesAssemblyBlobs) - { - if (IsWindows) - Assert.Ignore ("https://github.com/dotnet/runtime/issues/88625"); - - var abisSanitized = supportedAbis.Replace (";", "").Replace ("-", "").Replace ("_", ""); - var path = Path.Combine ("temp", string.Format ("BuildAot AndÜmläüts_{0}_{1}_{2}", abisSanitized, enableLLVM, usesAssemblyBlobs)); - var proj = new XamarinAndroidApplicationProject () { - IsRelease = true, - AotAssemblies = true, - PackageName = "com.xamarin.buildaotappandbundlewithspecialchars", - }; - - // Mono-only test - proj.SetRuntime (AndroidRuntime.MonoVM); - proj.SetRuntimeIdentifiers (supportedAbis.Split (';')); - proj.SetProperty ("EnableLLVM", enableLLVM.ToString ()); - proj.SetProperty ("AndroidUseAssemblyStore", usesAssemblyBlobs.ToString ()); - using (var b = CreateApkBuilder (path)) { - b.ThrowOnBuildFailure = false; - Assert.IsTrue (b.Build (proj), "Build should have succeeded."); - foreach (var abi in supportedAbis.Split (new char [] { ';' })) { - var intermediate = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath); - var aotNativeLibrary = Path.Combine (intermediate, AbiUtils.AbiToRuntimeIdentifier (abi), "aot", "UnnamedProject.dll.so"); - FileAssert.Exists (aotNativeLibrary); - var apk = Path.Combine (Root, b.ProjectDirectory, - proj.OutputPath, $"{proj.PackageName}-Signed.apk"); - - var helper = new ArchiveAssemblyHelper (apk, usesAssemblyBlobs); - Assert.IsTrue (helper.Exists ($"assemblies/{abi}/UnnamedProject.dll"), $"{abi}/UnnamedProject.dll should be in {proj.PackageName}-Signed.apk"); - using (var zipFile = ZipHelper.OpenZip (apk)) { - Assert.IsNotNull (ZipHelper.ReadFileFromZip (zipFile, - string.Format ("lib/{0}/libaot-UnnamedProject.dll.so", abi)), - $"lib/{0}/libaot-UnnamedProject.dll.so should be in the {proj.PackageName}-Signed.apk", abi); - } - } - Assert.IsTrue (b.Build (proj), "Second Build should have succeeded."); - Assert.IsTrue ( - b.Output.IsTargetSkipped ("_CompileJava"), - "the _CompileJava target should be skipped"); - Assert.IsTrue ( - b.Output.IsTargetSkipped ("_BuildApkEmbed"), - "the _BuildApkEmbed target should be skipped"); - } - } [Test] - [TestCase (AndroidRuntime.MonoVM)] [TestCase (AndroidRuntime.CoreCLR)] [NonParallelizable] [Category ("XamarinBuildDownload")] @@ -383,118 +195,6 @@ public static void Foo () { sb.Dispose (); } - [Test] - [Category ("LLVM")] - public void NoSymbolsArgShouldReduceAppSize ([Values (false, true)] bool skipDebugSymbols) - { - if (IsWindows) - Assert.Ignore ("https://github.com/dotnet/runtime/issues/88625"); - - var proj = new XamarinAndroidApplicationProject () { - IsRelease = true, - AotAssemblies = true, - }; - - // Mono-only test - proj.SetRuntime (AndroidRuntime.MonoVM); - - var supportedAbi = "arm64-v8a"; - proj.SetRuntimeIdentifiers (new[] { supportedAbi }); - proj.SetProperty ("EnableLLVM", true.ToString ()); - - var xaAssemblySize = 0; - var xaAssemblySizeNoSymbol = 0; - - using (var b = CreateApkBuilder ()) { - b.ThrowOnBuildFailure = false; - Assert.IsTrue (b.Build (proj), "First build should have succeeded."); - var apkPath = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath, $"{proj.PackageName}-Signed.apk"); - FileAssert.Exists (apkPath); - using (var apk = ZipHelper.OpenZip (apkPath)) { - xaAssemblySize = ZipHelper.ReadFileFromZip (apk, $"lib/{supportedAbi}/libaot-Mono.Android.dll.so").Length; - } - - string additionalArgs = "no-write-symbols"; - if (skipDebugSymbols) { - additionalArgs += ",nodebug"; - } - proj.SetProperty ("AndroidAotAdditionalArguments", additionalArgs); - Assert.IsTrue (b.Build (proj), "Second build should have succeeded."); - FileAssert.Exists (apkPath); - using (var apk = ZipHelper.OpenZip (apkPath)) { - xaAssemblySizeNoSymbol = ZipHelper.ReadFileFromZip (apk, $"lib/{supportedAbi}/libaot-Mono.Android.dll.so").Length; - } - Assert.IsTrue (xaAssemblySize > 0 && xaAssemblySizeNoSymbol > 0, $"Mono.Android.dll.so size was not updated after first or second build. Before: '{xaAssemblySize}' After: '{xaAssemblySizeNoSymbol}'."); - Assert.Less (xaAssemblySizeNoSymbol, xaAssemblySize, "Mono.Android.dll.so should have been smaller after 'no-write-symbols' build."); - } - } - - [Test] - [Category ("AOT")] - public void AotAssembliesInIDE () - { - string supportedAbis = "arm64-v8a"; - var proj = new XamarinAndroidApplicationProject () { - IsRelease = true, - AotAssemblies = true, - }; - // Mono-only test - proj.SetRuntime (AndroidRuntime.MonoVM); - proj.SetRuntimeIdentifiers (supportedAbis.Split (';')); - using var b = CreateApkBuilder (); - Assert.IsTrue (b.RunTarget (proj, target: "Build")); - - // .apk won't exist yet - var apk = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath, $"{proj.PackageName}-Signed.apk"); - FileAssert.DoesNotExist (apk); - - Assert.IsTrue (b.RunTarget (proj, target: "SignAndroidPackage")); - FileAssert.Exists (apk); - - using var zipFile = ZipHelper.OpenZip (apk); - foreach (var abi in supportedAbis.Split (';')) { - var path = $"lib/{abi}/libaot-Mono.Android.dll.so"; - var entry = ZipHelper.ReadFileFromZip (zipFile, path); - Assert.IsNotNull (entry, $"{path} should be in {apk}", abi); - } - } - - [Test] - public void CheckWhetherLibcAndLibmAreReferencedInAOTLibraries () - { - if (IsWindows) - Assert.Ignore ("https://github.com/dotnet/runtime/issues/88625"); - - var proj = new XamarinAndroidApplicationProject { - IsRelease = true, - EmbedAssembliesIntoApk = true, - AotAssemblies = true, - }; - // Mono-only test - proj.SetRuntime (AndroidRuntime.MonoVM); - proj.SetProperty ("EnableLLVM", "True"); - - var abis = new [] { "arm64-v8a", "x86_64" }; - proj.SetRuntimeIdentifiers (abis); - - var libPaths = new List (); - libPaths.Add (Path.Combine ("android-arm64", "aot", "Mono.Android.dll.so")); - libPaths.Add (Path.Combine ("android-x64", "aot", "Mono.Android.dll.so")); - - using (var b = CreateApkBuilder ()) { - Assert.IsTrue (b.Build (proj), "Build should have succeeded."); - string objPath = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath); - - foreach (string libPath in libPaths) { - string lib = Path.Combine (objPath, libPath); - - Assert.IsTrue (File.Exists (lib), $"Library {lib} should exist on disk"); - Assert.IsTrue (ELFHelper.ReferencesLibrary (lib, "libc.so"), $"Library {lib} should reference libc.so"); - Assert.IsTrue (ELFHelper.ReferencesLibrary (lib, "libm.so"), $"Library {lib} should reference libm.so"); - } - } - } - [Test] public void RunAOTCompilationWithCoreClrFailsBuild () { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AssetPackTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AssetPackTests.cs index 5b1a3831c71..c272847f290 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AssetPackTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AssetPackTests.cs @@ -14,7 +14,7 @@ public class AssetPackTests : BaseTest { [Test] [Category ("SmokeTests")] - public void BuildLibraryWithAssetPack ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void BuildLibraryWithAssetPack ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -41,7 +41,7 @@ public void BuildLibraryWithAssetPack ([Values] bool isRelease, [Values] Android [Test] [Category ("SmokeTests")] - public void BuildApplicationWithAssetPackThatHasInvalidName ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void BuildApplicationWithAssetPackThatHasInvalidName ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -69,7 +69,7 @@ public void BuildApplicationWithAssetPackThatHasInvalidName ([Values] bool isRel [Test] [Category ("SmokeTests")] - public void BuildApplicationWithAssetPackOutsideProjectDirectory ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void BuildApplicationWithAssetPackOutsideProjectDirectory ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -118,7 +118,7 @@ public void BuildApplicationWithAssetPackOutsideProjectDirectory ([Values] bool [Test] [Category ("SmokeTests")] - public void BuildApplicationWithAssetPackOverrides ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void BuildApplicationWithAssetPackOverrides ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -160,7 +160,7 @@ public void BuildApplicationWithAssetPackOverrides ([Values] bool isRelease, [Va [Test] [Category ("SmokeTests")] - public void BuildApplicationWithAssetPack ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void BuildApplicationWithAssetPack ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BindingBuildTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BindingBuildTest.cs index 3d4f5b6cad5..d1b598adf1e 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BindingBuildTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BindingBuildTest.cs @@ -18,7 +18,7 @@ namespace Xamarin.Android.Build.Tests public class BindingBuildTest : BaseTest { [Test] - public void DotNetBuildBinding ([Values] AndroidRuntime runtime) + public void DotNetBuildBinding ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -74,7 +74,7 @@ static IEnumerable Get_ClassParseOptions () { var ret = new List (); - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }) { AddTestData ("class-parse", runtime); } @@ -281,7 +281,7 @@ public void BuildLibraryZipBindingLibraryWithAarOfJar (string classParser, Andro [Test] [Category ("Minor")] - public void BindByteArrayInMethodParameter ([Values] AndroidRuntime runtime) + public void BindByteArrayInMethodParameter ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -301,7 +301,7 @@ public void BindByteArrayInMethodParameter ([Values] AndroidRuntime runtime) } [Test] - public void MergeAndroidManifest ([Values] AndroidRuntime runtime) + public void MergeAndroidManifest ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -337,7 +337,7 @@ public void MergeAndroidManifest ([Values] AndroidRuntime runtime) } [Test] - public void AnnotationSupport ([Values] AndroidRuntime runtime) + public void AnnotationSupport ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -360,7 +360,7 @@ public void AnnotationSupport ([Values] AndroidRuntime runtime) } [Test] - public void BindingCustomJavaApplicationClass ([Values] AndroidRuntime runtime) + public void BindingCustomJavaApplicationClass ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -390,7 +390,7 @@ public void BindingCustomJavaApplicationClass ([Values] AndroidRuntime runtime) } [Test] - public void BindngFilterUnsupportedNativeAbiLibraries ([Values] AndroidRuntime runtime) + public void BindngFilterUnsupportedNativeAbiLibraries ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -421,7 +421,7 @@ public void BindngFilterUnsupportedNativeAbiLibraries ([Values] AndroidRuntime r } [Test] - public void BindingCheckHiddenFiles ([Values] AndroidRuntime runtime) + public void BindingCheckHiddenFiles ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -475,7 +475,7 @@ public void BindingCheckHiddenFiles ([Values] AndroidRuntime runtime) } [Test] - public void BindingDoNotPackage ([Values] AndroidRuntime runtime) + public void BindingDoNotPackage ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -534,7 +534,7 @@ public void OnUpdate (Java.Lang.Object p0) } [Test] - public void AndroidLibraryPackFalseExcludesJarFromAar ([Values] AndroidRuntime runtime) + public void AndroidLibraryPackFalseExcludesJarFromAar ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -576,7 +576,7 @@ public void AndroidLibraryPackFalseExcludesJarFromAar ([Values] AndroidRuntime r } [Test] - public void RemoveEventHandlerResolution ([Values] AndroidRuntime runtime) + public void RemoveEventHandlerResolution ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -605,7 +605,7 @@ public void RemoveEventHandlerResolution ([Values] AndroidRuntime runtime) } [Test] - public void JavaSourceJar ([Values] AndroidRuntime runtime) + public void JavaSourceJar ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -644,7 +644,7 @@ public void JavaSourceJar ([Values] AndroidRuntime runtime) } [Test] - public void AppWithSingleJar ([Values] AndroidRuntime runtime) + public void AppWithSingleJar ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -686,7 +686,7 @@ public void AppWithSingleJar ([Values] AndroidRuntime runtime) [Test] [TestCaseSource (nameof (Get_ClassParseOptions))] - public void DesignTimeBuild (string classParser, [Values] AndroidRuntime runtime) + public void DesignTimeBuild (string classParser, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -718,7 +718,7 @@ public void DesignTimeBuild (string classParser, [Values] AndroidRuntime runtime [Test] [TestCaseSource (nameof (Get_ClassParseOptions))] - public void NullableReferenceTypes (string classParser, [Values] AndroidRuntime runtime) + public void NullableReferenceTypes (string classParser, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -747,7 +747,7 @@ public void NullableReferenceTypes (string classParser, [Values] AndroidRuntime [Test] [TestCaseSource (nameof (Get_ClassParseOptions))] - public void BindDefaultInterfaceMethods (string classParser, [Values] AndroidRuntime runtime) + public void BindDefaultInterfaceMethods (string classParser, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -809,7 +809,7 @@ public void BindDefaultInterfaceMethods (string classParser, [Values] AndroidRun [Test] [TestCaseSource (nameof (Get_ClassParseOptions))] - public void NothingToBind (string classParser, [Values] AndroidRuntime runtime) + public void NothingToBind (string classParser, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -827,7 +827,7 @@ public void NothingToBind (string classParser, [Values] AndroidRuntime runtime) } [Test] - public void BindingWithAndroidJavaSource ([Values] AndroidRuntime runtime) + public void BindingWithAndroidJavaSource ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -907,7 +907,7 @@ public void BindingWithAndroidJavaSource ([Values] AndroidRuntime runtime) } [Test] - public void LibraryProjectZipWithLint ([Values] AndroidRuntime runtime) + public void LibraryProjectZipWithLint ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -949,7 +949,7 @@ public void LibraryProjectZipWithLint ([Values] AndroidRuntime runtime) /// Tests two .aar files with r-classes.jar, repackaged.jar /// [Test] - public void CheckDuplicateJavaLibraries ([Values] AndroidRuntime runtime) + public void CheckDuplicateJavaLibraries ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1012,7 +1012,7 @@ public void CheckDuplicateJavaLibraries ([Values] AndroidRuntime runtime) [Test] [NonParallelizable] // All tests are accessing the same .pom file - public void AndroidMavenLibrary ([Values] AndroidRuntime runtime) + public void AndroidMavenLibrary ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1038,7 +1038,7 @@ public void AndroidMavenLibrary ([Values] AndroidRuntime runtime) } [Test] - public void AndroidMavenLibrary_FailsDueToUnverifiedDependency ([Values] AndroidRuntime runtime) + public void AndroidMavenLibrary_FailsDueToUnverifiedDependency ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1067,7 +1067,7 @@ public void AndroidMavenLibrary_FailsDueToUnverifiedDependency ([Values] Android } [Test] - public void AndroidMavenLibrary_IgnoreDependencyVerification ([Values] AndroidRuntime runtime) + public void AndroidMavenLibrary_IgnoreDependencyVerification ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1094,7 +1094,7 @@ public void AndroidMavenLibrary_IgnoreDependencyVerification ([Values] AndroidRu } [Test] - public void AndroidMavenLibrary_AllDependenciesAreVerified ([Values] AndroidRuntime runtime) + public void AndroidMavenLibrary_AllDependenciesAreVerified ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.TestCaseSource.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.TestCaseSource.cs index 4aff396a95b..468f5480140 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.TestCaseSource.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.TestCaseSource.cs @@ -13,118 +13,6 @@ namespace Xamarin.Android.Build.Tests public partial class BuildTest : BaseTest { static readonly object [] DotNetBuildSource = new object [] { - new object [] { - /* runtimeIdentifiers */ "android-arm", - /* isRelease */ false, - /* aot */ false, - /* usesAssemblyStore */ false, - /* runtime */ AndroidRuntime.MonoVM, - }, - new object [] { - /* runtimeIdentifiers */ "android-arm", - /* isRelease */ false, - /* aot */ false, - /* usesAssemblyStore */ true, - /* runtime */ AndroidRuntime.MonoVM, - }, - new object [] { - /* runtimeIdentifiers */ "android-arm64", - /* isRelease */ false, - /* aot */ false, - /* usesAssemblyStore */ false, - /* runtime */ AndroidRuntime.MonoVM, - }, - new object [] { - /* runtimeIdentifiers */ "android-x86", - /* isRelease */ false, - /* aot */ false, - /* usesAssemblyStore */ false, - /* runtime */ AndroidRuntime.MonoVM, - }, - new object [] { - /* runtimeIdentifiers */ "android-x64", - /* isRelease */ false, - /* aot */ false, - /* usesAssemblyStore */ false, - /* runtime */ AndroidRuntime.MonoVM, - }, - new object [] { - /* runtimeIdentifiers */ "android-arm", - /* isRelease */ true, - /* aot */ false, - /* usesAssemblyStore */ false, - /* runtime */ AndroidRuntime.MonoVM, - }, - new object [] { - /* runtimeIdentifiers */ "android-arm", - /* isRelease */ true, - /* aot */ false, - /* usesAssemblyStore */ true, - /* runtime */ AndroidRuntime.MonoVM, - }, - new object [] { - /* runtimeIdentifiers */ "android-arm", - /* isRelease */ true, - /* aot */ true, - /* usesAssemblyStore */ false, - /* runtime */ AndroidRuntime.MonoVM, - }, - new object [] { - /* runtimeIdentifiers */ "android-arm", - /* isRelease */ true, - /* aot */ true, - /* usesAssemblyStore */ true, - /* runtime */ AndroidRuntime.MonoVM, - }, - new object [] { - /* runtimeIdentifiers */ "android-arm64", - /* isRelease */ true, - /* aot */ false, - /* usesAssemblyStore */ false, - /* runtime */ AndroidRuntime.MonoVM, - }, - new object [] { - /* runtimeIdentifiers */ "android-arm;android-arm64;android-x86;android-x64", - /* isRelease */ false, - /* aot */ false, - /* usesAssemblyStore */ false, - /* runtime */ AndroidRuntime.MonoVM, - }, - new object [] { - /* runtimeIdentifiers */ "android-arm;android-arm64;android-x86;android-x64", - /* isRelease */ false, - /* aot */ false, - /* usesAssemblyStore */ true, - /* runtime */ AndroidRuntime.MonoVM, - }, - new object [] { - /* runtimeIdentifiers */ "android-arm;android-arm64;android-x86", - /* isRelease */ true, - /* aot */ false, - /* usesAssemblyStore */ false, - /* runtime */ AndroidRuntime.MonoVM, - }, - new object [] { - /* runtimeIdentifiers */ "android-arm;android-arm64;android-x86;android-x64", - /* isRelease */ true, - /* aot */ false, - /* usesAssemblyStore */ false, - /* runtime */ AndroidRuntime.MonoVM, - }, - new object [] { - /* runtimeIdentifiers */ "android-arm;android-arm64;android-x86;android-x64", - /* isRelease */ true, - /* aot */ false, - /* usesAssemblyStore */ true, - /* runtime */ AndroidRuntime.MonoVM, - }, - new object [] { - /* runtimeIdentifiers */ "android-arm;android-arm64;android-x86;android-x64", - /* isRelease */ true, - /* aot */ true, - /* usesAssemblyStore */ false, - /* runtime */ AndroidRuntime.MonoVM, - }, new object [] { /* runtimeIdentifiers */ "android-arm64", /* isRelease */ true, @@ -148,44 +36,5 @@ public partial class BuildTest : BaseTest }, }; -#pragma warning disable 414 - static object [] RuntimeChecks () => new object [] { - new object[] { - /* supportedAbi */ "armeabi-v7a", - /* debugSymbols */ true , - /* optimize */ true , - /* embedassebmlies */ true , - /* expectedResult */ "release", - }, - new object[] { - /* supportedAbi */ "armeabi-v7a", - /* debugSymbols */ true , - /* optimize */ true , - /* embedassebmlies */ false , - /* expectedResult */ "debug", - }, - new object[] { - /* supportedAbi */ "armeabi-v7a", - /* debugSymbols */ true , - /* optimize */ false , - /* embedassebmlies */ true , - /* expectedResult */ "debug", - }, - new object[] { - /* supportedAbi */ "armeabi-v7a", - /* debugSymbols */ true , - /* optimize */ false , - /* embedassebmlies */ false , - /* expectedResult */ "debug", - }, - new object[] { - /* supportedAbi */ "armeabi-v7a", - /* debugSymbols */ false , - /* optimize */ null , - /* embedassebmlies */ null , - /* expectedResult */ "debug", - }, - }; -#pragma warning restore 414 } } diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs index e78b7a7eaa2..0bce8de3328 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs @@ -210,69 +210,12 @@ public void DotNetBuild (string runtimeIdentifiers, bool isRelease, bool aot, bo } } - static object [] MonoComponentMaskChecks () => new object [] { - new object[] { - true, // enableProfiler - true, // useInterpreter - true, // debugBuild - 0x07U, // expectedMask - }, - - new object[] { - true, // enableProfiler - false, // useInterpreter - true, // debugBuild - 0x05U, // expectedMask - }, - - new object[] { - false, // enableProfiler - false, // useInterpreter - true, // debugBuild - 0x01U, // expectedMask - }, - - new object[] { - true, // enableProfiler - false, // useInterpreter - false, // debugBuild - 0x04U, // expectedMask - }, - }; - - [Test] - [TestCaseSource (nameof (MonoComponentMaskChecks))] - public void CheckMonoComponentsMask (bool enableProfiler, bool useInterpreter, bool debugBuild, uint expectedMask) - { - var proj = new XamarinAndroidApplicationProject () { - IsRelease = !debugBuild, - }; - - // Mono-only test - proj.SetRuntime (AndroidRuntime.MonoVM); - proj.SetProperty (proj.ActiveConfigurationProperties, "AndroidEnableProfiler", enableProfiler.ToString ()); - proj.SetProperty (proj.ActiveConfigurationProperties, "UseInterpreter", useInterpreter.ToString ()); - - var abis = new [] { "armeabi-v7a", "x86" }; - proj.SetRuntimeIdentifiers (abis); - - using (var b = CreateApkBuilder ()) { - Assert.IsTrue (b.Build (proj), "Build should have succeeded."); - b.AssertHasNoWarnings (); - string objPath = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath); - - List envFiles = EnvironmentHelper.GatherEnvironmentFiles (objPath, String.Join (";", abis), true); - var app_config = (EnvironmentHelper.ApplicationConfig_MonoVM)EnvironmentHelper.ReadApplicationConfig (envFiles, AndroidRuntime.MonoVM); - Assert.That (app_config, Is.Not.Null, "application_config must be present in the environment files"); - Assert.IsTrue (app_config.mono_components_mask == expectedMask, "Expected Mono Components mask 0x{expectedMask:x}, got 0x{app_config.mono_components_mask:x}"); - } - } [Test] [NonParallelizable] public void CheckAssemblyCounts ([Values (true, false)] bool isRelease, [Values (true, false)] bool aot, - [Values (AndroidRuntime.MonoVM, AndroidRuntime.CoreCLR)] AndroidRuntime runtime) + [Values (AndroidRuntime.CoreCLR)] AndroidRuntime runtime) { if (isRelease == false && aot == true) { Assert.Ignore ("Not testing AOT with Debug builds"); @@ -328,7 +271,7 @@ public void CheckAssemblyCounts ([Values (true, false)] bool isRelease, [Values // DotNet fails, see https://github.com/dotnet/runtime/issues/65484 // Enable the commented out signature (and AOT) once the above is fixed [Test] - public void SmokeTestBuildWithSpecialCharacters ([Values (false, true)] bool forms, [Values (false, true)] bool aot, [Values] AndroidRuntime runtime) + public void SmokeTestBuildWithSpecialCharacters ([Values (false, true)] bool forms, [Values (false, true)] bool aot, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, aot: aot, release: true)) { return; @@ -365,38 +308,7 @@ public static string GetLinkedPath (ProjectBuilder builder, bool isRelease, stri } [Test] - [TestCaseSource (nameof (RuntimeChecks))] - public void CheckWhichRuntimeIsIncluded (string supportedAbi, bool debugSymbols, bool? optimize, bool? embedAssemblies, string expectedRuntime) { - var proj = new XamarinAndroidApplicationProject (); - // MonoVM-only test - proj.SetRuntime (Android.Tasks.AndroidRuntime.MonoVM); - proj.SetRuntimeIdentifiers (new[] { supportedAbi }); - proj.SetProperty (proj.ActiveConfigurationProperties, "DebugSymbols", debugSymbols); - if (optimize.HasValue) - proj.SetProperty (proj.ActiveConfigurationProperties, "Optimize", optimize.Value); - else - proj.RemoveProperty (proj.ActiveConfigurationProperties, "Optimize"); - if (embedAssemblies.HasValue) - proj.SetProperty (proj.ActiveConfigurationProperties, KnownProperties.EmbedAssembliesIntoApk, embedAssemblies.Value); - else - proj.RemoveProperty (proj.ActiveConfigurationProperties, KnownProperties.EmbedAssembliesIntoApk); - using (var b = CreateApkBuilder ()) { - var runtimeInfo = b.GetSupportedRuntimes (); - Assert.IsTrue (b.Build (proj), "Build should have succeeded."); - var apkPath = Path.Combine (Root, b.ProjectDirectory, - proj.OutputPath, $"{proj.PackageName}-Signed.apk"); - using (var apk = ZipHelper.OpenZip (apkPath)) { - var runtime = runtimeInfo.FirstOrDefault (x => x.Abi == supportedAbi && x.Runtime == expectedRuntime); - Assert.IsNotNull (runtime, "Could not find the expected runtime."); - var inApk = ZipHelper.ReadFileFromZip (apk, $"lib/{supportedAbi}/{runtime.Name}"); - var inApkRuntime = runtimeInfo.FirstOrDefault (x => x.Abi == supportedAbi && x.Size == inApk.Length); - Assert.IsNotNull (inApkRuntime, "Could not find the actual runtime used."); - } - } - } - - [Test] - public void CheckItemMetadata ([Values (true, false)] bool isRelease, [Values] AndroidRuntime runtime) + public void CheckItemMetadata ([Values (true, false)] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -440,7 +352,7 @@ public void CheckItemMetadata ([Values (true, false)] bool isRelease, [Values] A // Context https://bugzilla.xamarin.com/show_bug.cgi?id=29706 [Test] - public void CheckLogicalNamePathSeperators ([Values (false, true)] bool isRelease, [Values (false, true)] bool useDesignerAssembly, [Values] AndroidRuntime runtime) + public void CheckLogicalNamePathSeperators ([Values (false, true)] bool isRelease, [Values (false, true)] bool useDesignerAssembly, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -491,7 +403,7 @@ public void CheckLogicalNamePathSeperators ([Values (false, true)] bool isReleas } [Test] - public void ApplicationJavaClassProperties ([Values] AndroidRuntime runtime) + public void ApplicationJavaClassProperties ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime)) { return; @@ -508,7 +420,7 @@ public void ApplicationJavaClassProperties ([Values] AndroidRuntime runtime) } [Test] - public void ApplicationIdPlaceholder ([Values] AndroidRuntime runtime) + public void ApplicationIdPlaceholder ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime)) { return; @@ -528,7 +440,7 @@ public void ApplicationIdPlaceholder ([Values] AndroidRuntime runtime) } [Test] - public void AarContentExtraction ([Values] AndroidRuntime runtime) + public void AarContentExtraction ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -724,7 +636,7 @@ public interface OnFooListener [Test] [Category ("AOT")] [NonParallelizable] - public void BuildApplicationWithSpacesInPath ([Values (true, false)] bool enableMultiDex, [Values ("", "r8")] string linkTool, [Values] AndroidRuntime runtime) + public void BuildApplicationWithSpacesInPath ([Values (true, false)] bool enableMultiDex, [Values ("", "r8")] string linkTool, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; bool aotAssemblies = runtime == AndroidRuntime.MonoVM; @@ -793,7 +705,7 @@ public void BuildApplicationWithSpacesInPath ([Values (true, false)] bool enable //This test validates the _CleanIntermediateIfNeeded target [Test] [NonParallelizable] - public void BuildAfterUpgradingNuget ([Values] AndroidRuntime runtime) + public void BuildAfterUpgradingNuget ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1022,7 +934,7 @@ public void InvalidTargetPlatformVersion ([Values ("android33", "android99.0")] } [Test] - public void XA4212 ([Values] AndroidRuntime runtime) + public void XA4212 ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1059,7 +971,7 @@ public void Dispose () } [Test] - public void Desugar ([Values (true, false)] bool isRelease, [Values ("", "r8")] string linkTool, [Values] AndroidRuntime runtime) + public void Desugar ([Values (true, false)] bool isRelease, [Values ("", "r8")] string linkTool, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -1172,7 +1084,7 @@ public void foo() //See: https://developer.android.com/about/versions/marshmallow/android-6.0-changes#behavior-apache-http-client [Test] - public void MissingOrgApacheHttpClient ([Values] AndroidRuntime runtime) + public void MissingOrgApacheHttpClient ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1199,7 +1111,7 @@ public void MissingOrgApacheHttpClient ([Values] AndroidRuntime runtime) //NOTE: tests type forwarders in Mono.Android.dll to System.Drawing.Common.dll [Test] - public void SystemDrawingCommon ([Values] AndroidRuntime runtime) + public void SystemDrawingCommon ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1225,7 +1137,7 @@ public void SystemDrawingCommon ([Values] AndroidRuntime runtime) //NOTE: Referencing only Microsoft.Extensions.Http, surfaced a bug in [Test] - public void MicrosoftExtensionsHttp ([Values] AndroidRuntime runtime) + public void MicrosoftExtensionsHttp ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1260,7 +1172,7 @@ public void MicrosoftExtensionsHttp ([Values] AndroidRuntime runtime) } [Test] - public void FastDeploymentDoesNotAddContentProvider ([Values (AndroidRuntime.MonoVM, AndroidRuntime.CoreCLR)] AndroidRuntime runtime) + public void FastDeploymentDoesNotAddContentProvider ([Values (AndroidRuntime.CoreCLR)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime)) { return; @@ -1285,7 +1197,7 @@ public void FastDeploymentDoesNotAddContentProvider ([Values (AndroidRuntime.Mon } [Test] - public void BuildOutsideVisualStudio ([Values] AndroidRuntime runtime) + public void BuildOutsideVisualStudio ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1328,7 +1240,7 @@ public void BuildOutsideVisualStudio ([Values] AndroidRuntime runtime) } [Test] - public void RemoveOldMonoPackageManager ([Values (AndroidRuntime.MonoVM, AndroidRuntime.CoreCLR)] AndroidRuntime runtime) + public void RemoveOldMonoPackageManager ([Values (AndroidRuntime.CoreCLR)] AndroidRuntime runtime) { // TODO: fix the test for NativeAOT. It currently fails on the assertion that MonoPackageManager_Resources.java exists bool isRelease = false; //runtime == AndroidRuntime.NativeAOT; @@ -1377,7 +1289,7 @@ public class ApplicationRegistration { }"); } [Test] - public void CompilerErrorShouldNotRunLinkAssemblies ([Values] AndroidRuntime runtime) + public void CompilerErrorShouldNotRunLinkAssemblies ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1402,7 +1314,7 @@ public void CompilerErrorShouldNotRunLinkAssemblies ([Values] AndroidRuntime run /// This assembly weirdly has no [assembly: System.Runtime.Versioning.TargetFrameworkAttribute()], at all... /// [Test] - public void AssemblyWithMissingTargetFramework ([Values (AndroidRuntime.MonoVM, AndroidRuntime.CoreCLR)] AndroidRuntime runtime) + public void AssemblyWithMissingTargetFramework ([Values (AndroidRuntime.CoreCLR)] AndroidRuntime runtime) { // TODO: fix the test for NativeAOT. It currently fails on the assertion that CircleImageView.java exists bool isRelease = false; // runtime == AndroidRuntime.NativeAOT; @@ -1437,7 +1349,7 @@ public void AssemblyWithMissingTargetFramework ([Values (AndroidRuntime.MonoVM, } [Test] - public void WorkManager ([Values] AndroidRuntime runtime) + public void WorkManager ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1470,7 +1382,7 @@ public MyWorker (Context c, WorkerParameters p) : base (c, p) { } } [Test] - public void NuGetizer3000 ([Values] AndroidRuntime runtime) + public void NuGetizer3000 ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1489,7 +1401,7 @@ public void NuGetizer3000 ([Values] AndroidRuntime runtime) } [Test] - public void NetworkSecurityConfig ([Values] AndroidRuntime runtime) + public void NetworkSecurityConfig ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1540,7 +1452,7 @@ public CustomApp(IntPtr handle, JniHandleOwnership ownerShip) : base(handle, own } [Test] - public void AbiNameInIntermediateOutputPath ([Values] AndroidRuntime runtime) + public void AbiNameInIntermediateOutputPath ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1566,7 +1478,7 @@ static IEnumerable Get_EnvironmentVariablesData () { var ret = new List (); - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }) { AddTestData (true, "LowercaseMD5", "", runtime); AddTestData (true, "LowercaseCrc64", "", runtime); AddTestData (false, "", "127.0.0.1:9000,suspend,connect", runtime); @@ -1635,7 +1547,7 @@ public void EnvironmentVariables (bool useInterpreter, string packageNamingPolic } [Test] - public void KotlinServiceLoader ([Values ("apk", "aab")] string packageFormat, [Values] AndroidRuntime runtime) + public void KotlinServiceLoader ([Values ("apk", "aab")] string packageFormat, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1677,7 +1589,7 @@ public void KotlinServiceLoader ([Values ("apk", "aab")] string packageFormat, [ } [Test] - public void XA1018 ([Values] AndroidRuntime runtime) + public void XA1018 ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1701,7 +1613,7 @@ public void XA1018 ([Values] AndroidRuntime runtime) } [Test] - public void XA4313 ([Values ("OpenTK-1.0", "Xamarin.Android.NUnitLite")] string reference, [Values] AndroidRuntime runtime) + public void XA4313 ([Values ("OpenTK-1.0", "Xamarin.Android.NUnitLite")] string reference, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1726,7 +1638,7 @@ public void XA4313 ([Values ("OpenTK-1.0", "Xamarin.Android.NUnitLite")] string } [Test] - public void OpenTKNugetWorks ([Values] AndroidRuntime runtime) + public void OpenTKNugetWorks ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1745,7 +1657,7 @@ public void OpenTKNugetWorks ([Values] AndroidRuntime runtime) } [Test] - public void NUnitLiteNugetWorks ([Values] AndroidRuntime runtime) + public void NUnitLiteNugetWorks ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1767,7 +1679,7 @@ static IEnumerable Get_XA1027XA1028Data () { var ret = new List (); - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }) { AddTestData ( linkTool: "r8", enableProguard: null, @@ -1858,7 +1770,7 @@ public void XA1027XA1028 (string linkTool, string enableProguard, string android } [Test] - public void XA4310 ([Values ("apk", "aab")] string packageFormat, [Values] AndroidRuntime runtime) + public void XA4310 ([Values ("apk", "aab")] string packageFormat, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1901,7 +1813,7 @@ public void XA4310 ([Values ("apk", "aab")] string packageFormat, [Values] Andro [Test] [NonParallelizable] - public void CheckLintErrorsAndWarnings ([Values] AndroidRuntime runtime) + public void CheckLintErrorsAndWarnings ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { string disabledIssues = "StaticFieldLeak,ObsoleteSdkInt,AllowBackup,ExportedReceiver,RedundantLabel,AppLinkWarning"; @@ -1957,7 +1869,7 @@ public class MainActivity : Activity } [Test] - public void CheckLintConfigMerging ([Values] AndroidRuntime runtime) + public void CheckLintConfigMerging ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -2000,7 +1912,7 @@ public void CheckLintConfigMerging ([Values] AndroidRuntime runtime) } [Test] - public void BuildApplicationWithJavaSourceUsingAndroidX ([Values(true, false)] bool isRelease, [Values] AndroidRuntime runtime) + public void BuildApplicationWithJavaSourceUsingAndroidX ([Values(true, false)] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -2034,7 +1946,7 @@ public static Toolbar GetToolbar (Context context) { } [Test] - public void BuildApplicationCheckThatAddStaticResourcesTargetDoesNotRerun ([Values] AndroidRuntime runtime) + public void BuildApplicationCheckThatAddStaticResourcesTargetDoesNotRerun ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -2059,7 +1971,7 @@ public void BuildApplicationCheckThatAddStaticResourcesTargetDoesNotRerun ([Valu } [Test] - public void CheckJavaError ([Values] AndroidRuntime runtime) + public void CheckJavaError ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -2097,7 +2009,7 @@ public void CheckJavaError ([Values] AndroidRuntime runtime) /// Based on issue raised in /// https://bugzilla.xamarin.com/show_bug.cgi?id=28721 /// - public void DuplicateValuesInResourceCaseMap ([Values] AndroidRuntime runtime) + public void DuplicateValuesInResourceCaseMap ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -2127,7 +2039,7 @@ public void DuplicateValuesInResourceCaseMap ([Values] AndroidRuntime runtime) } [Test] - public void CheckLintResourceFileReferencesAreFixed ([Values] AndroidRuntime runtime) + public void CheckLintResourceFileReferencesAreFixed ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -2168,8 +2080,6 @@ public void CheckLintResourceFileReferencesAreFixed ([Values] AndroidRuntime run } [Test] - [TestCase (true, AndroidRuntime.MonoVM)] - [TestCase (false, AndroidRuntime.MonoVM)] [TestCase (true, AndroidRuntime.CoreCLR)] [TestCase (false, AndroidRuntime.CoreCLR)] // TODO: [TestCase (false, AndroidRuntime.NativeAOT)] @@ -2207,7 +2117,7 @@ public void SimilarAndroidXAssemblyNames (bool publishTrimmed, AndroidRuntime ru } [Test] - public void IncrementalBuildDifferentDevice ([Values] AndroidRuntime runtime) + public void IncrementalBuildDifferentDevice ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -2245,7 +2155,7 @@ public void IncrementalBuildDifferentDevice ([Values] AndroidRuntime runtime) } [Test] - public void SystemIOHashing ([Values] AndroidRuntime runtime) + public void SystemIOHashing ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (runtime == AndroidRuntime.NativeAOT) { Assert.Ignore ("https://github.com/dotnet/android/issues/10606"); diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs index 05a317d6669..2e6214a7d89 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs @@ -38,66 +38,8 @@ public partial class BuildTest2 : BaseTest }, }; - // TODO: at some point it should work for CoreCLR, after its managed marshal methods are fixed [Test] - [TestCaseSource (nameof (MarshalMethodsDefaultStatusSource))] - public void MarshalMethodsDefaultEnabledStatus (bool isRelease, bool marshalMethodsEnabled) - { - var abis = new [] { "armeabi-v7a", "x86" }; - AndroidTargetArch[] supportedArches = new [] { - AndroidTargetArch.Arm, - AndroidTargetArch.X86, - }; - var proj = new XamarinAndroidApplicationProject { - IsRelease = isRelease, - EnableMarshalMethods = marshalMethodsEnabled, - }; - // MonoVM-only test - proj.SetRuntime (Android.Tasks.AndroidRuntime.MonoVM); - proj.SetRuntimeIdentifiers (abis); - bool shouldMarshalMethodsBeEnabled = isRelease && marshalMethodsEnabled; - - using (var b = CreateApkBuilder ()) { - b.Verbosity = LoggerVerbosity.Diagnostic; - Assert.IsTrue (b.Build (proj), "Build should have succeeded."); - Assert.IsTrue ( - StringAssertEx.ContainsText (b.LastBuildOutput, $"_AndroidUseMarshalMethods = {shouldMarshalMethodsBeEnabled}"), - $"The '_AndroidUseMarshalMethods' MSBuild property should have had the value of '{shouldMarshalMethodsBeEnabled}'" - ); - - string objPath = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath); - List envFiles = EnvironmentHelper.GatherEnvironmentFiles ( - objPath, - String.Join (";", supportedArches.Select (arch => MonoAndroidHelper.ArchToAbi (arch))), - true - ); - var app_config = (EnvironmentHelper.ApplicationConfig_MonoVM)EnvironmentHelper.ReadApplicationConfig (envFiles, Android.Tasks.AndroidRuntime.MonoVM); - - Assert.That (app_config, Is.Not.Null, "application_config must be present in the environment files"); - Assert.AreEqual (app_config.marshal_methods_enabled, shouldMarshalMethodsBeEnabled, $"Marshal methods enabled status should be '{shouldMarshalMethodsBeEnabled}', but it was '{app_config.marshal_methods_enabled}'"); - } - } - - // TODO: fix for CoreCLR - // Currently it fails with: - // - // Microsoft.Android.Sdk.AssemblyResolution.targets(198,5): error MSB4096: The item "obj/Release/UnnamedProject.pdb" in item list "ResolvedSymbols" does not define a value for metadata "DestinationSubPath". In order to use this metadata, either qualify it by specifying %(ResolvedSymbols.DestinationSubPath), or ensure that all items in this list define a value for this metadata. - [Test] - public void CompressedWithoutLinker () - { - var proj = new XamarinAndroidApplicationProject { - IsRelease = true - }; - // Mono-only test, at least for now - proj.SetRuntime (AndroidRuntime.MonoVM); - proj.SetProperty (proj.ReleaseProperties, KnownProperties.AndroidLinkMode, AndroidLinkMode.None.ToString ()); - using (var b = CreateApkBuilder ()) { - Assert.IsTrue (b.Build (proj), "Build should have succeeded."); - } - } - - [Test] - public void BuildBasicApplication ([Values] bool isRelease, [Values ("", "en_US.UTF-8", "sv_SE.UTF-8")] string langEnvironmentVariable, [Values] AndroidRuntime runtime) + public void BuildBasicApplication ([Values] bool isRelease, [Values ("", "en_US.UTF-8", "sv_SE.UTF-8")] string langEnvironmentVariable, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -286,7 +228,7 @@ void AssertTypeMap(string javaName, string managedName) } [Test] - public void BuildBasicApplicationThenMoveIt ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void BuildBasicApplicationThenMoveIt ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -330,7 +272,7 @@ public static string GetLinkedPath (ProjectBuilder builder, bool isRelease, stri } [Test] - public void BuildReleaseArm64 ([Values] bool forms, [Values] AndroidRuntime runtime) + public void BuildReleaseArm64 ([Values] bool forms, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -379,7 +321,7 @@ static IEnumerable Get_BuildHasNoWarningsData () { var ret = new List (); - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }) { AddTestData ( isRelease: false, multidex: false, @@ -493,7 +435,7 @@ static IEnumerable Get_BuildHasTrimmerWarningsData () { var ret = new List (); - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }) { AddTestData (runtime, "", new string [0], false); if (runtime == AndroidRuntime.NativeAOT) { @@ -578,7 +520,7 @@ public void BuildHasTrimmerWarnings (AndroidRuntime runtime, string properties, } [Test] - public void XA0141ErrorIsRaised ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void XA0141ErrorIsRaised ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -637,7 +579,7 @@ static IEnumerable Get_XA1037PropertyDeprecatedWarningData () { var ret = new List (); - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }) { AddTestData ("AndroidFastDeploymentType", "Assemblies", true, false, runtime); AddTestData ("AndroidFastDeploymentType", "Assemblies", false, false, runtime); AddTestData ("_AndroidUseJavaLegacyResolver", "true", false, true, runtime); @@ -681,7 +623,7 @@ public void XA1037PropertyDeprecatedWarning (string property, string value, bool } [Test] - public void ClassLibraryHasNoWarnings ([Values] AndroidRuntime runtime) + public void ClassLibraryHasNoWarnings ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -710,7 +652,7 @@ public void ClassLibraryHasNoWarnings ([Values] AndroidRuntime runtime) } [Test] - public void BuildBasicApplicationWithNuGetPackageConflicts ([Values] AndroidRuntime runtime) + public void BuildBasicApplicationWithNuGetPackageConflicts ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -763,7 +705,7 @@ static IEnumerable Get_BuildBasicApplicationFSharpData () // TODO: AndroidRuntime.NativeAOT doesn't work yet. Fails with // // Microsoft.Android.Sdk.Aot.targets(123,5): error : Runtime critical type System.RuntimeMethodHandle not found - foreach (AndroidRuntime runtime in new[] { AndroidRuntime.MonoVM, AndroidRuntime.CoreCLR }) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR }) { AddTestData (isRelease: false, aot: false, runtime); AddTestData (isRelease: true, aot: false, runtime); AddTestData (isRelease: true, aot: true, runtime); @@ -811,7 +753,7 @@ public void BuildBasicApplicationFSharp (bool isRelease, bool aot, AndroidRuntim [Test] [NonParallelizable] - public void BuildBasicApplicationAppCompat ([Values] bool publishAot, [Values] AndroidRuntime runtime) + public void BuildBasicApplicationAppCompat ([Values] bool publishAot, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease, aot: publishAot)) { @@ -833,7 +775,7 @@ public void BuildBasicApplicationAppCompat ([Values] bool publishAot, [Values] A } [Test] - public void DuplicateRJavaOutput ([Values] AndroidRuntime runtime) + public void DuplicateRJavaOutput ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -862,7 +804,7 @@ public void DuplicateRJavaOutput ([Values] AndroidRuntime runtime) [Test] [Category ("XamarinBuildDownload")] [NonParallelizable] // parallel NuGet restore causes failures - public void BuildXamarinFormsMapsApplication ([Values] bool multidex, [Values (AndroidRuntime.MonoVM, AndroidRuntime.CoreCLR)] AndroidRuntime runtime) + public void BuildXamarinFormsMapsApplication ([Values] bool multidex, [Values (AndroidRuntime.CoreCLR)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: false)) { return; @@ -900,7 +842,7 @@ public void BuildXamarinFormsMapsApplication ([Values] bool multidex, [Values (A [Test] [NonParallelizable] - public void SkipConvertResourcesCases ([Values] AndroidRuntime runtime) + public void SkipConvertResourcesCases ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -971,7 +913,7 @@ public void SkipConvertResourcesCases ([Values] AndroidRuntime runtime) } [Test] - public void BuildInParallel ([Values] AndroidRuntime runtime) + public void BuildInParallel ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (!IsWindows) { //TODO: one day we should fix the problems here, various MSBuild tasks step on each other when built in parallel @@ -1009,7 +951,7 @@ public void BuildInParallel ([Values] AndroidRuntime runtime) } [Test] - public void CheckKeystoreIsCreated ([Values] AndroidRuntime runtime) + public void CheckKeystoreIsCreated ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1033,7 +975,7 @@ public void CheckKeystoreIsCreated ([Values] AndroidRuntime runtime) [Test] [Category ("FSharp")] [NonParallelizable] // parallel NuGet restore causes failures - public void FSharpAppHasAndroidDefine ([Values] AndroidRuntime runtime) + public void FSharpAppHasAndroidDefine ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1062,7 +1004,7 @@ module Xamarin.Android.Tests } [Test] - public void DesignTimeBuildHasAndroidDefines ([Values] AndroidRuntime runtime) + public void DesignTimeBuildHasAndroidDefines ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1104,7 +1046,7 @@ public void FooMethod () {{ } [Test] - public void SwitchBetweenDesignTimeBuild ([Values] AndroidRuntime runtime) + public void SwitchBetweenDesignTimeBuild ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1187,7 +1129,7 @@ public CustomTextView(Context context, IAttributeSet attributes) : base(context, } [Test] - public void DesignTimeBuildMissingAndroidPlatformJar ([Values] AndroidRuntime runtime) + public void DesignTimeBuildMissingAndroidPlatformJar ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1210,7 +1152,7 @@ public void DesignTimeBuildMissingAndroidPlatformJar ([Values] AndroidRuntime ru } [Test] - public void AndroidResourceNotExist ([Values] AndroidRuntime runtime) + public void AndroidResourceNotExist ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1238,7 +1180,7 @@ public void AndroidResourceNotExist ([Values] AndroidRuntime runtime) } [Test] - public void TargetFrameworkMonikerAssemblyAttributesPath ([Values] AndroidRuntime runtime) + public void TargetFrameworkMonikerAssemblyAttributesPath ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const string filePattern = ".NETCoreApp,Version=*.AssemblyAttributes.cs"; bool isRelease = runtime == AndroidRuntime.NativeAOT; @@ -1262,7 +1204,7 @@ public void TargetFrameworkMonikerAssemblyAttributesPath ([Values] AndroidRuntim [Test] [NonParallelizable] - public void CheckTimestamps ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void CheckTimestamps ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -1327,7 +1269,7 @@ public void CheckTimestamps ([Values] bool isRelease, [Values] AndroidRuntime ru [Test] [NonParallelizable] // On MacOS, parallel /restore causes issues - public void BuildApplicationAndClean ([Values] bool isRelease, [Values ("apk", "aab")] string packageFormat, [Values] AndroidRuntime runtime) + public void BuildApplicationAndClean ([Values] bool isRelease, [Values ("apk", "aab")] string packageFormat, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -1362,7 +1304,7 @@ public void BuildApplicationAndClean ([Values] bool isRelease, [Values ("apk", " } [Test] - public void BuildApplicationWithLibraryAndClean ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void BuildApplicationWithLibraryAndClean ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -1426,7 +1368,7 @@ public void BuildApplicationWithLibraryAndClean ([Values] bool isRelease, [Value } [Test] - public void BuildIncrementingAssemblyVersion ([Values] AndroidRuntime runtime) + public void BuildIncrementingAssemblyVersion ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1462,7 +1404,7 @@ public void BuildIncrementingAssemblyVersion ([Values] AndroidRuntime runtime) } [Test] - public void BuildIncrementingClassName ([Values] AndroidRuntime runtime) + public void BuildIncrementingClassName ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1517,7 +1459,7 @@ public void BuildIncrementingClassName ([Values] AndroidRuntime runtime) } [Test] - public void CSharp8Features ([Values] bool bindingProject, [Values] AndroidRuntime runtime) + public void CSharp8Features ([Values] bool bindingProject, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1549,7 +1491,7 @@ public void CSharp8Features ([Values] bool bindingProject, [Values] AndroidRunti } [Test] - public void BuildProguardEnabledProject ([Values ("", "android-arm64")] string rid, [Values] AndroidRuntime runtime) + public void BuildProguardEnabledProject ([Values ("", "android-arm64")] string rid, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1625,7 +1567,7 @@ XamarinAndroidApplicationProject CreateMultiDexRequiredApplication (string debug } [Test] - public void CreateMultiDexWithSpacesInConfig ([Values] AndroidRuntime runtime) + public void CreateMultiDexWithSpacesInConfig ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1646,7 +1588,7 @@ public void CreateMultiDexWithSpacesInConfig ([Values] AndroidRuntime runtime) } [Test] - public void BuildMultiDexApplication ([Values] AndroidRuntime runtime) + public void BuildMultiDexApplication ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1666,7 +1608,7 @@ public void BuildMultiDexApplication ([Values] AndroidRuntime runtime) } [Test] - public void BuildAfterMultiDexIsNotRequired ([Values] AndroidRuntime runtime) + public void BuildAfterMultiDexIsNotRequired ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1711,7 +1653,7 @@ public void BuildAfterMultiDexIsNotRequired ([Values] AndroidRuntime runtime) } [Test] - public void CustomApplicationClassAndMultiDex ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void CustomApplicationClassAndMultiDex ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -1752,7 +1694,7 @@ public override void OnCreate() } [Test] - public void MultiDexAndCodeShrinker ([Values] AndroidRuntime runtime) + public void MultiDexAndCodeShrinker ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1774,7 +1716,7 @@ public void MultiDexAndCodeShrinker ([Values] AndroidRuntime runtime) } [Test] - public void MultiDexR8ConfigWithNoCodeShrinking ([Values] AndroidRuntime runtime) + public void MultiDexR8ConfigWithNoCodeShrinking ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1824,7 +1766,7 @@ abstract class ExtendsClassValue extends ClassValue {} [Test] - public void BuildBasicApplicationCheckPdb ([Values] AndroidRuntime runtime) + public void BuildBasicApplicationCheckPdb ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime)) { return; @@ -1846,7 +1788,7 @@ public void BuildBasicApplicationCheckPdb ([Values] AndroidRuntime runtime) } [Test] - public void BuildBasicApplicationCheckPdbRepeatBuild ([Values] AndroidRuntime runtime) + public void BuildBasicApplicationCheckPdbRepeatBuild ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime)) { return; @@ -1876,7 +1818,7 @@ public void BuildBasicApplicationCheckPdbRepeatBuild ([Values] AndroidRuntime ru } [Test] - public void BuildAppCheckDebugSymbols ([Values] AndroidRuntime runtime) + public void BuildAppCheckDebugSymbols ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime)) { return; @@ -2011,7 +1953,7 @@ void EnsureFilesAreTheSame (string intermediatePath, string? binPath, string fil } [Test] - public void BuildBasicApplicationCheckConfigFiles ([Values] AndroidRuntime runtime) + public void BuildBasicApplicationCheckConfigFiles ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -2041,7 +1983,7 @@ public void BuildBasicApplicationCheckConfigFiles ([Values] AndroidRuntime runti [Test] [NonParallelizable] // Environment variables are global! - public void BuildWithJavaToolOptions ([Values] AndroidRuntime runtime) + public void BuildWithJavaToolOptions ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -2070,7 +2012,7 @@ public void BuildWithJavaToolOptions ([Values] AndroidRuntime runtime) } [Test] - public void LibraryWithGenericAttribute ([Values] AndroidRuntime runtime) + public void LibraryWithGenericAttribute ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -2119,7 +2061,7 @@ class Class2 : Library1.Class1 { } } [Test] - public void Plugin_Maui_Audio ([Values] AndroidRuntime runtime) + public void Plugin_Maui_Audio ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -2156,7 +2098,7 @@ public void Plugin_Maui_Audio ([Values] AndroidRuntime runtime) } [Test] - public void MarshalMethodsUnhandledExceptionRuntimeFixUpWorks ([Values] AndroidRuntime runtime) + public void MarshalMethodsUnhandledExceptionRuntimeFixUpWorks ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest3.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest3.cs index 957b506b6ce..af3ec8254b7 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest3.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest3.cs @@ -16,7 +16,7 @@ public partial class BuildTest3 : BaseTest const string JniPreloadSourceLibraryName = "libtest-jni-library.so"; [Test] - public void NativeLibraryJniPreload_NoDuplicates ([Values] AndroidRuntime runtime) + public void NativeLibraryJniPreload_NoDuplicates ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const string MyLibKeep1 = "libMyStuffKeep.so"; const string MyLibKeep2 = "libMyStuffKeep.so"; @@ -35,7 +35,7 @@ public void NativeLibraryJniPreload_NoDuplicates ([Values] AndroidRuntime runtim } [Test] - public void NativeLibraryJniPreload_IncludeCustomLibraries ([Values] AndroidRuntime runtime) + public void NativeLibraryJniPreload_IncludeCustomLibraries ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const string MyLib = "libMyStuff.so"; @@ -53,7 +53,7 @@ public void NativeLibraryJniPreload_IncludeCustomLibraries ([Values] AndroidRunt } [Test] - public void NativeLibraryJniPreload_ExcludeSomeCustomLibraries ([Values] AndroidRuntime runtime) + public void NativeLibraryJniPreload_ExcludeSomeCustomLibraries ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const string MyLibKeep = "libMyStuffKeep.so"; const string MyLibExempt = "libMyStuffExempt.so"; @@ -75,7 +75,7 @@ public void NativeLibraryJniPreload_ExcludeSomeCustomLibraries ([Values] Android } [Test] - public void NativeLibraryJniPreload_ExcludeAllCustomLibraries ([Values] AndroidRuntime runtime) + public void NativeLibraryJniPreload_ExcludeAllCustomLibraries ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const string MyLibExempt1 = "libMyStuffExempt1.so"; const string MyLibExempt2 = "libMyStuffExempt2.so"; @@ -100,7 +100,7 @@ public void NativeLibraryJniPreload_ExcludeAllCustomLibraries ([Values] AndroidR } [Test] - public void NativeLibraryJniPreload_AddSomeCustomLibrariesAndIgnoreAll ([Values] AndroidRuntime runtime) + public void NativeLibraryJniPreload_AddSomeCustomLibrariesAndIgnoreAll ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { List? allPreloads = NativeLibraryJniPreload_CommonInitAndGetPreloads ( runtime, @@ -118,7 +118,7 @@ public void NativeLibraryJniPreload_AddSomeCustomLibrariesAndIgnoreAll ([Values] } [Test] - public void NativeLibraryJniPreload_AddSomeCustomLibrariesAndIgnoreAllByName ([Values] AndroidRuntime runtime) + public void NativeLibraryJniPreload_AddSomeCustomLibrariesAndIgnoreAllByName ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const string MyLibExemptOne = "libMyStuffExemptOne.so"; const string MyLibExemptTwo = "libMyStuffExemptTwo.so"; @@ -169,7 +169,7 @@ void NativeLibraryJniPreload_AddNativeLibraries (XamarinAndroidApplicationProjec } [Test] - public void NativeLibraryJniPreload_IgnoreAll_PreservesRequired ([Values] AndroidRuntime runtime) + public void NativeLibraryJniPreload_IgnoreAll_PreservesRequired ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { List? allPreloads = NativeLibraryJniPreload_CommonInitAndGetPreloads ( runtime, @@ -183,7 +183,7 @@ public void NativeLibraryJniPreload_IgnoreAll_PreservesRequired ([Values] Androi } [Test] - public void NativeLibraryJniPreload_DefaultsWork ([Values] AndroidRuntime runtime) + public void NativeLibraryJniPreload_DefaultsWork ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { List? allPreloads = NativeLibraryJniPreload_CommonInitAndGetPreloads (runtime); NativeLibraryJniPreload_VerifyDefaults (allPreloads); diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildWithLibraryTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildWithLibraryTests.cs index b9d54076804..0ee843db8ae 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildWithLibraryTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildWithLibraryTests.cs @@ -53,7 +53,7 @@ static IEnumerable Get_DotNetBuildLibraryParams () { var source = new List (); foreach (object[] args in DotNetBuildLibrarySource) { - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }) { source.Add (new object[] { args[0], args[1], @@ -314,7 +314,7 @@ public Foo () } [Test] - public void ProjectDependencies ([Values] bool projectReference, [Values] AndroidRuntime runtime) + public void ProjectDependencies ([Values] bool projectReference, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -413,7 +413,7 @@ public void ProjectDependencies ([Values] bool projectReference, [Values] Androi [Test] [NonParallelizable] - public void BuildWithNativeLibraries ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void BuildWithNativeLibraries ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -512,7 +512,7 @@ public void BuildWithNativeLibraries ([Values] bool isRelease, [Values] AndroidR } [Test] - public void BuildWithNativeLibraryUnknownAbi ([Values] AndroidRuntime runtime) + public void BuildWithNativeLibraryUnknownAbi ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -546,7 +546,7 @@ public void BuildWithNativeLibraryUnknownAbi ([Values] AndroidRuntime runtime) } [Test] - public void BuildWithExternalJavaLibrary ([Values] AndroidRuntime runtime) + public void BuildWithExternalJavaLibrary ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -583,7 +583,7 @@ public void BuildWithExternalJavaLibrary ([Values] AndroidRuntime runtime) } [Test] - public void AndroidLibraryProjectsZipWithOddPaths ([Values] AndroidRuntime runtime) + public void AndroidLibraryProjectsZipWithOddPaths ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -616,7 +616,7 @@ public void AndroidLibraryProjectsZipWithOddPaths ([Values] AndroidRuntime runti } [Test] - public void DuplicateJCWNames ([Values] AndroidRuntime runtime) + public void DuplicateJCWNames ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -676,7 +676,7 @@ public void DuplicateJCWNames ([Values] AndroidRuntime runtime) } [Test] - public void DuplicateManagedNames ([Values] AndroidRuntime runtime) + public void DuplicateManagedNames ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -736,7 +736,7 @@ public void DuplicateManagedNames ([Values] AndroidRuntime runtime) } [Test] - public void LibraryProjectsShouldSkipGetPrimaryCpuAbi ([Values] AndroidRuntime runtime) + public void LibraryProjectsShouldSkipGetPrimaryCpuAbi ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -751,7 +751,7 @@ public void LibraryProjectsShouldSkipGetPrimaryCpuAbi ([Values] AndroidRuntime r } [Test] - public void AllResourcesInClassLibrary ([Values] bool useDesignerAssembly, [Values] AndroidRuntime runtime) + public void AllResourcesInClassLibrary ([Values] bool useDesignerAssembly, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -816,7 +816,7 @@ public void AllResourcesInClassLibrary ([Values] bool useDesignerAssembly, [Valu /// /// Reference https://bugzilla.xamarin.com/show_bug.cgi?id=29568 /// - public void BuildLibraryWhichUsesResources ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void BuildLibraryWhichUsesResources ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -838,7 +838,7 @@ public void BuildLibraryWhichUsesResources ([Values] bool isRelease, [Values] An } [Test] - public void AndroidXClassLibraryNoResources ([Values] AndroidRuntime runtime) + public void AndroidXClassLibraryNoResources ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -856,7 +856,7 @@ public void AndroidXClassLibraryNoResources ([Values] AndroidRuntime runtime) } [Test] - public void CheckContentBuildAction ([Values] AndroidRuntime runtime) + public void CheckContentBuildAction ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -926,7 +926,7 @@ public void CheckContentBuildAction ([Values] AndroidRuntime runtime) } [Test] - public void ContentBuildActionForRazor ([Values] AndroidRuntime runtime) + public void ContentBuildActionForRazor ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -983,7 +983,7 @@ private void IncrementCount() // Combination of class libraries that triggered the problem: // error APT2144: invalid file path 'obj/Release/net8.0-android/lp/86.stamp'. [Test] - public void ClassLibraryAarDependencies ([Values] AndroidRuntime runtime) + public void ClassLibraryAarDependencies ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1024,7 +1024,7 @@ public void ClassLibraryAarDependencies ([Values] AndroidRuntime runtime) } [Test] - public void DotNetLibraryAarChanges ([Values] AndroidRuntime runtime) + public void DotNetLibraryAarChanges ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1087,7 +1087,7 @@ public void DotNetLibraryAarChanges ([Values] AndroidRuntime runtime) /// and producing empty .jlo.xml files. /// [Test] - public void MultiTfmTransitiveReference ([Values] AndroidRuntime runtime) + public void MultiTfmTransitiveReference ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: false)) { return; diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/CodeBehindTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/CodeBehindTests.cs index c1af443792c..efb5ce40f6c 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/CodeBehindTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/CodeBehindTests.cs @@ -284,25 +284,25 @@ static CodeBehindTests () } [Test] - public void SuccessfulBuildFew ([Values] AndroidRuntime runtime) + public void SuccessfulBuildFew ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { RunTest (TestName, many: false, dtb: false, runner: SuccessfulBuild_RunTest, runtime: runtime); } [Test] - public void SuccessfulBuildMany ([Values] AndroidRuntime runtime) + public void SuccessfulBuildMany ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { RunTest (TestName, many: true, dtb: false, runner: SuccessfulBuild_RunTest, runtime: runtime); } [Test] - public void SuccessfulBuildFew_DTB ([Values] AndroidRuntime runtime) + public void SuccessfulBuildFew_DTB ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { RunTest (TestName, many: false, dtb: true, runner: SuccessfulBuild_RunTest, runtime: runtime); } [Test] - public void SuccessfulBuildMany_DTB ([Values] AndroidRuntime runtime) + public void SuccessfulBuildMany_DTB ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { RunTest (TestName, many: true, dtb: true, runner: SuccessfulBuild_RunTest, runtime: runtime); } @@ -335,7 +335,7 @@ void SuccessfulBuild_RunTest (TestProjectInfo testInfo, bool many, bool dtb, Loc } [Test] - public void SuccessfulAndroidXApp ([Values] AndroidRuntime runtime) + public void SuccessfulAndroidXApp ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { RunTest (TestName, many: true, dtb: false, runner: SuccessfulBuild_AndroidX, runtime: runtime); } @@ -372,13 +372,13 @@ void SuccessfulBuild_AndroidX (TestProjectInfo testInfo, bool many, bool dtb, Lo } [Test] - public void FailedBuildFew_ConflictingFragment ([Values] AndroidRuntime runtime) + public void FailedBuildFew_ConflictingFragment ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { RunTest (TestName, many: false, dtb: false, runner: FailedBuild_ConflictingFragment_RunTest, runtime: runtime); } [Test] - public void FailedBuildMany_ConflictingFragment ([Values] AndroidRuntime runtime) + public void FailedBuildMany_ConflictingFragment ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { RunTest (TestName, many: true, dtb: false, runner: FailedBuild_ConflictingFragment_RunTest, runtime: runtime); } @@ -400,13 +400,13 @@ void FailedBuild_ConflictingFragment_RunTest (TestProjectInfo testInfo, bool man } [Test] - public void FailedBuildFew_ConflictingTextView ([Values] AndroidRuntime runtime) + public void FailedBuildFew_ConflictingTextView ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { RunTest (TestName, many: false, dtb: false, runner: FailedBuild_ConflictingTextView_RunTest, runtime: runtime); } [Test] - public void FailedBuildMany_ConflictingTextView ([Values] AndroidRuntime runtime) + public void FailedBuildMany_ConflictingTextView ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { RunTest (TestName, many: true, dtb: false, runner: FailedBuild_ConflictingTextView_RunTest, runtime: runtime); } @@ -428,13 +428,13 @@ void FailedBuild_ConflictingTextView_RunTest (TestProjectInfo testInfo, bool man } [Test] - public void FailedBuildFew_ConflictingButton ([Values] AndroidRuntime runtime) + public void FailedBuildFew_ConflictingButton ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { RunTest (TestName, many: false, dtb: false, runner: FailedBuild_ConflictingButton_RunTest, runtime: runtime); } [Test] - public void FailedBuildMany_ConflictingButton ([Values] AndroidRuntime runtime) + public void FailedBuildMany_ConflictingButton ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { RunTest (TestName, many: true, dtb: false, runner: FailedBuild_ConflictingButton_RunTest, runtime: runtime); } @@ -456,13 +456,13 @@ void FailedBuild_ConflictingButton_RunTest (TestProjectInfo testInfo, bool many, } [Test] - public void FailedBuildFew_ConflictingLinearLayout ([Values] AndroidRuntime runtime) + public void FailedBuildFew_ConflictingLinearLayout ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { RunTest (TestName, many: false, dtb: false, runner: FailedBuild_ConflictingLinearLayout_RunTest, runtime: runtime); } [Test] - public void FailedBuildMany_ConflictingLinearLayout ([Values] AndroidRuntime runtime) + public void FailedBuildMany_ConflictingLinearLayout ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { RunTest (TestName, many: true, dtb: false, runner: FailedBuild_ConflictingLinearLayout_RunTest, runtime: runtime); } @@ -484,13 +484,13 @@ void FailedBuild_ConflictingLinearLayout_RunTest (TestProjectInfo testInfo, bool } [Test] - public void FailedBuildFew_ConflictingRelativeLayout ([Values] AndroidRuntime runtime) + public void FailedBuildFew_ConflictingRelativeLayout ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { RunTest (TestName, many: false, dtb: false, runner: FailedBuild_ConflictingRelativeLayout_RunTest, runtime: runtime); } [Test] - public void FailedBuildMany_ConflictingRelativeLayout ([Values] AndroidRuntime runtime) + public void FailedBuildMany_ConflictingRelativeLayout ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { RunTest (TestName, many: true, dtb: false, runner: FailedBuild_ConflictingRelativeLayout_RunTest, runtime: runtime); } diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/DeferredBuildTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/DeferredBuildTest.cs index 07bd0676864..d58cfd2c970 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/DeferredBuildTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/DeferredBuildTest.cs @@ -10,7 +10,7 @@ namespace Xamarin.Android.Build.Tests public class DeferredBuildTest : BaseTest { [Test] - public void SelectivelyRunUpdateAndroidResources ([Values] AndroidRuntime runtime) + public void SelectivelyRunUpdateAndroidResources ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -61,7 +61,7 @@ public void SelectivelyRunUpdateAndroidResources ([Values] AndroidRuntime runtim } [Test] - public void RunUpdateAndroidResourcesIfBackgroundBuildNotSupported ([Values] AndroidRuntime runtime) + public void RunUpdateAndroidResourcesIfBackgroundBuildNotSupported ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/EnvironmentContentTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/EnvironmentContentTests.cs index 7616d8d0412..287ef642297 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/EnvironmentContentTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/EnvironmentContentTests.cs @@ -16,7 +16,7 @@ public class EnvironmentContentTests : BaseTest { [Test] [NonParallelizable] - public void BuildApplicationWithMonoEnvironment ([Values ("", "Normal", "Offline")] string sequencePointsMode, [Values] AndroidRuntime runtime) + public void BuildApplicationWithMonoEnvironment ([Values ("", "Normal", "Offline")] string sequencePointsMode, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -93,72 +93,5 @@ public void BuildApplicationWithMonoEnvironment ([Values ("", "Normal", "Offline } } - [Test] - public void CheckMonoDebugIsAddedToEnvironment ([Values ("", "Normal", "Offline")] string sequencePointsMode) - { - const string supportedAbis = "armeabi-v7a;x86"; - - var proj = new XamarinAndroidApplicationProject () { - IsRelease = true, - }; - - // Mono-only test - proj.SetRuntime (AndroidRuntime.MonoVM); - proj.SetProperty ("_AndroidSequencePointsMode", sequencePointsMode); - proj.SetRuntimeIdentifiers (supportedAbis.Split (';')); - using (var b = CreateApkBuilder ()) { - Assert.IsTrue (b.Build (proj), "Build should have succeeded."); - - string intermediateOutputDir = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath); - List envFiles = EnvironmentHelper.GatherEnvironmentFiles (intermediateOutputDir, supportedAbis, true, AndroidRuntime.MonoVM); - Dictionary envvars = EnvironmentHelper.ReadEnvironmentVariables (envFiles, AndroidRuntime.MonoVM); - Assert.IsTrue (envvars.Count > 0, $"No environment variables defined"); - - string monoDebugVar; - bool monoDebugVarFound = envvars.TryGetValue ("MONO_DEBUG", out monoDebugVar); - if (String.IsNullOrEmpty (sequencePointsMode)) - Assert.IsFalse (monoDebugVarFound, $"environment should not contain MONO_DEBUG={monoDebugVar}"); - else { - Assert.IsTrue (monoDebugVarFound, "environment should contain MONO_DEBUG"); - Assert.AreEqual ("gen-compact-seq-points", monoDebugVar, "environment should contain MONO_DEBUG=gen-compact-seq-points"); - } - - EnvironmentHelper.AssertValidEnvironmentSharedLibrary (intermediateOutputDir, AndroidSdkPath, AndroidNdkPath, supportedAbis, AndroidRuntime.MonoVM); - } - } - - [Test] - public void CheckConcurrentGC () - { - var proj = new XamarinAndroidApplicationProject () { - IsRelease = true, - }; - - var gcVarName = "MONO_GC_PARAMS"; - var expectedDefaultValue = "major=marksweep"; - var expectedUpdatedValue = "major=marksweep-conc"; - var supportedAbis = "armeabi-v7a;arm64-v8a"; - // MonoVM-only test - proj.SetRuntime (Android.Tasks.AndroidRuntime.MonoVM); - proj.SetRuntimeIdentifiers (supportedAbis.Split (';')); - - using (var b = CreateApkBuilder ()) { - proj.SetProperty ("AndroidEnableSGenConcurrent", "False"); - Assert.IsTrue (b.Build (proj), "Build should have succeeded."); - var intermediateOutputDir = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath); - // AndroidEnableSGenConcurrent=False by default - List envFiles = EnvironmentHelper.GatherEnvironmentFiles (intermediateOutputDir, supportedAbis, true, AndroidRuntime.MonoVM); - Dictionary envvars = EnvironmentHelper.ReadEnvironmentVariables (envFiles, AndroidRuntime.MonoVM); - Assert.IsTrue (envvars.ContainsKey (gcVarName), $"Environment should contain '{gcVarName}'."); - Assert.AreEqual (expectedDefaultValue, envvars[gcVarName], $"'{gcVarName}' should have been '{expectedDefaultValue}' when concurrent GC is disabled."); - - proj.SetProperty ("AndroidEnableSGenConcurrent", "True"); - Assert.IsTrue (b.Build (proj), "Second build should have succeeded."); - envFiles = EnvironmentHelper.GatherEnvironmentFiles (intermediateOutputDir, supportedAbis, true, AndroidRuntime.MonoVM); - envvars = EnvironmentHelper.ReadEnvironmentVariables (envFiles, AndroidRuntime.MonoVM); - Assert.IsTrue (envvars.ContainsKey (gcVarName), $"Environment should contain '{gcVarName}'."); - Assert.AreEqual (expectedUpdatedValue, envvars[gcVarName], $"'{gcVarName}' should have been '{expectedUpdatedValue}' when concurrent GC is enabled."); - } - } } } diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/IncrementalBuildTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/IncrementalBuildTest.cs index 7a354687753..53dc439cea7 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/IncrementalBuildTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/IncrementalBuildTest.cs @@ -16,7 +16,7 @@ namespace Xamarin.Android.Build.Tests public class IncrementalBuildTest : BaseTest { [Test] - public void BasicApplicationRepetitiveBuild ([Values] AndroidRuntime runtime) + public void BasicApplicationRepetitiveBuild ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -62,7 +62,7 @@ public void BasicApplicationRepetitiveBuild ([Values] AndroidRuntime runtime) // The target _RunILLink should have been skipped. // [Test] - public void BasicApplicationRepetitiveReleaseBuild ([Values] AndroidRuntime runtime) + public void BasicApplicationRepetitiveReleaseBuild ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -177,7 +177,7 @@ void AssertJniRemappingSourceTimestamps (Dictionary expectedTi } [Test] - public void CheckNothingIsDeletedByIncrementalClean ([Values] bool enableMultiDex, [Values] AndroidRuntime runtime) + public void CheckNothingIsDeletedByIncrementalClean ([Values] bool enableMultiDex, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -242,7 +242,7 @@ public void CheckNothingIsDeletedByIncrementalClean ([Values] bool enableMultiDe } [Test] - public void CheckResourceDirectoryDoesNotGetHosed ([Values] AndroidRuntime runtime) + public void CheckResourceDirectoryDoesNotGetHosed ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -272,7 +272,7 @@ public void CheckResourceDirectoryDoesNotGetHosed ([Values] AndroidRuntime runti } [Test] - public void IncrementalCleanDuringClean ([Values] AndroidRuntime runtime) + public void IncrementalCleanDuringClean ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -319,7 +319,7 @@ public void IncrementalCleanDuringClean ([Values] AndroidRuntime runtime) } [Test] - public void LibraryIncrementalBuild ([Values] AndroidRuntime runtime) + public void LibraryIncrementalBuild ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -347,7 +347,7 @@ public void LibraryIncrementalBuild ([Values] AndroidRuntime runtime) } [Test] - public void AllProjectsHaveSameOutputDirectory ([Values] AndroidRuntime runtime) + public void AllProjectsHaveSameOutputDirectory ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -381,7 +381,7 @@ public void AllProjectsHaveSameOutputDirectory ([Values] AndroidRuntime runtime) } [Test] - public void BuildSolutionWithMultipleProjectsInParallel ([Values] AndroidRuntime runtime) + public void BuildSolutionWithMultipleProjectsInParallel ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -420,7 +420,7 @@ public void BuildSolutionWithMultipleProjectsInParallel ([Values] AndroidRuntime } [Test] - public void JavacTaskDoesNotRunOnSecondBuild ([Values] AndroidRuntime runtime) + public void JavacTaskDoesNotRunOnSecondBuild ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -467,7 +467,7 @@ public TestMe createTestMe () { } [Test] - public void ResolveNativeLibrariesInManagedReferences ([Values] AndroidRuntime runtime) + public void ResolveNativeLibrariesInManagedReferences ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -599,7 +599,7 @@ public Class2 () //https://github.com/xamarin/xamarin-android/issues/2247 [Test] [NonParallelizable] // Do not run timing sensitive tests in parallel - public void AppProjectTargetsDoNotBreak ([Values] AndroidRuntime runtime) + public void AppProjectTargetsDoNotBreak ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -678,7 +678,7 @@ public void AppProjectTargetsDoNotBreak ([Values] AndroidRuntime runtime) } [Test] - public void LibraryProjectTargetsDoNotBreak ([Values] AndroidRuntime runtime) + public void LibraryProjectTargetsDoNotBreak ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -763,7 +763,7 @@ public void CreateAarRunsOnceWithGeneratePackageOnBuild () } [Test] - public void ManifestMergerIncremental ([Values] AndroidRuntime runtime) + public void ManifestMergerIncremental ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -790,7 +790,7 @@ public void ManifestMergerIncremental ([Values] AndroidRuntime runtime) } [Test] - public void ProduceReferenceAssembly ([Values] AndroidRuntime runtime) + public void ProduceReferenceAssembly ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -858,7 +858,7 @@ public void ProduceReferenceAssembly ([Values] AndroidRuntime runtime) } [Test] - public void TransitiveDependencyProduceReferenceAssembly ([Values] AndroidRuntime runtime) + public void TransitiveDependencyProduceReferenceAssembly ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -940,7 +940,7 @@ public void TransitiveDependencyProduceReferenceAssembly ([Values] AndroidRuntim } [Test] - public void LinkAssembliesNoShrink ([Values] AndroidRuntime runtime) + public void LinkAssembliesNoShrink ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -975,7 +975,7 @@ public void LinkAssembliesNoShrink ([Values] AndroidRuntime runtime) } [Test] - public void CSProjUserFileChanges ([Values] AndroidRuntime runtime) + public void CSProjUserFileChanges ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1006,7 +1006,7 @@ public void CSProjUserFileChanges ([Values] AndroidRuntime runtime) [Test] [NonParallelizable] // /restore can fail on Mac in parallel - public void ConvertCustomView ([Values] AndroidRuntime runtime) + public void ConvertCustomView ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1118,7 +1118,7 @@ public CustomTextView(Context context, IAttributeSet attributes) : base(context, } [Test] - public void ResolveLibraryProjectImports ([Values] AndroidRuntime runtime) + public void ResolveLibraryProjectImports ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1222,7 +1222,7 @@ ReadLibraryProjectImportsCache ReadCache (string cacheFile) [Test] [NonParallelizable] - public void AddNewAndroidResourceOnSecondBuild ([Values] AndroidRuntime runtime) + public void AddNewAndroidResourceOnSecondBuild ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1253,7 +1253,7 @@ public void AddNewAndroidResourceOnSecondBuild ([Values] AndroidRuntime runtime) [Test] [NonParallelizable] - public void InvalidAndroidResource ([Values] AndroidRuntime runtime) + public void InvalidAndroidResource ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1295,7 +1295,7 @@ public void InvalidAndroidResource ([Values] AndroidRuntime runtime) } [Test] - public void CasingOnJavaLangObject ([Values] AndroidRuntime runtime) + public void CasingOnJavaLangObject ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1323,7 +1323,7 @@ public void CasingOnJavaLangObject ([Values] AndroidRuntime runtime) } [Test] - public void GenerateJavaStubsAndAssembly ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void GenerateJavaStubsAndAssembly ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -1411,129 +1411,10 @@ void AssertAssemblyFilesInFileWrites (XamarinAndroidApplicationProject proj, Pro } #pragma warning disable 414 - static object [] AotChecks () => new object [] { - new object[] { - /* supportedAbis */ "arm64-v8a", - /* androidAotMode */ "", // None, Normal, Hybrib, Full - /* aotAssemblies */ false, - /* expectedResult */ true, - }, - new object[] { - /* supportedAbis */ "arm64-v8a", - /* androidAotMode */ "Normal", // None, Normal, Hybrid, Full - /* aotAssemblies */ true, - /* expectedResult */ true, - }, - new object[] { - /* supportedAbis */ "arm64-v8a", - /* androidAotMode */ "Normal", // None, Normal, Hybrid, Full - /* aotAssemblies */ false, - /* expectedResult */ true, - }, - }; #pragma warning restore 414 [Test] - [Category ("AOT")] - [TestCaseSource (nameof (AotChecks))] - public void BuildIncrementalAot (string supportedAbis, string androidAotMode, bool aotAssemblies, bool expectedResult) - { - // Setup dependencies App A -> Lib B - var path = Path.Combine ("temp", TestName); - - var libB = new XamarinAndroidLibraryProject { - ProjectName = "LibraryB", - IsRelease = true, - EnableDefaultItems = true, - }; - libB.Sources.Clear (); - libB.Sources.Add (new BuildItem.Source ("Foo.cs") { - TextContent = () => "public class Foo { }", - }); - - var libBBuilder = CreateDllBuilder (Path.Combine (path, libB.ProjectName)); - Assert.IsTrue (libBBuilder.Build(libB), $"{libB.ProjectName} should build"); - - var targets = new List { - "_RemoveRegisterAttribute", - "_BuildApkEmbed", - }; - var proj = new XamarinAndroidApplicationProject { - ProjectName = "AppA", - IsRelease = true, - AotAssemblies = aotAssemblies, - EnableDefaultItems = true, - Sources = { - new BuildItem.Source ("Bar.cs") { - TextContent = () => "public class Bar : Foo { }", - } - } - }; - // Mono-only test - proj.SetRuntime (AndroidRuntime.MonoVM); - proj.AddReference (libB); - if (aotAssemblies) { - targets.Add ("_AndroidAot"); - } - proj.SetRuntimeIdentifiers (supportedAbis.Split (';')); - if (!string.IsNullOrEmpty (androidAotMode)) - proj.SetProperty ("AndroidAotMode", androidAotMode); - using (var b = CreateApkBuilder (path)) { - if (!b.GetSupportedRuntimes ().Any (x => supportedAbis == x.Abi)) - Assert.Ignore ($"Runtime for {supportedAbis} was not available."); - - var apk = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath, $"{proj.PackageName}-Signed.apk"); - - b.BuildLogFile = "first.log"; - b.CleanupAfterSuccessfulBuild = false; - b.CleanupOnDispose = false; - b.ThrowOnBuildFailure = false; - Assert.AreEqual (expectedResult, b.Build (proj, doNotCleanupOnUpdate: true), "Build should have {0}.", expectedResult ? "succeeded" : "failed"); - if (!expectedResult) - return; - foreach (var target in targets) { - Assert.IsFalse (b.Output.IsTargetSkipped (target), $"`{target}` should *not* be skipped on first build!"); - } - AssertNativeLibrariesExist (); - - b.BuildLogFile = "second.log"; - b.CleanupAfterSuccessfulBuild = false; - b.CleanupOnDispose = false; - Assert.IsTrue (b.Build (proj, doNotCleanupOnUpdate: true), "Second build should have succeeded."); - foreach (var target in targets) { - Assert.IsTrue (b.Output.IsTargetSkipped (target), $"`{target}` should be skipped on second build!"); - } - AssertNativeLibrariesExist (); - - proj.Touch ("MainActivity.cs"); - - b.BuildLogFile = "third.log"; - b.CleanupAfterSuccessfulBuild = false; - b.CleanupOnDispose = false; - Assert.IsTrue (b.Build (proj, doNotCleanupOnUpdate: true), "Third build should have succeeded."); - foreach (var target in targets) { - Assert.IsFalse (b.Output.IsTargetSkipped (target), $"`{target}` should *not* be skipped on third build!"); - } - AssertNativeLibrariesExist (); - - void AssertNativeLibrariesExist () - { - FileAssert.Exists (apk); - if (!aotAssemblies) - return; - - using var zipFile = ZipHelper.OpenZip (apk); - foreach (var abi in supportedAbis.Split (';')) { - var path = $"lib/{abi}/libaot-Mono.Android.dll.so"; - var entry = ZipHelper.ReadFileFromZip (zipFile, path); - Assert.IsNotNull (entry, $"{path} should be in {apk}", abi); - } - } - } - } - - [Test] - public void DeterministicBuilds ([Values] bool deterministic, [Values] AndroidRuntime runtime) + public void DeterministicBuilds ([Values] bool deterministic, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1573,7 +1454,7 @@ public void DeterministicBuilds ([Values] bool deterministic, [Values] AndroidRu } [Test] - public void DesignTimeBuild ([Values] AndroidRuntime runtime) + public void DesignTimeBuild ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1609,7 +1490,7 @@ public void DesignTimeBuild ([Values] AndroidRuntime runtime) } [Test] - public void DesignTimeBuildSignAndroidPackage ([Values] AndroidRuntime runtime) + public void DesignTimeBuildSignAndroidPackage ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1646,7 +1527,7 @@ public void DesignTimeBuildSignAndroidPackage ([Values] AndroidRuntime runtime) } [Test] - public void ChangePackageNamingPolicy ([Values] AndroidRuntime runtime) + public void ChangePackageNamingPolicy ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1676,7 +1557,7 @@ public void ChangePackageNamingPolicy ([Values] AndroidRuntime runtime) } [Test] - public void MissingProjectReference ([Values] AndroidRuntime runtime) + public void MissingProjectReference ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1733,7 +1614,7 @@ public void MissingProjectReference ([Values] AndroidRuntime runtime) } [Test] - public void AaptError ([Values] AndroidRuntime runtime) + public void AaptError ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1757,7 +1638,7 @@ public void AaptError ([Values] AndroidRuntime runtime) } [Test] - public void AndroidResourceChange ([Values] AndroidRuntime runtime) + public void AndroidResourceChange ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1788,7 +1669,7 @@ public void AndroidResourceChange ([Values] AndroidRuntime runtime) } [Test] - public void AndroidAssetChange ([Values] AndroidRuntime runtime) + public void AndroidAssetChange ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1833,7 +1714,7 @@ void AssertAssetContents (string apk) } [Test] - public void AndroidAssetMissing ([Values] AndroidRuntime runtime) + public void AndroidAssetMissing ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1871,7 +1752,7 @@ public void AndroidAssetMissing ([Values] AndroidRuntime runtime) } [Test] - public void ChangeSupportedAbis ([Values] AndroidRuntime runtime) + public void ChangeSupportedAbis ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1904,7 +1785,7 @@ public void ChangeSupportedAbis ([Values] AndroidRuntime runtime) } [Test] - public void BuildPropsBreaksConvertResourcesCasesOnSecondBuild ([Values] AndroidRuntime runtime) + public void BuildPropsBreaksConvertResourcesCasesOnSecondBuild ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1949,7 +1830,7 @@ public void BuildPropsBreaksConvertResourcesCasesOnSecondBuild ([Values] Android } [Test] - public void AfterILLinkAdditionalStepsIsSkippedOnSecondBuild ([Values] AndroidRuntime runtime) + public void AfterILLinkAdditionalStepsIsSkippedOnSecondBuild ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/InvalidConfigTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/InvalidConfigTests.cs index 4d1f77bb090..c00b0c1846f 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/InvalidConfigTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/InvalidConfigTests.cs @@ -42,24 +42,6 @@ public class InvalidConfigTests : BaseTest }, }; - [Test] - [TestCaseSource (nameof (SettingCombinationsSource))] - public void SettingCombinations (bool isRelease, bool useInterpreter, bool publishTrimmed, bool aot, bool expected) - { - var proj = new XamarinAndroidApplicationProject { - IsRelease = isRelease, - EnableDefaultItems = true, - }; - // MonoVM-only test - proj.SetRuntime (Android.Tasks.AndroidRuntime.MonoVM); - proj.SetProperty ("UseInterpreter", useInterpreter.ToString ()); - proj.SetProperty ("PublishTrimmed", publishTrimmed.ToString ()); - proj.SetProperty ("RunAOTCompilation", aot.ToString ()); - var builder = CreateApkBuilder (); - builder.ThrowOnBuildFailure = false; - Assert.AreEqual (expected, builder.Build (proj), $"{proj.ProjectName} should {(expected ? "succeed" : "fail")}"); - } - [Test] public void EolFrameworks ([Values ("net6.0-android", "net7.0-android")] string targetFramework) { @@ -97,21 +79,5 @@ public void XA0119AAB () } } - [Test] - public void XA0119Interpreter () - { - var proj = new XamarinAndroidApplicationProject { - IsRelease = true, - AotAssemblies = true, - }; - // Mono-only test - proj.SetRuntime (AndroidRuntime.MonoVM); - proj.SetProperty ("UseInterpreter", "true"); - using (var builder = CreateApkBuilder ()) { - builder.ThrowOnBuildFailure = false; - Assert.IsTrue (builder.Build (proj), "Build should have succeeded."); - Assert.IsTrue (StringAssertEx.ContainsText (builder.LastBuildOutput, "XA0119"), "Output should contain XA0119 warnings"); - } - } } } diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/ManifestTest.TestCaseSource.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/ManifestTest.TestCaseSource.cs index d2ee2d84f88..db90ab95de1 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/ManifestTest.TestCaseSource.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/ManifestTest.TestCaseSource.cs @@ -18,7 +18,7 @@ static IEnumerable Get_DebuggerAttributeCases_Data () { var ret = new List (); - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }) { AddTestData ( "", true, false, runtime); AddTestData ( "", false, true, runtime); AddTestData ( "None", true, false, runtime); diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/ManifestTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/ManifestTest.cs index c11651105d0..45698ad1c29 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/ManifestTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/ManifestTest.cs @@ -72,7 +72,7 @@ protected override void OnCreate (Bundle bundle) "; [Test] - public void Bug12935 ([Values] AndroidRuntime runtime) + public void Bug12935 ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -131,7 +131,7 @@ public void Bug12935 ([Values] AndroidRuntime runtime) } [Test] - public void CheckElementReOrdering ([Values] AndroidRuntime runtime) + public void CheckElementReOrdering ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -182,7 +182,7 @@ static void AssertAttribute (XElement parent, XName name, string expected) } [Test] - public void OverlayManifestTest ([Values] AndroidRuntime runtime) + public void OverlayManifestTest ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -214,7 +214,7 @@ public void OverlayManifestTest ([Values] AndroidRuntime runtime) } [Test] - public void OverlayManifestIncrementalBuildTest ([Values] AndroidRuntime runtime) + public void OverlayManifestIncrementalBuildTest ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -264,7 +264,7 @@ public void OverlayManifestIncrementalBuildTest ([Values] AndroidRuntime runtime } [Test] - public void RemovePermissionTest ([Values] AndroidRuntime runtime) + public void RemovePermissionTest ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -294,7 +294,7 @@ public void RemovePermissionTest ([Values] AndroidRuntime runtime) } [Test] - public void IntentFilterData ([Values] AndroidRuntime runtime) + public void IntentFilterData ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -324,7 +324,7 @@ public void IntentFilterData ([Values] AndroidRuntime runtime) } [Test] - public void IntentFilterDataLists ([Values] AndroidRuntime runtime) + public void IntentFilterDataLists ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -358,7 +358,7 @@ public void IntentFilterDataLists ([Values] AndroidRuntime runtime) } [Test] - public void IntentFilterMultipleItems ([Values] AndroidRuntime runtime) + public void IntentFilterMultipleItems ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -381,7 +381,7 @@ public void IntentFilterMultipleItems ([Values] AndroidRuntime runtime) } [Test] - public void LayoutAttributeElement ([Values] AndroidRuntime runtime) + public void LayoutAttributeElement ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -408,7 +408,7 @@ public void LayoutAttributeElement ([Values] AndroidRuntime runtime) } [Test] - public void DirectBootAwareAttribute ([Values] AndroidRuntime runtime) + public void DirectBootAwareAttribute ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -570,66 +570,11 @@ public void DirectBootAwareAttribute ([Values] AndroidRuntime runtime) }, }; - // TODO: make it work on CoreCLR and NativeAOT - [Test] - [TestCaseSource(nameof (VersionCodeTestSource))] - public void VersionCodeTests (bool seperateApk, string abis, string versionCode, bool useLegacy, string versionCodePattern, string versionCodeProperties, bool shouldBuild, string expectedVersionCode) - { - var proj = new XamarinAndroidApplicationProject () { - IsRelease = true, - MinSdkVersion = "24", - SupportedOSPlatformVersion = "24.0", - }; - - // MonoVM-only test, for now (changing anything in the test data changes the codes, each case must be - // investigated and verified manually) - proj.SetRuntime (AndroidRuntime.MonoVM); - proj.SetProperty ("Foo", "1"); - proj.SetProperty ("GenerateApplicationManifest", "false"); // Disable $(AndroidVersionCode) support - proj.SetProperty (proj.ReleaseProperties, KnownProperties.AndroidCreatePackagePerAbi, seperateApk); - if (!string.IsNullOrEmpty (abis)) - proj.SetRuntimeIdentifiers (abis.Split (';')); - if (!string.IsNullOrEmpty (versionCodePattern)) - proj.SetProperty (proj.ReleaseProperties, "AndroidVersionCodePattern", versionCodePattern); - else - proj.RemoveProperty (proj.ReleaseProperties, "AndroidVersionCodePattern"); - if (!string.IsNullOrEmpty (versionCodeProperties)) - proj.SetProperty (proj.ReleaseProperties, "AndroidVersionCodeProperties", versionCodeProperties); - else - proj.RemoveProperty (proj.ReleaseProperties, "AndroidVersionCodeProperties"); - if (useLegacy) - proj.SetProperty (proj.ReleaseProperties, "AndroidUseLegacyVersionCode", true); - proj.AndroidManifest = proj.AndroidManifest.Replace ("android:versionCode=\"1\"", $"android:versionCode=\"{versionCode}\""); - using (var builder = CreateApkBuilder ()) { - builder.ThrowOnBuildFailure = false; - Assert.AreEqual (shouldBuild, builder.Build (proj), shouldBuild ? "Build should have succeeded." : "Build should have failed."); - if (!shouldBuild) - return; - var abiItems = seperateApk ? abis.Split (';') : new string[1]; - var expectedItems = expectedVersionCode.Split (';'); - XNamespace aNS = "http://schemas.android.com/apk/res/android"; - Assert.AreEqual (abiItems.Length, expectedItems.Length, "abis parameter should have matching elements for expected"); - for (int i = 0; i < abiItems.Length; i++) { - var path = seperateApk ? Path.Combine ("android", abiItems[i], "AndroidManifest.xml") : Path.Combine ("android", "manifest", "AndroidManifest.xml"); - var manifest = builder.Output.GetIntermediaryAsText (Root, path); - var doc = XDocument.Parse (manifest); - var nsResolver = new XmlNamespaceManager (new NameTable ()); - nsResolver.AddNamespace ("android", "http://schemas.android.com/apk/res/android"); - var m = doc.XPathSelectElement ("/manifest") as XElement; - Assert.IsNotNull (m, "no manifest element found"); - var vc = m.Attribute (aNS + "versionCode"); - Assert.IsNotNull (vc, "no versionCode attribute found"); - StringAssert.AreEqualIgnoringCase (expectedItems[i], vc.Value, - $"Version Code is incorrect. Found {vc.Value} expect {expectedItems[i]}"); - } - } - } - static IEnumerable Get_ApplicationVersionTests_Data () { var ret = new List (); - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }) { AddTestData ("1", false, "manifest=1", runtime); AddTestData ("1", true, "x86_64=500001;arm64-v8a=400001", runtime); AddTestData ("2", false, "manifest=2", runtime); @@ -691,7 +636,7 @@ public void ApplicationVersionTests (string applicationVersion, bool seperateApk } [Test] - public void ManifestDataPathError ([Values] AndroidRuntime runtime) + public void ManifestDataPathError ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -722,7 +667,7 @@ public void ManifestDataPathError ([Values] AndroidRuntime runtime) } [Test] - public void ManifestPlaceholders ([Values ("legacy", "manifestmerger.jar")] string manifestMerger, [Values] AndroidRuntime runtime) + public void ManifestPlaceholders ([Values ("legacy", "manifestmerger.jar")] string manifestMerger, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -751,7 +696,7 @@ public void ManifestPlaceholders ([Values ("legacy", "manifestmerger.jar")] stri } [Test] - public void ManifestPlaceHolders2 ([Values] AndroidRuntime runtime) + public void ManifestPlaceHolders2 ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -773,7 +718,7 @@ public void ManifestPlaceHolders2 ([Values] AndroidRuntime runtime) } [Test] - public void ManifestPlaceHoldersXA1010 ([Values ("legacy", "manifestmerger.jar")] string manifestMerger, [Values] AndroidRuntime runtime) + public void ManifestPlaceHoldersXA1010 ([Values ("legacy", "manifestmerger.jar")] string manifestMerger, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -824,7 +769,7 @@ public void DebuggerAttribute (string debugType, bool isRelease, bool expected, } [Test] - public void ModifyManifest ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void ModifyManifest ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -876,7 +821,7 @@ public void ModifyManifest ([Values] bool isRelease, [Values] AndroidRuntime run } [Test] - public void MergeLibraryManifest ([Values] AndroidRuntime runtime) + public void MergeLibraryManifest ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1001,7 +946,7 @@ public class TestActivity2 : FragmentActivity { } [Test] - public void AllActivityAttributeProperties ([Values ("legacy", "manifestmerger.jar")] string manifestMerger, [Values] AndroidRuntime runtime) + public void AllActivityAttributeProperties ([Values ("legacy", "manifestmerger.jar")] string manifestMerger, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1094,7 +1039,7 @@ static IEnumerable Get_AllForegroundServiceTypes_Data () { var ret = new List (); - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }) { AddTestData ("Android.Content.PM.ForegroundService.TypeSpecialUse", "specialUse", runtime); AddTestData ("Android.Content.PM.ForegroundService.TypeConnectedDevice", "connectedDevice", runtime); AddTestData ("Android.Content.PM.ForegroundService.TypeCamera|Android.Content.PM.ForegroundService.TypeMicrophone", "camera|microphone", runtime); @@ -1144,7 +1089,7 @@ public void AllForegroundServiceTypes (string serviceType, string expected, Andr } [Test] - public void AllServiceAttributeProperties ([Values ("legacy", "manifestmerger.jar")] string manifestMerger, [Values] AndroidRuntime runtime) + public void AllServiceAttributeProperties ([Values ("legacy", "manifestmerger.jar")] string manifestMerger, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1198,7 +1143,7 @@ public void AllServiceAttributeProperties ([Values ("legacy", "manifestmerger.ja /// https://github.com/microsoft/dotnet-podcasts/blob/09b733b406ecb128f026645ef4c7e69c773f8a4b/src/Mobile/Platforms/Android/Services/MediaPlayerService.cs#L15-L16 /// [Test] - public void ExportedErrorMessage ([Values] AndroidRuntime runtime) + public void ExportedErrorMessage ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1255,7 +1200,7 @@ static IEnumerable Get_SupportedOSTestSources_Data () { var ret = new List (); - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }) { AddTestData ( minSdkVersion: "", removeUsesSdkElement: true, @@ -1384,7 +1329,7 @@ static IEnumerable Get_SupportedOSErrorsTestSources_Data () { var ret = new List (); - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }) { AddTestData ( minSdkVersion: "", supportedOSPlatVers: "", @@ -1639,7 +1584,7 @@ public class TestService : global::Android.App.Service } [Test] - public void UsesPermissionFlagsAttribute ([Values] AndroidRuntime runtime) + public void UsesPermissionFlagsAttribute ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/MarshalMethodTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/MarshalMethodTests.cs index 0cde483e044..57e0e3fbdf6 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/MarshalMethodTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/MarshalMethodTests.cs @@ -12,154 +12,6 @@ namespace Xamarin.Android.Build.Tests; public class MarshalMethodTests : BaseTest { - [Test] - public void MarshalMethodsCollectionScanning () - { - // This test does 2 things: - // - Builds a binding project in Debug mode to create an assembly that contains convertible - // marshal methods to ensure they are found by MarshalMethodsCollection - // - Builds the same project in Release mode which rewrites the assembly to ensure those - // same marshal methods can be found after they are rewritten - var proj = new XamarinAndroidApplicationProject { - ProjectName = "mmtest", - }; - - // Mono-only test. - // Managed typemaps have known issues in CoreCLR and will be replaced by a different - // implementation at some point. - proj.SetRuntime (AndroidRuntime.MonoVM); - - proj.Sources.Add (new AndroidItem.AndroidLibrary ("javaclasses.jar") { - BinaryContent = () => ResourceData.JavaSourceJarTestJar, - }); - - proj.AndroidJavaSources.Add (new AndroidItem.AndroidJavaSource ("JavaSourceTestInterface.java") { - Encoding = Encoding.ASCII, - TextContent = () => ResourceData.JavaSourceTestInterface, - Metadata = { { "Bind", "True" } }, - }); - - proj.AndroidJavaSources.Add (new AndroidItem.AndroidJavaSource ("JavaSourceTestExtension.java") { - Encoding = Encoding.ASCII, - TextContent = () => ResourceData.JavaSourceTestExtension, - Metadata = { { "Bind", "True" } }, - }); - - proj.MainActivity = proj.DefaultMainActivity.Replace ("//${AFTER_MAINACTIVITY}", """ - // Implements Java interface method - class MyGreeter : Java.Lang.Object, Com.Xamarin.Android.Test.Msbuildtest.IJavaSourceTestInterface { - public virtual string? GreetWithQuestion (string? p0, Java.Util.Date? p1, string? p2) => "greetings!"; - } - - // Overrides implemented Java interface method - class MyExtendedGreeter : MyGreeter { - public override string? GreetWithQuestion (string? p0, Java.Util.Date? p1, string? p2) => "more greetings!"; - } - - // Implements Java interface method (duplicate) - class MyGreeter2 : Java.Lang.Object, Com.Xamarin.Android.Test.Msbuildtest.IJavaSourceTestInterface { - public virtual string? GreetWithQuestion (string? p0, Java.Util.Date? p1, string? p2) => "duplicate greetings!"; - } - - // Overrides Java class method - class MyOverriddenGreeter : Com.Xamarin.Android.Test.Msbuildtest.JavaSourceTestExtension { - public override string? GreetWithQuestion (string? p0, Java.Util.Date? p1, string? p2) => "even more greetings!"; - } - """); - - var builder = CreateApkBuilder (); - Assert.IsTrue (builder.Build (proj), "`dotnet build` should succeed"); - builder.AssertHasNoWarnings (); - - var intermediateDebugOutputPath = Path.Combine (Root, builder.ProjectDirectory, proj.IntermediateOutputPath, "android", "assets", "arm64-v8a"); - var outputDebugDll = Path.Combine (intermediateDebugOutputPath, $"{proj.ProjectName}.dll"); - - var log = new TaskLoggingHelper (new MockBuildEngine (TestContext.Out, [], [], []), nameof (MarshalMethodsCollectionScanning)); - var xaResolver = new XAAssemblyResolver (Tools.AndroidTargetArch.Arm64, log, false); - xaResolver.SearchDirectories.Add (Path.GetDirectoryName (outputDebugDll)!); - - var collection = MarshalMethodsCollection.FromAssemblies (Tools.AndroidTargetArch.Arm64, [CreateItem (outputDebugDll, "arm64-v8a")], xaResolver, log); - - Assert.AreEqual (3, collection.MarshalMethods.Count); - Assert.AreEqual (0, collection.ConvertedMarshalMethods.Count); - - var key1 = "Android.App.Activity, Mono.Android\tOnCreate"; - var key2 = "Com.Xamarin.Android.Test.Msbuildtest.IJavaSourceTestInterface, mmtest\tGreetWithQuestion"; - var key3 = "Com.Xamarin.Android.Test.Msbuildtest.JavaSourceTestExtension, mmtest\tGreetWithQuestion"; - - Assert.AreEqual (1, collection.MarshalMethods [key1].Count); - Assert.AreEqual (2, collection.MarshalMethods [key2].Count); - Assert.AreEqual (1, collection.MarshalMethods [key3].Count); - - AssertMarshalMethodData (collection.MarshalMethods [key1] [0], - callbackField: null, - connector: "System.Delegate Android.App.Activity::GetOnCreate_Landroid_os_Bundle_Handler()", - declaringType: "mmtest.MainActivity", - implementedMethod: "System.Void mmtest.MainActivity::OnCreate(Android.OS.Bundle)", - jniMethodName: "onCreate", - jniMethodSignature: "(Landroid/os/Bundle;)V", - jniTypeName: "com/xamarin/marshalmethodscollectionscanning/MainActivity", - nativeCallback: "System.Void Android.App.Activity::n_OnCreate_Landroid_os_Bundle_(System.IntPtr,System.IntPtr,System.IntPtr)", - registeredMethod: "System.Void Android.App.Activity::OnCreate(Android.OS.Bundle)"); - - AssertMarshalMethodData (collection.MarshalMethods [key2] [0], - callbackField: null, - connector: "System.Delegate Com.Xamarin.Android.Test.Msbuildtest.IJavaSourceTestInterfaceInvoker::GetGreetWithQuestion_Ljava_lang_String_Ljava_util_Date_Ljava_lang_String_Handler()", - declaringType: "mmtest.MyGreeter", - implementedMethod: "System.String Com.Xamarin.Android.Test.Msbuildtest.IJavaSourceTestInterface::GreetWithQuestion(System.String,Java.Util.Date,System.String)", - jniMethodName: "greetWithQuestion", - jniMethodSignature: "(Ljava/lang/String;Ljava/util/Date;Ljava/lang/String;)Ljava/lang/String;", - jniTypeName: "crc644a923d2fc5ca7023/MyGreeter", - nativeCallback: "System.IntPtr Com.Xamarin.Android.Test.Msbuildtest.IJavaSourceTestInterfaceInvoker::n_GreetWithQuestion_Ljava_lang_String_Ljava_util_Date_Ljava_lang_String_(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr)", - registeredMethod: "System.String Com.Xamarin.Android.Test.Msbuildtest.IJavaSourceTestInterface::GreetWithQuestion(System.String,Java.Util.Date,System.String)"); - - AssertMarshalMethodData (collection.MarshalMethods [key2] [1], - callbackField: null, - connector: "System.Delegate Com.Xamarin.Android.Test.Msbuildtest.IJavaSourceTestInterfaceInvoker::GetGreetWithQuestion_Ljava_lang_String_Ljava_util_Date_Ljava_lang_String_Handler()", - declaringType: "mmtest.MyGreeter2", - implementedMethod: "System.String Com.Xamarin.Android.Test.Msbuildtest.IJavaSourceTestInterface::GreetWithQuestion(System.String,Java.Util.Date,System.String)", - jniMethodName: "greetWithQuestion", - jniMethodSignature: "(Ljava/lang/String;Ljava/util/Date;Ljava/lang/String;)Ljava/lang/String;", - jniTypeName: "crc644a923d2fc5ca7023/MyGreeter2", - nativeCallback: "System.IntPtr Com.Xamarin.Android.Test.Msbuildtest.IJavaSourceTestInterfaceInvoker::n_GreetWithQuestion_Ljava_lang_String_Ljava_util_Date_Ljava_lang_String_(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr)", - registeredMethod: "System.String Com.Xamarin.Android.Test.Msbuildtest.IJavaSourceTestInterface::GreetWithQuestion(System.String,Java.Util.Date,System.String)"); - - AssertMarshalMethodData (collection.MarshalMethods [key3] [0], - callbackField: null, - connector: "System.Delegate Com.Xamarin.Android.Test.Msbuildtest.JavaSourceTestExtension::GetGreetWithQuestion_Ljava_lang_String_Ljava_util_Date_Ljava_lang_String_Handler()", - declaringType: "mmtest.MyOverriddenGreeter", - implementedMethod: "System.String mmtest.MyOverriddenGreeter::GreetWithQuestion(System.String,Java.Util.Date,System.String)", - jniMethodName: "greetWithQuestion", - jniMethodSignature: "(Ljava/lang/String;Ljava/util/Date;Ljava/lang/String;)Ljava/lang/String;", - jniTypeName: "crc644a923d2fc5ca7023/MyOverriddenGreeter", - nativeCallback: "System.IntPtr Com.Xamarin.Android.Test.Msbuildtest.JavaSourceTestExtension::n_GreetWithQuestion_Ljava_lang_String_Ljava_util_Date_Ljava_lang_String_(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr)", - registeredMethod: "System.String Com.Xamarin.Android.Test.Msbuildtest.JavaSourceTestExtension::GreetWithQuestion(System.String,Java.Util.Date,System.String)"); - - // Recompile with Release so marshal methods get rewritten - proj.IsRelease = true; - - Assert.IsTrue (builder.Build (proj), "`dotnet build` should succeed"); - builder.AssertHasNoWarnings (); - - // Rescan for modified marshal methods from the linked/ directory. - // When marshal methods are enabled, AssemblyModifierPipeline writes in-place - // to linked/ (not afterlink/) so that _RunAotForAllRIDs re-AOTs correctly. - var intermediateReleaseOutputPath = Path.Combine (Root, builder.ProjectDirectory, proj.IntermediateOutputPath, "android-arm64", "linked"); - var outputReleaseDll = Path.Combine (intermediateReleaseOutputPath, $"{proj.ProjectName}.dll"); - - xaResolver = new XAAssemblyResolver (Tools.AndroidTargetArch.Arm64, log, false); - xaResolver.SearchDirectories.Add (Path.GetDirectoryName (outputReleaseDll)!); - - var releaseCollection = MarshalMethodsCollection.FromAssemblies (Tools.AndroidTargetArch.Arm64, [CreateItem (outputReleaseDll, "arm64-v8a")], xaResolver, log); - - Assert.AreEqual (0, releaseCollection.MarshalMethods.Count); - Assert.AreEqual (3, releaseCollection.ConvertedMarshalMethods.Count); - - AssertRewrittenMethodData (releaseCollection.ConvertedMarshalMethods [key1] [0], collection.MarshalMethods [key1] [0]); - AssertRewrittenMethodData (releaseCollection.ConvertedMarshalMethods [key2] [0], collection.MarshalMethods [key2] [0]); - AssertRewrittenMethodData (releaseCollection.ConvertedMarshalMethods [key2] [1], collection.MarshalMethods [key2] [1]); - AssertRewrittenMethodData (releaseCollection.ConvertedMarshalMethods [key3] [0], collection.MarshalMethods [key3] [0]); - } void AssertMarshalMethodData (MarshalMethodEntry entry, string? callbackField, string? connector, string? declaringType, string? implementedMethod, string? jniMethodName, string? jniMethodSignature, string? jniTypeName, diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs index ea19d25ad0f..11bd0a3534e 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs @@ -17,7 +17,7 @@ namespace Xamarin.Android.Build.Tests public class PackagingTest : BaseTest { [Test] - public void CheckProguardMappingFileExists ([Values] AndroidRuntime runtime) + public void CheckProguardMappingFileExists ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -40,7 +40,7 @@ public void CheckProguardMappingFileExists ([Values] AndroidRuntime runtime) } [Test] - public void CheckR8InfoMessagesToNotBreakTheBuild ([Values] AndroidRuntime runtime) + public void CheckR8InfoMessagesToNotBreakTheBuild ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -68,7 +68,7 @@ public void CheckR8InfoMessagesToNotBreakTheBuild ([Values] AndroidRuntime runti } [Test] - public void CheckDebugModeWithTrimming ([Values (AndroidRuntime.MonoVM, AndroidRuntime.CoreCLR)] AndroidRuntime runtime) + public void CheckDebugModeWithTrimming ([Values (AndroidRuntime.CoreCLR)] AndroidRuntime runtime) { bool usesAssemblyStores = runtime == AndroidRuntime.CoreCLR; var proj = new XamarinAndroidApplicationProject { @@ -95,7 +95,7 @@ public void CheckDebugModeWithTrimming ([Values (AndroidRuntime.MonoVM, AndroidR [Test] [NonParallelizable] // Commonly fails NuGet restore - public void CheckIncludedAssemblies ([Values (false, true)] bool usesAssemblyStores, [Values (AndroidRuntime.MonoVM, AndroidRuntime.CoreCLR)] AndroidRuntime runtime) + public void CheckIncludedAssemblies ([Values (false, true)] bool usesAssemblyStores, [Values (AndroidRuntime.CoreCLR)] AndroidRuntime runtime) { if (!usesAssemblyStores && runtime == AndroidRuntime.CoreCLR) { Assert.Ignore ("CoreCLR only supports builds with assembly stores."); @@ -176,7 +176,7 @@ static IEnumerable Get_CheckProjectWithSpaceInNameWorks_Data () { var ret = new List (); - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }) { AddTestData ("Test Me", runtime); // testing characters as per https://www.compart.com/en/unicode/category/Zs @@ -219,7 +219,7 @@ public void CheckProjectWithSpaceInNameWorks (string projectName, AndroidRuntime } [Test] - public void CheckClassesDexIsIncluded ([Values] AndroidRuntime runtime) + public void CheckClassesDexIsIncluded ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -241,7 +241,7 @@ public void CheckClassesDexIsIncluded ([Values] AndroidRuntime runtime) [Test] [Parallelizable (ParallelScope.Self)] - public void CheckIncludedNativeLibraries ([Values] bool compressNativeLibraries, [Values] AndroidRuntime runtime) + public void CheckIncludedNativeLibraries ([Values] bool compressNativeLibraries, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -272,7 +272,7 @@ public void CheckIncludedNativeLibraries ([Values] bool compressNativeLibraries, } [Test] - public void EmbeddedDSOs ([Values] AndroidRuntime runtime) + public void EmbeddedDSOs ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -336,7 +336,7 @@ void AssertCompression (ZipEntry entry, bool compressed) } [Test] - public void IncrementalCompression ([Values] AndroidRuntime runtime) + public void IncrementalCompression ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -387,7 +387,7 @@ public void IncrementalCompression ([Values] AndroidRuntime runtime) } [Test] - public void ExplicitPackageNamingPolicy ([Values] AndroidRuntime runtime) + public void ExplicitPackageNamingPolicy ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -415,7 +415,7 @@ public void ExplicitPackageNamingPolicy ([Values] AndroidRuntime runtime) } [Test] - public void CheckMetadataSkipItemsAreProcessedCorrectly ([Values] AndroidRuntime runtime) + public void CheckMetadataSkipItemsAreProcessedCorrectly ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -512,7 +512,7 @@ public void Exported () } [Test] - public void CheckSignApk ([Values] bool useApkSigner, [Values] bool perAbiApk, [Values] AndroidRuntime runtime) + public void CheckSignApk ([Values] bool useApkSigner, [Values] bool perAbiApk, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -624,7 +624,7 @@ int GetVersionCodeFromIntermediateManifest (string manifestFilePath) } [Test] - public void CheckAppBundle ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void CheckAppBundle ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -656,7 +656,7 @@ public void CheckAppBundle ([Values] bool isRelease, [Values] AndroidRuntime run } [Test] - public void MissingSatelliteAssemblyInLibrary ([Values] AndroidRuntime runtime) + public void MissingSatelliteAssemblyInLibrary ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -714,7 +714,7 @@ public void MissingSatelliteAssemblyInLibrary ([Values] AndroidRuntime runtime) } [Test] - public void MissingSatelliteAssemblyInApp ([Values] bool publishAot, [Values] AndroidRuntime runtime) + public void MissingSatelliteAssemblyInApp ([Values] bool publishAot, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -762,90 +762,8 @@ public void MissingSatelliteAssemblyInApp ([Values] bool publishAot, [Values] An } } - /// - /// Verifies that _PostTrimmingPipeline does not include satellite assemblies - /// (.resources.dll) in its input. Satellite assemblies are not processed by - /// ILLink and retain their original paths in the shared NuGet package cache. - /// Including them causes PostTrimmingPipeline to open them with ReadWrite - /// access, leading to IOException in parallel multi-RID builds. - /// See: https://github.com/dotnet/android/issues/11085 - /// [Test] - [NonParallelizable] // Commonly fails NuGet restore - public void PostTrimmingPipelineExcludesSatelliteAssemblies () - { - var proj = new XamarinAndroidApplicationProject { - IsRelease = true, - }; - proj.SetRuntime (AndroidRuntime.MonoVM); - proj.SetRuntimeIdentifiers (AndroidTargetArch.Arm64); - proj.PackageReferences.Add (new Package { - Id = "Humanizer.Core", - Version = "2.14.1", - }); - proj.PackageReferences.Add (new Package { - Id = "Humanizer.Core.es", - Version = "2.14.1", - }); - proj.MainActivity = proj.DefaultMainActivity - .Replace ("//${USINGS}", @"using Humanizer; -using System.Globalization;") - .Replace ("//${AFTER_ONCREATE}", @"var c = new CultureInfo (""es-ES""); -Console.WriteLine ($""{DateTime.UtcNow.AddHours(-30).Humanize(culture:c)}"");"); - proj.OtherBuildItems.Add (new BuildItem ("Using", "System.Globalization")); - proj.OtherBuildItems.Add (new BuildItem ("Using", "Humanizer")); - - // Inject a diagnostic target that logs the _PostTrimmingAssembly items - // created by the production _PostTrimmingPipeline target. In MSBuild, - // items defined in a target's are visible to subsequent targets. - proj.Imports.Add (new Import ("PostTrimmingDiag.targets") { - TextContent = () => """ - - - - - - - """, - }); - - using var b = CreateApkBuilder (); - Assert.IsTrue (b.Build (proj), "Build should have succeeded."); - - // Verify the diagnostic target actually ran and logged assemblies - Assert.IsTrue ( - b.LastBuildOutput.ContainsText ("DIAG_PTA:"), - "Diagnostic target should have logged _PostTrimmingAssembly items"); - - // Verify satellite assemblies ARE present in ResolvedFileToPublish (positive check) - bool hasSatelliteInRfp = false; - foreach (var line in b.LastBuildOutput) { - if (line.Contains ("DIAG_RFP:") && line.Contains (".resources.dll")) { - hasSatelliteInRfp = true; - break; - } - } - Assert.IsTrue (hasSatelliteInRfp, - "Satellite assemblies should be present in ResolvedFileToPublish to confirm the scenario is exercised"); - - // Verify satellite assemblies were NOT included in _PostTrimmingAssembly - var satelliteLines = new List (); - foreach (var line in b.LastBuildOutput) { - if (line.Contains ("DIAG_PTA:") && line.Contains (".resources.dll")) { - satelliteLines.Add (line.Trim ()); - } - } - Assert.IsEmpty (satelliteLines, - "Satellite assemblies (.resources.dll) should not be passed to PostTrimmingPipeline. " + - "They retain paths in the shared NuGet cache and cause file locking conflicts in parallel RID builds. Found:\n" + - string.Join ("\n", satelliteLines)); - } - - [Test] - public void IgnoreManifestFromJar ([Values] AndroidRuntime runtime) + public void IgnoreManifestFromJar ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -903,7 +821,7 @@ public class Test } [Test] - public void CheckExcludedFilesAreMissing ([Values] AndroidRuntime runtime) + public void CheckExcludedFilesAreMissing ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -928,7 +846,7 @@ public void CheckExcludedFilesAreMissing ([Values] AndroidRuntime runtime) } [Test] - public void CheckExcludedFilesCanBeModified ([Values] AndroidRuntime runtime) + public void CheckExcludedFilesCanBeModified ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -961,7 +879,7 @@ public void CheckExcludedFilesCanBeModified ([Values] AndroidRuntime runtime) } [Test] - public void CheckIncludedFilesArePresent ([Values] AndroidRuntime runtime) + public void CheckIncludedFilesArePresent ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -986,7 +904,7 @@ static IEnumerable Get_BuildApkWithZipFlushLimits_Data () { var ret = new List (); - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }) { AddTestData (1, -1, runtime); AddTestData (5, -1, runtime); AddTestData (50, -1, runtime); @@ -1036,7 +954,7 @@ public void BuildApkWithZipFlushLimits (int filesLimit, int sizeLimit, AndroidRu } [Test] - public void ExtractNativeLibsTrue ([Values] AndroidRuntime runtime) + public void ExtractNativeLibsTrue ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1072,7 +990,7 @@ public void ExtractNativeLibsTrue ([Values] AndroidRuntime runtime) } [Test] - public void DefaultItems ([Values] AndroidRuntime runtime) + public void DefaultItems ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/SingleProjectTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/SingleProjectTest.cs index 6979535acd7..2dce3333f2e 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/SingleProjectTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/SingleProjectTest.cs @@ -18,7 +18,7 @@ static IEnumerable Get_AndroidManifestProperties_Data () { var ret = new List (); - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }) { AddTestData ( // TODO: this has changed across all the runtimes from the previous "2.1" to its current value. // Check if it's a valid change. @@ -151,7 +151,7 @@ public void AndroidManifestProperties (string versionName, string versionCode, s } [Test] - public void AndroidManifestValuesWin ([Values] AndroidRuntime runtime) + public void AndroidManifestValuesWin ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/AndroidResourceTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/AndroidResourceTests.cs index 57e3e7dabc6..fc24e5348d2 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/AndroidResourceTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/AndroidResourceTests.cs @@ -156,7 +156,7 @@ public void UserLayout () } [Test] - public void AdaptiveIcon ([Values] AndroidRuntime runtime) + public void AdaptiveIcon ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/LinkerTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/LinkerTests.cs index 1dc50e6de9c..6c097b7fa93 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/LinkerTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/LinkerTests.cs @@ -162,7 +162,7 @@ static AssemblyDefinition CreateFauxMonoAndroidAssembly () } [Test] - public void WarnAboutAppDomains ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void WarnAboutAppDomains ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -205,7 +205,7 @@ public void WarnAboutAppDomains ([Values] bool isRelease, [Values] AndroidRuntim } [Test] - public void RemoveDesigner ([Values (true, false)] bool useAssemblyStore, [Values (AndroidRuntime.MonoVM, AndroidRuntime.CoreCLR)] AndroidRuntime runtime) + public void RemoveDesigner ([Values (true, false)] bool useAssemblyStore, [Values (AndroidRuntime.CoreCLR)] AndroidRuntime runtime) { if (!useAssemblyStore && runtime == AndroidRuntime.CoreCLR) { Assert.Ignore ("CoreCLR supports only assembly stores"); @@ -247,7 +247,7 @@ public void RemoveDesigner ([Values (true, false)] bool useAssemblyStore, [Value } [Test] - public void LinkDescription ([Values (true, false)] bool useAssemblyStore, [Values (AndroidRuntime.MonoVM, AndroidRuntime.CoreCLR)] AndroidRuntime runtime) + public void LinkDescription ([Values (true, false)] bool useAssemblyStore, [Values (AndroidRuntime.CoreCLR)] AndroidRuntime runtime) { if (!useAssemblyStore && runtime == AndroidRuntime.CoreCLR) { Assert.Ignore ("CoreCLR doesn't support builds without assembly stores."); @@ -304,7 +304,7 @@ public void LinkDescription ([Values (true, false)] bool useAssemblyStore, [Valu } [Test] - public void LinkWithNullAttribute ([Values] AndroidRuntime runtime) + public void LinkWithNullAttribute ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -359,7 +359,7 @@ static IEnumerable Get_AndroidAddKeepAlivesData () { var ret = new List (); - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }) { // Debug configuration AddTestData (isRelease: false, setAndroidAddKeepAlivesTrue: false, setLinkModeNone: false, shouldAddKeepAlives: false, runtime); @@ -505,7 +505,7 @@ void CheckAssembly (string assemblyPath, string projectDir) } [Test] - public void AndroidUseNegotiateAuthentication ([Values (true, false, null)] bool? useNegotiateAuthentication, [Values] AndroidRuntime runtime) + public void AndroidUseNegotiateAuthentication ([Values (true, false, null)] bool? useNegotiateAuthentication, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -543,7 +543,7 @@ public void AndroidUseNegotiateAuthentication ([Values (true, false, null)] bool } [Test] - public void PreserveIX509TrustManagerSubclasses ([Values] bool hasServerCertificateCustomValidationCallback, [Values] AndroidRuntime runtime) + public void PreserveIX509TrustManagerSubclasses ([Values] bool hasServerCertificateCustomValidationCallback, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -582,7 +582,7 @@ public void PreserveIX509TrustManagerSubclasses ([Values] bool hasServerCertific } [Test] - public void PreserveServices ([Values] AndroidRuntime runtime) + public void PreserveServices ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -625,7 +625,7 @@ protected override void OnNewIntent (Android.Content.Intent? intent) [Test] public void DoNotErrorOnPerArchJavaTypeDuplicates ( [Values(true, false)] bool enableMarshalMethods, - [Values(AndroidRuntime.MonoVM, AndroidRuntime.CoreCLR)] AndroidRuntime runtime) + [Values (AndroidRuntime.CoreCLR)] AndroidRuntime runtime) { if (enableMarshalMethods == true && runtime == AndroidRuntime.CoreCLR) { // This currently fails with the following exception: @@ -728,7 +728,7 @@ void Assert64Bit(string rid, bool expected64) } [Test] - public void WarnWithReferenceToPreserveAttribute ([Values] AndroidRuntime runtime) + public void WarnWithReferenceToPreserveAttribute ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ManagedResourceParserTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ManagedResourceParserTests.cs index aaff26bd489..a708ebf0bd8 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ManagedResourceParserTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ManagedResourceParserTests.cs @@ -487,7 +487,7 @@ public void GenerateDesignerFileWithÜmläüts () } [Test] - public void GenerateDesignerFileFromRtxt ([Values] bool withLibraryReference, [Values] AndroidRuntime runtime) + public void GenerateDesignerFileFromRtxt ([Values] bool withLibraryReference, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { // TODO: fix NativeAOT, it currently fails with: // diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/NdkUtilTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/NdkUtilTests.cs index 593aeacc9ef..0389caeaf35 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/NdkUtilTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/NdkUtilTests.cs @@ -26,7 +26,7 @@ public void Setup () } [Test] - public void TestNdkUtil ([Values] AndroidRuntime runtime) + public void TestNdkUtil ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { var log = new TaskLoggingHelper (engine, TestName); using (var builder = new Builder ()) { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ResolveMonoAndroidSdksTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ResolveMonoAndroidSdksTests.cs index 45f522b886f..f46f0cf41c2 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ResolveMonoAndroidSdksTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ResolveMonoAndroidSdksTests.cs @@ -41,7 +41,7 @@ static Dictionary ValuesFromLog (ProjectBuilder b) } [Test] - public void NormalInputs ([Values] AndroidRuntime runtime) + public void NormalInputs ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -72,7 +72,7 @@ public void NormalInputs ([Values] AndroidRuntime runtime) } [Test] - public void MissingAndroidNDK ([Values] AndroidRuntime runtime) + public void MissingAndroidNDK ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -103,7 +103,7 @@ public void MissingAndroidNDK ([Values] AndroidRuntime runtime) } [Test] - public void HasTrailingSlash ([Values] AndroidRuntime runtime) + public void HasTrailingSlash ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/ProjectExtensions.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/ProjectExtensions.cs index fcaa4d86631..41e701a39e2 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/ProjectExtensions.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/ProjectExtensions.cs @@ -1,7 +1,5 @@ using System; -using NUnit.Framework; - using Xamarin.Android.Tasks; using Xamarin.ProjectTools; @@ -49,7 +47,6 @@ static void DoSetRuntime (XamarinProject project, AndroidRuntime runtime) project.SetProperty ("PublishAot", "true"); break; case AndroidRuntime.MonoVM: - Assert.Ignore ("The Mono runtime is not supported in .NET 11 and later. Use the .NET 10 SDK to build with the Mono runtime."); project.SetProperty ("UseMonoRuntime", "true"); break; diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/WearTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/WearTests.cs index e45a9aff2b7..c992f2df335 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/WearTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/WearTests.cs @@ -9,7 +9,7 @@ namespace Xamarin.Android.Build.Tests public class WearTests : BaseTest { [Test] - public void BasicProject ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void BasicProject ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -24,7 +24,7 @@ public void BasicProject ([Values] bool isRelease, [Values] AndroidRuntime runti } [Test] - public void BundledWearApp ([Values] AndroidRuntime runtime) + public void BundledWearApp ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -56,7 +56,7 @@ public void BundledWearApp ([Values] AndroidRuntime runtime) } [Test] - public void WearProjectJavaBuildFailure ([Values] AndroidRuntime runtime) + public void WearProjectJavaBuildFailure ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs index c43bc312316..7a7af12254a 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs @@ -50,7 +50,7 @@ static IEnumerable Get_DotNetPack_Data () { var ret = new List (); - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }) { AddTestData ( dotnetVersion: XABuildConfig.PreviousDotNetTargetFramework, platform: "android", @@ -91,7 +91,7 @@ void AddTestData (string dotnetVersion, string platform, Version apiLevel, Andro [Test] [TestCaseSource (nameof (Get_DotNetPack_Data))] - public void DotNetPack (string dotnetVersion, string platform, Version apiLevel, [Values] AndroidRuntime runtime) + public void DotNetPack (string dotnetVersion, string platform, Version apiLevel, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -197,7 +197,7 @@ static IEnumerable Get_DotNetTargetFrameworks_Data () { var ret = new List (); - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }) { AddTestData ( dotnetVersion: XABuildConfig.PreviousDotNetTargetFramework, platform: "android", @@ -254,7 +254,7 @@ static bool IsPreviewFrameworkVersion (string targetFramework) } [Test] - public void DotNetPublishDefaultValues ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void DotNetPublishDefaultValues ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; From 72788a388904b16330b5a2e4400378dd842ca1d7 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Tue, 16 Jun 2026 11:58:15 +0200 Subject: [PATCH 10/10] [mobile] Remove Mono runtime variants from device integration tests The Mono mobile runtime is no longer supported for Android in .NET 11, so building a project with UseMonoRuntime=true now errors with NETSDK1242. The device integration test suite still enumerated AndroidRuntime.MonoVM through [Values], Enum.GetValues, [Values(...)] and [TestCase(...)], causing those emulator legs to fail. Drop the MonoVM variants and keep CoreCLR and NativeAOT, matching the conversion already applied to Xamarin.Android.Build.Tests. Mono-only tests (AOT profiler, interpreter, LLVM, AppDomain.UnhandledException, and the MonoVM-only debugger break tests) are removed. Tests that merely pinned MonoVM now use the default CoreCLR runtime. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Tests/AotProfileTests.cs | 64 --- .../Tests/BundleToolNoAbiSplitTests.cs | 2 +- .../Tests/BundleToolTests.cs | 2 +- .../Tests/DebuggingTest.cs | 482 +----------------- .../Tests/InstallAndRunTests.cs | 183 +------ .../Tests/InstallTests.cs | 6 +- .../Tests/LocalizationTests.cs | 2 +- .../Tests/MarshalMethodsGCHangTests.cs | 2 +- .../Tests/MonoAndroidExportTest.cs | 4 +- .../Tests/PerformanceTest.cs | 2 - .../Tests/SystemApplicationTests.cs | 2 +- .../Tests/TimeZoneInfoTests.cs | 2 +- .../Tests/UncaughtExceptionTests.cs | 2 +- 13 files changed, 36 insertions(+), 719 deletions(-) delete mode 100644 tests/MSBuildDeviceIntegration/Tests/AotProfileTests.cs diff --git a/tests/MSBuildDeviceIntegration/Tests/AotProfileTests.cs b/tests/MSBuildDeviceIntegration/Tests/AotProfileTests.cs deleted file mode 100644 index 344b43caf31..00000000000 --- a/tests/MSBuildDeviceIntegration/Tests/AotProfileTests.cs +++ /dev/null @@ -1,64 +0,0 @@ -using NUnit.Framework; -using System; -using System.IO; -using System.Net; -using Xamarin.ProjectTools; - -namespace Xamarin.Android.Build.Tests -{ - [Category ("UsesDevice"), Category ("AOT"), Category ("ProfiledAOT")] - public class AotProfileTests : DeviceTest - { - [TearDown] - protected void ClearProp () - { - ClearShellProp ("debug.mono.profile"); - } - - readonly string PermissionManifest = @" - - - - - -"; - - [Test] - [NonParallelizable] - public void BuildBasicApplicationAndAotProfileIt () - { - var proj = new XamarinAndroidApplicationProject () { - IsRelease = true, - AotAssemblies = false, - }; - // MonoVM-only test - proj.SetRuntime (Android.Tasks.AndroidRuntime.MonoVM); - proj.SetRuntimeIdentifiers (new[] { DeviceAbi }); - - // TODO: only needed in .NET 6+ - // See https://github.com/dotnet/runtime/issues/56989 - proj.PackageReferences.Add (KnownPackages.Mono_AotProfiler_Android); - - var port = 9000 + new Random ().Next (1000); - proj.SetProperty ("AndroidAotProfilerPort", port.ToString ()); - proj.AndroidManifest = string.Format (PermissionManifest, proj.PackageName); - var projDirectory = Path.Combine ("temp", TestName); - using (var b = CreateApkBuilder (projDirectory)) { - Assert.IsTrue (b.RunTarget (proj, "BuildAndStartAotProfiling"), "Run of BuildAndStartAotProfiling should have succeeded."); - WaitForAppBuiltForOlderAndroidWarning (proj.PackageName, Path.Combine (Root, b.ProjectDirectory, "oldsdk-logcat.log")); - System.Threading.Thread.Sleep (5000); - b.BuildLogFile = "build2.log"; - - // Need execute permission - if (!IsWindows) { - var aprofutil = Path.Combine (Root, b.ProjectDirectory, "aprofutil"); - RunProcess ("chmod", $"u+x {aprofutil}"); - } - - Assert.IsTrue (b.RunTarget (proj, "FinishAotProfiling", doNotCleanupOnUpdate: true), "Run of FinishAotProfiling should have succeeded."); - var customProfile = Path.Combine (Root, projDirectory, "custom.aprof"); - FileAssert.Exists (customProfile); - } - } - } -} diff --git a/tests/MSBuildDeviceIntegration/Tests/BundleToolNoAbiSplitTests.cs b/tests/MSBuildDeviceIntegration/Tests/BundleToolNoAbiSplitTests.cs index eca4ab420d5..3b3b5ee14c2 100644 --- a/tests/MSBuildDeviceIntegration/Tests/BundleToolNoAbiSplitTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/BundleToolNoAbiSplitTests.cs @@ -38,7 +38,7 @@ public class BundleToolNoAbiSplitTests : DeviceTest static Array Get_ConstructorParameters () { - return Enum.GetValues (typeof (AndroidRuntime)); + return new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }; } public BundleToolNoAbiSplitTests (AndroidRuntime runtime) diff --git a/tests/MSBuildDeviceIntegration/Tests/BundleToolTests.cs b/tests/MSBuildDeviceIntegration/Tests/BundleToolTests.cs index 3a4e0bfa47a..d0511b0cca2 100644 --- a/tests/MSBuildDeviceIntegration/Tests/BundleToolTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/BundleToolTests.cs @@ -51,7 +51,7 @@ static IEnumerable Get_FixtureArgs () var ret = new List (); foreach (object[] args in fixtureArgs) { - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }) { ret.Add (new object[] { args[0], runtime, diff --git a/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs b/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs index 95da395eb31..c287a1416c1 100755 --- a/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs +++ b/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs @@ -4,8 +4,6 @@ using System.Threading; using System.Threading.Tasks; using System.Net; -using Mono.Debugging.Client; -using Mono.Debugging.Soft; using NUnit.Framework; using Xamarin.ProjectTools; using System.Collections.Generic; @@ -54,7 +52,7 @@ int FindTextInFile (string file, string text) } [Test] - public void ApplicationRunsWithoutDebugger ([Values] bool isRelease, [Values] bool extractNativeLibs, [Values] bool useEmbeddedDex, [Values] AndroidRuntime runtime) + public void ApplicationRunsWithoutDebugger ([Values] bool isRelease, [Values] bool extractNativeLibs, [Values] bool useEmbeddedDex, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -101,7 +99,7 @@ public void ApplicationRunsWithoutDebugger ([Values] bool isRelease, [Values] bo } [Test] - public void ClassLibraryMainLauncherRuns ([Values] bool preloadAssemblies, [Values] AndroidRuntime runtime) + public void ClassLibraryMainLauncherRuns ([Values] bool preloadAssemblies, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -179,481 +177,5 @@ public void ClassLibraryMainLauncherRuns ([Values] bool preloadAssemblies, [Valu } } - static IEnumerable Get_CustomApplicationRunsWithDebuggerAndBreaks_Data () - { - var ret = new List (); - - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { - // TODO: once CoreCLR debugging works, this needs to be adjusted accordingly - if (runtime != AndroidRuntime.MonoVM) { - continue; - } - - AddTestData ( - embedAssemblies: true, - activityStarts: true, - packageFormat: "apk", - runtime: runtime - ); - - AddTestData ( - embedAssemblies: false, - activityStarts: true, - packageFormat: "apk", - runtime: runtime - ); - - AddTestData ( - embedAssemblies: true, - activityStarts: true, - packageFormat: "aab", - runtime: runtime - ); - - AddTestData ( - embedAssemblies: false, - activityStarts: true, - packageFormat: "aab", - runtime: runtime - ); - } - - return ret; - - void AddTestData (bool embedAssemblies, bool activityStarts, string packageFormat, AndroidRuntime runtime) - { - ret.Add (new object[] { - embedAssemblies, - activityStarts, - packageFormat, - runtime, - }); - } - } - - // MonoVM-only test for the moment. - [Test, Category ("Debugger")] - [TestCaseSource (nameof (Get_CustomApplicationRunsWithDebuggerAndBreaks_Data))] - [Retry(5)] - public void CustomApplicationRunsWithDebuggerAndBreaks (bool embedAssemblies, bool activityStarts, string packageFormat, AndroidRuntime runtime) - { - const bool isRelease = false; - if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { - return; - } - - SwitchUser (); - - var path = Path.Combine (Root, "temp", TestName); - if (Directory.Exists (path)) { - TestContext.Out.WriteLine ($"Deleting previous run at '{path}'"); - Directory.Delete (path,recursive:true); - } - - var proj = new XamarinAndroidApplicationProject () { - IsRelease = isRelease, - }; - - proj.SetRuntime (runtime); - proj.SetRuntimeIdentifiers (new[] { DeviceAbi }); - proj.SetProperty ("EmbedAssembliesIntoApk", embedAssemblies.ToString ()); - proj.SetProperty ("AndroidPackageFormat", packageFormat); - proj.SetDefaultTargetDevice (); - proj.Sources.Add (new BuildItem.Source ("MyApplication.cs") { - TextContent = () => proj.ProcessSourceTemplate (@"using System; -using Android.App; -using Android.OS; -using Android.Runtime; -using Android.Widget; - -namespace ${ROOT_NAMESPACE} { - [Application] - public class MyApplication : Application { - public MyApplication (IntPtr handle, JniHandleOwnership jniHandle) - : base (handle, jniHandle) - { - } - - public override void OnCreate () - { - base.OnCreate (); - } - } -} -"), - }); - using (var b = CreateApkBuilder (path)) { - SetTargetFrameworkAndManifest (proj, b, null); - Assert.True (b.Install (proj), "Project should have installed."); - - int breakcountHitCount = 0; - ManualResetEvent resetEvent = new ManualResetEvent (false); - var sw = new Stopwatch (); - // setup the debugger - var session = new SoftDebuggerSession (); - try { - session.Breakpoints = new BreakpointStore (); - string file = Path.Combine (Root, b.ProjectDirectory, "MainActivity.cs"); - int line = FindTextInFile (file, "base.OnCreate (bundle);"); - session.Breakpoints.Add (file, line); - file = Path.Combine (Root, b.ProjectDirectory, "MyApplication.cs"); - line = FindTextInFile (file, "base.OnCreate ();"); - session.Breakpoints.Add (file, line); - session.TargetHitBreakpoint += (sender, e) => { - TestContext.WriteLine ($"BREAK {e.Type}, {e.Backtrace.GetFrame (0)}"); - breakcountHitCount++; - session.Continue (); - }; - var rnd = new Random (); - int port = rnd.Next (10000, 20000); - TestContext.Out.WriteLine ($"{port}"); - var args = new SoftDebuggerConnectArgs ("", IPAddress.Loopback, port) { - MaxConnectionAttempts = DEBUGGER_MAX_CONNECTIONS, // we need a long delay here to get a reliable connection - TimeBetweenConnectionAttempts = DEBUGGER_CONNECTION_TIMEOUT, - }; - var startInfo = new SoftDebuggerStartInfo (args) { - WorkingDirectory = Path.Combine (b.ProjectDirectory, proj.IntermediateOutputPath, "android", "assets"), - }; - var options = new DebuggerSessionOptions () { - EvaluationOptions = EvaluationOptions.DefaultOptions, - }; - options.EvaluationOptions.UseExternalTypeResolver = true; - RunProjectAndAssert (proj, b, doNotCleanupOnUpdate: true, parameters: new string [] { - $"AndroidSdbTargetPort={port}", - $"AndroidSdbHostPort={port}", - "AndroidAttachDebugger=True", - }); - - session.LogWriter += (isStderr, text) => { Console.WriteLine (text); }; - session.OutputWriter += (isStderr, text) => { Console.WriteLine (text); }; - session.DebugWriter += (level, category, message) => { Console.WriteLine (message); }; - // do we expect the app to start? - Assert.AreEqual (activityStarts, WaitForDebuggerToStart (Path.Combine (Root, b.ProjectDirectory, "logcat.log")), "Debugger should have started"); - if (!activityStarts) - return; - Assert.False (session.HasExited, "Target should not have exited."); - session.Run (startInfo, options); - var expectedTime = TimeSpan.FromSeconds (1); - var actualTime = ProfileFor (() => session.IsConnected); - Assert.True (session.IsConnected, "Debugger should have connected but it did not."); - TestContext.Out.WriteLine ($"Debugger connected in {actualTime}"); - Assert.LessOrEqual (actualTime, expectedTime, $"Debugger should have connected within {expectedTime} but it took {actualTime}."); - // we need to wait here for a while to allow the breakpoints to hit - // but we need to timeout - TimeSpan timeout = TimeSpan.FromSeconds (60); - while (session.IsConnected && breakcountHitCount < 2 && timeout >= TimeSpan.Zero) { - Thread.Sleep (10); - timeout = timeout.Subtract (TimeSpan.FromMilliseconds (10)); - } - WaitFor (2000); - int expected = 2; - Assert.AreEqual (expected, breakcountHitCount, $"Should have hit {expected} breakpoints. Only hit {breakcountHitCount}"); - b.BuildLogFile = "uninstall.log"; - Assert.True (b.Uninstall (proj), "Project should have uninstalled."); - } catch (Exception ex) { - Assert.Fail ($"Exception occurred {ex}"); - } finally { - session.Exit (); - } - } - } - - static IEnumerable Get_ApplicationRunsWithDebuggerAndBreaks_Data () - { - var ret = new List (); - - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { - // TODO: once CoreCLR debugging works, this needs to be adjusted accordingly - if (runtime != AndroidRuntime.MonoVM) { - continue; - } - - AddTestData ( - embedAssemblies: true, - username: null, - packageFormat: "apk", - useLatestSdk: true, - runtime: runtime - ); - - AddTestData ( - embedAssemblies: true, - username: null, - packageFormat: "apk", - useLatestSdk: false, - runtime: runtime - ); - - AddTestData ( - embedAssemblies: false, - username: null, - packageFormat: "apk", - useLatestSdk: true, - runtime: runtime - ); - - AddTestData ( - embedAssemblies: true, - username: DeviceTest.GuestUserName, - packageFormat: "apk", - useLatestSdk: true, - runtime: runtime - ); - - AddTestData ( - embedAssemblies: false, - username: DeviceTest.GuestUserName, - packageFormat: "apk", - useLatestSdk: true, - runtime: runtime - ); - - AddTestData ( - embedAssemblies: true, - username: null, - packageFormat: "aab", - useLatestSdk: true, - runtime: runtime - ); - - AddTestData ( - embedAssemblies: false, - username: null, - packageFormat: "aab", - useLatestSdk: true, - runtime: runtime - ); - - AddTestData ( - embedAssemblies: true, - username: DeviceTest.GuestUserName, - packageFormat: "aab", - useLatestSdk: true, - runtime: runtime - ); - - AddTestData ( - embedAssemblies: false, - username: DeviceTest.GuestUserName, - packageFormat: "aab", - useLatestSdk: true, - runtime: runtime - ); - } - - return ret; - - void AddTestData (bool embedAssemblies, string username, string packageFormat, bool useLatestSdk, AndroidRuntime runtime) - { - ret.Add (new object[] { - embedAssemblies, - username, - packageFormat, - useLatestSdk, - runtime, - }); - } - } - - // MonoVM-only test for the moment. - [Test, Category ("Debugger")] - [TestCaseSource (nameof(Get_ApplicationRunsWithDebuggerAndBreaks_Data))] - [Retry (5)] - public void ApplicationRunsWithDebuggerAndBreaks (bool embedAssemblies, string username, string packageFormat, bool useLatestSdk, AndroidRuntime runtime) - { - const bool isRelease = false; - if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { - return; - } - - SwitchUser (); - WaitFor (5000); - - var path = Path.Combine (Root, "temp", TestName); - if (Directory.Exists (path)) { - TestContext.Out.WriteLine ($"Deleting previous run at '{path}'"); - Directory.Delete (path,recursive:true); - } - - int userId = GetUserId (username); - List parameters = new List (); - if (userId >= 0) - parameters.Add ($"AndroidDeviceUserId={userId}"); - if (SwitchUser (username)) { - WaitFor (5000); - ClearBlockingDialogs (); - ClickButton ("", "android:id/button1", "Yes continue"); - } - - var lib = new XamarinAndroidLibraryProject { - IsRelease = isRelease, - ProjectName = "Library1", - Sources = { - new BuildItem.Source ("Foo.cs") { - TextContent = () => -@"public class Foo -{ - public Foo () - { - } -}" - }, - }, - }; - - var app = new XamarinFormsAndroidApplicationProject { - ProjectName = "App", - IsRelease = isRelease, - EmbedAssembliesIntoApk = embedAssemblies, - }; - - app.SetRuntime (runtime); - if (!useLatestSdk) { - lib.TargetFramework = $"{XABuildConfig.PreviousDotNetTargetFramework}-android"; - app.TargetFramework = $"{XABuildConfig.PreviousDotNetTargetFramework}-android"; - } - - app.SetProperty ("AndroidPackageFormat", packageFormat); - app.MainPage = app.MainPage - .Replace ("InitializeComponent ();", "InitializeComponent (); new Foo ();") - // NOTE: can trigger deadlock/loop on startup: - // 08-25 09:40:36.759 32259 32293 D monodroid-assembly: monodroid_dlopen: hash match found, DSO name is 'libSystem.Security.Cryptography.Native.Android.so' - // 08-25 09:40:36.759 32259 32293 D monodroid-assembly: Trying to load loading shared JNI library /data/user/0/com.companyname.testgrendel/files/.__override__/arm64-v8a/libSystem.Security.Cryptography.Native.Android.so with System.loadLibrary - // 08-25 09:40:36.759 32259 32293 D monodroid-assembly: Running DSO loader on thread 32293, dispatching to main thread - .Replace ("//${AFTER_MAINACTIVITY}", """ - static MainActivity() - { - try - { - var text = new HttpClient().GetStringAsync("https://www.google.com").GetAwaiter().GetResult(); - Console.WriteLine("Web request:" + text); - } - catch (Exception ex) - { - // Doesn't actually matter if succeeds - Console.WriteLine("Web request failed:" + ex); - } - } - """); - app.AddReference (lib); - var abis = new [] { DeviceAbi }; - app.SetRuntimeIdentifiers (abis); - app.SetDefaultTargetDevice (); - using (var libBuilder = CreateDllBuilder (Path.Combine (path, lib.ProjectName))) - using (var appBuilder = CreateApkBuilder (Path.Combine (path, app.ProjectName))) { - appBuilder.Verbosity = LoggerVerbosity.Detailed; - Assert.True (libBuilder.Build (lib), "Library should have built."); - - SetTargetFrameworkAndManifest (app, appBuilder, app.TargetFramework == $"{XABuildConfig.PreviousDotNetTargetFramework}-android" ? 36 : null); - Assert.True (appBuilder.Install (app, parameters: parameters.ToArray ()), "App should have installed."); - - if (!embedAssemblies) { - // Check that we deployed app and framework .pdb files - StringAssertEx.ContainsRegex ($@"NotifySync CopyFile.+{app.ProjectName}\.pdb", appBuilder.LastBuildOutput, - $"{app.ProjectName}.pdb should be deployed!"); - StringAssertEx.ContainsRegex ($@"NotifySync CopyFile.+{lib.ProjectName}\.pdb", appBuilder.LastBuildOutput, - $"{lib.ProjectName}.pdb should be deployed!"); - } - - int breakcountHitCount = 0; - ManualResetEvent resetEvent = new ManualResetEvent (false); - var sw = new Stopwatch (); - // setup the debugger - var session = new SoftDebuggerSession (); - try { - session.Breakpoints = new BreakpointStore (); - string file = Path.Combine (Root, appBuilder.ProjectDirectory, "MainActivity.cs"); - int line = FindTextInFile (file, "base.OnCreate (savedInstanceState);"); - session.Breakpoints.Add (file, line); - - file = Path.Combine (Root, appBuilder.ProjectDirectory, "MainPage.xaml.cs"); - line = FindTextInFile (file, "InitializeComponent ();"); - session.Breakpoints.Add (file, line); - - file = Path.Combine (Root, appBuilder.ProjectDirectory, "MainPage.xaml.cs"); - line = FindTextInFile (file, "Console.WriteLine ("); - session.Breakpoints.Add (file, line); - - file = Path.Combine (Root, appBuilder.ProjectDirectory, "App.xaml.cs"); - line = FindTextInFile (file, "InitializeComponent ();"); - session.Breakpoints.Add (file, line); - - file = Path.Combine (Root, libBuilder.ProjectDirectory, "Foo.cs"); - line = FindTextInFile (file, "public Foo ()"); - // Add one to the line so we get the '{' under the constructor - session.Breakpoints.Add (file, line++); - - session.TargetHitBreakpoint += (sender, e) => { - TestContext.WriteLine ($"BREAK {e.Type}, {e.Backtrace.GetFrame (0)}"); - breakcountHitCount++; - session.Continue (); - }; - var rnd = new Random (); - int port = rnd.Next (10000, 20000); - TestContext.Out.WriteLine ($"{port}"); - var args = new SoftDebuggerConnectArgs ("", IPAddress.Loopback, port) { - MaxConnectionAttempts = DEBUGGER_MAX_CONNECTIONS, - TimeBetweenConnectionAttempts = DEBUGGER_CONNECTION_TIMEOUT, - }; - var startInfo = new SoftDebuggerStartInfo (args) { - WorkingDirectory = Path.Combine (appBuilder.ProjectDirectory, app.IntermediateOutputPath, "android", "assets"), - }; - var options = new DebuggerSessionOptions () { - EvaluationOptions = EvaluationOptions.DefaultOptions, - }; - options.EvaluationOptions.UseExternalTypeResolver = true; - - parameters.Add ($"AndroidSdbTargetPort={port}"); - parameters.Add ($"AndroidSdbHostPort={port}"); - parameters.Add ("AndroidAttachDebugger=True"); - - RunProjectAndAssert (app, appBuilder, doNotCleanupOnUpdate: true, parameters: parameters.ToArray ()); - - session.LogWriter += (isStderr, text) => { - TestContext.Out.WriteLine (text); - }; - session.OutputWriter += (isStderr, text) => { - TestContext.Out.WriteLine (text); - }; - session.DebugWriter += (level, category, message) => { - TestContext.Out.WriteLine (message); - }; - Assert.IsTrue (WaitForDebuggerToStart (Path.Combine (Root, appBuilder.ProjectDirectory, "logcat.log")), "Debugger should have started"); - session.Run (startInfo, options); - TestContext.Out.WriteLine ($"Detected debugger startup in log"); - Assert.False (session.HasExited, "Target should not have exited."); - WaitFor (TimeSpan.FromSeconds (30), () => session.IsConnected ); - Assert.True (session.IsConnected, "Debugger should have connected but it did not."); - // we need to wait here for a while to allow the breakpoints to hit - // but we need to timeout - TestContext.Out.WriteLine ($"Debugger connected."); - TimeSpan timeout = TimeSpan.FromSeconds (60); - int expected = 4; - while (session.IsConnected && breakcountHitCount < 3 && timeout >= TimeSpan.Zero) { - Thread.Sleep (10); - timeout = timeout.Subtract (TimeSpan.FromMilliseconds (10)); - } - WaitFor (2000); - Assert.AreEqual (expected, breakcountHitCount, $"Should have hit {expected} breakpoints. Only hit {breakcountHitCount}"); - breakcountHitCount = 0; - ClearAdbLogcat (); - ClearBlockingDialogs (); - Assert.True (ClickButton (app.PackageName, "myXFButton", "CLICK ME"), "Button should have been clicked!"); - timeout = TimeSpan.FromSeconds (60); - while (session.IsConnected && breakcountHitCount < 1 && timeout >= TimeSpan.Zero) { - Thread.Sleep (10); - timeout = timeout.Subtract (TimeSpan.FromMilliseconds (10)); - } - expected = 1; - Assert.AreEqual (expected, breakcountHitCount, $"Should have hit {expected} breakpoints. Only hit {breakcountHitCount}"); - appBuilder.BuildLogFile = "uninstall.log"; - Assert.True (appBuilder.Uninstall (app), "Project should have uninstalled."); - } catch (Exception ex) { - Assert.Fail($"Exception occurred {ex}"); - } finally { - session.Exit (); - } - } - } } } diff --git a/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs b/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs index 5eae82b12ce..60ffb69cdd2 100644 --- a/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs @@ -48,7 +48,7 @@ static IEnumerable Get_DotNetRun_Data () { var ret = new List (); - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }) { AddTestData (true, "llvm-ir", runtime); AddTestData (false, "llvm-ir", runtime); AddTestData (true, "managed", runtime); @@ -526,7 +526,7 @@ public void DotNetRunWithDeviceParameter () } [Test] - public void DotNetWatchHotReload ([Values (AndroidRuntime.MonoVM, AndroidRuntime.CoreCLR)] AndroidRuntime runtime) + public void DotNetWatchHotReload ([Values (AndroidRuntime.CoreCLR)] AndroidRuntime runtime) { const string initialMessage = "DOTNET_WATCH_INITIAL_12345"; const string hotReloadMessage = "DOTNET_WATCH_HOT_RELOAD_APPLIED"; @@ -628,7 +628,7 @@ public void DotNetWatchHotReload ([Values (AndroidRuntime.MonoVM, AndroidRuntime } [Test] - public void DeployToDevice ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void DeployToDevice ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -671,7 +671,7 @@ public void DeployToDevice ([Values] bool isRelease, [Values] AndroidRuntime run } [Test] - public void ActivityAliasRuns ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void ActivityAliasRuns ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -703,7 +703,7 @@ public void ActivityAliasRuns ([Values] bool isRelease, [Values] AndroidRuntime } [Test] - public void NativeAssemblyCacheWithSatelliteAssemblies ([Values] bool enableMarshalMethods, [Values] AndroidRuntime runtime) + public void NativeAssemblyCacheWithSatelliteAssemblies ([Values] bool enableMarshalMethods, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -775,7 +775,7 @@ public void NativeAssemblyCacheWithSatelliteAssemblies ([Values] bool enableMars } [Test] - public void GlobalLayoutEvent_ShouldRegisterAndFire_OnActivityLaunch ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void GlobalLayoutEvent_ShouldRegisterAndFire_OnActivityLaunch ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -811,52 +811,6 @@ void Button_ViewTreeObserver_GlobalLayout (object sender, EventArgs e) }, Path.Combine (Root, builder.ProjectDirectory, "startup-logcat.log"), 60), $"Output did not contain {expectedLogcatOutput}!"); } - [Test] - public void SubscribeToAppDomainUnhandledException ([Values] AndroidRuntime runtime) - { - const bool isRelease = true; - if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { - return; - } - - if (runtime == AndroidRuntime.CoreCLR || runtime == AndroidRuntime.NativeAOT) { - Assert.Ignore ("AppDomain.CurrentDomain.UnhandledException doesn't work in CoreCLR or NativeAOT"); - } - - var proj = new XamarinAndroidApplicationProject (packageName: PackageUtils.MakePackageName (runtime)) { - IsRelease = isRelease, - }; - proj.SetRuntime (runtime); - if (runtime == AndroidRuntime.MonoVM) { - proj.SetRuntimeIdentifiers (new[] { "armeabi-v7a", "arm64-v8a", "x86", "x86_64" }); - } else { - proj.SetRuntimeIdentifiers (new [] {"arm64-v8a", "x86_64"}); - } - - proj.MainActivity = proj.DefaultMainActivity.Replace ("//${AFTER_ONCREATE}", -@" AppDomain.CurrentDomain.UnhandledException += (sender, e) => { - Console.WriteLine (""# Unhandled Exception: sender={0}; e.IsTerminating={1}; e.ExceptionObject={2}"", - sender, e.IsTerminating, e.ExceptionObject); - }; - throw new Exception (""CRASH""); -"); - builder = CreateApkBuilder (); - Assert.IsTrue (builder.Install (proj), "Install should have succeeded."); - RunProjectAndAssert (proj, builder); - - string? expectedSender = runtime switch - { - AndroidRuntime.MonoVM => "System.Object", // MonoVM passes the current domain as the sender - AndroidRuntime.CoreCLR => null, // CoreCLR explicitly passes a `null` sender - _ => throw new NotImplementedException($"Test does not support runtime {runtime}"), - }; - string expectedLogcatOutput = $"# Unhandled Exception: sender={expectedSender}; e.IsTerminating=True; e.ExceptionObject=System.Exception: CRASH"; - Assert.IsTrue ( - MonitorAdbLogcat (CreateLineChecker (expectedLogcatOutput), - logcatFilePath: Path.Combine (Root, builder.ProjectDirectory, "startup-logcat.log"), timeout: 60), - $"Output did not contain {expectedLogcatOutput}!"); - } - public static Func CreateLineChecker (string expectedLogcatOutput) { @@ -891,7 +845,7 @@ static IEnumerable Get_SmokeTestBuildAndRunWithSpecialCharacters_Data { var ret = new List (); - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }) { AddTestData ("テスト", runtime); AddTestData ("随机生成器", runtime); AddTestData ("中国", runtime); @@ -909,7 +863,7 @@ void AddTestData (string testName, AndroidRuntime runtime) } [Test] - public void UnhandledExceptionFromButtonClick ([Values (AndroidRuntime.MonoVM, AndroidRuntime.CoreCLR)] AndroidRuntime runtime) + public void UnhandledExceptionFromButtonClick ([Values (AndroidRuntime.CoreCLR)] AndroidRuntime runtime) { proj = new XamarinAndroidApplicationProject (); proj.SetRuntime (runtime); @@ -1075,7 +1029,7 @@ public void SmokeTestBuildAndRunWithSpecialCharacters (string testName, AndroidR [Test] public void CustomLinkDescriptionPreserve ( [Values (AndroidLinkMode.SdkOnly, AndroidLinkMode.Full)] AndroidLinkMode linkMode, - [Values] AndroidRuntime runtime + [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime ) { const bool isRelease = true; @@ -1238,7 +1192,7 @@ string getResource (string name) } [Test] - public void JsonDeserializationCreatesJavaHandle ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void JsonDeserializationCreatesJavaHandle ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -1334,94 +1288,7 @@ public override Type BindToType (string assemblyName, string typeName) } [Test] - public void RunWithInterpreterEnabled ([Values] bool isRelease, [Values] AndroidRuntime runtime) - { - if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { - return; - } - - // MonoVM-only test, for now (until CoreCLR has interpreter we can use) - if (runtime != AndroidRuntime.MonoVM) { - Assert.Ignore ("MonoVM-only test for the moment"); - } - - var proj = new XamarinAndroidApplicationProject (packageName: PackageUtils.MakePackageName (runtime)) { - IsRelease = isRelease, - AotAssemblies = false, // Release defaults to Profiled AOT for .NET 6 - }; - proj.SetRuntime (runtime); - var abis = new string[] { "armeabi-v7a", "arm64-v8a", "x86", "x86_64" }; - proj.SetRuntimeIdentifiers (abis); - proj.SetProperty (proj.CommonProperties, "UseInterpreter", "True"); - builder = CreateApkBuilder (); - builder.BuildLogFile = "install.log"; - Assert.IsTrue (builder.Install (proj), "Install should have succeeded."); - - RunAdbCommand ("shell setprop debug.mono.log all"); - var logProp = RunAdbCommand ("shell getprop debug.mono.log")?.Trim (); - Assert.AreEqual (logProp, "all", "The debug.mono.log prop was not set correctly."); - RunProjectAndAssert (proj, builder); - - Func checkForInterpMessage = line => { - return line.Contains ("Enabling Mono Interpreter"); - }; - var timeoutInSeconds = ActivityStartTimeoutInSeconds; - var didPrintInterpMessage = MonitorAdbLogcat ( - action: checkForInterpMessage, - logcatFilePath: Path.Combine (Root, builder.ProjectDirectory, "interpreter-logcat.log"), - timeout: timeoutInSeconds); - var didStart = WaitForActivityToStart (proj.PackageName, "MainActivity", - Path.Combine (Root, builder.ProjectDirectory, "startup-logcat.log"), timeoutInSeconds); - ClearShellProp ("debug.mono.log"); - logProp = RunAdbCommand ("shell getprop debug.mono.log")?.Trim (); - Assert.AreEqual (logProp, string.Empty, "The debug.mono.log prop was not unset correctly."); - Assert.IsTrue (didPrintInterpMessage, "logcat output did not contain 'Enabling Mono Interpreter'."); - Assert.IsTrue (didStart, "Activity should have started."); - } - - [Test] - public void RunWithLLVMEnabled () - { - var proj = new XamarinAndroidApplicationProject () { - IsRelease = true, - }; - // Mono-only test - proj.SetRuntime (AndroidRuntime.MonoVM); - proj.SetRuntimeIdentifiers (new[] { "armeabi-v7a", "arm64-v8a", "x86", "x86_64" }); - proj.SetProperty ("EnableLLVM", true.ToString ()); - - builder = CreateApkBuilder (); - Assert.IsTrue (builder.Install (proj), "Install should have succeeded."); - RunProjectAndAssert (proj, builder); - - var activityNamespace = proj.PackageName; - var activityName = "MainActivity"; - var logcatFilePath = Path.Combine (Root, builder.ProjectDirectory, "startup-logcat.log"); - var failedToLoad = new List (); - bool appLaunched = MonitorAdbLogcat ((line) => { - if (SeenFailedToLoad (line)) - failedToLoad.Add (line); - return SeenActivityDisplayed (line); - }, logcatFilePath, timeout: ActivityStartTimeoutInSeconds); - - Assert.IsTrue (appLaunched, "LLVM app did not launch"); - Assert.AreEqual (0, failedToLoad.Count, $"LLVM .so files not loaded:\n{string.Join ("\n", failedToLoad)}"); - - bool SeenActivityDisplayed (string line) - { - var idx1 = line.IndexOf ("ActivityManager: Displayed", StringComparison.OrdinalIgnoreCase); - var idx2 = idx1 > 0 ? 0 : line.IndexOf ("ActivityTaskManager: Displayed", StringComparison.OrdinalIgnoreCase); - return (idx1 > 0 || idx2 > 0) && line.Contains (activityNamespace) && line.Contains (activityName); - } - - bool SeenFailedToLoad (string line) - { - return line.Contains ("Failed to load shared library"); - } - } - - [Test] - public void SingleProject_ApplicationId ([Values] bool testOnly, [Values] AndroidRuntime runtime) + public void SingleProject_ApplicationId ([Values] bool testOnly, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1455,7 +1322,7 @@ public void SingleProject_ApplicationId ([Values] bool testOnly, [Values] Androi } [Test] - public void AppWithStyleableUsageRuns ([Values] bool isRelease, [Values] bool linkResources, [Values] bool useStringTypeMaps, [Values] AndroidRuntime runtime) + public void AppWithStyleableUsageRuns ([Values] bool isRelease, [Values] bool linkResources, [Values] bool useStringTypeMaps, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -1611,7 +1478,7 @@ public MyLayout (Android.Content.Context context, Android.Util.IAttributeSet att } [Test] - public void CheckXamarinFormsAppDeploysAndAButtonWorks ([Values] AndroidRuntime runtime) + public void CheckXamarinFormsAppDeploysAndAButtonWorks ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1650,7 +1517,7 @@ public void CheckXamarinFormsAppDeploysAndAButtonWorks ([Values] AndroidRuntime } [Test] - public void SkiaSharpCanvasBasedAppRuns ([Values] bool isRelease, [Values] bool addResource, [Values] AndroidRuntime runtime) + public void SkiaSharpCanvasBasedAppRuns ([Values] bool isRelease, [Values] bool addResource, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -1771,7 +1638,7 @@ private void OnPaintSurface(object sender, SKPaintSurfaceEventArgs e) [Test] - public void CheckResouceIsOverridden ([Values] AndroidRuntime runtime) + public void CheckResouceIsOverridden ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -1878,7 +1745,7 @@ public void CheckResouceIsOverridden ([Values] AndroidRuntime runtime) [Test] public void DotNetInstallAndRunPreviousSdk ( [Values] bool isRelease, - [Values] AndroidRuntime runtime) + [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -1962,7 +1829,7 @@ public void DotNetInstallAndRunPreviewAPILevels ( public void DotNetInstallAndRunMinorAPILevels ( [Values] bool isRelease, [Values ("net10.0-android36.1")] string targetFramework, - [Values] AndroidRuntime runtime) + [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -2026,7 +1893,7 @@ public MyTextObjectFont (PdfPageTextObjectFont font) : base (font) } [Test] - public void TypeAndMemberRemapping ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void TypeAndMemberRemapping ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -2077,7 +1944,7 @@ public void TypeAndMemberRemapping ([Values] bool isRelease, [Values] AndroidRun } [Test] - public void SupportDesugaringStaticInterfaceMethods ([Values] AndroidRuntime runtime) + public void SupportDesugaringStaticInterfaceMethods ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -2130,7 +1997,7 @@ public void SupportDesugaringStaticInterfaceMethods ([Values] AndroidRuntime run } [Test] - public void FastDeployEnvironmentFiles ([Values] bool isRelease, [Values] bool embedAssembliesIntoApk, [Values] AndroidRuntime runtime) + public void FastDeployEnvironmentFiles ([Values] bool isRelease, [Values] bool embedAssembliesIntoApk, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -2262,7 +2129,7 @@ public void DotNetRunEnvironmentVariables () } [Test] - public void FixLegacyResourceDesignerStep ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void FixLegacyResourceDesignerStep ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -2321,7 +2188,7 @@ public void FixLegacyResourceDesignerStep ([Values] bool isRelease, [Values] And } [Test] - public void MicrosoftIntune ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void MicrosoftIntune ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { Assert.Ignore ("https://github.com/xamarin/xamarin-android/issues/8548"); if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -2361,7 +2228,7 @@ public void MicrosoftIntune ([Values] bool isRelease, [Values] AndroidRuntime ru } [Test] - public void GradleFBProj ([Values] bool isRelease, [Values] AndroidRuntime runtime) + public void GradleFBProj ([Values] bool isRelease, [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { return; @@ -2513,7 +2380,7 @@ public void NativeAOTSample () } [Test] - public void AppStartsWithManagedMarshalMethodsLookupEnabled ([Values] AndroidRuntime runtime) + public void AppStartsWithManagedMarshalMethodsLookupEnabled ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { @@ -2561,9 +2428,7 @@ public void StartAndroidActivityRespectsAndroidDeviceUserId () } [Test] - [TestCase ("run", AndroidRuntime.MonoVM)] [TestCase ("run", AndroidRuntime.CoreCLR)] - [TestCase ("test", AndroidRuntime.MonoVM)] [TestCase ("test", AndroidRuntime.CoreCLR)] public void DotNetNewAndroidTest (string mode, AndroidRuntime runtime) { diff --git a/tests/MSBuildDeviceIntegration/Tests/InstallTests.cs b/tests/MSBuildDeviceIntegration/Tests/InstallTests.cs index 0fa2694c376..4d3397ae73a 100644 --- a/tests/MSBuildDeviceIntegration/Tests/InstallTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/InstallTests.cs @@ -157,7 +157,7 @@ public void SwitchConfigurationsShouldRedeploy () } [Test] - public void InstallWithoutSharedRuntime ([Values (AndroidRuntime.MonoVM, AndroidRuntime.CoreCLR)] AndroidRuntime runtimeType) + public void InstallWithoutSharedRuntime ([Values (AndroidRuntime.CoreCLR)] AndroidRuntime runtimeType) { var proj = new XamarinAndroidApplicationProject () { IsRelease = true, @@ -212,8 +212,6 @@ public void InstallErrorCode () var proj = new XamarinAndroidApplicationProject { EmbedAssembliesIntoApk = true, }; - // MonoVM-only test - proj.SetRuntime (Android.Tasks.AndroidRuntime.MonoVM); proj.SetRuntimeIdentifiers (new[] { abi }); using (var builder = CreateApkBuilder ()) { @@ -311,8 +309,6 @@ public void LoggingPropsShouldCreateOverrideDirForRelease () var proj = new XamarinAndroidApplicationProject { IsRelease = true, }; - // MonoVM-only test - proj.SetRuntime (Android.Tasks.AndroidRuntime.MonoVM); // Set debuggable=true to allow run-as command usage with a release build proj.AndroidManifest = proj.AndroidManifest.Replace (" Get_Fixture_Args () { var ret = new List (); - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }) { ret.Add (new object[] { runtime }); } diff --git a/tests/MSBuildDeviceIntegration/Tests/MarshalMethodsGCHangTests.cs b/tests/MSBuildDeviceIntegration/Tests/MarshalMethodsGCHangTests.cs index 299347d054a..82891bab472 100644 --- a/tests/MSBuildDeviceIntegration/Tests/MarshalMethodsGCHangTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/MarshalMethodsGCHangTests.cs @@ -84,7 +84,7 @@ public override void Close () "; [Test] - public void MarshalMethodsAppRuns ([Values] AndroidRuntime runtime) + public void MarshalMethodsAppRuns ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = true; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { diff --git a/tests/MSBuildDeviceIntegration/Tests/MonoAndroidExportTest.cs b/tests/MSBuildDeviceIntegration/Tests/MonoAndroidExportTest.cs index 4d61be823d3..bcf142ef9f5 100644 --- a/tests/MSBuildDeviceIntegration/Tests/MonoAndroidExportTest.cs +++ b/tests/MSBuildDeviceIntegration/Tests/MonoAndroidExportTest.cs @@ -20,7 +20,7 @@ public class MonoAndroidExportTest : DeviceTest public void MonoAndroidExportReferencedAppStarts ( [Values] bool embedAssemblies, [Values] bool isRelease, - [Values] AndroidRuntime runtime) + [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (runtime == AndroidRuntime.NativeAOT) { Assert.Ignore ("NativeAOT does not support Mono.Android.Export"); @@ -109,7 +109,7 @@ protected override void OnCreate (Bundle bundle) [Test] public void ExportedMembersSurviveGarbageCollection ( [Values] bool isRelease, - [Values] AndroidRuntime runtime) + [Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { if (runtime == AndroidRuntime.NativeAOT) { Assert.Ignore ("NativeAOT does not support Mono.Android.Export"); diff --git a/tests/MSBuildDeviceIntegration/Tests/PerformanceTest.cs b/tests/MSBuildDeviceIntegration/Tests/PerformanceTest.cs index 915cbf9c57c..608dae19fd2 100644 --- a/tests/MSBuildDeviceIntegration/Tests/PerformanceTest.cs +++ b/tests/MSBuildDeviceIntegration/Tests/PerformanceTest.cs @@ -159,8 +159,6 @@ XamarinAndroidApplicationProject CreateApplicationProject () { var proj = new XamarinAndroidApplicationProject () { }; - // TODO: update times for CoreCLR in the future - proj.SetRuntime (Android.Tasks.AndroidRuntime.MonoVM); proj.SetRuntimeIdentifiers (new[] { DeviceAbi }); // Use a single ABI proj.SetProperty ("_FastDeploymentDiagnosticLogging", "False"); return proj; diff --git a/tests/MSBuildDeviceIntegration/Tests/SystemApplicationTests.cs b/tests/MSBuildDeviceIntegration/Tests/SystemApplicationTests.cs index 46d12ffe8eb..9bde7e63e83 100644 --- a/tests/MSBuildDeviceIntegration/Tests/SystemApplicationTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/SystemApplicationTests.cs @@ -17,7 +17,7 @@ public class SystemApplicationTests : DeviceTest { // All Tests here require the emulator to be started with -writable-system [Test, Category ("SystemApplication")] - public void SystemApplicationCanInstall ([Values] AndroidRuntime runtime) + public void SystemApplicationCanInstall ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { const bool isRelease = false; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) { diff --git a/tests/MSBuildDeviceIntegration/Tests/TimeZoneInfoTests.cs b/tests/MSBuildDeviceIntegration/Tests/TimeZoneInfoTests.cs index ac934888791..33417011dcb 100644 --- a/tests/MSBuildDeviceIntegration/Tests/TimeZoneInfoTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/TimeZoneInfoTests.cs @@ -25,7 +25,7 @@ static IEnumerable Get_Fixture_Args () { var ret = new List (); - foreach (AndroidRuntime runtime in Enum.GetValues (typeof (AndroidRuntime))) { + foreach (AndroidRuntime runtime in new[] { AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT }) { ret.Add (new object[] { runtime }); } diff --git a/tests/MSBuildDeviceIntegration/Tests/UncaughtExceptionTests.cs b/tests/MSBuildDeviceIntegration/Tests/UncaughtExceptionTests.cs index 8b56eb48056..5cc02823946 100644 --- a/tests/MSBuildDeviceIntegration/Tests/UncaughtExceptionTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/UncaughtExceptionTests.cs @@ -21,7 +21,7 @@ class LogcatLine }; [Test] - public void EnsureUncaughtExceptionWorks ([Values] AndroidRuntime runtime) + public void EnsureUncaughtExceptionWorks ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime) { bool isRelease = runtime == AndroidRuntime.NativeAOT; if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) {