From 22cbbfcb7e425549244b11218d1ba947e993b180 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 2 Nov 2023 18:28:43 -0400 Subject: [PATCH] chore: Make runtime tests engine more global using friendly --- .../ExternalRunner/_Private/DevServer.cs | 96 +-- .../ExternalRunner/_Private/SecondaryApp.cs | 43 +- .../Library/Helpers/AsyncAssert.cs | 681 +++++++++--------- .../Library/Helpers/HotReloadHelper.Local.cs | 22 +- .../HotReloadHelper.MetadataUpdateHandler.cs | 13 +- .../Helpers/HotReloadHelper.NotSupported.cs | 13 +- .../Library/Helpers/HotReloadHelper.cs | 97 ++- 7 files changed, 450 insertions(+), 515 deletions(-) diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/ExternalRunner/_Private/DevServer.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/ExternalRunner/_Private/DevServer.cs index 3625203..37bbe4a 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/ExternalRunner/_Private/DevServer.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/ExternalRunner/_Private/DevServer.cs @@ -5,23 +5,6 @@ #pragma warning disable #endif #pragma warning disable CA1848 // Log perf - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Net; -using System.Net.Sockets; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Text.RegularExpressions; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Extensions.Logging; -using Uno.Extensions; -using Uno.UI.RuntimeTests.Engine; - namespace Uno.UI.RuntimeTests.Internal.Helpers; /// @@ -31,9 +14,9 @@ namespace Uno.UI.RuntimeTests.Internal.Helpers; /// This class is intended to be used only by the the test engine itself and should not be used by applications. /// API contract is not guaranteed and might change in future releases. /// -internal sealed partial class DevServer : IAsyncDisposable +internal sealed partial class DevServer : global::System.IAsyncDisposable { - private static readonly ILogger _log = typeof(DevServer).Log(); + private static readonly global::Microsoft.Extensions.Logging.ILogger _log = global::Uno.Extensions.LogExtensionPoint.Log(typeof(DevServer)); private static int _instance; private static string? _devServerPath; @@ -42,7 +25,7 @@ internal sealed partial class DevServer : IAsyncDisposable /// /// Cancellation token to abort the initialization of the server. /// The new dev server instance. - public static async Task Start(CancellationToken ct) + public static async global::System.Threading.Tasks.Task Start(global::System.Threading.CancellationToken ct) { #if !HAS_UNO_DEVSERVER throw new NotSupportedException("Dev server has not been referenced."); @@ -54,9 +37,9 @@ public static async Task Start(CancellationToken ct) #endif } - private readonly Process _process; + private readonly global::System.Diagnostics.Process _process; - private DevServer(Process process, int port) + private DevServer(global::System.Diagnostics.Process process, int port) { Port = port; _process = process; @@ -67,16 +50,16 @@ private DevServer(Process process, int port) /// public int Port { get; } - private static async Task GetDevServer(CancellationToken ct) + private static async global::System.Threading.Tasks.Task GetDevServer(global::System.Threading.CancellationToken ct) => _devServerPath ??= await PullDevServer(ct); /// /// Pulls the latest version of dev server from NuGet and returns the path to the executable /// - private static async Task PullDevServer(CancellationToken ct) + private static async global::System.Threading.Tasks.Task PullDevServer(global::System.Threading.CancellationToken ct) { - var dir = Path.Combine(Path.GetTempPath(), $"DevServer_{Guid.NewGuid():N}"); - Directory.CreateDirectory(dir); + var dir = global::System.IO.Path.Combine(global::System.IO.Path.GetTempPath(), $"DevServer_{(global::System.Guid.NewGuid()):N}"); + global::System.IO.Directory.CreateDirectory(dir); try { @@ -86,7 +69,7 @@ private static async Task PullDevServer(CancellationToken ct) ct, "dotnet", new() { "--version" }, - Environment.CurrentDirectory, // Needed to get the version used by the current app (i.e. including global.json) + global::System.Environment.CurrentDirectory, // Needed to get the version used by the current app (i.e. including global.json) log); var dotnetVersion = GetDotnetVersion(rawVersion); @@ -96,12 +79,12 @@ private static async Task PullDevServer(CancellationToken ct) net{dotnetVersion.Major}.{dotnetVersion.Minor} "; - await File.WriteAllTextAsync(Path.Combine(dir, "PullDevServer.csproj"), csProj, ct); + await global::System.IO.File.WriteAllTextAsync(global::System.IO.Path.Combine(dir, "PullDevServer.csproj"), csProj, ct); } using (var log = _log.Scope("PULL_DEV_SERVER")) { - var args = new List { "add", "package" }; + var args = new global::System.Collections.Generic.List { "add", "package" }; #if HAS_UNO_WINUI || WINDOWS_WINUI args.Add("Uno.WinUI.DevServer"); #else @@ -109,17 +92,15 @@ private static async Task PullDevServer(CancellationToken ct) #endif // If the assembly is not a debug version it should have a valid version // Note: This is the version of the RemoteControl assembly, not the RemoteControl.Host, but they should be in sync (both are part of the DevServer package) - if (Type.GetType("Uno.UI.RemoteControl.RemoteControlClient, Uno.UI.RemoteControl", throwOnError: false) - ?.Assembly - .GetCustomAttribute() - ?.InformationalVersion is { Length: > 0 } runtimeVersion - && Regex.Match(runtimeVersion, @"^(?\d+\.\d+\.\d+(-\w+\.\d+))+") is {Success: true} match) + if (global::System.Type.GetType("Uno.UI.RemoteControl.RemoteControlClient, Uno.UI.RemoteControl", throwOnError: false)?.Assembly is { } devServerAssembly + && global::System.Reflection.CustomAttributeExtensions.GetCustomAttribute(devServerAssembly)?.InformationalVersion is { Length: > 0 } runtimeVersion + && global::System.Text.RegularExpressions.Regex.Match(runtimeVersion, @"^(?\d+\.\d+\.\d+(-\w+\.\d+))+") is { Success: true } match) { args.Add("--version"); args.Add(match.Groups["version"].Value); } // Otherwise we use the version used to compile the test engine - else if (typeof(DevServer).Assembly.GetCustomAttribute()?.Version is { Length: > 0 } version) + else if (global::System.Reflection.CustomAttributeExtensions.GetCustomAttribute(typeof(DevServer).Assembly)?.Version is { Length: > 0 } version) { args.Add("--version"); args.Add(version); @@ -144,14 +125,14 @@ private static async Task PullDevServer(CancellationToken ct) return GetConfigurationValue(data, "RemoteControlHostPath") is { Length: > 0 } path ? path - : throw new InvalidOperationException("Failed to get remote control host path"); + : throw new global::System.InvalidOperationException("Failed to get remote control host path"); } } finally { try { - Directory.Delete(dir, recursive: true); + global::System.IO.Directory.Delete(dir, recursive: true); } catch { /* Nothing to do */ } } @@ -162,51 +143,52 @@ private static async Task PullDevServer(CancellationToken ct) /// private static DevServer StartCore(string hostBinPath, int port) { - if (!File.Exists(hostBinPath)) + if (!global::System.IO.File.Exists(hostBinPath)) { - _log.LogError($"DevServer {hostBinPath} does not exist"); - throw new InvalidOperationException($"Unable to find {hostBinPath}"); + global::Microsoft.Extensions.Logging.LoggerExtensions.LogError(_log, $"DevServer {hostBinPath} does not exist"); + throw new global::System.InvalidOperationException($"Unable to find {hostBinPath}"); } - var arguments = $"\"{hostBinPath}\" --httpPort {port} --ppid {Environment.ProcessId} --metadata-updates true"; - var pi = new ProcessStartInfo("dotnet", arguments) + var arguments = $"\"{hostBinPath}\" --httpPort {port} --ppid {(global::System.Environment.ProcessId)} --metadata-updates true"; + var pi = new global::System.Diagnostics.ProcessStartInfo("dotnet", arguments) { UseShellExecute = false, CreateNoWindow = true, - WindowStyle = ProcessWindowStyle.Hidden, - WorkingDirectory = Path.GetDirectoryName(hostBinPath), + WindowStyle = global::System.Diagnostics.ProcessWindowStyle.Hidden, + WorkingDirectory = global::System.IO.Path.GetDirectoryName(hostBinPath), }; - var process = new System.Diagnostics.Process { StartInfo = pi }; + var process = new global::System.Diagnostics.Process { StartInfo = pi }; - process.StartAndLog(_log.Scope($"DEV_SERVER_{Interlocked.Increment(ref _instance):D2}")); + process.StartAndLog(_log.Scope($"DEV_SERVER_{(global::System.Threading.Interlocked.Increment(ref _instance)):D2}")); return new DevServer(process, port); } #region Misc helpers private static string? GetConfigurationValue(string msbuildResult, string nodeName) - => Regex.Match(msbuildResult, $"<{nodeName}>(?.*?)") is { Success: true } match + => global::System.Text.RegularExpressions.Regex.Match(msbuildResult, $"<{nodeName}>(?.*?)") is { Success: true } match ? match.Groups["value"].Value : null; - private static Version GetDotnetVersion(string dotnetRawVersion) - => Version.TryParse(dotnetRawVersion?.Split('-').FirstOrDefault(), out var version) - ? version - : throw new InvalidOperationException("Failed to read dotnet version"); + private static global::System.Version GetDotnetVersion(string dotnetRawVersion) + => dotnetRawVersion?.Split('-') is { } versionParts + && global::System.Version.TryParse(global::System.Linq.Enumerable.FirstOrDefault(versionParts), out var version) + ? version + : throw new global::System.InvalidOperationException("Failed to read dotnet version"); private static int GetTcpPort() { - var l = new TcpListener(IPAddress.Loopback, 0); + var l = new global::System.Net.Sockets.TcpListener(global::System.Net.IPAddress.Loopback, 0); l.Start(); - var port = ((IPEndPoint)l.LocalEndpoint).Port; + var port = ((global::System.Net.IPEndPoint)l.LocalEndpoint).Port; l.Stop(); return port; } #endregion /// - public async ValueTask DisposeAsync() + public async global::System.Threading.Tasks.ValueTask DisposeAsync() { if (_process is null or { HasExited: true }) { @@ -217,12 +199,12 @@ public async ValueTask DisposeAsync() { _process.Kill(true); // Best effort, the app should kill itself anyway } - catch (Exception e) + catch (global::System.Exception e) { - _log.LogError("Failed to kill dev server", e); + global::Microsoft.Extensions.Logging.LoggerExtensions.LogError(_log, "Failed to kill dev server", e); } - await _process.WaitForExitAsync(CancellationToken.None); + await _process.WaitForExitAsync(global::System.Threading.CancellationToken.None); } } diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/ExternalRunner/_Private/SecondaryApp.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/ExternalRunner/_Private/SecondaryApp.cs index a4cd4a5..1c3d225 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/ExternalRunner/_Private/SecondaryApp.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/ExternalRunner/_Private/SecondaryApp.cs @@ -9,16 +9,6 @@ #define IS_SECONDARY_APP_SUPPORTED #endif -using System; -using System.Diagnostics; -using System.IO; -using System.Threading.Tasks; -using System.Threading; -using System.Linq; -using System.Text.Json; -using System.Text.Json.Serialization; -using Uno.Extensions; - namespace Uno.UI.RuntimeTests.Internal.Helpers; /// @@ -47,10 +37,10 @@ internal static partial class SecondaryApp /// Token to cancel the test run. /// Indicates if the application should be ran head-less or not. /// The test results. - internal static async Task RunTest(UnitTestEngineConfig config, CancellationToken ct, bool isAppVisible = false) + internal static async global::System.Threading.Tasks.Task RunTest(UnitTestEngineConfig config, global::System.Threading.CancellationToken ct, bool isAppVisible = false) { #if !IS_SECONDARY_APP_SUPPORTED - throw new NotSupportedException("Secondary app is not supported on this platform."); + throw new global::System.NotSupportedException("Secondary app is not supported on this platform."); #else // First we fetch and start the dev-server (needed to HR tests for instance) await using var devServer = await DevServer.Start(ct); @@ -61,13 +51,13 @@ internal static async Task RunTest(UnitTestEngineConfig config // Finally, read the test results try { - var results = await JsonSerializer.DeserializeAsync(File.OpenRead(resultFile), cancellationToken: ct); + var results = await global::System.Text.Json.JsonSerializer.DeserializeAsync(global::System.IO.File.OpenRead(resultFile), cancellationToken: ct); - return results ?? Array.Empty(); + return results ?? global::System.Array.Empty(); } - catch (JsonException error) + catch (global::System.Text.Json.JsonException error) { - throw new InvalidOperationException( + throw new global::System.InvalidOperationException( $"Failed to deserialize the test results from '{resultFile}', this usually indicates that the secondary app has been closed (or crashed) before the end of the test suit.", error); } @@ -75,18 +65,19 @@ internal static async Task RunTest(UnitTestEngineConfig config private static int _instance; - private static async Task RunLocalApp(string devServerHost, int devServerPort, UnitTestEngineConfig config, bool isAppVisible, CancellationToken ct) + private static async global::System.Threading.Tasks.Task RunLocalApp(string devServerHost, int devServerPort, UnitTestEngineConfig config, bool isAppVisible, global::System.Threading.CancellationToken ct) { - var testOutput = Path.GetTempFileName(); + var testOutput = global::System.IO.Path.GetTempFileName(); + var configJson = global::System.Text.Json.JsonSerializer.Serialize(config, new global::System.Text.Json.JsonSerializerOptions { DefaultIgnoreCondition = global::System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault }); - var childStartInfo = new ProcessStartInfo( - Environment.ProcessPath ?? throw new InvalidOperationException("Cannot determine the current app executable path"), - string.Join(" ", Environment.GetCommandLineArgs().Select(arg => '"' + arg + '"'))) + var childStartInfo = new global::System.Diagnostics.ProcessStartInfo( + global::System.Environment.ProcessPath ?? throw new global::System.InvalidOperationException("Cannot determine the current app executable path"), + string.Join(" ", global::System.Linq.Enumerable.Select(global::System.Environment.GetCommandLineArgs(), arg => '"' + arg + '"'))) { UseShellExecute = false, CreateNoWindow = !isAppVisible, - WindowStyle = isAppVisible ? ProcessWindowStyle.Normal : ProcessWindowStyle.Hidden, - WorkingDirectory = Environment.CurrentDirectory, + WindowStyle = isAppVisible ? global::System.Diagnostics.ProcessWindowStyle.Normal : global::System.Diagnostics.ProcessWindowStyle.Hidden, + WorkingDirectory = global::System.Environment.CurrentDirectory, }; // Configure the runtime to allow hot-reload @@ -97,14 +88,14 @@ private static async Task RunLocalApp(string devServerHost, int devServe childStartInfo.EnvironmentVariables.Add("UNO_DEV_SERVER_PORT", devServerPort.ToString()); // Request to the runtime tests engine to auto-start at startup - childStartInfo.EnvironmentVariables.Add("UNO_RUNTIME_TESTS_RUN_TESTS", JsonSerializer.Serialize(config, new JsonSerializerOptions { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault })); + childStartInfo.EnvironmentVariables.Add("UNO_RUNTIME_TESTS_RUN_TESTS", configJson); childStartInfo.EnvironmentVariables.Add("UNO_RUNTIME_TESTS_OUTPUT_PATH", testOutput); childStartInfo.EnvironmentVariables.Add("UNO_RUNTIME_TESTS_OUTPUT_KIND", "UnoRuntimeTests"); // "NUnit" childStartInfo.EnvironmentVariables.Add("UNO_RUNTIME_TESTS_IS_SECONDARY_APP", "true"); // "NUnit" - var childProcess = new Process { StartInfo = childStartInfo }; + var childProcess = new global::System.Diagnostics.Process { StartInfo = childStartInfo }; - await childProcess.ExecuteAndLogAsync(typeof(SecondaryApp).CreateScopedLog($"CHILD_TEST_APP_{Interlocked.Increment(ref _instance):D2}"), ct); + await childProcess.ExecuteAndLogAsync(typeof(SecondaryApp).CreateScopedLog($"CHILD_TEST_APP_{(global::System.Threading.Interlocked.Increment(ref _instance)):D2}"), ct); return testOutput; #endif diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Library/Helpers/AsyncAssert.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Library/Helpers/AsyncAssert.cs index 593de94..16dfafc 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Library/Helpers/AsyncAssert.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Library/Helpers/AsyncAssert.cs @@ -3,15 +3,6 @@ #pragma warning disable #endif -using System; -using System.Collections.Generic; -using System.IO; -using System.Runtime.CompilerServices; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.VisualStudio.TestTools.UnitTesting; - namespace Uno.UI.RuntimeTests; public static partial class AsyncAssert @@ -25,13 +16,13 @@ public static partial class AsyncAssert /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask IsTrue( - Func condition, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("condition")] string conditionExpression = "") - => IsTrueCore(condition, $"{conditionExpression} to be true but found false ({Path.GetFileName(file)}@{line})", TestHelper.DefaultTimeout, ct); + public static global::System.Threading.Tasks.ValueTask IsTrue( + global::System.Func condition, + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("condition")] string conditionExpression = "") + => IsTrueCore(condition, $"{conditionExpression} to be true but found false ({(global::System.IO.Path.GetFileName(file))}@{line})", TestHelper.DefaultTimeout, ct); /// /// Asynchronously tests whether the specified condition is true and throws an exception if the condition is false. @@ -42,14 +33,14 @@ public static ValueTask IsTrue( /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask IsTrue( - Func condition, - TimeSpan timeout, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("condition")] string conditionExpression = "") - => IsTrueCore(condition, $"{conditionExpression} to be true but found false ({Path.GetFileName(file)}@{line})", timeout, ct); + public static global::System.Threading.Tasks.ValueTask IsTrue( + global::System.Func condition, + global::System.TimeSpan timeout, + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("condition")] string conditionExpression = "") + => IsTrueCore(condition, $"{conditionExpression} to be true but found false ({(global::System.IO.Path.GetFileName(file))}@{line})", timeout, ct); /// /// Asynchronously tests whether the specified condition is true and throws an exception if the condition is false. @@ -60,14 +51,14 @@ public static ValueTask IsTrue( /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask IsTrue( - Func condition, + public static global::System.Threading.Tasks.ValueTask IsTrue( + global::System.Func condition, int timeoutMs, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("condition")] string conditionExpression = "") - => IsTrueCore(condition, $"{conditionExpression} to be true but found false ({Path.GetFileName(file)}@{line})", TimeSpan.FromMilliseconds(timeoutMs), ct); + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("condition")] string conditionExpression = "") + => IsTrueCore(condition, $"{conditionExpression} to be true but found false ({(global::System.IO.Path.GetFileName(file))}@{line})", global::System.TimeSpan.FromMilliseconds(timeoutMs), ct); /// /// Asynchronously tests whether the specified condition is true and throws an exception if the condition is false. @@ -75,7 +66,7 @@ public static ValueTask IsTrue( /// The condition the test expects to be true. /// The message to include in the exception when condition is not equal to expected. The message is shown in test results. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask IsTrue(Func condition, string message, CancellationToken ct = default) + public static global::System.Threading.Tasks.ValueTask IsTrue(global::System.Func condition, string message, global::System.Threading.CancellationToken ct = default) => IsTrueCore(condition, message, TestHelper.DefaultTimeout, ct); /// @@ -85,7 +76,7 @@ public static ValueTask IsTrue(Func condition, string message, Cancellatio /// The message to include in the exception when condition is not equal to expected. The message is shown in test results. /// The max duration to wait for. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask IsTrue(Func condition, string message, TimeSpan timeout, CancellationToken ct = default) + public static global::System.Threading.Tasks.ValueTask IsTrue(global::System.Func condition, string message, global::System.TimeSpan timeout, global::System.Threading.CancellationToken ct = default) => IsTrueCore(condition, message, timeout, ct); /// @@ -95,8 +86,8 @@ public static ValueTask IsTrue(Func condition, string message, TimeSpan ti /// The message to include in the exception when condition is not equal to expected. The message is shown in test results. /// The max duration to wait for in milliseconds. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask IsTrue(Func condition, string message, int timeoutMs, CancellationToken ct = default) - => IsTrueCore( condition, message, TimeSpan.FromMilliseconds(timeoutMs), ct); + public static global::System.Threading.Tasks.ValueTask IsTrue(global::System.Func condition, string message, int timeoutMs, global::System.Threading.CancellationToken ct = default) + => IsTrueCore( condition, message, global::System.TimeSpan.FromMilliseconds(timeoutMs), ct); /// /// Asynchronously tests whether the specified condition is true and throws an exception if the condition is false. @@ -106,13 +97,13 @@ public static ValueTask IsTrue(Func condition, string message, int timeout /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask IsTrue( - Func> condition, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("condition")] string conditionExpression = "") - => IsTrueCore(condition, $"{conditionExpression} to be true but found false ({Path.GetFileName(file)}@{line})", TestHelper.DefaultTimeout, ct); + public static global::System.Threading.Tasks.ValueTask IsTrue( + global::System.Func> condition, + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("condition")] string conditionExpression = "") + => IsTrueCore(condition, $"{conditionExpression} to be true but found false ({(global::System.IO.Path.GetFileName(file))}@{line})", TestHelper.DefaultTimeout, ct); /// /// Asynchronously tests whether the specified condition is true and throws an exception if the condition is false. @@ -123,14 +114,14 @@ public static ValueTask IsTrue( /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask IsTrue( - Func> condition, - TimeSpan timeout, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("condition")] string conditionExpression = "") - => IsTrueCore(condition, $"{conditionExpression} to be true but found false ({Path.GetFileName(file)}@{line})", timeout, ct); + public static global::System.Threading.Tasks.ValueTask IsTrue( + global::System.Func> condition, + global::System.TimeSpan timeout, + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("condition")] string conditionExpression = "") + => IsTrueCore(condition, $"{conditionExpression} to be true but found false ({(global::System.IO.Path.GetFileName(file))}@{line})", timeout, ct); /// /// Asynchronously tests whether the specified condition is true and throws an exception if the condition is false. @@ -141,14 +132,14 @@ public static ValueTask IsTrue( /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask IsTrue( - Func> condition, + public static global::System.Threading.Tasks.ValueTask IsTrue( + global::System.Func> condition, int timeoutMs, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("condition")] string conditionExpression = "") - => IsTrueCore(condition, $"{conditionExpression} to be true but found false ({Path.GetFileName(file)}@{line})", TimeSpan.FromMilliseconds(timeoutMs), ct); + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("condition")] string conditionExpression = "") + => IsTrueCore(condition, $"{conditionExpression} to be true but found false ({(global::System.IO.Path.GetFileName(file))}@{line})", global::System.TimeSpan.FromMilliseconds(timeoutMs), ct); /// /// Asynchronously tests whether the specified condition is true and throws an exception if the condition is false. @@ -156,7 +147,7 @@ public static ValueTask IsTrue( /// The condition the test expects to be true. /// The message to include in the exception when condition is not equal to expected. The message is shown in test results. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask IsTrue(Func> condition, string message, CancellationToken ct = default) + public static global::System.Threading.Tasks.ValueTask IsTrue(global::System.Func> condition, string message, global::System.Threading.CancellationToken ct = default) => IsTrueCore(condition, message, TestHelper.DefaultTimeout, ct); /// @@ -166,7 +157,7 @@ public static ValueTask IsTrue(Func> condition, string message, /// The message to include in the exception when condition is not equal to expected. The message is shown in test results. /// The max duration to wait for. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask IsTrue(Func> condition, string message, TimeSpan timeout, CancellationToken ct = default) + public static global::System.Threading.Tasks.ValueTask IsTrue(global::System.Func> condition, string message, global::System.TimeSpan timeout, global::System.Threading.CancellationToken ct = default) => IsTrueCore(condition, message, timeout, ct); /// @@ -176,21 +167,21 @@ public static ValueTask IsTrue(Func> condition, string message, /// The message to include in the exception when condition is not equal to expected. The message is shown in test results. /// The max duration to wait for in milliseconds. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask IsTrue(Func> condition, string message, int timeoutMs, CancellationToken ct = default) - => IsTrueCore(condition, message, TimeSpan.FromMilliseconds(timeoutMs), ct); + public static global::System.Threading.Tasks.ValueTask IsTrue(global::System.Func> condition, string message, int timeoutMs, global::System.Threading.CancellationToken ct = default) + => IsTrueCore(condition, message, global::System.TimeSpan.FromMilliseconds(timeoutMs), ct); - private static async ValueTask IsTrueCore(Func condition, string reason, TimeSpan timeout, CancellationToken ct) + private static async global::System.Threading.Tasks.ValueTask IsTrueCore(global::System.Func condition, string reason, global::System.TimeSpan timeout, global::System.Threading.CancellationToken ct) { await TestHelper.TryWaitFor(condition, timeout, ct); - Assert.IsTrue(condition(), reason); + global::Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(condition(), reason); } - private static async ValueTask IsTrueCore(Func> condition, string reason, TimeSpan timeout, CancellationToken ct) + private static async global::System.Threading.Tasks.ValueTask IsTrueCore(global::System.Func> condition, string reason, global::System.TimeSpan timeout, global::System.Threading.CancellationToken ct) { await TestHelper.TryWaitFor(async _ => await condition().ConfigureAwait(false), timeout, ct); - Assert.IsTrue(await condition().ConfigureAwait(false), reason); + global::Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(await condition().ConfigureAwait(false), reason); } #endregion @@ -203,13 +194,13 @@ private static async ValueTask IsTrueCore(Func> condition, strin /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask IsFalse( - Func condition, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("condition")] string conditionExpression = "") - => IsFalseCore(condition, $"{conditionExpression} to be false but found true ({Path.GetFileName(file)}@{line})", TestHelper.DefaultTimeout, ct); + public static global::System.Threading.Tasks.ValueTask IsFalse( + global::System.Func condition, + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("condition")] string conditionExpression = "") + => IsFalseCore(condition, $"{conditionExpression} to be false but found true ({(global::System.IO.Path.GetFileName(file))}@{line})", TestHelper.DefaultTimeout, ct); /// /// Asynchronously tests whether the specified condition is false and throws an exception if the condition is true. @@ -220,14 +211,14 @@ public static ValueTask IsFalse( /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask IsFalse( - Func condition, - TimeSpan timeout, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("condition")] string conditionExpression = "") - => IsFalseCore(condition, $"{conditionExpression} to be false but found true ({Path.GetFileName(file)}@{line})", timeout, ct); + public static global::System.Threading.Tasks.ValueTask IsFalse( + global::System.Func condition, + global::System.TimeSpan timeout, + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("condition")] string conditionExpression = "") + => IsFalseCore(condition, $"{conditionExpression} to be false but found true ({(global::System.IO.Path.GetFileName(file))}@{line})", timeout, ct); /// /// Asynchronously tests whether the specified condition is false and throws an exception if the condition is true. @@ -238,14 +229,14 @@ public static ValueTask IsFalse( /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask IsFalse( - Func condition, + public static global::System.Threading.Tasks.ValueTask IsFalse( + global::System.Func condition, int timeoutMs, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("condition")] string conditionExpression = "") - => IsFalseCore(condition, $"{conditionExpression} to be false but found true ({Path.GetFileName(file)}@{line})", TimeSpan.FromMilliseconds(timeoutMs), ct); + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("condition")] string conditionExpression = "") + => IsFalseCore(condition, $"{conditionExpression} to be false but found true ({(global::System.IO.Path.GetFileName(file))}@{line})", global::System.TimeSpan.FromMilliseconds(timeoutMs), ct); /// /// Asynchronously tests whether the specified condition is false and throws an exception if the condition is true. @@ -253,7 +244,7 @@ public static ValueTask IsFalse( /// The condition the test expects to be false. /// The message to include in the exception when condition is not equal to expected. The message is shown in test results. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask IsFalse(Func condition, string message, CancellationToken ct = default) + public static global::System.Threading.Tasks.ValueTask IsFalse(global::System.Func condition, string message, global::System.Threading.CancellationToken ct = default) => IsFalseCore(condition, message, TestHelper.DefaultTimeout, ct); /// @@ -263,7 +254,7 @@ public static ValueTask IsFalse(Func condition, string message, Cancellati /// The message to include in the exception when condition is not equal to expected. The message is shown in test results. /// The max duration to wait for. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask IsFalse(Func condition, string message, TimeSpan timeout, CancellationToken ct = default) + public static global::System.Threading.Tasks.ValueTask IsFalse(global::System.Func condition, string message, global::System.TimeSpan timeout, global::System.Threading.CancellationToken ct = default) => IsFalseCore(condition, message, timeout, ct); /// @@ -273,8 +264,8 @@ public static ValueTask IsFalse(Func condition, string message, TimeSpan t /// The message to include in the exception when condition is not equal to expected. The message is shown in test results. /// The max duration to wait for in milliseconds. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask IsFalse(Func condition, string message, int timeoutMs, CancellationToken ct = default) - => IsFalseCore(condition, message, TimeSpan.FromMilliseconds(timeoutMs), ct); + public static global::System.Threading.Tasks.ValueTask IsFalse(global::System.Func condition, string message, int timeoutMs, global::System.Threading.CancellationToken ct = default) + => IsFalseCore(condition, message, global::System.TimeSpan.FromMilliseconds(timeoutMs), ct); /// /// Asynchronously tests whether the specified condition is false and throws an exception if the condition is true. @@ -284,13 +275,13 @@ public static ValueTask IsFalse(Func condition, string message, int timeou /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask IsFalse( - Func> condition, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("condition")] string conditionExpression = "") - => IsFalseCore(condition, $"{conditionExpression} to be false but found true ({Path.GetFileName(file)}@{line})", TestHelper.DefaultTimeout, ct); + public static global::System.Threading.Tasks.ValueTask IsFalse( + global::System.Func> condition, + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("condition")] string conditionExpression = "") + => IsFalseCore(condition, $"{conditionExpression} to be false but found true ({(global::System.IO.Path.GetFileName(file))}@{line})", TestHelper.DefaultTimeout, ct); /// /// Asynchronously tests whether the specified condition is false and throws an exception if the condition is true. @@ -301,14 +292,14 @@ public static ValueTask IsFalse( /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask IsFalse( - Func> condition, - TimeSpan timeout, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("condition")] string conditionExpression = "") - => IsFalseCore(condition, $"{conditionExpression} to be false but found true ({Path.GetFileName(file)}@{line})", timeout, ct); + public static global::System.Threading.Tasks.ValueTask IsFalse( + global::System.Func> condition, + global::System.TimeSpan timeout, + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("condition")] string conditionExpression = "") + => IsFalseCore(condition, $"{conditionExpression} to be false but found true ({(global::System.IO.Path.GetFileName(file))}@{line})", timeout, ct); /// /// Asynchronously tests whether the specified condition is false and throws an exception if the condition is true. @@ -319,14 +310,14 @@ public static ValueTask IsFalse( /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask IsFalse( - Func> condition, + public static global::System.Threading.Tasks.ValueTask IsFalse( + global::System.Func> condition, int timeoutMs, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("condition")] string conditionExpression = "") - => IsFalseCore(condition, $"{conditionExpression} to be false but found true ({Path.GetFileName(file)}@{line})", TimeSpan.FromMilliseconds(timeoutMs), ct); + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("condition")] string conditionExpression = "") + => IsFalseCore(condition, $"{conditionExpression} to be false but found true ({(global::System.IO.Path.GetFileName(file))}@{line})", global::System.TimeSpan.FromMilliseconds(timeoutMs), ct); /// /// Asynchronously tests whether the specified condition is false and throws an exception if the condition is true. @@ -334,7 +325,7 @@ public static ValueTask IsFalse( /// The condition the test expects to be false. /// The message to include in the exception when condition is not equal to expected. The message is shown in test results. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask IsFalse(Func> condition, string message, CancellationToken ct = default) + public static global::System.Threading.Tasks.ValueTask IsFalse(global::System.Func> condition, string message, global::System.Threading.CancellationToken ct = default) => IsFalseCore(condition, message, TestHelper.DefaultTimeout, ct); /// @@ -344,7 +335,7 @@ public static ValueTask IsFalse(Func> condition, string message, /// The message to include in the exception when condition is not equal to expected. The message is shown in test results. /// The max duration to wait for. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask IsFalse(Func> condition, string message, TimeSpan timeout, CancellationToken ct = default) + public static global::System.Threading.Tasks.ValueTask IsFalse(global::System.Func> condition, string message, global::System.TimeSpan timeout, global::System.Threading.CancellationToken ct = default) => IsFalseCore(condition, message, timeout, ct); /// @@ -354,21 +345,21 @@ public static ValueTask IsFalse(Func> condition, string message, /// The message to include in the exception when condition is not equal to expected. The message is shown in test results. /// The max duration to wait for in milliseconds. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask IsFalse(Func> condition, string message, int timeoutMs, CancellationToken ct = default) - => IsFalseCore(condition, message, TimeSpan.FromMilliseconds(timeoutMs), ct); + public static global::System.Threading.Tasks.ValueTask IsFalse(global::System.Func> condition, string message, int timeoutMs, global::System.Threading.CancellationToken ct = default) + => IsFalseCore(condition, message, global::System.TimeSpan.FromMilliseconds(timeoutMs), ct); - private static async ValueTask IsFalseCore(Func condition, string reason, TimeSpan timeout, CancellationToken ct) + private static async global::System.Threading.Tasks.ValueTask IsFalseCore(global::System.Func condition, string reason, global::System.TimeSpan timeout, global::System.Threading.CancellationToken ct) { await TestHelper.TryWaitFor(() => !condition(), timeout, ct); - Assert.IsFalse(condition(), reason); + global::Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsFalse(condition(), reason); } - private static async ValueTask IsFalseCore(Func> condition, string reason, TimeSpan timeout, CancellationToken ct) + private static async global::System.Threading.Tasks.ValueTask IsFalseCore(global::System.Func> condition, string reason, global::System.TimeSpan timeout, global::System.Threading.CancellationToken ct) { await TestHelper.TryWaitFor(async _ => !await condition().ConfigureAwait(false), timeout, ct); - Assert.IsFalse(await condition().ConfigureAwait(false), reason); + global::Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsFalse(await condition().ConfigureAwait(false), reason); } #endregion @@ -382,13 +373,13 @@ private static async ValueTask IsFalseCore(Func> condition, stri /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask IsNull( - Func value, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("value")] string valueExpression = "") - => IsNullCore(value, a => $"{valueExpression} to be null but found {a} ({Path.GetFileName(file)}@{line})", TestHelper.DefaultTimeout, ct); + public static global::System.Threading.Tasks.ValueTask IsNull( + global::System.Func value, + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("value")] string valueExpression = "") + => IsNullCore(value, a => $"{valueExpression} to be null but found {a} ({(global::System.IO.Path.GetFileName(file))}@{line})", TestHelper.DefaultTimeout, ct); /// /// Asynchronously tests whether the specified object is null and throws an exception if it is not. @@ -400,14 +391,14 @@ public static ValueTask IsNull( /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask IsNull( - Func value, - TimeSpan timeout, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("value")] string valueExpression = "") - => IsNullCore(value, a => $"{valueExpression} to be null but found {a} ({Path.GetFileName(file)}@{line})", timeout, ct); + public static global::System.Threading.Tasks.ValueTask IsNull( + global::System.Func value, + global::System.TimeSpan timeout, + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("value")] string valueExpression = "") + => IsNullCore(value, a => $"{valueExpression} to be null but found {a} ({(global::System.IO.Path.GetFileName(file))}@{line})", timeout, ct); /// /// Asynchronously tests whether the specified object is null and throws an exception if it is not. @@ -419,14 +410,14 @@ public static ValueTask IsNull( /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask IsNull( - Func value, + public static global::System.Threading.Tasks.ValueTask IsNull( + global::System.Func value, int timeoutMs, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("value")] string valueExpression = "") - => IsNullCore(value, a => $"{valueExpression} to be null but found {a} ({Path.GetFileName(file)}@{line})", TimeSpan.FromMilliseconds(timeoutMs), ct); + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("value")] string valueExpression = "") + => IsNullCore(value, a => $"{valueExpression} to be null but found {a} ({(global::System.IO.Path.GetFileName(file))}@{line})", global::System.TimeSpan.FromMilliseconds(timeoutMs), ct); /// /// Asynchronously tests whether the specified object is null and throws an exception if it is not. @@ -435,7 +426,7 @@ public static ValueTask IsNull( /// The object the test expects to be null. /// The message to include in the exception when value is not equal to expected. The message is shown in test results. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask IsNull(Func value, string message, CancellationToken ct = default) + public static global::System.Threading.Tasks.ValueTask IsNull(global::System.Func value, string message, global::System.Threading.CancellationToken ct = default) => IsNullCore(value, a => message, TestHelper.DefaultTimeout, ct); /// @@ -446,7 +437,7 @@ public static ValueTask IsNull(Func value, string message, CancellationTok /// The message to include in the exception when value is not equal to expected. The message is shown in test results. /// The max duration to wait for. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask IsNull(Func value, string message, TimeSpan timeout, CancellationToken ct = default) + public static global::System.Threading.Tasks.ValueTask IsNull(global::System.Func value, string message, global::System.TimeSpan timeout, global::System.Threading.CancellationToken ct = default) => IsNullCore(value, a => message, timeout, ct); /// @@ -457,8 +448,8 @@ public static ValueTask IsNull(Func value, string message, TimeSpan timeou /// The message to include in the exception when value is not equal to expected. The message is shown in test results. /// The max duration to wait for in milliseconds. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask IsNull(Func value, string message, int timeoutMs, CancellationToken ct = default) - => IsNullCore(value, a => message, TimeSpan.FromMilliseconds(timeoutMs), ct); + public static global::System.Threading.Tasks.ValueTask IsNull(global::System.Func value, string message, int timeoutMs, global::System.Threading.CancellationToken ct = default) + => IsNullCore(value, a => message, global::System.TimeSpan.FromMilliseconds(timeoutMs), ct); /// /// Asynchronously tests whether the specified object is null and throws an exception if it is not. @@ -469,13 +460,13 @@ public static ValueTask IsNull(Func value, string message, int timeoutMs, /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask IsNull( - Func> value, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("value")] string valueExpression = "") - => IsNullCore(value, a => $"{valueExpression} to be null but found {a} ({Path.GetFileName(file)}@{line})", TestHelper.DefaultTimeout, ct); + public static global::System.Threading.Tasks.ValueTask IsNull( + global::System.Func> value, + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("value")] string valueExpression = "") + => IsNullCore(value, a => $"{valueExpression} to be null but found {a} ({(global::System.IO.Path.GetFileName(file))}@{line})", TestHelper.DefaultTimeout, ct); /// /// Asynchronously tests whether the specified object is null and throws an exception if it is not. @@ -487,14 +478,14 @@ public static ValueTask IsNull( /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask IsNull( - Func> value, - TimeSpan timeout, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("value")] string valueExpression = "") - => IsNullCore(value, a => $"{valueExpression} to be null but found {a} ({Path.GetFileName(file)}@{line})", timeout, ct); + public static global::System.Threading.Tasks.ValueTask IsNull( + global::System.Func> value, + global::System.TimeSpan timeout, + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("value")] string valueExpression = "") + => IsNullCore(value, a => $"{valueExpression} to be null but found {a} ({(global::System.IO.Path.GetFileName(file))}@{line})", timeout, ct); /// /// Asynchronously tests whether the specified object is null and throws an exception if it is not. @@ -506,14 +497,14 @@ public static ValueTask IsNull( /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask IsNull( - Func> value, + public static global::System.Threading.Tasks.ValueTask IsNull( + global::System.Func> value, int timeoutMs, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("value")] string valueExpression = "") - => IsNullCore(value, a => $"{valueExpression} to be null but found {a} ({Path.GetFileName(file)}@{line})", TimeSpan.FromMilliseconds(timeoutMs), ct); + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("value")] string valueExpression = "") + => IsNullCore(value, a => $"{valueExpression} to be null but found {a} ({(global::System.IO.Path.GetFileName(file))}@{line})", global::System.TimeSpan.FromMilliseconds(timeoutMs), ct); /// /// Asynchronously tests whether the specified object is null and throws an exception if it is not. @@ -522,7 +513,7 @@ public static ValueTask IsNull( /// The object the test expects to be null. /// The message to include in the exception when value is not equal to expected. The message is shown in test results. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask IsNull(Func> value, string message, CancellationToken ct = default) + public static global::System.Threading.Tasks.ValueTask IsNull(global::System.Func> value, string message, global::System.Threading.CancellationToken ct = default) => IsNullCore(value, a => message, TestHelper.DefaultTimeout, ct); /// @@ -533,7 +524,7 @@ public static ValueTask IsNull(Func> value, string message, Canc /// The message to include in the exception when value is not equal to expected. The message is shown in test results. /// The max duration to wait for. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask IsNull(Func> value, string message, TimeSpan timeout, CancellationToken ct = default) + public static global::System.Threading.Tasks.ValueTask IsNull(global::System.Func> value, string message, global::System.TimeSpan timeout, global::System.Threading.CancellationToken ct = default) => IsNullCore(value, a => message, timeout, ct); /// @@ -544,23 +535,23 @@ public static ValueTask IsNull(Func> value, string message, Time /// The message to include in the exception when value is not equal to expected. The message is shown in test results. /// The max duration to wait for in milliseconds. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask IsNull(Func> value, string message, int timeoutMs, CancellationToken ct = default) - => IsNullCore(value, a => message, TimeSpan.FromMilliseconds(timeoutMs), ct); + public static global::System.Threading.Tasks.ValueTask IsNull(global::System.Func> value, string message, int timeoutMs, global::System.Threading.CancellationToken ct = default) + => IsNullCore(value, a => message, global::System.TimeSpan.FromMilliseconds(timeoutMs), ct); - private static async ValueTask IsNullCore(Func value, Func reason, TimeSpan timeout, CancellationToken ct) + private static async global::System.Threading.Tasks.ValueTask IsNullCore(global::System.Func value, global::System.Func reason, global::System.TimeSpan timeout, global::System.Threading.CancellationToken ct) { await TestHelper.TryWaitFor(() => object.Equals(null, value()), timeout, ct); var a = value(); - Assert.IsNull(a, reason(a)); + global::Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNull(a, reason(a)); } - private static async ValueTask IsNullCore(Func> value, Func reason, TimeSpan timeout, CancellationToken ct) + private static async global::System.Threading.Tasks.ValueTask IsNullCore(global::System.Func> value, global::System.Func reason, global::System.TimeSpan timeout, global::System.Threading.CancellationToken ct) { await TestHelper.TryWaitFor(async _ => object.Equals(null, await value().ConfigureAwait(false)), timeout, ct); var a = await value().ConfigureAwait(false); - Assert.IsNotNull(a, reason(a)); + global::Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(a, reason(a)); } #endregion @@ -574,13 +565,13 @@ private static async ValueTask IsNullCore(Func> value, FuncFor debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask IsNotNull( - Func value, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("value")] string valueExpression = "") - => IsNotNullCore(value, a => $"{valueExpression} to be null but found {a} ({Path.GetFileName(file)}@{line})", TestHelper.DefaultTimeout, ct); + public static global::System.Threading.Tasks.ValueTask IsNotNull( + global::System.Func value, + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("value")] string valueExpression = "") + => IsNotNullCore(value, a => $"{valueExpression} to be null but found {a} ({(global::System.IO.Path.GetFileName(file))}@{line})", TestHelper.DefaultTimeout, ct); /// /// Asynchronously tests whether the specified object is non-null and throws an exception if it is null. @@ -592,14 +583,14 @@ public static ValueTask IsNotNull( /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask IsNotNull( - Func value, - TimeSpan timeout, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("value")] string valueExpression = "") - => IsNotNullCore(value, a => $"{valueExpression} to be null but found {a} ({Path.GetFileName(file)}@{line})", timeout, ct); + public static global::System.Threading.Tasks.ValueTask IsNotNull( + global::System.Func value, + global::System.TimeSpan timeout, + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("value")] string valueExpression = "") + => IsNotNullCore(value, a => $"{valueExpression} to be null but found {a} ({(global::System.IO.Path.GetFileName(file))}@{line})", timeout, ct); /// /// Asynchronously tests whether the specified object is non-null and throws an exception if it is null. @@ -611,14 +602,14 @@ public static ValueTask IsNotNull( /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask IsNotNull( - Func value, + public static global::System.Threading.Tasks.ValueTask IsNotNull( + global::System.Func value, int timeoutMs, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("value")] string valueExpression = "") - => IsNotNullCore(value, a => $"{valueExpression} to be null but found {a} ({Path.GetFileName(file)}@{line})", TimeSpan.FromMilliseconds(timeoutMs), ct); + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("value")] string valueExpression = "") + => IsNotNullCore(value, a => $"{valueExpression} to be null but found {a} ({(global::System.IO.Path.GetFileName(file))}@{line})", global::System.TimeSpan.FromMilliseconds(timeoutMs), ct); /// /// Asynchronously tests whether the specified object is non-null and throws an exception if it is null. @@ -627,7 +618,7 @@ public static ValueTask IsNotNull( /// The object the test expects to be null. /// The message to include in the exception when value is not equal to expected. The message is shown in test results. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask IsNotNull(Func value, string message, CancellationToken ct = default) + public static global::System.Threading.Tasks.ValueTask IsNotNull(global::System.Func value, string message, global::System.Threading.CancellationToken ct = default) => IsNotNullCore(value, a => message, TestHelper.DefaultTimeout, ct); /// @@ -638,7 +629,7 @@ public static ValueTask IsNotNull(Func value, string message, Cancellation /// The message to include in the exception when value is not equal to expected. The message is shown in test results. /// The max duration to wait for. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask IsNotNull(Func value, string message, TimeSpan timeout, CancellationToken ct = default) + public static global::System.Threading.Tasks.ValueTask IsNotNull(global::System.Func value, string message, global::System.TimeSpan timeout, global::System.Threading.CancellationToken ct = default) => IsNotNullCore(value, a => message, timeout, ct); /// @@ -649,8 +640,8 @@ public static ValueTask IsNotNull(Func value, string message, TimeSpan tim /// The message to include in the exception when value is not equal to expected. The message is shown in test results. /// The max duration to wait for in milliseconds. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask IsNotNull(Func value, string message, int timeoutMs, CancellationToken ct = default) - => IsNotNullCore(value, a => message, TimeSpan.FromMilliseconds(timeoutMs), ct); + public static global::System.Threading.Tasks.ValueTask IsNotNull(global::System.Func value, string message, int timeoutMs, global::System.Threading.CancellationToken ct = default) + => IsNotNullCore(value, a => message, global::System.TimeSpan.FromMilliseconds(timeoutMs), ct); /// /// Asynchronously tests whether the specified object is non-null and throws an exception if it is null. @@ -661,13 +652,13 @@ public static ValueTask IsNotNull(Func value, string message, int timeoutM /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask IsNotNull( - Func> value, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("value")] string valueExpression = "") - => IsNotNullCore(value, a => $"{valueExpression} to be null but found {a} ({Path.GetFileName(file)}@{line})", TestHelper.DefaultTimeout, ct); + public static global::System.Threading.Tasks.ValueTask IsNotNull( + global::System.Func> value, + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("value")] string valueExpression = "") + => IsNotNullCore(value, a => $"{valueExpression} to be null but found {a} ({(global::System.IO.Path.GetFileName(file))}@{line})", TestHelper.DefaultTimeout, ct); /// /// Asynchronously tests whether the specified object is non-null and throws an exception if it is null. @@ -679,14 +670,14 @@ public static ValueTask IsNotNull( /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask IsNotNull( - Func> value, - TimeSpan timeout, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("value")] string valueExpression = "") - => IsNotNullCore(value, a => $"{valueExpression} to be null but found {a} ({Path.GetFileName(file)}@{line})", timeout, ct); + public static global::System.Threading.Tasks.ValueTask IsNotNull( + global::System.Func> value, + global::System.TimeSpan timeout, + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("value")] string valueExpression = "") + => IsNotNullCore(value, a => $"{valueExpression} to be null but found {a} ({(global::System.IO.Path.GetFileName(file))}@{line})", timeout, ct); /// /// Asynchronously tests whether the specified object is non-null and throws an exception if it is null. @@ -698,14 +689,14 @@ public static ValueTask IsNotNull( /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask IsNotNull( - Func> value, + public static global::System.Threading.Tasks.ValueTask IsNotNull( + global::System.Func> value, int timeoutMs, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("value")] string valueExpression = "") - => IsNotNullCore(value, a => $"{valueExpression} to be null but found {a} ({Path.GetFileName(file)}@{line})", TimeSpan.FromMilliseconds(timeoutMs), ct); + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("value")] string valueExpression = "") + => IsNotNullCore(value, a => $"{valueExpression} to be null but found {a} ({(global::System.IO.Path.GetFileName(file))}@{line})", global::System.TimeSpan.FromMilliseconds(timeoutMs), ct); /// /// Asynchronously tests whether the specified object is non-null and throws an exception if it is null. @@ -714,7 +705,7 @@ public static ValueTask IsNotNull( /// The object the test expects to be null. /// The message to include in the exception when value is not equal to expected. The message is shown in test results. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask IsNotNull(Func> value, string message, CancellationToken ct = default) + public static global::System.Threading.Tasks.ValueTask IsNotNull(global::System.Func> value, string message, global::System.Threading.CancellationToken ct = default) => IsNotNullCore(value, a => message, TestHelper.DefaultTimeout, ct); /// @@ -725,7 +716,7 @@ public static ValueTask IsNotNull(Func> value, string message, C /// The message to include in the exception when value is not equal to expected. The message is shown in test results. /// The max duration to wait for. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask IsNotNull(Func> value, string message, TimeSpan timeout, CancellationToken ct = default) + public static global::System.Threading.Tasks.ValueTask IsNotNull(global::System.Func> value, string message, global::System.TimeSpan timeout, global::System.Threading.CancellationToken ct = default) => IsNotNullCore(value, a => message, timeout, ct); /// @@ -736,23 +727,23 @@ public static ValueTask IsNotNull(Func> value, string message, T /// The message to include in the exception when value is not equal to expected. The message is shown in test results. /// The max duration to wait for in milliseconds. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask IsNotNull(Func> value, string message, int timeoutMs, CancellationToken ct = default) - => IsNotNullCore(value, a => message, TimeSpan.FromMilliseconds(timeoutMs), ct); + public static global::System.Threading.Tasks.ValueTask IsNotNull(global::System.Func> value, string message, int timeoutMs, global::System.Threading.CancellationToken ct = default) + => IsNotNullCore(value, a => message, global::System.TimeSpan.FromMilliseconds(timeoutMs), ct); - private static async ValueTask IsNotNullCore(Func value, Func reason, TimeSpan timeout, CancellationToken ct) + private static async global::System.Threading.Tasks.ValueTask IsNotNullCore(global::System.Func value, global::System.Func reason, global::System.TimeSpan timeout, global::System.Threading.CancellationToken ct) { await TestHelper.TryWaitFor(() => !object.Equals(null, value()), timeout, ct); var a = value(); - Assert.IsNotNull(a, reason(a)); + global::Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(a, reason(a)); } - private static async ValueTask IsNotNullCore(Func> value, Func reason, TimeSpan timeout, CancellationToken ct) + private static async global::System.Threading.Tasks.ValueTask IsNotNullCore(global::System.Func> value, global::System.Func reason, global::System.TimeSpan timeout, global::System.Threading.CancellationToken ct) { await TestHelper.TryWaitFor(async _ => !object.Equals(null, await value().ConfigureAwait(false)), timeout, ct); var a = await value().ConfigureAwait(false); - Assert.IsNotNull(a, reason(a)); + global::Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(a, reason(a)); } #endregion @@ -767,14 +758,14 @@ private static async ValueTask IsNotNullCore(Func> value, FuncFor debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask AreEqual( + public static global::System.Threading.Tasks.ValueTask AreEqual( T expected, - Func actual, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("actual")] string actualExpression = "") - => AreEqualCore(expected, actual, a => $"{actualExpression} to equals {expected} but found {a} ({Path.GetFileName(file)}@{line})", TestHelper.DefaultTimeout, ct); + global::System.Func actual, + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("actual")] string actualExpression = "") + => AreEqualCore(expected, actual, a => $"{actualExpression} to equals {expected} but found {a} ({(global::System.IO.Path.GetFileName(file))}@{line})", TestHelper.DefaultTimeout, ct); /// /// Asynchronously tests whether the specified values are equal and throws an exception if the two values are not equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42. @@ -787,15 +778,15 @@ public static ValueTask AreEqual( /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask AreEqual( + public static global::System.Threading.Tasks.ValueTask AreEqual( T expected, - Func actual, - TimeSpan timeout, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("actual")] string actualExpression = "") - => AreEqualCore(expected, actual, a => $"{actualExpression} to equals {expected} but found {a} ({Path.GetFileName(file)}@{line})", timeout, ct); + global::System.Func actual, + global::System.TimeSpan timeout, + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("actual")] string actualExpression = "") + => AreEqualCore(expected, actual, a => $"{actualExpression} to equals {expected} but found {a} ({(global::System.IO.Path.GetFileName(file))}@{line})", timeout, ct); /// /// Asynchronously tests whether the specified values are equal and throws an exception if the two values are not equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42. @@ -808,15 +799,15 @@ public static ValueTask AreEqual( /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask AreEqual( + public static global::System.Threading.Tasks.ValueTask AreEqual( T expected, - Func actual, + global::System.Func actual, int timeoutMs, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("actual")] string actualExpression = "") - => AreEqualCore(expected, actual, a => $"{actualExpression} to equals {expected} but found {a} ({Path.GetFileName(file)}@{line})", TimeSpan.FromMilliseconds(timeoutMs), ct); + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("actual")] string actualExpression = "") + => AreEqualCore(expected, actual, a => $"{actualExpression} to equals {expected} but found {a} ({(global::System.IO.Path.GetFileName(file))}@{line})", global::System.TimeSpan.FromMilliseconds(timeoutMs), ct); /// /// Asynchronously tests whether the specified values are equal and throws an exception if the two values are not equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42. @@ -826,7 +817,7 @@ public static ValueTask AreEqual( /// The second value to compare. This is the value produced by the code under test. /// The message to include in the exception when actual is not equal to expected. The message is shown in test results. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask AreEqual(T expected, Func actual, string message, CancellationToken ct = default) + public static global::System.Threading.Tasks.ValueTask AreEqual(T expected, global::System.Func actual, string message, global::System.Threading.CancellationToken ct = default) => AreEqualCore(expected, actual, a => message, TestHelper.DefaultTimeout, ct); /// @@ -838,7 +829,7 @@ public static ValueTask AreEqual(T expected, Func actual, string message, /// The message to include in the exception when actual is not equal to expected. The message is shown in test results. /// The max duration to wait for. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask AreEqual(T expected, Func actual, string message, TimeSpan timeout, CancellationToken ct = default) + public static global::System.Threading.Tasks.ValueTask AreEqual(T expected, global::System.Func actual, string message, global::System.TimeSpan timeout, global::System.Threading.CancellationToken ct = default) => AreEqualCore(expected, actual, a => message, timeout, ct); /// @@ -850,8 +841,8 @@ public static ValueTask AreEqual(T expected, Func actual, string message, /// The message to include in the exception when actual is not equal to expected. The message is shown in test results. /// The max duration to wait for in milliseconds. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask AreEqual(T expected, Func actual, string message, int timeoutMs, CancellationToken ct = default) - => AreEqualCore(expected, actual, a => message, TimeSpan.FromMilliseconds(timeoutMs), ct); + public static global::System.Threading.Tasks.ValueTask AreEqual(T expected, global::System.Func actual, string message, int timeoutMs, global::System.Threading.CancellationToken ct = default) + => AreEqualCore(expected, actual, a => message, global::System.TimeSpan.FromMilliseconds(timeoutMs), ct); /// /// Asynchronously tests whether the specified values are equal and throws an exception if the two values are not equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42. @@ -863,14 +854,14 @@ public static ValueTask AreEqual(T expected, Func actual, string message, /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask AreEqual( + public static global::System.Threading.Tasks.ValueTask AreEqual( T expected, - Func> actual, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("actual")] string actualExpression = "") - => AreEqualCore(expected, actual, a => $"{actualExpression} to equals {expected} but found {a} ({Path.GetFileName(file)}@{line})", TestHelper.DefaultTimeout, ct); + global::System.Func> actual, + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("actual")] string actualExpression = "") + => AreEqualCore(expected, actual, a => $"{actualExpression} to equals {expected} but found {a} ({(global::System.IO.Path.GetFileName(file))}@{line})", TestHelper.DefaultTimeout, ct); /// /// Asynchronously tests whether the specified values are equal and throws an exception if the two values are not equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42. @@ -883,15 +874,15 @@ public static ValueTask AreEqual( /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask AreEqual( + public static global::System.Threading.Tasks.ValueTask AreEqual( T expected, - Func> actual, - TimeSpan timeout, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("actual")] string actualExpression = "") - => AreEqualCore(expected, actual, a => $"{actualExpression} to equals {expected} but found {a} ({Path.GetFileName(file)}@{line})", timeout, ct); + global::System.Func> actual, + global::System.TimeSpan timeout, + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("actual")] string actualExpression = "") + => AreEqualCore(expected, actual, a => $"{actualExpression} to equals {expected} but found {a} ({(global::System.IO.Path.GetFileName(file))}@{line})", timeout, ct); /// /// Asynchronously tests whether the specified values are equal and throws an exception if the two values are not equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42. @@ -904,15 +895,15 @@ public static ValueTask AreEqual( /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask AreEqual( + public static global::System.Threading.Tasks.ValueTask AreEqual( T expected, - Func> actual, + global::System.Func> actual, int timeoutMs, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("actual")] string actualExpression = "") - => AreEqualCore(expected, actual, a => $"{actualExpression} to equals {expected} but found {a} ({Path.GetFileName(file)}@{line})", TimeSpan.FromMilliseconds(timeoutMs), ct); + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("actual")] string actualExpression = "") + => AreEqualCore(expected, actual, a => $"{actualExpression} to equals {expected} but found {a} ({(global::System.IO.Path.GetFileName(file))}@{line})", global::System.TimeSpan.FromMilliseconds(timeoutMs), ct); /// /// Asynchronously tests whether the specified values are equal and throws an exception if the two values are not equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42. @@ -922,7 +913,7 @@ public static ValueTask AreEqual( /// The second value to compare. This is the value produced by the code under test. /// The message to include in the exception when actual is not equal to expected. The message is shown in test results. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask AreEqual(T expected, Func> actual, string message, CancellationToken ct = default) + public static global::System.Threading.Tasks.ValueTask AreEqual(T expected, global::System.Func> actual, string message, global::System.Threading.CancellationToken ct = default) => AreEqualCore(expected, actual, a => message, TestHelper.DefaultTimeout, ct); /// @@ -934,7 +925,7 @@ public static ValueTask AreEqual(T expected, Func> actual, strin /// The message to include in the exception when actual is not equal to expected. The message is shown in test results. /// The max duration to wait for. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask AreEqual(T expected, Func> actual, string message, TimeSpan timeout, CancellationToken ct = default) + public static global::System.Threading.Tasks.ValueTask AreEqual(T expected, global::System.Func> actual, string message, global::System.TimeSpan timeout, global::System.Threading.CancellationToken ct = default) => AreEqualCore(expected, actual, a => message, timeout, ct); /// @@ -946,23 +937,23 @@ public static ValueTask AreEqual(T expected, Func> actual, strin /// The message to include in the exception when actual is not equal to expected. The message is shown in test results. /// The max duration to wait for in milliseconds. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask AreEqual(T expected, Func> actual, string message, int timeoutMs, CancellationToken ct = default) - => AreEqualCore(expected, actual, a => message, TimeSpan.FromMilliseconds(timeoutMs), ct); + public static global::System.Threading.Tasks.ValueTask AreEqual(T expected, global::System.Func> actual, string message, int timeoutMs, global::System.Threading.CancellationToken ct = default) + => AreEqualCore(expected, actual, a => message, global::System.TimeSpan.FromMilliseconds(timeoutMs), ct); - private static async ValueTask AreEqualCore(T expected, Func actual, Func reason, TimeSpan timeout, CancellationToken ct) + private static async global::System.Threading.Tasks.ValueTask AreEqualCore(T expected, global::System.Func actual, global::System.Func reason, global::System.TimeSpan timeout, global::System.Threading.CancellationToken ct) { await TestHelper.TryWaitFor(() => object.Equals(expected, actual()), timeout, ct); var a = actual(); - Assert.AreEqual(expected, a, reason(a)); + global::Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(expected, a, reason(a)); } - private static async ValueTask AreEqualCore(T expected, Func> actual, Func reason, TimeSpan timeout, CancellationToken ct) + private static async global::System.Threading.Tasks.ValueTask AreEqualCore(T expected, global::System.Func> actual, global::System.Func reason, global::System.TimeSpan timeout, global::System.Threading.CancellationToken ct) { await TestHelper.TryWaitFor(async _ => object.Equals(expected, await actual().ConfigureAwait(false)), timeout, ct); var a = await actual().ConfigureAwait(false); - Assert.AreEqual(expected, a, reason(a)); + global::Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(expected, a, reason(a)); } #endregion @@ -977,14 +968,14 @@ private static async ValueTask AreEqualCore(T expected, Func> ac /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask AreNotEqual( + public static global::System.Threading.Tasks.ValueTask AreNotEqual( T expected, - Func actual, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("actual")] string actualExpression = "") - => AreNotEqualCore(expected, actual, a => $"{actualExpression} to equals {expected} but found {a} ({Path.GetFileName(file)}@{line})", TestHelper.DefaultTimeout, ct); + global::System.Func actual, + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("actual")] string actualExpression = "") + => AreNotEqualCore(expected, actual, a => $"{actualExpression} to equals {expected} but found {a} ({(global::System.IO.Path.GetFileName(file))}@{line})", TestHelper.DefaultTimeout, ct); /// /// Asynchronously tests whether the specified values are unequal and throws an exception if the two values are equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42. @@ -997,15 +988,15 @@ public static ValueTask AreNotEqual( /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask AreNotEqual( + public static global::System.Threading.Tasks.ValueTask AreNotEqual( T expected, - Func actual, - TimeSpan timeout, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("actual")] string actualExpression = "") - => AreNotEqualCore(expected, actual, a => $"{actualExpression} to equals {expected} but found {a} ({Path.GetFileName(file)}@{line})", timeout, ct); + global::System.Func actual, + global::System.TimeSpan timeout, + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("actual")] string actualExpression = "") + => AreNotEqualCore(expected, actual, a => $"{actualExpression} to equals {expected} but found {a} ({(global::System.IO.Path.GetFileName(file))}@{line})", timeout, ct); /// /// Asynchronously tests whether the specified values are unequal and throws an exception if the two values are equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42. @@ -1018,15 +1009,15 @@ public static ValueTask AreNotEqual( /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask AreNotEqual( + public static global::System.Threading.Tasks.ValueTask AreNotEqual( T expected, - Func actual, + global::System.Func actual, int timeoutMs, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("actual")] string actualExpression = "") - => AreNotEqualCore(expected, actual, a => $"{actualExpression} to equals {expected} but found {a} ({Path.GetFileName(file)}@{line})", TimeSpan.FromMilliseconds(timeoutMs), ct); + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("actual")] string actualExpression = "") + => AreNotEqualCore(expected, actual, a => $"{actualExpression} to equals {expected} but found {a} ({(global::System.IO.Path.GetFileName(file))}@{line})", global::System.TimeSpan.FromMilliseconds(timeoutMs), ct); /// /// Asynchronously tests whether the specified values are unequal and throws an exception if the two values are equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42. @@ -1036,7 +1027,7 @@ public static ValueTask AreNotEqual( /// The second value to compare. This is the value produced by the code under test. /// The message to include in the exception when actual is not equal to expected. The message is shown in test results. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask AreNotEqual(T expected, Func actual, string message, CancellationToken ct = default) + public static global::System.Threading.Tasks.ValueTask AreNotEqual(T expected, global::System.Func actual, string message, global::System.Threading.CancellationToken ct = default) => AreNotEqualCore(expected, actual, a => message, TestHelper.DefaultTimeout, ct); /// @@ -1048,7 +1039,7 @@ public static ValueTask AreNotEqual(T expected, Func actual, string messag /// The message to include in the exception when actual is not equal to expected. The message is shown in test results. /// The max duration to wait for. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask AreNotEqual(T expected, Func actual, string message, TimeSpan timeout, CancellationToken ct = default) + public static global::System.Threading.Tasks.ValueTask AreNotEqual(T expected, global::System.Func actual, string message, global::System.TimeSpan timeout, global::System.Threading.CancellationToken ct = default) => AreNotEqualCore(expected, actual, a => message, timeout, ct); /// @@ -1060,8 +1051,8 @@ public static ValueTask AreNotEqual(T expected, Func actual, string messag /// The message to include in the exception when actual is not equal to expected. The message is shown in test results. /// The max duration to wait for in milliseconds. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask AreNotEqual(T expected, Func actual, string message, int timeoutMs, CancellationToken ct = default) - => AreNotEqualCore(expected, actual, a => message, TimeSpan.FromMilliseconds(timeoutMs), ct); + public static global::System.Threading.Tasks.ValueTask AreNotEqual(T expected, global::System.Func actual, string message, int timeoutMs, global::System.Threading.CancellationToken ct = default) + => AreNotEqualCore(expected, actual, a => message, global::System.TimeSpan.FromMilliseconds(timeoutMs), ct); /// /// Asynchronously tests whether the specified values are unequal and throws an exception if the two values are equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42. @@ -1073,14 +1064,14 @@ public static ValueTask AreNotEqual(T expected, Func actual, string messag /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask AreNotEqual( + public static global::System.Threading.Tasks.ValueTask AreNotEqual( T expected, - Func> actual, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("actual")] string actualExpression = "") - => AreNotEqualCore(expected, actual, a => $"{actualExpression} to equals {expected} but found {a} ({Path.GetFileName(file)}@{line})", TestHelper.DefaultTimeout, ct); + global::System.Func> actual, + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("actual")] string actualExpression = "") + => AreNotEqualCore(expected, actual, a => $"{actualExpression} to equals {expected} but found {a} ({(global::System.IO.Path.GetFileName(file))}@{line})", TestHelper.DefaultTimeout, ct); /// /// Asynchronously tests whether the specified values are unequal and throws an exception if the two values are equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42. @@ -1093,15 +1084,15 @@ public static ValueTask AreNotEqual( /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask AreNotEqual( + public static global::System.Threading.Tasks.ValueTask AreNotEqual( T expected, - Func> actual, - TimeSpan timeout, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("actual")] string actualExpression = "") - => AreNotEqualCore(expected, actual, a => $"{actualExpression} to equals {expected} but found {a} ({Path.GetFileName(file)}@{line})", timeout, ct); + global::System.Func> actual, + global::System.TimeSpan timeout, + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("actual")] string actualExpression = "") + => AreNotEqualCore(expected, actual, a => $"{actualExpression} to equals {expected} but found {a} ({(global::System.IO.Path.GetFileName(file))}@{line})", timeout, ct); /// /// Asynchronously tests whether the specified values are unequal and throws an exception if the two values are equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42. @@ -1114,15 +1105,15 @@ public static ValueTask AreNotEqual( /// For debug purposes. /// For debug purposes. /// For debug purposes. - public static ValueTask AreNotEqual( + public static global::System.Threading.Tasks.ValueTask AreNotEqual( T expected, - Func> actual, + global::System.Func> actual, int timeoutMs, - CancellationToken ct = default, - [CallerLineNumber] int line = -1, - [CallerFilePath] string file = "", - [CallerArgumentExpression("actual")] string actualExpression = "") - => AreNotEqualCore(expected, actual, a => $"{actualExpression} to equals {expected} but found {a} ({Path.GetFileName(file)}@{line})", TimeSpan.FromMilliseconds(timeoutMs), ct); + global::System.Threading.CancellationToken ct = default, + [global::System.Runtime.CompilerServices.CallerLineNumber] int line = -1, + [global::System.Runtime.CompilerServices.CallerFilePath] string file = "", + [global::System.Runtime.CompilerServices.CallerArgumentExpression("actual")] string actualExpression = "") + => AreNotEqualCore(expected, actual, a => $"{actualExpression} to equals {expected} but found {a} ({(global::System.IO.Path.GetFileName(file))}@{line})", global::System.TimeSpan.FromMilliseconds(timeoutMs), ct); /// /// Asynchronously tests whether the specified values are unequal and throws an exception if the two values are equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42. @@ -1132,7 +1123,7 @@ public static ValueTask AreNotEqual( /// The second value to compare. This is the value produced by the code under test. /// The message to include in the exception when actual is not equal to expected. The message is shown in test results. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask AreNotEqual(T expected, Func> actual, string message, CancellationToken ct = default) + public static global::System.Threading.Tasks.ValueTask AreNotEqual(T expected, global::System.Func> actual, string message, global::System.Threading.CancellationToken ct = default) => AreNotEqualCore(expected, actual, a => message, TestHelper.DefaultTimeout, ct); /// @@ -1144,7 +1135,7 @@ public static ValueTask AreNotEqual(T expected, Func> actual, st /// The message to include in the exception when actual is not equal to expected. The message is shown in test results. /// The max duration to wait for. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask AreNotEqual(T expected, Func> actual, string message, TimeSpan timeout, CancellationToken ct = default) + public static global::System.Threading.Tasks.ValueTask AreNotEqual(T expected, global::System.Func> actual, string message, global::System.TimeSpan timeout, global::System.Threading.CancellationToken ct = default) => AreNotEqualCore(expected, actual, a => message, timeout, ct); /// @@ -1156,23 +1147,23 @@ public static ValueTask AreNotEqual(T expected, Func> actual, st /// The message to include in the exception when actual is not equal to expected. The message is shown in test results. /// The max duration to wait for in milliseconds. /// Cancellation token to cancel teh asynchronous operation - public static ValueTask AreNotEqual(T expected, Func> actual, string message, int timeoutMs, CancellationToken ct = default) - => AreNotEqualCore(expected, actual, a => message, TimeSpan.FromMilliseconds(timeoutMs), ct); + public static global::System.Threading.Tasks.ValueTask AreNotEqual(T expected, global::System.Func> actual, string message, int timeoutMs, global::System.Threading.CancellationToken ct = default) + => AreNotEqualCore(expected, actual, a => message, global::System.TimeSpan.FromMilliseconds(timeoutMs), ct); - private static async ValueTask AreNotEqualCore(T expected, Func actual, Func reason, TimeSpan timeout, CancellationToken ct) + private static async global::System.Threading.Tasks.ValueTask AreNotEqualCore(T expected, global::System.Func actual, global::System.Func reason, global::System.TimeSpan timeout, global::System.Threading.CancellationToken ct) { await TestHelper.TryWaitFor(() => !object.Equals(expected, actual()), timeout, ct); var a = actual(); - Assert.AreNotEqual(expected, a, reason(a)); + global::Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreNotEqual(expected, a, reason(a)); } - private static async ValueTask AreNotEqualCore(T expected, Func> actual, Func reason, TimeSpan timeout, CancellationToken ct) + private static async global::System.Threading.Tasks.ValueTask AreNotEqualCore(T expected, global::System.Func> actual, global::System.Func reason, global::System.TimeSpan timeout, global::System.Threading.CancellationToken ct) { await TestHelper.TryWaitFor(async _ => !object.Equals(expected, await actual().ConfigureAwait(false)), timeout, ct); var a = await actual().ConfigureAwait(false); - Assert.AreNotEqual(expected, a, reason(a)); + global::Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreNotEqual(expected, a, reason(a)); } #endregion } diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Library/Helpers/HotReloadHelper.Local.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Library/Helpers/HotReloadHelper.Local.cs index 98a8b09..6deaecd 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Library/Helpers/HotReloadHelper.Local.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Library/Helpers/HotReloadHelper.Local.cs @@ -4,14 +4,6 @@ #pragma warning disable #endif -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.IO; -using System.Text; -using System.Threading; -using System.Threading.Tasks; - namespace Uno.UI.RuntimeTests; partial class HotReloadHelper @@ -19,27 +11,27 @@ partial class HotReloadHelper static partial void TryUseLocalFileUpdater() => Use(new LocalFileUpdater()); - [EditorBrowsable(EditorBrowsableState.Advanced)] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Advanced)] public static void UseLocalFileUpdater() => Use(new LocalFileUpdater()); private class LocalFileUpdater : IFileUpdater { /// - public async ValueTask EnsureReady(CancellationToken ct) { } + public async global::System.Threading.Tasks.ValueTask EnsureReady(global::System.Threading.CancellationToken ct) { } /// - public async ValueTask Apply(FileEdit edition, CancellationToken ct) + public async global::System.Threading.Tasks.ValueTask Apply(FileEdit edition, global::System.Threading.CancellationToken ct) { - if (!File.Exists(edition.FilePath)) + if (!global::System.IO.File.Exists(edition.FilePath)) { - throw new InvalidOperationException($"Source file {edition.FilePath} does not exist!"); + throw new global::System.InvalidOperationException($"Source file {edition.FilePath} does not exist!"); } - var originalContent = await File.ReadAllTextAsync(edition.FilePath, ct); + var originalContent = await global::System.IO.File.ReadAllTextAsync(edition.FilePath, ct); var updatedContent = originalContent.Replace(edition.OldText, edition.NewText); - await File.WriteAllTextAsync(edition.FilePath, updatedContent, ct); + await global::System.IO.File.WriteAllTextAsync(edition.FilePath, updatedContent, ct); return null; } diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Library/Helpers/HotReloadHelper.MetadataUpdateHandler.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Library/Helpers/HotReloadHelper.MetadataUpdateHandler.cs index bc7002e..3fe0395 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Library/Helpers/HotReloadHelper.MetadataUpdateHandler.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Library/Helpers/HotReloadHelper.MetadataUpdateHandler.cs @@ -4,12 +4,7 @@ #pragma warning disable #endif -using System; -using System.Collections.Generic; -using System.Text; -using Uno.UI.RuntimeTests; - -[assembly:System.Reflection.Metadata.MetadataUpdateHandlerAttribute(typeof(HotReloadHelper.MetadataUpdateHandler))] +[assembly:System.Reflection.Metadata.MetadataUpdateHandlerAttribute(typeof(global::Uno.UI.RuntimeTests.HotReloadHelper.MetadataUpdateHandler))] namespace Uno.UI.RuntimeTests; @@ -17,11 +12,11 @@ partial class HotReloadHelper { internal static class MetadataUpdateHandler { - public static event EventHandler? MetadataUpdated; + public static event global::System.EventHandler? MetadataUpdated; - internal static void UpdateApplication(Type[]? types) + internal static void UpdateApplication(global::System.Type[]? types) { - MetadataUpdated?.Invoke(null, EventArgs.Empty); + MetadataUpdated?.Invoke(null, global::System.EventArgs.Empty); } } } diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Library/Helpers/HotReloadHelper.NotSupported.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Library/Helpers/HotReloadHelper.NotSupported.cs index 4b8ac88..b462e4d 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Library/Helpers/HotReloadHelper.NotSupported.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Library/Helpers/HotReloadHelper.NotSupported.cs @@ -4,11 +4,6 @@ #pragma warning disable #endif -using System; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - namespace Uno.UI.RuntimeTests; public static partial class HotReloadHelper @@ -16,12 +11,12 @@ public static partial class HotReloadHelper private class NotSupported : IFileUpdater { /// - public ValueTask EnsureReady(CancellationToken ct) - => throw new NotSupportedException("Source code file edition is not supported on this platform."); + public global::System.Threading.Tasks.ValueTask EnsureReady(global::System.Threading.CancellationToken ct) + => throw new global::System.NotSupportedException("Source code file edition is not supported on this platform."); /// - public ValueTask Apply(FileEdit edition, CancellationToken ct) - => throw new NotSupportedException("Source code file edition is not supported on this platform."); + public global::System.Threading.Tasks.ValueTask Apply(FileEdit edition, global::System.Threading.CancellationToken ct) + => throw new global::System.NotSupportedException("Source code file edition is not supported on this platform."); } } #endif \ No newline at end of file diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Library/Helpers/HotReloadHelper.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Library/Helpers/HotReloadHelper.cs index 4c7f99d..4053fb8 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Library/Helpers/HotReloadHelper.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Library/Helpers/HotReloadHelper.cs @@ -8,26 +8,15 @@ #pragma warning disable CA1848 // Log perf #pragma warning disable CA1823 // Field not used -using System; -using System.Collections; -using System.ComponentModel; -using System.Globalization; -using System.Linq; -using System.Reflection; -using System.Threading.Tasks; -using System.Threading; -using System.IO; -using System.Diagnostics; -using System.Net.WebSockets; -using System.Runtime.CompilerServices; -using Microsoft.Extensions.Logging; -using Uno.Extensions; -using Uno.UI.RuntimeTests.Engine; +// Add using for extensions methods only +using global::System.Reflection; +using global::Microsoft.Extensions.Logging; +using global::Uno.Extensions; #if HAS_UNO_WINUI || WINDOWS_WINUI -using Microsoft.UI.Xaml; +using global::Microsoft.UI.Xaml; #else -using Windows.UI.Xaml; +using global::Windows.UI.Xaml; #endif namespace Uno.UI.RuntimeTests; @@ -39,22 +28,22 @@ public partial record FileEdit(string FilePath, string OldText, string NewText) public FileEdit Revert() => this with { OldText = NewText, NewText = OldText }; } - private record RevertFileEdit(FileEdit Edition, bool WaitForMetadataUpdate) : IAsyncDisposable + private record RevertFileEdit(FileEdit Edition, bool WaitForMetadataUpdate) : global::System.IAsyncDisposable { /// - public async ValueTask DisposeAsync() + public async global::System.Threading.Tasks.ValueTask DisposeAsync() { var revert = Edition.Revert(); _log.LogInformation($"Reverting changes made on {revert.FilePath} (from: \"{StartEnd(revert.OldText)}\" to \"{StartEnd(revert.NewText)}\")."); // Note: We also wait for metadata update here to ensure that the file is reverted before the test continues / we run another test. - if (await SendMessageCore(revert, WaitForMetadataUpdate, CancellationToken.None) is ReConnect reconnect) + if (await SendMessageCore(revert, WaitForMetadataUpdate, global::System.Threading.CancellationToken.None) is ReConnect reconnect) { _log.LogWarning($"Failed to revert file edition, let {_impl} reconnect."); - await reconnect(CancellationToken.None); - if (await SendMessageCore(revert, WaitForMetadataUpdate, CancellationToken.None) is not null) + await reconnect(global::System.Threading.CancellationToken.None); + if (await SendMessageCore(revert, WaitForMetadataUpdate, global::System.Threading.CancellationToken.None) is not null) { _log.LogError($"Failed to revert file edition on file {revert.FilePath}."); } @@ -62,26 +51,26 @@ public async ValueTask DisposeAsync() } } - public delegate Task ReConnect(CancellationToken ct); + public delegate global::System.Threading.Tasks.Task ReConnect(global::System.Threading.CancellationToken ct); public interface IFileUpdater { - ValueTask EnsureReady(CancellationToken ct); + global::System.Threading.Tasks.ValueTask EnsureReady(global::System.Threading.CancellationToken ct); - ValueTask Apply(FileEdit edition, CancellationToken ct); + global::System.Threading.Tasks.ValueTask Apply(FileEdit edition, global::System.Threading.CancellationToken ct); } - private static readonly ILogger _log = typeof(HotReloadHelper).Log(); + private static readonly global::Microsoft.Extensions.Logging.ILogger _log = typeof(HotReloadHelper).Log(); private static IFileUpdater _impl = new NotSupported(); // The delay for the client to connect to the dev-server - private static TimeSpan ConnectionTimeout = TimeSpan.FromSeconds(3); + private static global::System.TimeSpan ConnectionTimeout = global::System.TimeSpan.FromSeconds(3); // The delay for the server to load the workspace and let the client know it's ready - private static TimeSpan WorkspaceTimeout = TimeSpan.FromSeconds(30); + private static global::System.TimeSpan WorkspaceTimeout = global::System.TimeSpan.FromSeconds(30); // The delay for the server to send metadata update once a file has been modified - private static TimeSpan MetadataUpdateTimeout = TimeSpan.FromSeconds(5); + private static global::System.TimeSpan MetadataUpdateTimeout = global::System.TimeSpan.FromSeconds(5); static HotReloadHelper() { @@ -103,7 +92,7 @@ static HotReloadHelper() /// Configures the to use. /// /// - [EditorBrowsable(EditorBrowsableState.Advanced)] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Advanced)] public static void Use(IFileUpdater updater) => _impl = updater; @@ -121,7 +110,7 @@ public static void Use(IFileUpdater updater) /// The replacement text. /// An cancellation token to abort the asynchronous operation. /// An IAsyncDisposable object that will revert the change when disposed. - public static async ValueTask UpdateSourceFile(string filPathRelativeToProject, string originalText, string replacementText, CancellationToken ct = default) + public static async global::System.Threading.Tasks.ValueTask UpdateSourceFile(string filPathRelativeToProject, string originalText, string replacementText, global::System.Threading.CancellationToken ct = default) => await UpdateSourceFile(filPathRelativeToProject, originalText, replacementText, true, ct); /// @@ -133,28 +122,28 @@ public static async ValueTask UpdateSourceFile(string filPathR /// Request to wait for a metadata update to consider the file update to be applied. /// An cancellation token to abort the asynchronous operation. /// An IAsyncDisposable object that will revert the change when disposed. - public static async ValueTask UpdateSourceFile(string filPathRelativeToProject, string originalText, string replacementText, bool waitForMetadataUpdate, CancellationToken ct = default) + public static async global::System.Threading.Tasks.ValueTask UpdateSourceFile(string filPathRelativeToProject, string originalText, string replacementText, bool waitForMetadataUpdate, global::System.Threading.CancellationToken ct = default) { - var projectFile = typeof(HotReloadHelper).Assembly.GetCustomAttribute()?.ProjectFullPath; + var projectFile = typeof(HotReloadHelper).Assembly.GetCustomAttribute()?.ProjectFullPath; if (projectFile is null or { Length: 0 }) { - throw new InvalidOperationException("The project file path could not be found."); + throw new global::System.InvalidOperationException("The project file path could not be found."); } - var projectDir = Path.GetDirectoryName(projectFile) ?? ""; + var projectDir = global::System.IO.Path.GetDirectoryName(projectFile) ?? ""; #if __SKIA__ - if (!File.Exists(projectFile)) // Sanity! + if (!global::System.IO.File.Exists(projectFile)) // Sanity! { - throw new InvalidOperationException("Unable to find project file."); + throw new global::System.InvalidOperationException("Unable to find project file."); } - if (!Directory.Exists(projectDir)) + if (!global::System.IO.Directory.Exists(projectDir)) { - throw new InvalidOperationException("Unable to find project directory."); + throw new global::System.InvalidOperationException("Unable to find project directory."); } #endif - return await UpdateSourceFile(new FileEdit(Path.Combine(projectDir, filPathRelativeToProject), originalText, replacementText), waitForMetadataUpdate, ct); + return await UpdateSourceFile(new FileEdit(global::System.IO.Path.Combine(projectDir, filPathRelativeToProject), originalText, replacementText), waitForMetadataUpdate, ct); } /// @@ -165,7 +154,7 @@ public static async ValueTask UpdateSourceFile(string filPathR /// The replacement text. /// An cancellation token to abort the asynchronous operation. /// An IAsyncDisposable object that will revert the change when disposed. - public static async ValueTask UpdateSourceFile(string originalText, string replacementText, CancellationToken ct = default) + public static async global::System.Threading.Tasks.ValueTask UpdateSourceFile(string originalText, string replacementText, global::System.Threading.CancellationToken ct = default) where T : FrameworkElement, new() { var edition = new T().CreateFileEdit( @@ -182,7 +171,7 @@ public static async ValueTask UpdateSourceFile(string origi /// Request to wait for a metadata update to consider the file update to be applied. /// An cancellation token to abort the asynchronous operation. /// An IAsyncDisposable object that will revert the change when disposed. - public static async Task UpdateSourceFile(FileEdit message, bool waitForMetadataUpdate, CancellationToken ct = default) + public static async global::System.Threading.Tasks.Task UpdateSourceFile(FileEdit message, bool waitForMetadataUpdate, global::System.Threading.CancellationToken ct = default) { _log.LogTrace($"Waiting for connection in order to update file {message.FilePath} (from: \"{StartEnd(message.OldText)}\" to \"{StartEnd(message.NewText)}\") ..."); await _impl.EnsureReady(ct); @@ -215,11 +204,11 @@ public static FileEdit CreateFileEdit( string replacementText) => new(element.GetDebugParseContext().FileName, originalText, replacementText); - private static async Task SendMessageCore(FileEdit message, bool waitForMetadataUpdate, CancellationToken ct) + private static async global::System.Threading.Tasks.Task SendMessageCore(FileEdit message, bool waitForMetadataUpdate, global::System.Threading.CancellationToken ct) { if (waitForMetadataUpdate) { - var cts = new TaskCompletionSource(); + var cts = new global::System.Threading.Tasks.TaskCompletionSource(); using var ctReg = ct.Register(() => cts.TrySetCanceled()); void UpdateReceived(object? sender, object? args) => cts.TrySetResult(default); @@ -238,10 +227,10 @@ public static FileEdit CreateFileEdit( _log.LogTrace("File edition requested, waiting for metadata update (i.e. the code changes to be applied in the current app) ..."); - var timeout = Task.Delay(MetadataUpdateTimeout, ct); - if (await Task.WhenAny(timeout, cts.Task) == timeout) + var timeout = global::System.Threading.Tasks.Task.Delay(MetadataUpdateTimeout, ct); + if (await global::System.Threading.Tasks.Task.WhenAny(timeout, cts.Task) == timeout) { - throw new TimeoutException( + throw new global::System.TimeoutException( "Timeout while waiting for metadata update. " + "This usually indicates that the dev-server failed to process the requested update, you will find more info in dev-server logs " + "(output in main app logs with [DEV_SERVER] prefix for runtime-tests run in secondary app instance)."); @@ -253,7 +242,7 @@ public static FileEdit CreateFileEdit( MetadataUpdateHandler.MetadataUpdated -= UpdateReceived; } - await Task.Delay(100, ct); // Let the metadata to be updated by all handlers. + await global::System.Threading.Tasks.Task.Delay(100, ct); // Let the metadata to be updated by all handlers. _log.LogTrace("Received **a** metadata update, continuing test."); return null; @@ -274,7 +263,7 @@ private static (string FileName, int FileLine, int LinePosition) GetDebugParseCo var dpcProp = typeof(FrameworkElement).GetProperty("DebugParseContext", BindingFlags.Instance | BindingFlags.NonPublic); if (dpcProp == null) { - throw new InvalidOperationException("Could not find DebugParseContext property on FrameworkElement. You should consider to define the property '' in your project in order to enable it's generation even in release."); + throw new global::System.InvalidOperationException("Could not find DebugParseContext property on FrameworkElement. You should consider to define the property '' in your project in order to enable it's generation even in release."); } var dpcForElement = dpcProp.GetValue(element); @@ -294,19 +283,19 @@ private static (string FileName, int FileLine, int LinePosition) GetDebugParseCo var fileName = fl[0].GetValue(dpcForElement)?.ToString() ?? string.Empty; // Don't return details for embedded controls. - if (fileName.StartsWith("ms-appx:///Uno.UI/", StringComparison.InvariantCultureIgnoreCase) - || fileName.EndsWith("mergedstyles.xaml", StringComparison.InvariantCultureIgnoreCase)) + if (fileName.StartsWith("ms-appx:///Uno.UI/", global::System.StringComparison.InvariantCultureIgnoreCase) + || fileName.EndsWith("mergedstyles.xaml", global::System.StringComparison.InvariantCultureIgnoreCase)) { return (string.Empty, -1, -1); } - _ = int.TryParse(fl[1].GetValue(dpcForElement)?.ToString(), NumberStyles.Integer, CultureInfo.InvariantCulture, out int line); - _ = int.TryParse(fl[2].GetValue(dpcForElement)?.ToString(), NumberStyles.Integer, CultureInfo.InvariantCulture, out int pos); + _ = int.TryParse(fl[1].GetValue(dpcForElement)?.ToString(), global::System.Globalization.NumberStyles.Integer, global::System.Globalization.CultureInfo.InvariantCulture, out int line); + _ = int.TryParse(fl[2].GetValue(dpcForElement)?.ToString(), global::System.Globalization.NumberStyles.Integer, global::System.Globalization.CultureInfo.InvariantCulture, out int pos); const string FileTypePrefix = "file:///"; // Strip any file protocol prefix as not expected by the server - if (fileName.StartsWith(FileTypePrefix, StringComparison.InvariantCultureIgnoreCase)) + if (fileName.StartsWith(FileTypePrefix, global::System.StringComparison.InvariantCultureIgnoreCase)) { fileName = fileName.Substring(FileTypePrefix.Length); }