@@ -31,7 +31,6 @@ public static bool IsDevBox()
31
31
return false ;
32
32
}
33
33
34
- #if NETFRAMEWORK
35
34
// Check for machine (HKLM) registry keys for Cloud PC indicators
36
35
// Note that the keys are only found in the 64-bit registry view
37
36
using ( Microsoft . Win32 . RegistryKey hklm64 = Microsoft . Win32 . RegistryKey . OpenBaseKey ( Microsoft . Win32 . RegistryHive . LocalMachine , Microsoft . Win32 . RegistryView . Registry64 ) )
@@ -48,9 +47,6 @@ public static bool IsDevBox()
48
47
49
48
return w365Value is not null && Guid . TryParse ( partnerValue , out Guid partnerId ) && partnerId == Constants . DevBoxPartnerId ;
50
49
}
51
- #else
52
- return false ;
53
- #endif
54
50
}
55
51
56
52
public static bool IsWindowsBrokerSupported ( )
@@ -99,11 +95,7 @@ public static bool IsWindowsBrokerSupported()
99
95
/// <returns>True if running on macOS, false otherwise.</returns>
100
96
public static bool IsMacOS ( )
101
97
{
102
- #if NETFRAMEWORK
103
- return Environment . OSVersion . Platform == PlatformID . MacOSX ;
104
- #else
105
98
return RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) ;
106
- #endif
107
99
}
108
100
109
101
/// <summary>
@@ -112,11 +104,7 @@ public static bool IsMacOS()
112
104
/// <returns>True if running on Windows, false otherwise.</returns>
113
105
public static bool IsWindows ( )
114
106
{
115
- #if NETFRAMEWORK
116
- return Environment . OSVersion . Platform == PlatformID . Win32NT ;
117
- #else
118
107
return RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ;
119
- #endif
120
108
}
121
109
122
110
/// <summary>
@@ -125,11 +113,7 @@ public static bool IsWindows()
125
113
/// <returns>True if running on a Linux distribution, false otherwise.</returns>
126
114
public static bool IsLinux ( )
127
115
{
128
- #if NETFRAMEWORK
129
- return Environment . OSVersion . Platform == PlatformID . Unix ;
130
- #else
131
116
return RuntimeInformation . IsOSPlatform ( OSPlatform . Linux ) ;
132
- #endif
133
117
}
134
118
135
119
/// <summary>
@@ -193,11 +177,9 @@ public static bool IsElevatedUser()
193
177
{
194
178
if ( IsWindows ( ) )
195
179
{
196
- #if NETFRAMEWORK
197
180
var identity = System . Security . Principal . WindowsIdentity . GetCurrent ( ) ;
198
181
var principal = new System . Security . Principal . WindowsPrincipal ( identity ) ;
199
182
return principal . IsInRole ( System . Security . Principal . WindowsBuiltInRole . Administrator ) ;
200
- #endif
201
183
}
202
184
else if ( IsPosix ( ) )
203
185
{
@@ -283,9 +265,6 @@ private static string GetLinuxEntryPath()
283
265
}
284
266
}
285
267
286
- #if NETFRAMEWORK
287
- return null ;
288
- #else
289
268
//
290
269
// We cannot determine the absolute file path from argv[0]
291
270
// (how we were launched), so let's now try to extract the
@@ -295,7 +274,6 @@ private static string GetLinuxEntryPath()
295
274
//
296
275
FileSystemInfo fsi = File . ResolveLinkTarget ( "/proc/self/exe" , returnFinalTarget : false ) ;
297
276
return fsi ? . FullName ;
298
- #endif
299
277
}
300
278
301
279
private static string GetMacOSEntryPath ( )
@@ -364,12 +342,11 @@ private static string GetOSVersion(ITrace2 trace2)
364
342
// However, we still need to use the old method for Windows on .NET Framework
365
343
// and call into the Win32 API to get the correct version (regardless of app
366
344
// compatibility settings).
367
- #if NETFRAMEWORK
368
345
if ( IsWindows ( ) && RtlGetVersionEx ( out RTL_OSVERSIONINFOEX osvi ) == 0 )
369
346
{
370
347
return $ "{ osvi . dwMajorVersion } .{ osvi . dwMinorVersion } (build { osvi . dwBuildNumber } )";
371
348
}
372
- #endif
349
+
373
350
if ( IsWindows ( ) || IsMacOS ( ) )
374
351
{
375
352
return Environment . OSVersion . Version . ToString ( ) ;
@@ -459,9 +436,6 @@ string GetLinuxDistroVersion()
459
436
460
437
private static string GetCpuArchitecture ( )
461
438
{
462
- #if NETFRAMEWORK
463
- return Environment . Is64BitOperatingSystem ? "x86-64" : "x86" ;
464
- #else
465
439
switch ( RuntimeInformation . OSArchitecture )
466
440
{
467
441
case Architecture . Arm :
@@ -475,16 +449,11 @@ private static string GetCpuArchitecture()
475
449
default :
476
450
return RuntimeInformation . OSArchitecture . ToString ( ) ;
477
451
}
478
- #endif
479
452
}
480
453
481
454
private static string GetClrVersion ( )
482
455
{
483
- #if NETFRAMEWORK
484
- return $ ".NET Framework { Environment . Version } ";
485
- #else
486
456
return RuntimeInformation . FrameworkDescription ;
487
- #endif
488
457
}
489
458
490
459
#endregion
0 commit comments