Skip to content

Commit

Permalink
Merge branch 'main' into native-profiling-and-debugging
Browse files Browse the repository at this point in the history
* main:
  [tests] Add nightly localization unit tests (dotnet#6693)
  [Xamarin.Android.Build.Tasks] Fix XA4215 if AssemblyName is the same (dotnet#7477)
  Bump to dotnet/installer@24f5950 8.0.100-alpha.1.22577.1 (dotnet#7585)
  Bump manifest-merger from 30.3.0 to 30.3.1 in /src/manifestmerger (dotnet#7467)
  • Loading branch information
grendello committed Nov 30, 2022
2 parents b095fdf + 997c22e commit ae9fe5d
Show file tree
Hide file tree
Showing 14 changed files with 407 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void Run (string emulator)

var port = string.IsNullOrEmpty (Port) ? "" : $" -port {Port}";
var showWindow = ShowWindow ? "" : " -no-window";
var arguments = $"{Arguments ?? string.Empty} -verbose -detect-image-hang -logcat-output \"{LogcatFile}\" -no-boot-anim -no-audio -no-snapshot -cache-size 512 -timezone \"Etc/UTC\" {showWindow}{port} -avd {ImageName}";
var arguments = $"{Arguments ?? string.Empty} -verbose -detect-image-hang -logcat-output \"{LogcatFile}\" -no-boot-anim -no-audio -no-snapshot -cache-size 512 -change-locale en-US -timezone \"Etc/UTC\" {showWindow}{port} -avd {ImageName}";
Log.LogMessage (MessageImportance.Low, $"Tool {emulator} execution started with arguments: {arguments}");
var psi = new ProcessStartInfo () {
FileName = emulator,
Expand Down
49 changes: 49 additions & 0 deletions build-tools/automation/azure-pipelines-nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,53 @@ stages:
parameters:
node_id: 4

# Localization test jobs
- template: yaml-templates/run-localization-tests.yaml
parameters:
node_id: 1

- template: yaml-templates/run-localization-tests.yaml
parameters:
node_id: 2

- template: yaml-templates/run-localization-tests.yaml
parameters:
node_id: 3

- template: yaml-templates/run-localization-tests.yaml
parameters:
node_id: 4

- template: yaml-templates/run-localization-tests.yaml
parameters:
node_id: 5

- template: yaml-templates/run-localization-tests.yaml
parameters:
node_id: 6

- template: yaml-templates/run-localization-tests.yaml
parameters:
node_id: 7

- template: yaml-templates/run-localization-tests.yaml
parameters:
node_id: 8

- template: yaml-templates/run-localization-tests.yaml
parameters:
node_id: 9

- template: yaml-templates/run-localization-tests.yaml
parameters:
node_id: 10

- template: yaml-templates/run-localization-tests.yaml
parameters:
node_id: 11

- template: yaml-templates/run-localization-tests.yaml
parameters:
node_id: 12

- template: yaml-templates/run-systemapp-tests.yaml
57 changes: 57 additions & 0 deletions build-tools/automation/yaml-templates/run-localization-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Runs Localization tests against an emulator running on macOS

parameters:
node_id: 0

jobs:
- job: mac_localization_tests_${{ parameters.node_id }}
displayName: Localization Emulator Tests ${{ parameters.node_id }}
pool:
vmImage: $(HostedMacImage)
timeoutInMinutes: 180
cancelTimeoutInMinutes: 5
workspace:
clean: all
steps:
- template: setup-test-environment.yaml

- template: run-xaprepare.yaml
parameters:
arguments: --s=EmulatorTestDependencies

- task: DownloadPipelineArtifact@2
inputs:
artifactName: $(TestAssembliesArtifactName)
downloadPath: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)

- task: MSBuild@1
displayName: start emulator
inputs:
solution: tests/Mono.Android-Tests/Mono.Android-Tests.csproj
configuration: $(XA.Build.Configuration)
msbuildArguments: >-
/t:AcquireAndroidTarget /bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/start-emulator.binlog
- template: run-nunit-tests.yaml
parameters:
testRunTitle: LocalizationTests On Device - macOS
testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/$(DotNetStableTargetFramework)/MSBuildDeviceIntegration.dll
useDotNet: true
dotNetTestExtraArgs: --filter "Name~CheckLocalizationIsCorrectNode${{ parameters.node_id }}"
testResultsFile: TestResult-LocalizationTests-Node${{ parameters.node_id }}-$(XA.Build.Configuration).xml

- task: MSBuild@1
displayName: shut down emulator
inputs:
solution: tests/Mono.Android-Tests/Mono.Android-Tests.csproj
configuration: $(XA.Build.Configuration)
msbuildArguments: >-
/t:AcquireAndroidTarget,ReleaseAndroidTarget
/bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/shutdown-emulator.binlog
condition: always()

- template: upload-results.yaml
parameters:
artifactName: Test Results - TimeZoneInfo With Emulator - macOS - ${{ parameters.node_id }}

- template: fail-on-issue.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ jobs:
useDotNet: ${{ eq(parameters.target_framework, parameters.dotnet_targetframework) }}
testRunTitle: MSBuildDeviceIntegration On Device - macOS-${{ parameters.node_id }} - ${{ parameters.job_suffix }}
testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/${{ parameters.target_framework }}/MSBuildDeviceIntegration.dll
nunitConsoleExtraArgs: --where "cat == Node-${{ parameters.node_id }} && cat != SystemApplication && cat != TimeZoneInfo && cat != SmokeTests ${{ parameters.nunit_categories }}"
dotNetTestExtraArgs: --filter "TestCategory = Node-${{ parameters.node_id }} & TestCategory != TimeZoneInfo ${{ parameters.nunit_categories }}"
nunitConsoleExtraArgs: --where "cat == Node-${{ parameters.node_id }} && cat != SystemApplication && cat != TimeZoneInfo && cat != Localization && cat != SmokeTests ${{ parameters.nunit_categories }}"
dotNetTestExtraArgs: --filter "TestCategory = Node-${{ parameters.node_id }} & TestCategory != TimeZoneInfo & TestCategory != Localization ${{ parameters.nunit_categories }}"
testResultsFile: TestResult-MSBuildDeviceIntegration-${{ parameters.job_name }}-$(XA.Build.Configuration).xml

# Tests with no "Node" category. This should be empty, but just in case! Only run these tests on node 1
Expand All @@ -76,8 +76,8 @@ jobs:
useDotNet: ${{ eq(parameters.target_framework, parameters.dotnet_targetframework) }}
testRunTitle: MSBuildDeviceIntegration On Device - macOS-NoNode - ${{ parameters.job_suffix }}
testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/${{ parameters.target_framework }}/MSBuildDeviceIntegration.dll
nunitConsoleExtraArgs: --where "cat != Node-1 && cat != Node-2 && cat != Node-3 && cat != Node-4 && cat != SystemApplication && cat != TimeZoneInfo && cat != SmokeTests ${{ parameters.nunit_categories }}"
dotNetTestExtraArgs: --filter "TestCategory != Node-1 & TestCategory != Node-2 & TestCategory != Node-3 & TestCategory != Node-4 & TestCategory != TimeZoneInfo ${{ parameters.nunit_categories }}"
nunitConsoleExtraArgs: --where "cat != Node-1 && cat != Node-2 && cat != Node-3 && cat != Node-4 && cat != SystemApplication && cat != TimeZoneInfo && cat != Localization && cat != SmokeTests ${{ parameters.nunit_categories }}"
dotNetTestExtraArgs: --filter "TestCategory != Node-1 & TestCategory != Node-2 & TestCategory != Node-3 & TestCategory != Node-4 & TestCategory != TimeZoneInfo & TestCategory != Localization ${{ parameters.nunit_categories }}"
testResultsFile: TestResult-MSBuildDeviceIntegration-${{ parameters.job_name }}-NoNode-$(XA.Build.Configuration).xml

- task: MSBuild@1
Expand Down
4 changes: 2 additions & 2 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="8.0.100-alpha.1.22570.9">
<Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="8.0.100-alpha.1.22577.1">
<Uri>https://github.com/dotnet/installer</Uri>
<Sha>296eeb3fa3d9b4fdf6552a1aa3ed07092e12f403</Sha>
<Sha>24f595040d104553a809179a7093dde2f01c1f9c</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.ILLink.Tasks" Version="7.0.100-1.22564.1" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Uri>https://github.com/dotnet/linker</Uri>
Expand Down
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<!--Package versions-->
<PropertyGroup>
<MicrosoftDotnetSdkInternalPackageVersion>8.0.100-alpha.1.22570.9</MicrosoftDotnetSdkInternalPackageVersion>
<MicrosoftDotnetSdkInternalPackageVersion>8.0.100-alpha.1.22577.1</MicrosoftDotnetSdkInternalPackageVersion>
<MicrosoftNETILLinkTasksPackageVersion>7.0.100-1.22564.1</MicrosoftNETILLinkTasksPackageVersion>
<MicrosoftNETCoreAppRefPackageVersion>8.0.0-alpha.1.22559.2</MicrosoftNETCoreAppRefPackageVersion>
<MicrosoftDotNetApiCompatPackageVersion>7.0.0-beta.22103.1</MicrosoftDotNetApiCompatPackageVersion>
Expand Down
19 changes: 11 additions & 8 deletions src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ void Run (DirectoryAssemblyResolver res, bool useMarshalMethods)
if ((!useMarshalMethods && !userAssemblies.ContainsKey (td.Module.Assembly.Name.Name)) || JavaTypeScanner.ShouldSkipJavaCallableWrapperGeneration (td, cache)) {
continue;
}

javaTypes.Add (td);
}

Expand Down Expand Up @@ -288,16 +287,20 @@ void Run (DirectoryAssemblyResolver res, bool useMarshalMethods)
TypeDefinition conflict;
bool hasConflict = false;
if (managed.TryGetValue (managedKey, out conflict)) {
if (!managedConflicts.TryGetValue (managedKey, out var list))
managedConflicts.Add (managedKey, list = new List<string> { conflict.GetPartialAssemblyName (cache) });
list.Add (type.GetPartialAssemblyName (cache));
if (!conflict.Module.Name.Equals (type.Module.Name)) {
if (!managedConflicts.TryGetValue (managedKey, out var list))
managedConflicts.Add (managedKey, list = new List<string> { conflict.GetPartialAssemblyName (cache) });
list.Add (type.GetPartialAssemblyName (cache));
}
hasConflict = true;
}
if (java.TryGetValue (javaKey, out conflict)) {
if (!javaConflicts.TryGetValue (javaKey, out var list))
javaConflicts.Add (javaKey, list = new List<string> { conflict.GetAssemblyQualifiedName (cache) });
list.Add (type.GetAssemblyQualifiedName (cache));
success = false;
if (!conflict.Module.Name.Equals (type.Module.Name)) {
if (!javaConflicts.TryGetValue (javaKey, out var list))
javaConflicts.Add (javaKey, list = new List<string> { conflict.GetAssemblyQualifiedName (cache) });
list.Add (type.GetAssemblyQualifiedName (cache));
success = false;
}
hasConflict = true;
}
if (!hasConflict) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,5 +509,39 @@ public void AndroidUseNegotiateAuthentication ([Values (true, false, null)] bool
}
}
}

[Test]
public void DoNotErrorOnPerArchJavaTypeDuplicates ()
{
if (!Builder.UseDotNet)
Assert.Ignore ("Test only valid on .NET");

var path = Path.Combine (Root, "temp", TestName);
var lib = new XamarinAndroidLibraryProject { IsRelease = true, ProjectName = "Lib1" };
lib.SetProperty ("IsTrimmable", "true");
lib.Sources.Add (new BuildItem.Source ("Library1.cs") {
TextContent = () => @"
namespace Lib1;
public class Library1 : Java.Lang.Object {
private static bool Is64Bits = IntPtr.Size >= 8;
public static bool Is64 () {
return Is64Bits;
}
}",
});
var proj = new XamarinAndroidApplicationProject { IsRelease = true, ProjectName = "App1" };
proj.References.Add(new BuildItem.ProjectReference (Path.Combine ("..", "Lib1", "Lib1.csproj"), "Lib1"));
proj.MainActivity = proj.DefaultMainActivity.Replace (
"base.OnCreate (bundle);",
"base.OnCreate (bundle);\n" +
"if (Lib1.Library1.Is64 ()) Console.WriteLine (\"Hello World!\");");


using var lb = CreateDllBuilder (Path.Combine (path, "Lib1"));
using var b = CreateApkBuilder (Path.Combine (path, "App1"));
Assert.IsTrue (lb.Build (lib), "build should have succeeded.");
Assert.IsTrue (b.Build (proj), "build should have succeeded.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public void CheckDevice ()
if (!HasDevices) {
// something went wrong with the emulator.
// lets restart it.
TestContext.Out.WriteLine ($"{nameof(CheckDevice)} is restarting the emulator.");
RestartDevice (Path.Combine (Root, "Emulator.csproj"));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,51 @@ static class InlineData
<!--contents-->
</root>";

const string Designer = @"
using System;
using System.Reflection;
namespace @projectName@
{
[System.CodeDom.Compiler.GeneratedCodeAttribute(""System.Resources.Tools.StronglyTypedResourceBuilder"", ""4.0.0.0"")]
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class @className@ {
private static System.Resources.ResourceManager resourceMan;
private static System.Globalization.CultureInfo resourceCulture;
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute(""Microsoft.Performance"", ""CA1811:AvoidUncalledPrivateCode"")]
internal @className@() {
}
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
internal static System.Resources.ResourceManager ResourceManager {
get {
if (object.Equals(null, resourceMan)) {
System.Resources.ResourceManager temp = new System.Resources.ResourceManager(""@projectName@.@className@"", typeof(@className@).GetTypeInfo().Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
internal static System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
@content@
}
}
";

public static string ResxWithContents (string contents)
{
return Resx.Replace ("<!--contents-->", contents);
Expand All @@ -40,5 +85,27 @@ public static void AddCultureResourcesToProject (IShortFormProject proj, string
});
}
}

public static string DesignerWithContents (string projectName, string className, string[] dataNames)
{
var content = new StringBuilder ();
foreach (string data in dataNames) {
content.AppendFormat (@"internal static string {0} {{
get {{
return ResourceManager.GetString(""{0}"", resourceCulture);
}}
}}" + Environment.NewLine, data);
}
return Designer.Replace ("@className@", className)
.Replace ("@projectName@", projectName)
.Replace ("@content@", content.ToString ());
}

public static void AddCultureResourceDesignerToProject (IShortFormProject proj, string projectName, string className, params string[] dataNames)
{
proj.OtherBuildItems.Add (new BuildItem.Source ($"{className}.Designer.cs") {
TextContent = () => InlineData.DesignerWithContents (projectName, className, dataNames)
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="${ROOT_NAMESPACE}.MainPage">
<StackLayout>
<Label Text="Welcome to Xamarin.Forms!"
<Label x:Name="myLabel"
Text="Welcome to Xamarin.Forms!"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
<Button Text="Click Me" Clicked="Button_Clicked" x:Name="myXFButton" AutomationId="myXFButton" />
Expand Down
2 changes: 1 addition & 1 deletion src/manifestmerger/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repositories {

dependencies {
// https://mvnrepository.com/artifact/com.android.tools.build/manifest-merger
compile group: 'com.android.tools.build', name: 'manifest-merger', version: '30.3.0'
compile group: 'com.android.tools.build', name: 'manifest-merger', version: '30.3.1'
}

sourceSets {
Expand Down
Loading

0 comments on commit ae9fe5d

Please # to comment.