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

Non serializable #9

Open
Lurler opened this issue Sep 18, 2022 · 9 comments
Open

Non serializable #9

Lurler opened this issue Sep 18, 2022 · 9 comments
Assignees

Comments

@Lurler
Copy link

Lurler commented Sep 18, 2022

Greetings.

Can you consider marking your classes as serializable? I instantiate the grid and pathfinder inside the game map object, so when I want to save the map with a binary serializer I'm unable to do so due to the classes not being marked as such.

It would simplify things massively if you can make it serializable, rather than me trying to concoct some kind of proxy and store pathfinder for each map separately and regenerating them after map loading or switching.

Regards.

@valantonini
Copy link
Owner

Hi @Lurler,

That makes sense. Just some clarifications:

cheers,

val

@Lurler
Copy link
Author

Lurler commented Sep 19, 2022

Thank you for the quick reply. Let me try to explain in details.

Is it just the world grid that needs binary serialization?
All classes that are part of object hierarchy need to be marked as [Serializable] for that to work. In my case WorldGrid and PathFinder are both inside of the map object, so they and any other objects that are instantiated or used/referenced inside them must be also marked as such.

Does the game map serializer use the [SerializableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.serializableattribute?view=net-6.0) to serialize its children (the WorldGrid) as per [making an object serializable](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/serialization/#making-an-object-serializable)
Yes, I simply use binary serializer for now. I may consider alternative approaches, but that's what I use for now.

@valantonini
Copy link
Owner

Makes sense, I'll have a look at it this week.

Did you get it from nuget? If so, i can publish a prerelease package with the change for you to test.

@Lurler
Copy link
Author

Lurler commented Sep 19, 2022

Yes, from nuget.

If you'd like me to test the experimental package just let me know and I will pull it and see if everything works.

@valantonini
Copy link
Owner

Hi @Lurler,

I've started work on a branch. I noticed when writing the test that a few of the binary serialization APIs are deprecated. I've only every binary serialized using protobuf, is this unit test using the correct serialize/deserialize api?

@valantonini valantonini self-assigned this Sep 26, 2022
@Lurler
Copy link
Author

Lurler commented Sep 29, 2022

Hm, I was not aware of that. I remember using it back in the day, so I just reused the same code.
I guess it is a good point. If this serialization approach is deprecated then it might not be a good idea to support it in the long run or encourage bad practices, I guess.
In that case I will just search for an alternative serialization solution.
Thanks!

@valantonini
Copy link
Owner

It's no problem, the game engine may not necessarily be using that serialization method. I pushed up a beta version of the package to nuget with the serialization support. See if it fixes your issue.

@valantonini
Copy link
Owner

@Lurler were you ever able to try this?

@Lurler
Copy link
Author

Lurler commented Feb 20, 2023

Sorry for late reply. I did try the native serialization, but in the end I decided to use a different serialization approach as it's more robust and would work with any package, even if it's not setup for serialization.

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

When branches are created from issues, their pull requests are automatically linked.

2 participants