From d9bfe3b2ffebead430a2914fa3c34be70d8977ac Mon Sep 17 00:00:00 2001 From: David Date: Fri, 3 Nov 2023 13:55:24 -0400 Subject: [PATCH] chore: Change compile constants confition to improve usability + rely on running platform to check is 2nd app is surppoted instead of compile const --- src/Directory.Build.props | 3 --- .../Engine/ExternalRunner/_Private/DevServer.cs | 5 +++-- .../ExternalRunner/_Private/ProcessHelper.cs | 2 +- .../Engine/ExternalRunner/_Private/SecondaryApp.cs | 14 +++++--------- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 83e847e..23635bc 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -36,9 +36,6 @@ latest AllEnabledByDefault - - - 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 37bbe4a..b95507c 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 @@ -1,10 +1,11 @@ -#if !UNO_RUNTIMETESTS_DISABLE_UI && (__SKIA__ || IS_SECONDARY_APP_SUPPORTED) +#if !UNO_RUNTIMETESTS_DISABLE_UI && HAS_UNO_WINUI // HAS_UNO_WINUI: exclude non net7 platforms #nullable enable #if !IS_UNO_RUNTIMETEST_PROJECT #pragma warning disable #endif #pragma warning disable CA1848 // Log perf +#pragma warning disable CS1998 // No await namespace Uno.UI.RuntimeTests.Internal.Helpers; /// @@ -28,7 +29,7 @@ internal sealed partial class DevServer : global::System.IAsyncDisposable 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."); + throw new global::System.NotSupportedException("Dev server has not been referenced."); #else var path = await GetDevServer(ct); var port = GetTcpPort(); diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/ExternalRunner/_Private/ProcessHelper.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/ExternalRunner/_Private/ProcessHelper.cs index d5656f6..7cb0a9b 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/ExternalRunner/_Private/ProcessHelper.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/ExternalRunner/_Private/ProcessHelper.cs @@ -1,4 +1,4 @@ -#if !UNO_RUNTIMETESTS_DISABLE_UI && (__SKIA__ || IS_SECONDARY_APP_SUPPORTED) +#if !UNO_RUNTIMETESTS_DISABLE_UI && HAS_UNO_WINUI // HAS_UNO_WINUI: exclude non net7 platforms #nullable enable #if !IS_UNO_RUNTIMETEST_PROJECT 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 1c3d225..e27d001 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 @@ -5,10 +5,6 @@ #pragma warning disable #endif -#if __SKIA__ -#define IS_SECONDARY_APP_SUPPORTED -#endif - namespace Uno.UI.RuntimeTests.Internal.Helpers; /// @@ -23,11 +19,11 @@ internal static partial class SecondaryApp /// /// Gets a boolean indicating if the current platform supports running tests in a secondary app. /// - public static bool IsSupported => // Note: not as const to avoid "CS0162 unreachable code" warning -#if IS_SECONDARY_APP_SUPPORTED - true; -#else + public static bool IsSupported => +#if !HAS_UNO_WINUI || __IOS__ || __ANDROID__ || __MACOS__ false; +#else + !global::System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(global::System.Runtime.InteropServices.OSPlatform.Create("BROWSER")); #endif /// @@ -39,7 +35,7 @@ internal static partial class SecondaryApp /// The test results. internal static async global::System.Threading.Tasks.Task RunTest(UnitTestEngineConfig config, global::System.Threading.CancellationToken ct, bool isAppVisible = false) { -#if !IS_SECONDARY_APP_SUPPORTED +#if !HAS_UNO_WINUI // HAS_UNO_WINUI: exclude non net7 platforms 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)