GithubHelp home page GithubHelp logo

MessagePackDynamicObjectResolverException: can't find matched constructor. type:System.Text.Json.JsonElement about messagepack-csharp HOT 3 OPEN

flobernd avatar flobernd commented on September 22, 2024
MessagePackDynamicObjectResolverException: can't find matched constructor. type:System.Text.Json.JsonElement

from messagepack-csharp.

Comments (3)

AArnott avatar AArnott commented on September 22, 2024 1

At least the following works perfectly fine if I rename @namespace and the corresponding property to something different:

Ok, my curiosity is peaked. If you send me a minimal repro I'll be happy to take a look.

from messagepack-csharp.

AArnott avatar AArnott commented on September 22, 2024

The @ prefix isn't part of the parameter name. That's just C# syntax. At runtime, where MessagePack is reflecting over your members, there is no @ character. So that's not the problem.

Why are you using the JsonConstructor attribute if you're using MessagePack? In fact I don't see any messagepack attributes at all on this class, so I wonder why you expect it to work.
You mention using Typeless. But to work without attributes, you need to write a custom formatter, or use the Contractless resolver.

from messagepack-csharp.

flobernd avatar flobernd commented on September 22, 2024

@AArnott Thanks for the reply.

The @ prefix isn't part of the parameter name. That's just C# syntax. At runtime, where MessagePack is reflecting over your members, there is no @ character. So that's not the problem.

I admit, I have not checked in detail and I know the verbatim operator is just an escape character, but I was thinking it might probably get included in the name that is reported by reflection or something similar.

Why are you using the JsonConstructor attribute if you're using MessagePack?

The whole reason for me to use MessagePack is for caching reasons. I load a huge JSON payload with System.Text.Json. This process is quite slow compared to the binary deserialization MessagePack offers.

In fact I don't see any messagepack attributes at all on this class, so I wonder why you expect it to work.
You mention using Typeless. But to work without attributes, you need to write a custom formatter, or use the Contractless resolver.

I don't think this is true. At least the following works perfectly fine if I rename @namespace and the corresponding property to something different:

var data = await MessagePackSerializer.Typeless
    .DeserializeAsync(fs, default, cancellationToken)
    .ConfigureAwait(false);

I'm not using any attributes (for now) because the JSON payload is pretty complex and consists of 50-100 sub-classes which I didn't want to annotate during the evaluation/test phase for MessagePack 🙂

from messagepack-csharp.

Related Issues (20)

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.