Closed alexyakunin closed 2 months ago
Thanks, it seems like a good approach. Could you please add unit tests and sample code to the README?
Will do somewhere on this week. Thanks!
Well, I don't think there's any particular problem, so I'll try merging it for now.
Thanks - yes, sorry, didn't have a chance to get back to that. I'm 100% for tests, but I guess this specific thing is fine to be uncovered for now: it doesn't affect the primary logic + if it doesn't work, you'll get another bug report quite soon ;)
Sometimes you want to invoke
MemoryPackSerializer.Serialize
while serializing another type (e.g. to serialize a complex nested structure into a byte array on serialization). And sometimes you want to do the same on deserialization. Since MemoryPack uses[ThreadStatic]
to store its serializer/deserializer state, this doesn't work - unless you backup its state & reset it.The provided implementation does exactly this. Currently we have to resort to CreateDelegate/ILEmit-based workaround to address that, this change would address the problem in more straightforward way.