John Lam 1997 — 2026

Blittable vs. non-blittable types

Just the other day, I was attempting to marshal a DateTime value type from Ruby and RubyCLR blew up. Now I know why.

I should have known better, but I failed to account for blittable vs. non-blittable value types in RubyCLR. I explicitly avoid boxing value types in RubyCLR by blitting the value type into memory that I explicilty allocate for the Ruby object.

All of my value type marshaling tests were done on sequential layout types such as Point whose layout in managed memory is the same as they would be in unmanaged memory.

The trick now is figuring out how to marshal auto layout value types generically across the interop boundary.