Skip to content

Commit

Permalink
chore: Change compile constants confition to improve usability + rely…
Browse files Browse the repository at this point in the history
… on running platform to check is 2nd app is surppoted instead of compile const
  • Loading branch information
dr1rrb committed Nov 3, 2023
1 parent 22cbbfc commit d677a4c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
3 changes: 0 additions & 3 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
<AnalysisLevel>latest</AnalysisLevel>
<AnalysisModePerformance>AllEnabledByDefault</AnalysisModePerformance>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.0-preview1.22403.2" PrivateAssets="All" />
</ItemGroup>

<Choose>
<When Condition="'$(IsTestProject)' != 'true' and '$(SourceLinkEnabled)' != 'false' and '$(IsSampleProject)' != 'true'">
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

/// <summary>
Expand All @@ -14,6 +15,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.
/// </remarks>
[global::System.Runtime.Versioning.SupportedOSPlatform("windows")]
[global::System.Runtime.Versioning.SupportedOSPlatform("linux")]
[global::System.Runtime.Versioning.SupportedOSPlatform("freeBSD")]
internal sealed partial class DevServer : global::System.IAsyncDisposable
{
private static readonly global::Microsoft.Extensions.Logging.ILogger _log = global::Uno.Extensions.LogExtensionPoint.Log(typeof(DevServer));
Expand All @@ -28,7 +32,7 @@ internal sealed partial class DevServer : global::System.IAsyncDisposable
public static async global::System.Threading.Tasks.Task<DevServer> 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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -24,6 +24,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.
/// </remarks>
[global::System.Runtime.Versioning.SupportedOSPlatform("windows")]
[global::System.Runtime.Versioning.SupportedOSPlatform("linux")]
[global::System.Runtime.Versioning.SupportedOSPlatform("freeBSD")]
internal static partial class ProcessHelper
{
public static async Task<string> ExecuteAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
#pragma warning disable
#endif

#if __SKIA__
#define IS_SECONDARY_APP_SUPPORTED
#endif

namespace Uno.UI.RuntimeTests.Internal.Helpers;

/// <summary>
Expand All @@ -23,9 +19,9 @@ internal static partial class SecondaryApp
/// <summary>
/// Gets a boolean indicating if the current platform supports running tests in a secondary app.
/// </summary>
public static bool IsSupported => // Note: not as const to avoid "CS0162 unreachable code" warning
#if IS_SECONDARY_APP_SUPPORTED
true;
public static bool IsSupported =>
#if HAS_UNO_WINUI // HAS_UNO_WINUI: exclude non net7 platforms
global::System.OperatingSystem.IsWindows() || global::System.OperatingSystem.IsLinux() || global::System.OperatingSystem.IsFreeBSD();
#else
false;
#endif
Expand All @@ -39,9 +35,14 @@ internal static partial class SecondaryApp
/// <returns>The test results.</returns>
internal static async global::System.Threading.Tasks.Task<TestCaseResult[]> RunTest(UnitTestEngineConfig config, global::System.Threading.CancellationToken ct, bool isAppVisible = false)

Check failure on line 36 in src/Uno.UI.RuntimeTests.Engine.Library/Engine/ExternalRunner/_Private/SecondaryApp.cs

View workflow job for this annotation

GitHub Actions / build

'SecondaryApp.RunTest(UnitTestEngineConfig, CancellationToken, bool)': not all code paths return a value

Check failure on line 36 in src/Uno.UI.RuntimeTests.Engine.Library/Engine/ExternalRunner/_Private/SecondaryApp.cs

View workflow job for this annotation

GitHub Actions / build

'SecondaryApp.RunTest(UnitTestEngineConfig, CancellationToken, bool)': not all code paths return a value
{
#if !IS_SECONDARY_APP_SUPPORTED
throw new global::System.NotSupportedException("Secondary app is not supported on this platform.");
#else
#if !HAS_UNO_WINUI // HAS_UNO_WINUI: exclude non net7 platforms
if (!IsSupported)
#endif
{
throw new global::System.NotSupportedException("Secondary app is not supported on this platform.");
}

#if HAS_UNO_WINUI // HAS_UNO_WINUI: exclude non net7 platforms
// First we fetch and start the dev-server (needed to HR tests for instance)
await using var devServer = await DevServer.Start(ct);

Expand Down

0 comments on commit d677a4c

Please sign in to comment.