Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: MemoryPackSerializer.ResetState, ResetReaderState, ResetWriterState #288

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

alexyakunin
Copy link

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.

@neuecc
Copy link
Member

neuecc commented May 8, 2024

Thanks, it seems like a good approach.
Could you please add unit tests and sample code to the README?

@alexyakunin
Copy link
Author

Will do somewhere on this week. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants