Table of Contents

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

bool

IsArm

True if process architecture is Arm (32-bit).

public static bool IsArm { get; }

Property Value

bool

IsArm64

True if process architecture is Arm64 (64-bit ARM).

public static bool IsArm64 { get; }

Property Value

bool

IsBrowser

True if runtime platform is running on WebAssembly in a browser.

public static bool IsBrowser { get; }

Property Value

bool

IsIOS

True if runtime platform is iOS.

public static bool IsIOS { get; }

Property Value

bool

IsLinux

True if runtime platform is Linux (desktop/server).

public static bool IsLinux { get; }

Property Value

bool

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

bool

IsMacOsX

True if runtime platform is macOS.

public static bool IsMacOsX { get; }

Property Value

bool

IsS390x

True if process architecture is IBM s390x.

public static bool IsS390x { get; }

Property Value

bool

IsTvOS

True if runtime platform is tvOS.

public static bool IsTvOS { get; }

Property Value

bool

IsUnknown

True if runtime platform is unknown or not explicitly handled above.

public static bool IsUnknown { get; }

Property Value

bool

IsUnknownArchitecture

True if process architecture is unknown or not explicitly handled above.

public static bool IsUnknownArchitecture { get; }

Property Value

bool

IsWasm

True if process architecture is WebAssembly.

public static bool IsWasm { get; }

Property Value

bool

IsWatchOS

True if runtime platform is watchOS.

public static bool IsWatchOS { get; }

Property Value

bool

IsWindows

True if runtime platform is Windows.

public static bool IsWindows { get; }

Property Value

bool

IsX64

True if process architecture is x64 (64-bit Intel/AMD).

public static bool IsX64 { get; }

Property Value

bool

IsX86

True if process architecture is x86 (32-bit Intel/AMD).

public static bool IsX86 { get; }

Property Value

bool

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

int

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

int

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

bool

Uses64BitRuntime

True if 64-bit runtime is used (x64, Arm64, s390x, or other 64-bit).

public static bool Uses64BitRuntime { get; }

Property Value

bool