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

Optional support for opt-in public member serialization? #342

Open
MaxSavenkov opened this issue Oct 17, 2024 · 2 comments
Open

Optional support for opt-in public member serialization? #342

MaxSavenkov opened this issue Oct 17, 2024 · 2 comments

Comments

@MaxSavenkov
Copy link

When switching to MemoryPack from another serialization solution, it would be useful to have an option to avoid automatically serializing all public members of MemoryPackable classes, because marking them all with MemoryPackIgnore is too much work and makes code ugly. I propose to add an option to MemoryPackable attribute, or, if it's too much work for generator, maybe add a separate MemoryPack.OptIn attriubte?

@PragmaGame
Copy link

Is it possible in MemoryPack not to serealize the base class fields?

@MaxSavenkov
Copy link
Author

@PragmaGame With a hack. You can declare those fields as "private new" in derived classes, and don't mark them with MemoryPackInclude. This should prevent their serialization, I think. But in general, this is very suspicious, so you might want to rethink your hierarchy if you really need this.

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

No branches or pull requests

2 participants