Jump to content
  • Advertisement
Sign in to follow this  
cyansoft

[.net] Serialization Best Practices

This topic is 3944 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was wondering what everyone is using for serialization for their .Net projects, especially when it comes to loading (and saving) scene information. The ISerializable interface works great with it's GetObjectData method combined with a protected constructor. The serialization of generic containers works perfectly. Unfortunately, I want my data stored in XML for easy editing, but only the BinaryFormatter supports generics. Plus even if the SoapFormatter supported generics, it generates very hard to read XML. The XmlSerializer class also doesn't support generics, but more importantly, doesn't ignores the GetObjectData and protected constructor, requires a empty public constructor, and only supports serializing public fields. I don't want to have to create my own custom methods for serialization/deserialization and rather use something that's already build in to the framework. Unless I'm missing something, it looks like the framework is lacking in the ability to easily support semi-complex serialization to XML. I would prefer any solution to remain compatible with the Compact 2.0 framework so it can be easily ported to the Xbox 360. Anyone willing to share some techniques and/or your experiences with XML serialization in .Net?

Share this post


Link to post
Share on other sites
Advertisement
I never found a good solution and ended up writing my own XML serializers. Luckily it's not too complex; my latest serializer is ~600 lines of C# with lots of comments and parameter validation.

The closest solution that is "built-into" .NET is XamlReader, but that requires .NET 3.0. Plus I don't think XAML supports generics.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!