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 d9bfe3b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 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 @@ -28,7 +29,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 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,11 +19,11 @@ 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;
#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

/// <summary>
Expand All @@ -39,7 +35,7 @@ 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)
{
#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)
Expand Down

0 comments on commit d9bfe3b

Please sign in to comment.