Class Platform
- Namespace
- Utils.Reflection
- Assembly
- Utils.Reflection.dll
Utility class for runtime platform and architecture detection.
public static class Platform
- Inheritance
-
Platform
- Inherited Members
Properties
IsAndroid
True if runtime platform is Android.
public static bool IsAndroid { get; }
Property Value
IsArm
True if process architecture is Arm (32-bit).
public static bool IsArm { get; }
Property Value
IsArm64
True if process architecture is Arm64 (64-bit ARM).
public static bool IsArm64 { get; }
Property Value
IsBrowser
True if runtime platform is running on WebAssembly in a browser.
public static bool IsBrowser { get; }
Property Value
IsIOS
True if runtime platform is iOS.
public static bool IsIOS { get; }
Property Value
IsLinux
True if runtime platform is Linux (desktop/server).
public static bool IsLinux { get; }
Property Value
IsMacOS
True if runtime platform is macOS. Alias for IsMacOsX using Apple's current platform name (matching IsMacOS(), used internally), kept alongside it for source/binary compatibility with existing callers of IsMacOsX.
public static bool IsMacOS { get; }
Property Value
IsMacOsX
True if runtime platform is macOS.
public static bool IsMacOsX { get; }
Property Value
IsS390x
True if process architecture is IBM s390x.
public static bool IsS390x { get; }
Property Value
IsTvOS
True if runtime platform is tvOS.
public static bool IsTvOS { get; }
Property Value
IsUnknown
True if runtime platform is unknown or not explicitly handled above.
public static bool IsUnknown { get; }
Property Value
IsUnknownArchitecture
True if process architecture is unknown or not explicitly handled above.
public static bool IsUnknownArchitecture { get; }
Property Value
IsWasm
True if process architecture is WebAssembly.
public static bool IsWasm { get; }
Property Value
IsWatchOS
True if runtime platform is watchOS.
public static bool IsWatchOS { get; }
Property Value
IsWindows
True if runtime platform is Windows.
public static bool IsWindows { get; }
Property Value
IsX64
True if process architecture is x64 (64-bit Intel/AMD).
public static bool IsX64 { get; }
Property Value
IsX86
True if process architecture is x86 (32-bit Intel/AMD).
public static bool IsX86 { get; }
Property Value
NativeULongSize
Size of native (unmanaged) 'ulong' (e.g., CK_ULONG in PKCS#11). Default logic:
- On Linux/macOS (including iOS, Android) it depends on process bitness (4 bytes on 32-bit, 8 bytes on 64-bit).
- On Windows it is 4 bytes, regardless of x86/x64. This value can be overridden by setter if needed.
public static int NativeULongSize { get; set; }
Property Value
Remarks
Not thread-safe. This is process-wide mutable state, not scoped to a caller or a single library binding: setting it from one component (for example, one PKCS#11 provider with unusual struct layout needs) changes the value observed by every other concurrent consumer of Platform in the same process, including ones that never touched this property themselves. There is no synchronization around reads/writes, so a set racing with a get from another thread is also a plain (if usually benign, given int writes are atomic on supported platforms) data race. Only set this once, as early as possible during startup, before any other code that might read it runs concurrently.
StructPackingSize
Controls alignment of unmanaged struct fields:
- On Windows, CRYPTOKI structs are usually packed with 1-byte alignment.
- On Unix-like platforms, they are usually packed with default alignment (0). This can be overridden by setter if needed.
public static int StructPackingSize { get; set; }
Property Value
Remarks
Not thread-safe — see the identical caveat on NativeULongSize: this is process-wide mutable state shared by every consumer of Platform, with no synchronization. Only set this once, as early as possible during startup.
Uses32BitRuntime
True if 32-bit runtime is used (x86, Arm32, etc.).
public static bool Uses32BitRuntime { get; }
Property Value
Uses64BitRuntime
True if 64-bit runtime is used (x64, Arm64, s390x, or other 64-bit).
public static bool Uses64BitRuntime { get; }