Skip to content

Commit

Permalink
platformutils: drop unnecessary netfx #ifdefs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mjcheetham committed Oct 25, 2023
1 parent e549586 commit 81211fb
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions src/shared/Core/PlatformUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -99,11 +99,7 @@ public static bool IsWindowsBrokerSupported()
/// <returns>True if running on macOS, false otherwise.</returns>
public static bool IsMacOS()
{
#if NETFRAMEWORK
return Environment.OSVersion.Platform == PlatformID.MacOSX;
#else
return RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
#endif
}

/// <summary>
Expand All @@ -112,11 +108,7 @@ public static bool IsMacOS()
/// <returns>True if running on Windows, false otherwise.</returns>
public static bool IsWindows()
{
#if NETFRAMEWORK
return Environment.OSVersion.Platform == PlatformID.Win32NT;
#else
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
#endif
}

/// <summary>
Expand All @@ -125,11 +117,7 @@ public static bool IsWindows()
/// <returns>True if running on a Linux distribution, false otherwise.</returns>
public static bool IsLinux()
{
#if NETFRAMEWORK
return Environment.OSVersion.Platform == PlatformID.Unix;
#else
return RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
#endif
}

/// <summary>
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit 81211fb

Please sign in to comment.