Skip to content

Commit ae9fe5d

Browse files
committed
Merge branch 'main' into native-profiling-and-debugging
* 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)
2 parents b095fdf + 997c22e commit ae9fe5d

File tree

14 files changed

+407
-22
lines changed

14 files changed

+407
-22
lines changed

build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/StartAndroidEmulator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void Run (string emulator)
7171

7272
var port = string.IsNullOrEmpty (Port) ? "" : $" -port {Port}";
7373
var showWindow = ShowWindow ? "" : " -no-window";
74-
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}";
74+
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}";
7575
Log.LogMessage (MessageImportance.Low, $"Tool {emulator} execution started with arguments: {arguments}");
7676
var psi = new ProcessStartInfo () {
7777
FileName = emulator,

build-tools/automation/azure-pipelines-nightly.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,53 @@ stages:
175175
parameters:
176176
node_id: 4
177177

178+
# Localization test jobs
179+
- template: yaml-templates/run-localization-tests.yaml
180+
parameters:
181+
node_id: 1
182+
183+
- template: yaml-templates/run-localization-tests.yaml
184+
parameters:
185+
node_id: 2
186+
187+
- template: yaml-templates/run-localization-tests.yaml
188+
parameters:
189+
node_id: 3
190+
191+
- template: yaml-templates/run-localization-tests.yaml
192+
parameters:
193+
node_id: 4
194+
195+
- template: yaml-templates/run-localization-tests.yaml
196+
parameters:
197+
node_id: 5
198+
199+
- template: yaml-templates/run-localization-tests.yaml
200+
parameters:
201+
node_id: 6
202+
203+
- template: yaml-templates/run-localization-tests.yaml
204+
parameters:
205+
node_id: 7
206+
207+
- template: yaml-templates/run-localization-tests.yaml
208+
parameters:
209+
node_id: 8
210+
211+
- template: yaml-templates/run-localization-tests.yaml
212+
parameters:
213+
node_id: 9
214+
215+
- template: yaml-templates/run-localization-tests.yaml
216+
parameters:
217+
node_id: 10
218+
219+
- template: yaml-templates/run-localization-tests.yaml
220+
parameters:
221+
node_id: 11
222+
223+
- template: yaml-templates/run-localization-tests.yaml
224+
parameters:
225+
node_id: 12
226+
178227
- template: yaml-templates/run-systemapp-tests.yaml
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Runs Localization tests against an emulator running on macOS
2+
3+
parameters:
4+
node_id: 0
5+
6+
jobs:
7+
- job: mac_localization_tests_${{ parameters.node_id }}
8+
displayName: Localization Emulator Tests ${{ parameters.node_id }}
9+
pool:
10+
vmImage: $(HostedMacImage)
11+
timeoutInMinutes: 180
12+
cancelTimeoutInMinutes: 5
13+
workspace:
14+
clean: all
15+
steps:
16+
- template: setup-test-environment.yaml
17+
18+
- template: run-xaprepare.yaml
19+
parameters:
20+
arguments: --s=EmulatorTestDependencies
21+
22+
- task: DownloadPipelineArtifact@2
23+
inputs:
24+
artifactName: $(TestAssembliesArtifactName)
25+
downloadPath: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)
26+
27+
- task: MSBuild@1
28+
displayName: start emulator
29+
inputs:
30+
solution: tests/Mono.Android-Tests/Mono.Android-Tests.csproj
31+
configuration: $(XA.Build.Configuration)
32+
msbuildArguments: >-
33+
/t:AcquireAndroidTarget /bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/start-emulator.binlog
34+
35+
- template: run-nunit-tests.yaml
36+
parameters:
37+
testRunTitle: LocalizationTests On Device - macOS
38+
testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/$(DotNetStableTargetFramework)/MSBuildDeviceIntegration.dll
39+
useDotNet: true
40+
dotNetTestExtraArgs: --filter "Name~CheckLocalizationIsCorrectNode${{ parameters.node_id }}"
41+
testResultsFile: TestResult-LocalizationTests-Node${{ parameters.node_id }}-$(XA.Build.Configuration).xml
42+
43+
- task: MSBuild@1
44+
displayName: shut down emulator
45+
inputs:
46+
solution: tests/Mono.Android-Tests/Mono.Android-Tests.csproj
47+
configuration: $(XA.Build.Configuration)
48+
msbuildArguments: >-
49+
/t:AcquireAndroidTarget,ReleaseAndroidTarget
50+
/bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/shutdown-emulator.binlog
51+
condition: always()
52+
53+
- template: upload-results.yaml
54+
parameters:
55+
artifactName: Test Results - TimeZoneInfo With Emulator - macOS - ${{ parameters.node_id }}
56+
57+
- template: fail-on-issue.yaml

