-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
Automatically select constructor #73
Comments
Hi, Anyway, now as for your questions:
I'm not sure. How does Wire do it?
Ceras/src/Ceras/Config/TypeConfig.cs Lines 357 to 360 in 1dd0872
But keep in mind that this does not call ANY constructor!! Meaning that if your constructor(s) don't just set fields/props, but also cause side effects; then those will not happen. However you can just use the [OnAfterDeserializeAttribute] to run any method after all members have been set 😄 That said; maybe Ceras should try to be smart and automatically select some constructor? Maybe filter out the ones that it couldn't possibly use (those where it can't match up members and parameters automatically), and then take the one with the most amount of parameters? And finally, if that results in multiple potential constructors, just throw.
That does indeed seem like a bug! 😮 |
Thanks for the detailed answer!
Cool, but i also support the other serializers, so it was easier), and I also think MethodInfo stores a lot of garbage 😄
looks like by uninitialized object too, in my test for MethodModel, constructor is not called щт deserialize :(, sorry, i will use uninitialized object in OnConfigNewType :)
|
Using TypeConstruction.ByUninitialized, MethodModel not deserialized again 😃 , i think because setters in not public :) |
You'll have to enable serialization of compiler generated fields, and also explicitly target private fields:
and in your
|
Hi, i am using Wire(hyperion) and trying use Ceras for my library as main serializer because hyperion is poorly maintained and messagepack is not user friendly for customers:)
There is my model https://gist.github.com/DaniilSokolyuk/64f933c5fe5deb71f0c1cc35d59cf820, i have 2 problems
The text was updated successfully, but these errors were encountered: