John Lam 1997 — 2026

Sometimes you just have to look at a problem from a different perspective

Or have someone else look at your problem from that perspective :)

Earlier today I blogged about the automatic boxing problem for value types in RubyCLR. I was looking at the problem from the perspective of boxing the value type. Seems logical, right? But it turned out to be totally the wrong way to approach it given the current implementation of the CLR.

A big thank-you goes out to Shri Borde of the CLR team at Microsoft for suggesting another way of looking at the problem: create a boxed value type and copy the value type to be marshaled into it. You can create a boxed value type via Activator.CreateInstance(Type) and then you can copy the value type blob using the cpblk instruction. RubyCLR already caches the size of value types using my sizeof hack so this is a very easy thing to do.

4 archived reader comments

Sam (2006-05-25)

Does this mean we might see a fix for my ArrayList << Guid bugrep in the 4th drop sometime next week? (Hopefully? :-) )

Jeroen Frijters (2006-05-25)

Doh! :-)

John Lam (2006-05-25)

Sam, This fix will absolutely be in the 4th drop, which I’m now projecting out to be next week (I just became very busy in my day job).

Sam (2006/05/25)

Does this mean we might see a fix for my ArrayList << Guid bugrep in the 4th drop sometime next week? (Hopefully? :-) )