slice2cs: struct/class unmarshalling problem

in Bug Reports
I have a struct defined in Slice that is mapped to a class in C#, but I get a null-reference exception on unmarshalling. Here is the Slice:
Now, debugging it, I can see that exception happens in the unmarshalling code for ActionPermission:
When it is called, Action_prop is null, leading to the exception.
Karl
["clr:property"] struct Action { string Key; string Description; }; ["clr:property"] struct ActionPermission { ::IServices2ICE::Action Action; bool IsAuthorized; }; sequence<ActionPermission> ActionPermissionSeq; ["ami", "amd"] interface ClassifiedServices { . . . idempotent OpStatus GetClientPermissions( string clientGroupKey, string orderStatus, out ActionPermissionSeq permissions ) throws ServiceError; };
Now, debugging it, I can see that exception happens in the unmarshalling code for ActionPermission:
public void read__(IceInternal.BasicStream is__) { Action_prop.read__(is__); IsAuthorized_prop = is__.readBool(); }
When it is called, Action_prop is null, leading to the exception.
Karl
0
Comments
It seems the marshalling code has the same problem:
It looks as if the code was generated assuming that Action was mapped to a struct instead of a class.
Karl
I'm looking at your problem. Unfortunately, the fix isn't entirely trivial (and I was away on vacation all last week), which is why this is taking so long. I'll have a patch for you by tomorrow.
Cheers,
Michi.
Thanks, that is OK, we are still in development, and there is a simple workaround.
And even you are entitled to some vacation.
Karl
Cheers,
Michi.
There is now another issue with the generated code (in another part of my Slice) that does not allow it to compile. The problem is when a struct is mapped to a C# struct. The generated code does not initialize the struct when reading it from the stream. Here is the code generated - the function is the one called by IceInternal.DispatchStatus dispatch__(). I hope this is sufficient detail for you:
The type IServices2ICE.Date is a struct, and it should be initialized by calling the default struct constructor, see the comment in the code.
Because of the compile issue I haven't tested your patch yet, although the generated code looks OK for it.
Karl
my apologies--I missed two spots in the code generator that were affected by the changes.
I've updated the patch. Could you try again please?
Thanks,
Michi.
Good news - it works now.
Thanks,
Karl