Problem with classes in struct

in Help Center
Is it possible to have class inside struct?
I have slice files like this:
I have factory for instances of PropertyValue both on clien and on server. I have no problems with function getProperty, but when calling getModulesAskingForCreation it has to return some ModuleAskingForCreation with PropertySetting with value set to some instance of PropertyValue, but client receives null even if server returns for example instance of BoolT.
We are using Ice for C#
thank you,
Michal
I have slice files like this:
class PropertyValue { }; interface BoolTInterface { nonmutating bool getBoolValue(); }; class BoolT extends PropertyValue implements BoolTInterface { bool boolValue; }; struct PropertySetting { PropertyValue value; }; sequence<PropertySetting> PropertySettingSeq; struct ModuleAskingForCreation { PropertySettingSeq propertySetting; }; sequence<ModuleAskingForCreation> ModuleAskingForCreationSeq; interface test { nonmutating ModuleAskingForCreationSeq getModulesAskingForCreation(); nonmutating PropertyValue getProperty(string propertyName); };
I have factory for instances of PropertyValue both on clien and on server. I have no problems with function getProperty, but when calling getModulesAskingForCreation it has to return some ModuleAskingForCreation with PropertySetting with value set to some instance of PropertyValue, but client receives null even if server returns for example instance of BoolT.
We are using Ice for C#
thank you,
Michal
0
Comments
Are you sure you have all the object factories installed with the correct type-id?
Matthew
I am adding attachment with compilable complete example.
Thanks,
Michi.
As a work-around in the mean time, can you apply the patch I posted for the "cs:class" metadata problem, and use the class mapping for the struct? This should get you off the hook.
Cheers,
Michi.
Michal
The simplest way for you to work around this bug is to map your structs to classes using the ["cs:class"] metadata attribute, as Michi suggested. If you do this then the class within the slice struct should work.
Will this not work for you for some reason?
- You have a sequence of structures.
- You use the structure mapping (instead of the class mapping) for these structures.
- The structures contain one or more class members.
Otherwise, for structures that are not sequence elements, marshaling works correctly even if the structures contain class members.
The fix is fairly complex, so I can't offer you a patch, but the fix will be included in Ice 3.0.
Cheers,
Michi.