public static void AssertSize <T>(ElementSize elementSize) { if (TypeHelpers.ToElementSize <T>() != elementSize) { throw new InvalidOperationException($"Element size mismatch, T is {Unsafe.SizeOf<T>()}, pointer is {elementSize}"); } }
private ElementSize GetElementSize() { if (ReflectionCache <T> .ImplementsIStruct) { return(ReflectionCache <T> .PreferredElementSize); } else if (ReflectionCache <T> .ImplementsIAbsPointer) { return(ElementSize.EightBytesPointer); } else if (typeof(T) == typeof(Void)) { return(ElementSize.Zero); } return(TypeHelpers.ToElementSize <T>()); }