I have a custom class that is virtually identical to the following:
class X { // add toData/fromData}
class Y(T) : X
{
T Data;
this(T d) { Data = d; }
override void toData(Serializer serializer, Serializer.Data key) inout
{
serializer.serialize(Data, "Data");
return;
}
override void fromData(Serializer serializer, Serializer.Data key)
{
Data = serializer.deserialize!(T)("Data");
return;
}
}
But when I run the code, during deserialization I get the error
Orange\serialization\Serializer.d(1274): Failed to unarchive object of type 'X' with key '0'
The reason I have X and Y is because I can't register Y for every possible type, if I just use Y with no X involved then I get errors about registering Y. Ideally I'd want to use Y!T directly because it would make coding much easier(I won't have to manually figure out the type from X and cast).
I figured that I'd use a base class as a common type and just serialize it. Everything seems to work but the deserialization process seems to fail and I can't figure out why.
The serialized data is:
string
TESTING
Everything looks right except the runtime type:
runtimeType="mX.Y!string.Y"
Seems there is an extra Y appended to the end.
Although remove the .Y in the xml fixes nothing.
If I remove the toData and fromData
"The object of the static type "inout(mX.X)" have a different runtime type (mX.Y!string.Y) and therefore needs to either register its type or register a serializer for its type "mX.Y!string.Y".
I'm not sure if I'm doing something wrong or what. Any ideas what it could be?
I have a custom class that is virtually identical to the following:
class X { // add toData/fromData}
class Y(T) : X
{
T Data;
this(T d) { Data = d; }
}
But when I run the code, during deserialization I get the error
Orange\serialization\Serializer.d(1274): Failed to unarchive object of type 'X' with key '0'
The reason I have X and Y is because I can't register Y for every possible type, if I just use Y with no X involved then I get errors about registering Y. Ideally I'd want to use Y!T directly because it would make coding much easier(I won't have to manually figure out the type from X and cast).
I figured that I'd use a base class as a common type and just serialize it. Everything seems to work but the deserialization process seems to fail and I can't figure out why.
The serialized data is:
string TESTINGEverything looks right except the runtime type:
runtimeType="mX.Y!string.Y"
Seems there is an extra Y appended to the end.
Although remove the .Y in the xml fixes nothing.
If I remove the toData and fromData
"The object of the static type "inout(mX.X)" have a different runtime type (mX.Y!string.Y) and therefore needs to either register its type or register a serializer for its type "mX.Y!string.Y".
I'm not sure if I'm doing something wrong or what. Any ideas what it could be?