build-tools/automation/yaml-templates/run-msbuild-device-tests.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ jobs:
6565
useDotNet: ${{ eq(parameters.target_framework, parameters.dotnet_targetframework) }}
6666
testRunTitle: MSBuildDeviceIntegration On Device - macOS-${{ parameters.node_id }} - ${{ parameters.job_suffix }}
6767
testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/${{ parameters.target_framework }}/MSBuildDeviceIntegration.dll
68-
nunitConsoleExtraArgs: --where "cat == Node-${{ parameters.node_id }} && cat != SystemApplication && cat != TimeZoneInfo && cat != SmokeTests ${{ parameters.nunit_categories }}"
69-
dotNetTestExtraArgs: --filter "TestCategory = Node-${{ parameters.node_id }} & TestCategory != TimeZoneInfo ${{ parameters.nunit_categories }}"
68+
nunitConsoleExtraArgs: --where "cat == Node-${{ parameters.node_id }} && cat != SystemApplication && cat != TimeZoneInfo && cat != Localization && cat != SmokeTests ${{ parameters.nunit_categories }}"
69+
dotNetTestExtraArgs: --filter "TestCategory = Node-${{ parameters.node_id }} & TestCategory != TimeZoneInfo & TestCategory != Localization ${{ parameters.nunit_categories }}"
7070
testResultsFile: TestResult-MSBuildDeviceIntegration-${{ parameters.job_name }}-$(XA.Build.Configuration).xml
7171

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

8383
- task: MSBuild@1

eng/Version.Details.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Dependencies>
22
<ProductDependencies>
3-
<Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="8.0.100-alpha.1.22570.9">
3+
<Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="8.0.100-alpha.1.22577.1">
44
<Uri>https://github.com/dotnet/installer</Uri>
5-
<Sha>296eeb3fa3d9b4fdf6552a1aa3ed07092e12f403</Sha>
5+
<Sha>24f595040d104553a809179a7093dde2f01c1f9c</Sha>
66
</Dependency>
77
<Dependency Name="Microsoft.NET.ILLink.Tasks" Version="7.0.100-1.22564.1" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
88
<Uri>https://github.com/dotnet/linker</Uri>

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<!--Package versions-->
33
<PropertyGroup>
4-
<MicrosoftDotnetSdkInternalPackageVersion>8.0.100-alpha.1.22570.9</MicrosoftDotnetSdkInternalPackageVersion>
4+
<MicrosoftDotnetSdkInternalPackageVersion>8.0.100-alpha.1.22577.1</MicrosoftDotnetSdkInternalPackageVersion>
55
<MicrosoftNETILLinkTasksPackageVersion>7.0.100-1.22564.1</MicrosoftNETILLinkTasksPackageVersion>
66
<MicrosoftNETCoreAppRefPackageVersion>8.0.0-alpha.1.22559.2</MicrosoftNETCoreAppRefPackageVersion>
77
<MicrosoftDotNetApiCompatPackageVersion>7.0.0-beta.22103.1</MicrosoftDotNetApiCompatPackageVersion>

src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ void Run (DirectoryAssemblyResolver res, bool useMarshalMethods)
222222
if ((!useMarshalMethods && !userAssemblies.ContainsKey (td.Module.Assembly.Name.Name)) || JavaTypeScanner.ShouldSkipJavaCallableWrapperGeneration (td, cache)) {
223223
continue;
224224
}
225-
226225
javaTypes.Add (td);
227226
}
228227

@@ -288,16 +287,20 @@ void Run (DirectoryAssemblyResolver res, bool useMarshalMethods)
288287
TypeDefinition conflict;
289288
bool hasConflict = false;
290289
if (managed.TryGetValue (managedKey, out conflict)) {
291-
if (!managedConflicts.TryGetValue (managedKey, out var list))
292-
managedConflicts.Add (managedKey, list = new List<string> { conflict.GetPartialAssemblyName (cache) });
293-
list.Add (type.GetPartialAssemblyName (cache));
290+
if (!conflict.Module.Name.Equals (type.Module.Name)) {
291+
if (!managedConflicts.TryGetValue (managedKey, out var list))
292+
managedConflicts.Add (managedKey, list = new List<string> { conflict.GetPartialAssemblyName (cache) });
293+
list.Add (type.GetPartialAssemblyName (cache));
294+
}
294295
hasConflict = true;
295296
}
296297
if (java.TryGetValue (javaKey, out conflict)) {
297-
if (!javaConflicts.TryGetValue (javaKey, out var list))
298-
javaConflicts.Add (javaKey, list = new List<string> { conflict.GetAssemblyQualifiedName (cache) });
299-
list.Add (type.GetAssemblyQualifiedName (cache));
300-
success = false;
298+
if (!conflict.Module.Name.Equals (type.Module.Name)) {
299+
if (!javaConflicts.TryGetValue (javaKey, out var list))
300+
javaConflicts.Add (javaKey, list = new List<string> { conflict.GetAssemblyQualifiedName (cache) });
301+
list.Add (type.GetAssemblyQualifiedName (cache));
302+
success = false;
303+
}
301304
hasConflict = true;
302305
}
303306
if (!hasConflict) {

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/LinkerTests.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,5 +509,39 @@ public void AndroidUseNegotiateAuthentication ([Values (true, false, null)] bool
509509
}
510510
}
511511
}
512+
513+
[Test]
514+
public void DoNotErrorOnPerArchJavaTypeDuplicates ()
515+
{
516+
if (!Builder.UseDotNet)
517+
Assert.Ignore ("Test only valid on .NET");
518+
519+
var path = Path.Combine (Root, "temp", TestName);
520+
var lib = new XamarinAndroidLibraryProject { IsRelease = true, ProjectName = "Lib1" };
521+
lib.SetProperty ("IsTrimmable", "true");
522+
lib.Sources.Add (new BuildItem.Source ("Library1.cs") {
523+
TextContent = () => @"
524+
namespace Lib1;
525+
public class Library1 : Java.Lang.Object {
526+
private static bool Is64Bits = IntPtr.Size >= 8;
527+
528+
public static bool Is64 () {
529+
return Is64Bits;
530+
}
531+
}",
532+
});
533+
var proj = new XamarinAndroidApplicationProject { IsRelease = true, ProjectName = "App1" };
534+
proj.References.Add(new BuildItem.ProjectReference (Path.Combine ("..", "Lib1", "Lib1.csproj"), "Lib1"));
535+
proj.MainActivity = proj.DefaultMainActivity.Replace (
536+
"base.OnCreate (bundle);",
537+
"base.OnCreate (bundle);\n" +
538+
"if (Lib1.Library1.Is64 ()) Console.WriteLine (\"Hello World!\");");
539+
540+
541+
using var lb = CreateDllBuilder (Path.Combine (path, "Lib1"));
542+
using var b = CreateApkBuilder (Path.Combine (path, "App1"));
543+
Assert.IsTrue (lb.Build (lib), "build should have succeeded.");
544+
Assert.IsTrue (b.Build (proj), "build should have succeeded.");
545+
}
512546
}
513547
}

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public void CheckDevice ()
6666
if (!HasDevices) {
6767
// something went wrong with the emulator.
6868
// lets restart it.
69+
TestContext.Out.WriteLine ($"{nameof(CheckDevice)} is restarting the emulator.");
6970
RestartDevice (Path.Combine (Root, "Emulator.csproj"));
7071
}
7172
}

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/InlineData.cs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,51 @@ static class InlineData
2727
<!--contents-->
2828
</root>";
2929

30+
const string Designer = @"
31+
using System;
32+
using System.Reflection;
33+
34+
namespace @projectName@
35+
{
36+
[System.CodeDom.Compiler.GeneratedCodeAttribute(""System.Resources.Tools.StronglyTypedResourceBuilder"", ""4.0.0.0"")]
37+
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
38+
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
39+
internal class @className@ {
40+
41+
private static System.Resources.ResourceManager resourceMan;
42+
43+
private static System.Globalization.CultureInfo resourceCulture;
44+
45+
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute(""Microsoft.Performance"", ""CA1811:AvoidUncalledPrivateCode"")]
46+
internal @className@() {
47+
}
48+
49+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
50+
internal static System.Resources.ResourceManager ResourceManager {
51+
get {
52+
if (object.Equals(null, resourceMan)) {
53+
System.Resources.ResourceManager temp = new System.Resources.ResourceManager(""@projectName@.@className@"", typeof(@className@).GetTypeInfo().Assembly);
54+
resourceMan = temp;
55+
}
56+
return resourceMan;
57+
}
58+
}
59+
60+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
61+
internal static System.Globalization.CultureInfo Culture {
62+
get {
63+
return resourceCulture;
64+
}
65+
set {
66+
resourceCulture = value;
67+
}
68+
}
69+
70+
@content@
71+
}
72+
}
73+
";
74+
3075
public static string ResxWithContents (string contents)
3176
{
3277
return Resx.Replace ("<!--contents-->", contents);
@@ -40,5 +85,27 @@ public static void AddCultureResourcesToProject (IShortFormProject proj, string
4085
});
4186
}
4287
}
88+
89+
public static string DesignerWithContents (string projectName, string className, string[] dataNames)
90+
{
91+
var content = new StringBuilder ();
92+
foreach (string data in dataNames) {
93+
content.AppendFormat (@"internal static string {0} {{
94+
get {{
95+
return ResourceManager.GetString(""{0}"", resourceCulture);
96+
}}
97+
}}" + Environment.NewLine, data);
98+
}
99+
return Designer.Replace ("@className@", className)
100+
.Replace ("@projectName@", projectName)
101+
.Replace ("@content@", content.ToString ());
102+
}
103+
104+
public static void AddCultureResourceDesignerToProject (IShortFormProject proj, string projectName, string className, params string[] dataNames)
105+
{
106+
proj.OtherBuildItems.Add (new BuildItem.Source ($"{className}.Designer.cs") {
107+
TextContent = () => InlineData.DesignerWithContents (projectName, className, dataNames)
108+
});
109+
}
43110
}
44111
}

0 commit comments

Comments
 (0)