@Horusiath Hey I was poking at some code thinking about akkadotnet/Hyperion#8 and noticed something that may be useful depending on how elegant MVP versus final solution needs to be...But it looks like you can set readonly values on a struct if it was created by GetUninitializedObject: Sample here http://share.linqpad.net/499axc.linq

basically, the code-gen first we were creating instance using Activator. That was returning a null, so the next we generated cast to a deserialized type. However later, for readonly fields, we were setting them with FieldInfo.SetValue(object, object), but that requires an object as a first param. So we generated code responsible for casting it back to object (but only for readonly fields). So struct created using activator → casted to its type → casted back to object, was causing an error.

what I've changed, was passing a direct reference to an object returned from activator (so we omitted all casts in this case). That worked.