Skip to content

Commit 59f01d9

Browse files
authored
platformutils: drop unnecessary netfx #ifdefs (#1447)
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.
2 parents b30eab3 + 81211fb commit 59f01d9

File tree

1 file changed

+1
-26
lines changed

1 file changed

+1
-26
lines changed

src/shared/Core/PlatformUtils.cs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static PlatformInformation GetPlatformInformation(ITrace2 trace2)
1919
string osType = GetOSType();
2020
string osVersion = GetOSVersion(trace2);
2121
string cpuArch = GetCpuArchitecture();
22-
string clrVersion = GetClrVersion();
22+
string clrVersion = RuntimeInformation.FrameworkDescription;
2323

2424
return new PlatformInformation(osType, osVersion, cpuArch, clrVersion);
2525
}
@@ -115,11 +115,7 @@ public static bool IsWindowsBrokerSupported()
115115
/// <returns>True if running on macOS, false otherwise.</returns>
116116
public static bool IsMacOS()
117117
{
118-
#if NETFRAMEWORK
119-
return Environment.OSVersion.Platform == PlatformID.MacOSX;
120-
#else
121118
return RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
122-
#endif
123119
}
124120

125121
/// <summary>
@@ -128,11 +124,7 @@ public static bool IsMacOS()
128124
/// <returns>True if running on Windows, false otherwise.</returns>
129125
public static bool IsWindows()
130126
{
131-
#if NETFRAMEWORK
132-
return Environment.OSVersion.Platform == PlatformID.Win32NT;
133-
#else
134127
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
135-
#endif
136128
}
137129

138130
/// <summary>
@@ -141,11 +133,7 @@ public static bool IsWindows()
141133
/// <returns>True if running on a Linux distribution, false otherwise.</returns>
142134
public static bool IsLinux()
143135
{
144-
#if NETFRAMEWORK
145-
return Environment.OSVersion.Platform == PlatformID.Unix;
146-
#else
147136
return RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
148-
#endif
149137
}
150138

151139
/// <summary>
@@ -475,9 +463,6 @@ string GetLinuxDistroVersion()
475463

476464
private static string GetCpuArchitecture()
477465
{
478-
#if NETFRAMEWORK
479-
return Environment.Is64BitOperatingSystem ? "x86-64" : "x86";
480-
#else
481466
switch (RuntimeInformation.OSArchitecture)
482467
{
483468
case Architecture.Arm:
@@ -491,16 +476,6 @@ private static string GetCpuArchitecture()
491476
default:
492477
return RuntimeInformation.OSArchitecture.ToString();
493478
}
494-
#endif
495-
}
496-
497-
private static string GetClrVersion()
498-
{
499-
#if NETFRAMEWORK
500-
return $".NET Framework {Environment.Version}";
501-
#else
502-
return RuntimeInformation.FrameworkDescription;
503-
#endif
504479
}
505480

506481
#endregion

0 commit comments

Comments
 (0)