From 81211fba139cc30c6eac7368a7684bc8663c9cd0 Mon Sep 17 00:00:00 2001 From: Matthew John Cheetham Date: Wed, 25 Oct 2023 11:53:34 -0700 Subject: [PATCH] platformutils: drop unnecessary netfx #ifdefs Since we're targetting .NET Framework 4.7.2 there are some unnecessary conditional compliation `#if NETFRAMEWORK` blocks. Namely around CLR and runtime/OS detection. --- src/shared/Core/PlatformUtils.cs | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/src/shared/Core/PlatformUtils.cs b/src/shared/Core/PlatformUtils.cs index 212c13219..5d00ffcf6 100644 --- a/src/shared/Core/PlatformUtils.cs +++ b/src/shared/Core/PlatformUtils.cs @@ -19,7 +19,7 @@ public static PlatformInformation GetPlatformInformation(ITrace2 trace2) string osType = GetOSType(); string osVersion = GetOSVersion(trace2); string cpuArch = GetCpuArchitecture(); - string clrVersion = GetClrVersion(); + string clrVersion = RuntimeInformation.FrameworkDescription; return new PlatformInformation(osType, osVersion, cpuArch, clrVersion); } @@ -99,11 +99,7 @@ public static bool IsWindowsBrokerSupported() /// True if running on macOS, false otherwise. public static bool IsMacOS() { -#if NETFRAMEWORK - return Environment.OSVersion.Platform == PlatformID.MacOSX; -#else return RuntimeInformation.IsOSPlatform(OSPlatform.OSX); -#endif } /// @@ -112,11 +108,7 @@ public static bool IsMacOS() /// True if running on Windows, false otherwise. public static bool IsWindows() { -#if NETFRAMEWORK - return Environment.OSVersion.Platform == PlatformID.Win32NT; -#else return RuntimeInformation.IsOSPlatform(OSPlatform.Windows); -#endif } /// @@ -125,11 +117,7 @@ public static bool IsWindows() /// True if running on a Linux distribution, false otherwise. public static bool IsLinux() { -#if NETFRAMEWORK - return Environment.OSVersion.Platform == PlatformID.Unix; -#else return RuntimeInformation.IsOSPlatform(OSPlatform.Linux); -#endif } /// @@ -459,9 +447,6 @@ string GetLinuxDistroVersion() private static string GetCpuArchitecture() { -#if NETFRAMEWORK - return Environment.Is64BitOperatingSystem ? "x86-64" : "x86"; -#else switch (RuntimeInformation.OSArchitecture) { case Architecture.Arm: @@ -475,16 +460,6 @@ private static string GetCpuArchitecture() default: return RuntimeInformation.OSArchitecture.ToString(); } -#endif - } - - private static string GetClrVersion() - { -#if NETFRAMEWORK - return $".NET Framework {Environment.Version}"; -#else - return RuntimeInformation.FrameworkDescription; -#endif } #endregion