AdamsLair / duality

a 2D Game Development Framework
https://adamslair.github.io/duality
MIT License
1.41k stars 290 forks source link

Keep an Eye on TypeInfo Serialization #198

Open AdamsLair opened 9 years ago

AdamsLair commented 9 years ago

Making the Duality Core a PCL also requires switching from the old Type API to the new TypeInfo API. Unfortunately, Serialization will have a hard time coping with this, to the point that I would consider TypeInfo completely unsupported as a serializable type.

This results in an erroneous deserialization of content, depending on whether the underlying platform implements Type as part of the TypeInfo inheritance or not. There is nothing Duality can do about this, because there is no difference between the two for an object in the .Net 4.5 runtime.

AdamsLair commented 9 years ago

Until further notice, TypeInfo should be regarded as completely unsupported in serialization. Use Type for serializable fields instead.

AdamsLair commented 9 years ago

Created a StackOverflow Question for gathering some feedback on the matter and seeing if there is something I'm missing.

AdamsLair commented 9 years ago

One possible solution would be to implement some hacky type-conversion code for the sake of compatibility with TypeInfo, in case anyone (or worse, any .Net classes) attempts to serialize one. It should be done in a small protected static method in the Serializer base class, so its usage can easily be tracked. Maybe name it ConvertToTypeInfo or something.

It would

It would be used for

A typical usage check would test

This should cover all the basic cases.