-
-
Notifications
You must be signed in to change notification settings - Fork 710
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
Deserialization of generic types fails due to inability to find property setters that use init
#1134
Comments
init
init
Repro for failure as reported in MessagePack-CSharp#1134
Based on this doc it seems likely that our IL code gen has to be updated to include As to why it only fails in generic classes may be a bug/detail of the .NET 5 runtime. |
See linked dotnet/runtime bug for more info. I'm pretty certain this is a bug in .NET. |
This is a bug in .NET. .NET 6.0 has the fix, which may be ported to 5.x. |
…y setters Fixes MessagePack-CSharp#1134 as much as we can while .NET has the underlying bug. When .NET 6 ships with the fix, we can add a .NET 6 target that re-allows setting `init` property setters from the `DynamicObjectResolver`.
…y setters Fixes MessagePack-CSharp#1134 as much as we can while .NET has the underlying bug. When .NET 6 ships with the fix, we can add a .NET 6 target that re-allows setting `init` property setters from the `DynamicObjectResolver`.
@AArnott thanks for moving #1147 to here. I probably cannot use StandardResolverAllowPrivate because of side effects through my code base. For now I am selectively using |
I'd like to make it "just work" with either dynamic resolver, perhaps by falling back to reflection when the bug is present. Hopefully by end of year. |
Hi @AArnott - since you closed this, what is the status pls? |
The PR with the fix has merged and will be included in our 2.3 release. |
Thanks @AArnott. I just returned to working to integrate MessagePack into my data model. I see that 2.3 is in Alpha. Do you anticipate any issues for me using this release? Many thanks, Simon |
@simonziegler no, there's no known instability in messagepack 2.3-alpha. |
Hey @AArnott I was going to drop by here this week to let you know that 2.3-alpha is working great and without any issues regarding init/set. It all just works. Many thanks! |
Hey, I see this has been closed and a fix was included in 2.3, but I am on 2.4.35 and I just got an exception linking me to this issue while using the
I am having some trouble putting together a minimum reproducible example though, and my existing code probably wouldn't be much help because it's in an ASP.NET Core MVC app. I was able to fix it by including the [MessagePackObject(true)] decorator above my class, but I didn't think I would have to do that with the contractless resolver. Is the ContractlessStandardResolver supposed to throw this error? |
@SapiensAnatis did you notice my comment #1134 (comment)? What runtime are you on? Anything less than .NET 6 may give you trouble unless you use an |
@AArnott I hadn’t seen that comment, but I’m on 6.0 as this is a new project. I won’t have access to a development environment for a week or so, but I would like to try putting together a minimal example using ASP.NET since a simple console app was unable to reproduce the issue. Will let you know what I find.
|
Hey, I am facing this issue after upgrading to .NET 8 while using the same code as in .NET 7. |
@martinvaner What does your linked issue have to do with failing deserialization due to |
@AArnott Well, on server side I got exception linking me to this issue, therefore I assume the underlying problem might be something similar. On client side (.NET SignalR client) I got HubException described in the linked issue. |
Hi, this problem clearly remains in .NET 8.
|
Ok, from #1137's description:
It sounds like there was some follow-up that perhaps never happened. I'll check it out. |
Check out the fix in 2.5.171 |
Bug description
A generic type containing properties with an
init
accessor fails to serialize.Repro steps
This type fails to serialize with the
DynamicObjectResolver
:This test fails:
Expected behavior
Successful pass.
Actual behavior
The text was updated successfully, but these errors were encountered: