Skip to content

Commit 81211fb

Browse files
committed
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.
1 parent e549586 commit 81211fb

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
}
@@ -99,11 +99,7 @@ public static bool IsWindowsBrokerSupported()
9999
/// <returns>True if running on macOS, false otherwise.</returns>
100100
public static bool IsMacOS()
101101
{
102-
#if NETFRAMEWORK
103-
return Environment.OSVersion.Platform == PlatformID.MacOSX;
104-
#else
105102
return RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
106-
#endif
107103
}
108104

109105
/// <summary>
@@ -112,11 +108,7 @@ public static bool IsMacOS()
112108
/// <returns>True if running on Windows, false otherwise.</returns>
113109
public static bool IsWindows()
114110
{
115-
#if NETFRAMEWORK
116-
return Environment.OSVersion.Platform == PlatformID.Win32NT;
117-
#else
118111
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
119-
#endif
120112
}
121113

122114
/// <summary>
@@ -125,11 +117,7 @@ public static bool IsWindows()
125117
/// <returns>True if running on a Linux distribution, false otherwise.</returns>
126118
public static bool IsLinux()
127119
{
128-
#if NETFRAMEWORK
129-
return Environment.OSVersion.Platform == PlatformID.Unix;
130-
#else
131120
return RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
132-
#endif
133121
}
134122

135123
/// <summary>
@@ -459,9 +447,6 @@ string GetLinuxDistroVersion()
459447

460448
private static string GetCpuArchitecture()
461449
{
462-
#if NETFRAMEWORK
463-
return Environment.Is64BitOperatingSystem ? "x86-64" : "x86";
464-
#else
465450
switch (RuntimeInformation.OSArchitecture)
466451
{
467452
case Architecture.Arm:
@@ -475,16 +460,6 @@ private static string GetCpuArchitecture()
475460
default:
476461
return RuntimeInformation.OSArchitecture.ToString();
477462
}
478-
#endif
479-
}
480-
481-
private static string GetClrVersion()
482-
{
483-
#if NETFRAMEWORK
484-
return $".NET Framework {Environment.Version}";
485-
#else
486-
return RuntimeInformation.FrameworkDescription;
487-
#endif
488463
}
489464

490465
#endregion

0 commit comments

Comments
 (0)