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

Add support for ExpandoObject #948

Merged
merged 3 commits into from
Sep 12, 2020
Merged

Conversation

AArnott
Copy link
Collaborator

@AArnott AArnott commented Jun 7, 2020

Consider/TODO:

  • Should we enable this only in 'trusted data' mode? Perhaps so, if ExpandoObject uses a hash algorithm that cannot be made secure. No worries. It's a list of keys, not a hashed key.
  • Given ExpandoObject implements IDictionary<string, object> we could enable more scenarios by using ExpandoObject instead of Dictionary<string, object> when deserializing untyped data.

Closes #446

@AArnott AArnott added this to the v2.2 milestone Jun 7, 2020
@AArnott AArnott requested a review from neuecc June 7, 2020 04:09
@AArnott AArnott self-assigned this Jun 7, 2020
Comment on lines 41 to 45
var options = MessagePackSerializerOptions.Standard;
var deserializerOptions = MessagePackSerializerOptions.Standard.WithResolver(
CompositeResolver.Create(
PrimitiveObjectResolver.InstanceWithExpandoObject,
MessagePackSerializerOptions.Standard.Resolver));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is somewhat cumbersome. I'd at least like to have just one set of resolvers used both for serializing and deserializing. And if we could reasonably expose a pre-composed resolver, so much the better. But I'm not sure how to do that, nor how worthwhile the effort is.

Copy link
Member

@neuecc neuecc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, do I need to support it?
ExpandoObject is a bad as ArrayList, or even worse than that.

@AArnott
Copy link
Collaborator Author

AArnott commented Jun 12, 2020

ExpandoObject is a bad as ArrayList, or even worse than that.

I figured this one would need more discussion. I'm curious what you have against ArrayList (the only thing I can think of is that it isn't a generic type), and how that applies to ExpandoObject.

ExpandoObject is freakin' awesome for folks who just want to deserialize something and call into it as naturally as in Javascript. But only one person has asked for it. I personally would rarely (if ever) use it, but unless it messes up the rest of the library in some way, it seems fine to add, IMHO.

@neuecc
Copy link
Member

neuecc commented Jul 13, 2020

@AArnott

I have no concern if add only Formatter.
This doesn't affect the user in anyway, same as ArrayListFormatter.

I don't like the addition to PrimitiveObjectResolver.
I don't want this to make the ReadMe too long.
(By the way, it might be weird to have it under Typeless, dynamic and Typeless is not same thing).

However, if you really want to add it, okay to add.
In fact, it's designed to have no effect at all.

@AArnott
Copy link
Collaborator Author

AArnott commented Sep 10, 2020

@neuecc I've reduced the impact of the change on the PrimitiveObjectResolver and did some other things to make it both easier to use and less intrusive to the existing types. Your thoughts, please?

This adopts a slighty new usage pattern that IMO is easier to work with and explain, so that's good. :)
@neuecc
Copy link
Member

neuecc commented Sep 11, 2020

@AArnott
Very interesting, and also pretty easy to use!

@AArnott
Copy link
Collaborator Author

AArnott commented Sep 11, 2020

I'm glad you like it. I take it you're ok with the change as-is then? I'll give you a few hours to respond before merging. :)

@AArnott AArnott merged commit 6f5c234 into MessagePack-CSharp:v2.2 Sep 12, 2020
@AArnott AArnott deleted the expandoObject branch September 12, 2020 02:01
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

Successfully merging this pull request may close these issues.

None yet

2 participants