Skip to content

TypeInfo

Utility class providing methods for obtaining information about different types.

Methods

ApproximateIsBlittable

public static bool ApproximateIsBlittable<T>()
Returns true if a type is blittable, else false. This method uses an approximation, and may not work with generic types with blittable (unmanaged) constraints.

ApproximateIsBlittable

public static bool ApproximateIsBlittable(Type type)
Returns true if a type is blittable, else false. This method uses an approximation, and may not work with generic types with blittable (unmanaged) constraints.

MarshalledSizeOf

public static int MarshalledSizeOf<T>()
Returns size of item after marshalling is performed. This caches the value, thus is faster to access.

Usage

Check if a Type is Blittable (Generic)

bool isBlittable = TypeInfo.ApproximateIsBlittable<int>();

Check if a Type is Blittable (Non-Generic)

bool isBlittable = TypeInfo.ApproximateIsBlittable(typeof(int));

Check size of Type After Marshalling

int size = TypeInfo.MarshalledSizeOf<int>();