FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

`[CompositeResolverAttribute]` not yet that useful · Issue #1920 · MessagePack-CSharp/MessagePack-CSharp · GitHub

[CompositeResolverAttribute] not yet that useful #1920

Description

In my application that I'm migrating to v3, I have a bunch of data types that must be serialized:

  • Many are in the assembly with the messagepack reference
    • A few use [MessagePackObject]
    • Most use hand-authored formatters
  • Some are in an assembly w/o a messagepack reference. These have custom formatters declared in the above mentioned assembly.

I mix in the StandardResolver with my own resolver.

Ultimately, the resolver I use must be able to find the formatters that are declared in the same assembly as the data types as well as the formatters I define for data types outside my assembly. The former is easy and well automated. But I have to write my own resolver to find the formatters I define locally for data types found elsewhere because by default, StandardResolver only consults the automatically generated resolver for data types declared in the same assembly.

So I thought I'd create my own top-level resolver that forces the source generated resolver to always be asked, alongside the StandardResolver.

[CompositeResolver(typeof(GeneratedMessagePackResolver), typeof(StandardResolver))]
partial class CombinedResolver { }

The problem here is that CombinedResolver gets generated with this error:

#error No accessible default constructor or static Instance member on GeneratedMessagePackResolver.,

This is almost certainly because source generators (of which MessagePack v3 has two) cannot see each other's output, so it doesn't know that in fact GeneratedMessagePackResolver does in fact have an accessible instance:

public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver();

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL