Skip to content

Commit

Permalink
Merge main into net9.0 (#24341)
Browse files Browse the repository at this point in the history
### Description of Change

Update the net9.0 branch with all the latest things.
  • Loading branch information
mattleibow authored Aug 21, 2024
2 parents 79bdab0 + f129f6e commit 11aa1bd
Show file tree
Hide file tree
Showing 39 changed files with 754 additions and 156 deletions.
1 change: 1 addition & 0 deletions Microsoft.Maui-windows.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"src\\TestUtils\\src\\DeviceTests\\TestUtils.DeviceTests.csproj",
"src\\TestUtils\\src\\Microsoft.Maui.IntegrationTests\\Microsoft.Maui.IntegrationTests.csproj",
"src\\TestUtils\\src\\TestUtils\\TestUtils.csproj",
"src\\TestUtils\\src\\UITest.Analyzers\\UITest.Analyzers.csproj",
"src\\TestUtils\\src\\UITest.Appium\\UITest.Appium.csproj",
"src\\TestUtils\\src\\UITest.Core\\UITest.Core.csproj",
"src\\TestUtils\\src\\UITest.NUnit\\UITest.NUnit.csproj",
Expand Down
12 changes: 9 additions & 3 deletions eng/cake/dotnet.cake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ string officialBuildId = Argument("officialbuildid", "");

string testFilter = Argument("test-filter", EnvironmentVariable("TEST_FILTER"));

var rootFolder = Context.Environment.WorkingDirectory;

if (rootFolder.FullPath.EndsWith("/devices", StringComparison.OrdinalIgnoreCase))
rootFolder = rootFolder.Combine("../../").Collapse();

var arcadeBin = MakeAbsolute(new DirectoryPath("./artifacts/bin/"));

string TestTFM = Argument("testtfm", "");
Expand Down Expand Up @@ -55,12 +60,12 @@ Task("dotnet")
if(!string.IsNullOrEmpty(nugetSource))
{
EnsureDirectoryExists(nugetSource);
var originalNuget = File("./NuGet.config");
var originalNuget = File($"{rootFolder}/NuGet.config");
ReplaceTextInFiles(originalNuget, "<add key=\"nuget-only\" value=\"true\" />", "");
ReplaceTextInFiles(originalNuget, "NUGET_ONLY_PLACEHOLDER", nugetSource);
}
DotNetBuild("./src/DotNet/DotNet.csproj", new DotNetBuildSettings
DotNetBuild($"{rootFolder}/src/DotNet/DotNet.csproj", new DotNetBuildSettings
{
MSBuildSettings = new DotNetMSBuildSettings()
.EnableBinaryLogger($"{GetLogDirectory()}/dotnet-{configuration}-{DateTime.UtcNow.ToFileTimeUtc()}.binlog")
Expand Down Expand Up @@ -109,7 +114,7 @@ Task("dotnet-buildtasks")
.IsDependentOn("dotnet")
.Does(() =>
{
RunMSBuildWithDotNet("./Microsoft.Maui.BuildTasks.slnf");
RunMSBuildWithDotNet($"{rootFolder}/Microsoft.Maui.BuildTasks.slnf");
})
.OnError(exception =>
{
Expand Down Expand Up @@ -166,6 +171,7 @@ Task("dotnet-build")
});

Task("dotnet-samples")
.IsDependentOn("dotnet-buildtasks")
.Does(() =>
{
var tempDir = PrepareSeparateBuildContext("samplesTest");
Expand Down
16 changes: 8 additions & 8 deletions eng/devices/android.cake
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#addin nuget:?package=Cake.Android.Adb&version=3.2.0
#addin nuget:?package=Cake.Android.AvdManager&version=2.2.0
#load "../cake/helpers.cake"
#load "../cake/dotnet.cake"
#load "./devices-shared.cake"
#load "./uitests-shared.cake"

const int DefaultApiLevel = 30;

Information("Local Dotnet: {0}", localDotnet);

string DEFAULT_ANDROID_PROJECT = "../../src/Controls/tests/TestCases.Android.Tests/Controls.TestCases.Android.Tests.csproj";
var projectPath = Argument("project", EnvironmentVariable("ANDROID_TEST_PROJECT") ?? DEFAULT_ANDROID_PROJECT);
var testDevice = Argument("device", EnvironmentVariable("ANDROID_TEST_DEVICE") ?? $"android-emulator-64_{DefaultApiLevel}");
Expand All @@ -23,9 +23,6 @@ var deviceSkin = Argument("skin", EnvironmentVariable("ANDROID_TEST_SKIN") ?? "N
var androidAvd = "DEVICE_TESTS_EMULATOR";
var androidAvdImage = "";
var deviceArch = "";
bool deviceBoot = Argument("boot", true);
bool deviceBootWait = Argument("wait", true);

var androidVersion = Argument("apiversion", EnvironmentVariable("ANDROID_PLATFORM_VERSION") ?? DefaultApiLevel.ToString());

// Directory setup
Expand Down Expand Up @@ -59,6 +56,7 @@ var dotnetToolPath = GetDotnetToolPath();
Setup(context =>
{
LogSetupInfo(dotnetToolPath);
PerformCleanupIfNeeded(deviceCleanupEnabled);
DetermineDeviceCharacteristics(testDevice, DefaultApiLevel);
Expand Down Expand Up @@ -88,18 +86,20 @@ Task("test")
});

Task("uitest-build")
.IsDependentOn("dotnet-buildtasks")
.Does(() =>
{
ExecuteBuildUITestApp(testAppProjectPath, testDevice, binlogDirectory, configuration, targetFramework, "", dotnetToolPath);
});

Task("uitest")
.Does(() =>
{
ExecuteUITests(projectPath, testAppProjectPath, testAppPackageName, testDevice, testResultsPath, binlogDirectory, configuration, targetFramework, "", androidVersion, dotnetToolPath, testAppInstrumentation);
});

Task("cg-uitest")
.IsDependentOn("dotnet-buildtasks")
.Does(() =>
{
ExecuteCGLegacyUITests(projectPath, testAppProjectPath, testAppPackageName, testDevice, testResultsPath, configuration, targetFramework, dotnetToolPath, testAppInstrumentation);
Expand Down Expand Up @@ -461,7 +461,7 @@ void HandleVirtualDevice(AndroidEmulatorToolSettings emuSettings, AndroidAvdMana
void CleanUpVirtualDevice(AndroidEmulatorProcess emulatorProcess, AndroidAvdManagerToolSettings avdSettings)
{
// no virtual device was used
if (emulatorProcess == null || !deviceBoot || TARGET.ToLower() == "boot")
if (emulatorProcess == null || !deviceBoot || targetBoot)
return;

//stop and cleanup the emulator
Expand Down
4 changes: 1 addition & 3 deletions eng/devices/catalyst.cake
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#load "../cake/helpers.cake"
#load "../cake/dotnet.cake"
#load "./devices-shared.cake"
#load "./uitests-shared.cake"

// Argument handling
string DEFAULT_MAC_PROJECT = "../../src/Controls/tests/TestCases.Mac.Tests/Controls.TestCases.Mac.Tests.csproj";
Expand Down
13 changes: 12 additions & 1 deletion eng/devices/devices-shared.cake
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,18 @@ void LogSetupInfo(string toolPath)
string GetDotnetToolPath()
{
var isLocalDotnet = GetBuildVariable("workloads", "local") == "local";
var toolPath = isLocalDotnet ? $"{MakeAbsolute(Directory("../../bin/dotnet/")).ToString()}/dotnet" : DotnetToolPathDefault;
string toolPath;


if(IsRunningOnWindows())
{
toolPath = isLocalDotnet ? $"{MakeAbsolute(Directory("../../bin/dotnet/")).ToString()}/dotnet" : null;
}
else
{
toolPath = isLocalDotnet ? $"{MakeAbsolute(Directory("../../bin/dotnet/")).ToString()}/dotnet" : DotnetToolPathDefault;
}

Information(isLocalDotnet ? "Using local dotnet" : "Using system dotnet");
return toolPath;
}
Expand Down
74 changes: 64 additions & 10 deletions eng/devices/ios.cake
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#addin nuget:?package=Cake.AppleSimulator&version=0.2.0
#load "../cake/helpers.cake"
#load "../cake/dotnet.cake"
#load "./devices-shared.cake"
#load "./uitests-shared.cake"

const string DefaultVersion = "17.2";
const string DefaultTestDevice = $"ios-simulator-64_{DefaultVersion}";

// Required arguments
string DEFAULT_IOS_PROJECT = "../../src/Controls/tests/TestCases.iOS.Tests/Controls.TestCases.iOS.Tests.csproj";
var projectPath = Argument("project", EnvironmentVariable("IOS_TEST_PROJECT") ?? DEFAULT_IOS_PROJECT);
var testDevice = Argument("device", EnvironmentVariable("IOS_TEST_DEVICE") ?? $"ios-simulator-64_{DefaultVersion}");
var testDevice = Argument("device", EnvironmentVariable("IOS_TEST_DEVICE") ?? DefaultTestDevice);
var targetFramework = Argument("tfm", EnvironmentVariable("TARGET_FRAMEWORK") ?? $"{DotnetVersion}-ios");
var binlogArg = Argument("binlog", EnvironmentVariable("IOS_TEST_BINLOG") ?? "");
var testApp = Argument("app", EnvironmentVariable("IOS_TEST_APP") ?? "");
Expand Down Expand Up @@ -45,6 +44,12 @@ var dotnetToolPath = GetDotnetToolPath();
Setup(context =>
{
LogSetupInfo(dotnetToolPath);
if (!deviceBoot)
{
return;
}
PerformCleanupIfNeeded(deviceCleanupEnabled, false);
// Device or simulator setup
Expand All @@ -59,10 +64,21 @@ Setup(context =>
}
});

Teardown(context => PerformCleanupIfNeeded(deviceCleanupEnabled, true));
Teardown(context =>
{
if (!deviceBoot || targetBoot)
{
return;
}
PerformCleanupIfNeeded(deviceCleanupEnabled, true);
});

Task("Cleanup");

// Todo this doesn't work for iOS currently
// Task("boot");

Task("Build")
.WithCriteria(!string.IsNullOrEmpty(projectPath))
.Does(() =>
Expand All @@ -78,10 +94,10 @@ Task("Test")
});

Task("uitest-build")
.IsDependentOn("dotnet-buildtasks")
.Does(() =>
{
ExecuteBuildUITestApp(testAppProjectPath, testDevice, binlogDirectory, configuration, targetFramework, runtimeIdentifier, dotnetToolPath);
});

Task("uitest")
Expand All @@ -92,6 +108,7 @@ Task("uitest")
});

Task("cg-uitest")
.IsDependentOn("dotnet-buildtasks")
.Does(() =>
{
ExecuteCGLegacyUITests(projectPath, testAppProjectPath, testDevice, testResultsPath, configuration, targetFramework, runtimeIdentifier, iosVersion, dotnetToolPath);
Expand Down Expand Up @@ -385,7 +402,7 @@ string GetDefaultRuntimeIdentifier(string testDeviceIdentifier)

void InstallIpa(string testApp, string testAppPackageName, string testDevice, string testResultsDirectory, string version, string toolPath)
{
Information("Install with xharness: {0}", testApp);
Information("Install with xharness: {0} testDevice:{1}", testApp, testDevice);
var settings = new DotNetToolSettings
{
ToolPath = toolPath,
Expand All @@ -397,6 +414,7 @@ void InstallIpa(string testApp, string testAppPackageName, string testDevice, st
$"--targets=\"{testDevice}\" " +
$"--output-directory=\"{testResultsDirectory}\" " +
$"--verbosity=\"Debug\" ");
if (testDevice.Contains("device"))
{
if (string.IsNullOrEmpty(DEVICE_UDID))
Expand Down Expand Up @@ -435,12 +453,14 @@ void InstallIpa(string testApp, string testAppPackageName, string testDevice, st
}
else
{
var simulatorName = "XHarness";
Information("Looking for simulator: {0} iosversion {1}", simulatorName, iosVersionToRun);
var UDID = GetUDID(testDevice, dotnetToolPath);
var sims = ListAppleSimulators();
var simXH = sims.Where(s => s.Name.Contains(simulatorName) && s.Name.Contains(iosVersionToRun)).FirstOrDefault();

var simXH = sims.Where(s => s.UDID == UDID).FirstOrDefault();
if (simXH == null)
{
throw new Exception("No simulator was found to run tests on.");
}

deviceToRun = simXH.UDID;
DEVICE_NAME = simXH.Name;
Expand All @@ -454,6 +474,40 @@ void InstallIpa(string testApp, string testAppPackageName, string testDevice, st
}
}

string GetUDID(string testDevice, string tool)
{
Information("Looking for simulator: {0}", testDevice);
string result = string.Empty;

DotNetTool("tool", new DotNetToolSettings
{
ToolPath = tool,
ArgumentCustomization = args => args.Append($"run xharness apple device {testDevice}"),
SetupProcessSettings = processSettings =>
{
processSettings.RedirectStandardOutput = true;
processSettings.RedirectedStandardOutputHandler = line =>
{
// The output from this command returns the UDID of the simulator
// and NULL so we're filtering out the NULL
if (!string.IsNullOrWhiteSpace(line))
{
result = line;
}
return line;
};
}
});

if(!string.IsNullOrWhiteSpace(result))
Information("Yay we found your device: {0}", result);
else
Information("No device found installed: {0}", testDevice);

return result;
}

void GetSimulators(string version, string tool)
{
Information("Getting simulators for version {0}", version);
Expand Down
13 changes: 13 additions & 0 deletions eng/devices/uitests-shared.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#load "../cake/helpers.cake"

if (!IsCIBuild() && GetBuildVariable("workloads", "notset") == "notset")
{
SetEnvironmentVariable("workloads", "global");
}

#load "../cake/dotnet.cake"
#load "./devices-shared.cake"

bool deviceBoot = Argument("boot", TARGET.ToLower() != "uitest-build");
bool targetBoot = TARGET.ToLower() == "boot";
bool deviceBootWait = Argument("wait", true);
4 changes: 1 addition & 3 deletions eng/devices/windows.cake
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#load "../cake/helpers.cake"
#load "../cake/dotnet.cake"
#load "./devices-shared.cake"
#load "./uitests-shared.cake"

using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
Expand Down
3 changes: 0 additions & 3 deletions eng/pipelines/common/ui-tests-build-sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ steps:
- pwsh: echo "##vso[task.prependpath]$(DotNet.Dir)"
displayName: 'Add .NET to PATH'

- pwsh: ./build.ps1 --target=dotnet-buildtasks --configuration="${{ parameters.configuration }}"
displayName: 'Build the MSBuild Tasks'

- pwsh: ./build.ps1 --target=dotnet-samples --configuration="${{ parameters.configuration }}" --${{ parameters.platform }} --verbosity=diagnostic --usenuget=false --runtimevariant="${{ parameters.runtimeVariant }}"
displayName: 'Build the samples'

Expand Down
3 changes: 0 additions & 3 deletions eng/pipelines/common/ui-tests-compatibility-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ steps:
- pwsh: echo "##vso[task.prependpath]$(DotNet.Dir)"
displayName: 'Add .NET to PATH'

- pwsh: ./build.ps1 --target=dotnet-buildtasks --configuration="${{ parameters.configuration }}"
displayName: 'Build the MSBuild Tasks'

- pwsh: ./build.ps1 --target=${{ parameters.targetSample }} --configuration="${{ parameters.configuration }}" --${{ parameters.platform }} --verbosity=diagnostic
displayName: 'Build the Legacy ControlGallery'

Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ stages:
androidApiLevels: [ 30 ]
iosVersions: [ '17.2' ]
provisionatorChannel: ${{ parameters.provisionatorChannel }}
${{ if or(parameters.CompatibilityTests, ne(variables['Build.Reason'], 'PullRequest')) }}:
${{ if parameters.CompatibilityTests }}:
runCompatibilityTests: true
projects:
- name: controls
Expand Down
3 changes: 2 additions & 1 deletion src/Controls/src/Core/Element/Element.cs
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,8 @@ internal void OnResourcesChanged(IEnumerable<KeyValuePair<string, object>> value
internal override void OnSetDynamicResource(BindableProperty property, string key, SetterSpecificity specificity)
{
base.OnSetDynamicResource(property, key, specificity);
DynamicResources[property] = (key, specificity);
if (!DynamicResources.TryGetValue(property, out var existing) || existing.Item2 < specificity)
DynamicResources[property] = (key, specificity);
if (this.TryGetResource(key, out var value))
OnResourceChanged(property, value, specificity);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public InnerGestureListener(

bool HasAnyGestures()
{
return _panGestureHandler.HasAnyGestures() || _tapGestureHandler.HasAnyGestures() || _swipeGestureHandler.HasAnyGestures();
return (_panGestureHandler?.HasAnyGestures() ?? false) || (_tapGestureHandler?.HasAnyGestures() ?? false) || (_swipeGestureHandler?.HasAnyGestures() ?? false);
}

// This is needed because GestureRecognizer callbacks can be delayed several hundred milliseconds
Expand Down
Loading

0 comments on commit 11aa1bd

Please sign in to comment.