-
-
Notifications
You must be signed in to change notification settings - Fork 673
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
MessagePackFormatter(typeof(TypelessFormatter)) throws exception during Serialization #1097
Comments
I think this is a bug. |
Moreover, I noticed that currently there is also a |
Ya, I still think we need to support resolver delegation to avoid this problem. I just haven't had time to design that. @gjaw do you know that you can use Typeless as your top-level resolver and it only uses typeless when the concrete type may not be known at deserialization time? At least, I think that's how it behaves. So for now perhaps you can just use the Typeless serializer/resolver to workaround the failure to use the attribute.
@neuecc I don't think this is of concern in v2.x because all those mutable fields have moved to
That's my bad. I didn't realize that formatters needed public default ctors for the attribute scenario. I'll add a test and fix the bug. |
This corrects a regression from 1.x to 2.0. Fixes MessagePack-CSharp#1097
This corrects a regression from 1.x to 2.0. Fixes MessagePack-CSharp#1097
Thanks, and yes. Using Typeless resolver did work for that case, but since the code did use unknown "object" types elsewhere in custom serialization relying on the lack of Typeless formatter, adding the Typeless resolver did cause other parts of the code to break. But for your peace of mind, I was able to work around those kinks so this bug didn't become a blocker. Anyway, the PR also looks good to me for this bug specifically, but I'm afraid that it might not allow the example case of serializing |
Please open a separate bug for that. |
With the merged changes I cannot reproduce infinite recursion. Using the attribute on a And now I realize that the |
Bug description
Context: I want to use
TypelessFormatter
only for a specific member of a class instance, while using standard formatter (or other formatters) for everything else.The example for this given in README.md is:
Trying to serialize such a class
Foo
results inMissingMethodException: Constructor on type 'MessagePack.Formatters.TypelessFormatter' not found.
This is kind of expected since all of the resolvers I saw will create an instance of the found formatter, but
TypelessFormatter
only has a private constructor as it apparently should only be accessed through its singletonInstance
property.Repro steps
Here's a fully self-contained code to repro and showing my final intent:
Expected behavior
As per the README, I would expect the
TypelessFormatter
to be successfully used for the property with[MessagePackFormatter(typeof(TypelessFormatter))]
attribute applied.Actual behavior
An exception
MissingMethodException: Constructor on type 'MessagePack.Formatters.TypelessFormatter' not found.
is thrown.Additional context
Not sure whether this is a bug, as in the example should work, or if this is a documentation bug, as in the example shouldn't even work but is included in README by mistake.
The text was updated successfully, but these errors were encountered: