mirror of
https://github.com/quasar/Quasar.git
synced 2026-04-25 15:25:59 +03:00
[GH-ISSUE #1096] ProtoBuf Deserialization #797
Labels
No labels
bug
bug
cant-reproduce
discussion
duplicate
easy
enhancement
help wanted
improvement
invalid
need more info
pull-request
question
wont-add
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/Quasar#797
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Senc3951 on GitHub (Sep 1, 2022).
Original GitHub issue: https://github.com/quasar/Quasar/issues/1096
Hi, I tried making a project based on this rat, but according to ProtoBuf documentation, in order to deserialize parent object to a child one, eg. IMessage to ClientIdentification, IMessage must contain an attribute saying [ProtoInclude... child object] which in this project wasn't done, but somehow it still works, but when I tried deserializing IMessage to a child without this attribute, it didn't work. Only when I included the attribute, it worked.
@MaxXor commented on GitHub (Sep 1, 2022):
Please check the code:
github.com/quasar/Quasar@16a4702d0e/Quasar.Common/Networking/PayloadReader.cs (L45-L54)@Senc3951 commented on GitHub (Sep 1, 2022):
The problem is not deserializing to IMessage, but converting from iMessage to the wanted class
@MaxXor commented on GitHub (Sep 1, 2022):
This is shown here:
github.com/quasar/Quasar@16a4702d0e/Quasar.Client/Networking/QuasarClient.cs (L99-L112)@Senc3951 commented on GitHub (Sep 1, 2022):
I probably didn't explain myself well, This project depends heavily on the ability to convert from IMessage to any class that inherits from it. This conversion should only work when adding the ProtoInclude attribute, to inform ProtoBuf that IMessage may actually be a child class, but this project doesn't include this attribute and somehow the conversion still works.
You can find an example here: https://stackoverflow.com/questions/12988964/how-to-serialize-inherited-class-with-protobuf-net (this is about serializing, but it's same as deserializing)
@MaxXor commented on GitHub (Sep 1, 2022):
Can you test using the same Protobuf version used in this project? Maybe it only works with the rather "outdated" version here.
@Senc3951 commented on GitHub (Sep 1, 2022):
From some reason it still doesn't work, here is my serialization, deserialization code
I went around the problem by including a bunch of ProtoInclude's, but I thought that maybe you had a different solution