Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 75e0209

Browse files
committed
Implement InitializePlatformData without calling Python
1 parent a9b91a3 commit 75e0209

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/runtime/runtime.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ internal static void Initialize(bool initSigs = false)
356356
/// </summary>
357357
private static void InitializePlatformData()
358358
{
359+
#if !NETSTANDARD
359360
IntPtr op;
360361
IntPtr fn;
361362
IntPtr platformModule = PyImport_ImportModule("platform");
@@ -391,6 +392,34 @@ private static void InitializePlatformData()
391392
MType = MachineType.Other;
392393
}
393394
Machine = MType;
395+
#else
396+
OperatingSystem = OperatingSystem.Other;
397+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
398+
OperatingSystem = OperatingSystemType.Linux;
399+
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
400+
OperatingSystem = OperatingSystemType.Darwin;
401+
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
402+
OperatingSystem = OperatingSystemType.Windows;
403+
404+
Machine = MachineType.Other;
405+
switch (RuntimeInformation.ProcessArchitecture)
406+
{
407+
case Architecture.X86:
408+
Machine = MachineType.i386;
409+
break;
410+
case Architecture.X64:
411+
Machine = MachineType.amd64;
412+
break;
413+
case Architecture.Arm:
414+
Machine = MachineType.armv7l;
415+
break;
416+
case Architecture.Arm64:
417+
Machine = MachineType.aarch64;
418+
break;
419+
default:
420+
Machine = MachineType.Other;
421+
}
422+
#endif
394423
}
395424

396425
internal static void Shutdown()

0 commit comments

Comments
 (0)