-
Notifications
You must be signed in to change notification settings - Fork 10
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
JsonSerializer and XmlSerializer don't serialize DynamicObject.Type property #4
Comments
The issue lies in the fact that DynamicObject implements IEnumerable which apparently XmlSerializer treats as a collection only and ignores any of its actual properties. Apparently, the same is true for Json.net. I’ll have to address this, and I’m actually tempted to get rid of the interfaces on DynamicObject since the only alternative I can think of is having a surrogate class which seems unpractical. |
Since XmlSerializer applies special behavior to IEnumerable, I had to remove this interface from DynamicObject. The only workaround I found was to implement IXmlSerializable, but this doesn't mix with DataContractAttribute. Json.net in addition to IEnumerable also adds specific logic for types implementing IDynamicMetaObjectProvider. Hence DynamicObject is now marked with JsonObjectAttribute along with JsonIgnoreAttribute on its calculated properties. |
…on.net related to specific handling of IEnumerable<> and IDynamicMetaObjectProvider
Works fine in 4.0.0-alpha-031. Thank you! |
Here we address two problems: 1. DynamicObject.Type property not serialized (6bee/aqua-core#4). Have to add "__ClrType" pseudo-property to each DynamicObject representing a boxed primitive value. Need to remove this workaround after the original bug is fixed. 2. Remote.Linq misinterprets a single element of type T[] as a collection of T, so we need to compensate this effect.
I extended
When_using_dynamic_object_for_complex_object_tree
class with one more testIt passes with
BinaryFormatter
,DataContractSerializer
andNetDataContractSerializer
, but fails withJsonSerializer
andXmlSerializer
.The text was updated successfully, but these errors were encountered: