Code Monkey home page Code Monkey logo

Comments (6)

kevin-montrose avatar kevin-montrose commented on September 27, 2024

I suspect the problem here is RouteValueDictionary is an IDictionary<string, object>, which probably greatly confuses deserialization.

I haven't time to investigate further though, hopefully this weekend I'll get the free time.

from public-broadcasting.

jgeurts avatar jgeurts commented on September 27, 2024

Not a huge rush - I modified my code to convert the RouteValueDictionary to a Dictionary<string, object> shim and then when I deserialize, convert the shim back to a RouteValueDictionary.

from public-broadcasting.

kevin-montrose avatar kevin-montrose commented on September 27, 2024

@jgeurts Dictionary<string, object>? Are you sure you didn't use Dictionary<string, string> for your shim?

It looks like the issue is object as the dictionary's TValue type (really just System.Object as a discovered "to be serialized" type, at all), protobuf doesn't know what to do with that (it has no properties or fields to annotate). I could make it not fail, but since no properties would be deserialized you'd just get a dictionary like { { "some value", new object() }, { "some other value", new object() }, ... } out.

But if you've got working code with a Dictionary<string, object> shim, that kind of kills that theory. Would love to see some more code if that's the case.

from public-broadcasting.

jgeurts avatar jgeurts commented on September 27, 2024

@kevin-montrose I apologize - I was trying to get the serialization working with Public Broadcasting and then TypeSerializer from service stack. I apparently settled on TypeSerializer, which handles the Dictionary<string,object> type. Added a test with #6, if that helps. Please let me know if I can help with anything else.

from public-broadcasting.

kevin-montrose avatar kevin-montrose commented on September 27, 2024

@jgeurts Yeah, protocol buffers can't really deal with heterogeneous collections. I think the best thing to do here is to generate a better error message.

I think the way ServiceStack deals with this is by attaching type information to every stored value whose compile time type System.Object, which doesn't work with Public Broadcasting's "leading type description" approach.

I suppose I could detect when a collection is typed System.Object but actually contains only a single type (probably as a defaults-off option). That wouldn't do anything for #6 though.

from public-broadcasting.

jgeurts avatar jgeurts commented on September 27, 2024

Ok, thanks for taking a bit of time on this. I do think that heterogeneous collections are a bit of an edge case and in my instance, I'm completely fine using a Dictionary<string,string> as an alternative.

As a side note, I looked at the serialized result from ServiceStack's TypeSerializer and it didn't include the __type property with type information for each value. When deserializing, it just recreates the objects as strings.

from public-broadcasting.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.