From 3593803b18616820ba97facc7c3b122af4f3b613 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 10 Nov 2022 14:06:49 +0000 Subject: [PATCH] browser runtime platform is much simpler. --- .../Avalonia.Web/BrowserRuntimePlatform.cs | 58 ++----------------- 1 file changed, 5 insertions(+), 53 deletions(-) diff --git a/src/Web/Avalonia.Web/BrowserRuntimePlatform.cs b/src/Web/Avalonia.Web/BrowserRuntimePlatform.cs index 96fda806ce..ebcd3a9921 100644 --- a/src/Web/Avalonia.Web/BrowserRuntimePlatform.cs +++ b/src/Web/Avalonia.Web/BrowserRuntimePlatform.cs @@ -11,62 +11,14 @@ internal class BrowserRuntimePlatform : StandardRuntimePlatform { private static readonly Lazy Info = new(() => { - OperatingSystemType os; - - bool isBrowserMobile = false; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - os = OperatingSystemType.OSX; - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - os = OperatingSystemType.Linux; - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - os = OperatingSystemType.WinNT; - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("Android"))) - os = OperatingSystemType.Android; - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("iOS"))) - os = OperatingSystemType.iOS; - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("Browser"))) - { - os = OperatingSystemType.Browser; - isBrowserMobile = AvaloniaModule.IsMobile(); - } - else - throw new Exception("Unknown OS platform " + RuntimeInformation.OSDescription); - - // Source: https://github.com/dotnet/runtime/blob/main/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs - var isCoreClr = Environment.Version.Major >= 5 || - RuntimeInformation.FrameworkDescription.StartsWith(".NET Core", - StringComparison.OrdinalIgnoreCase); - var isMonoRuntime = Type.GetType("Mono.Runtime") != null; - var isFramework = !isCoreClr && - RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework", - StringComparison.OrdinalIgnoreCase); - var result = new RuntimePlatformInfo { - IsCoreClr = isCoreClr, - IsDotNetFramework = isFramework, - IsMono = isMonoRuntime, - IsDesktop = os is OperatingSystemType.Linux or OperatingSystemType.OSX or OperatingSystemType.WinNT, - IsMobile = os is OperatingSystemType.Android or OperatingSystemType.iOS, - IsUnix = os is OperatingSystemType.Linux or OperatingSystemType.OSX or OperatingSystemType.Android, - IsBrowser = os == OperatingSystemType.Browser, - OperatingSystem = os, + IsCoreClr = true, // WASM browser is always CoreCLR + IsBrowser = true, // BrowserRuntimePlatform only runs on Browser. + OperatingSystem = OperatingSystemType.Browser, + IsMobile = AvaloniaModule.IsMobile() }; - - if (result.IsBrowser) - { - if (isBrowserMobile) - { - result.IsMobile = true; - } - else - { - result.IsDesktop = true; - } - } - - + return result; });