-
Notifications
You must be signed in to change notification settings - Fork 174
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
Serialising anonymous/immutable types #68
Comments
In my unstanding, anon types cannot be take away from declaring method, so I cannot imagine use case when anon type serialization is really useful. Would you tell me when and how do you use anon types serialization? |
Anonymous classes are regular classes and their type can be known and passed around. This is especially easy when using generic methods:
That's actually pretty close to our use case. The logging API should support arbitrary data from users, so long as it only contains serialisable types. However the anonymous type simply isn't serialisable. The problem seems to be that msgpack-cli uses one set of restrictions across both encodable/decodable types. This means types must always have read/write properties in order to work with the lib. This seems like a significant limitation, especially when you use immutability extensively in your code. Of course it's not limited to anonymous types:
In this case, as with anonymous types, |
Thank you for great suggestion. I understand that there are use cases that need 'asymmetric' serializer which only available for serialization or deserialization. Although I'm interested in asymmetric serializers feature, I cannot tuckle to it soon because I'm working on another issue. |
This would certainly be very useful for us. I'm not sure how hard it would be to retrofit this to the current API. I suppose the current serialiser objects could implement both
|
This commit relaxes serialization target retrieval, so it allows 'asymmetric'(pack only) serializer generation. * This commit also adds unit tests. * Unpack only serializer is not supported yet because there are no patterns found which can be deserialize but cannot be serialize. * Supporting capabilities is needed to distingush pack only serializers from normal serializers.
This was implemented in 0.9. |
Great news! |
Is it possible to serialise an anonymous type?
For example:
This would be very useful for us.
Unfortunately,
GetSerializer<T>
doesn't seem to work, presumably as the properties of anonymous types are read only. Because the returned serializer can both serialise and deserialise, it's not possible to build it. However we only need the serialiser bit.(cc @lufka)
The text was updated successfully, but these errors were encountered: