-
Notifications
You must be signed in to change notification settings - Fork 102
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
Reflection and serialization issues between classes with the same number and type of fields #226
Comments
Hi @JDWon, thanks for reporting. Curious if this is related with the "global context" described here? #131 If you define the properties of each State with their own "context" does this issue goes away? e.g.: const type = Context.create(); // this is your @type() decorator bound to a context
class State2 extends Schema {
@type(...) my_prop
} (This limitation will be fixed on colyseus/colyseus#709 with no need to manually create contexts.) |
Hi @endel , thanks for your reply. Unfortunately, even with the solution you provided, this problem occurs in Colyseus Unity sdk (Client schema).
C# code State schema
From what I understand, the HandShake step of ColyseusSchemaSerializer in C# code performs reflection based on the field type, name, and field index. ( At this time, it appears that a class with the same configuration (type, name, index...) is found in the assembly and the typeID is set. (Assets/Colyseus/Runtime/Colyseus/Serializer/Schema/Context.cs => ColyseusContext.GetInstance().SetTypeId(..))
It is expected to read State1 during the reflection stage, but it reads State2 first, causing an unintended operation. This appears to be because State2 is declared first on an assembly basis and has the same field configuration. I wonder if there is a plan to deal with this or if it is placed as a restriction. |
Hi @JDWon, you're right, thanks for the detailed report! This is considered a bug and is intended to be fixed in the next version. On the incoming v3 of schemas we have a |
Thanks for your reply. I will wait next version. Thanks! |
Hi, There is an issue related to Reflection and I would like to report it.
=> ColyseusContext.GetInstance().SetTypeId(schemaType, reflection.types[i].id); schemaType is State2
In the following case, after reflecting the State, I expect the State to be designated as the Type id in the Serialize that occurs during the handshake, but State2 is designated, so I think I need to check.
Is it possible to check whether this is a restriction or whether separate exception handling is required?
The text was updated successfully, but these errors were encountered: