Serializing custom objects with BaseObjectSerializerv2

Hello everyone,

We were storing a custom object type in one of our streams as below:

 ServerTransport sendTransport = new ServerTransport(speckleGraphClient.Account, streamId);

 Base baseObject = new Base();

 baseObject["data"] = ekkodaleObjects //List<EkkodaleObject>;
         
 string objectId = await Operations.Send(baseObject, new List<ITransport>() { sendTransport});

We were also able to expand the collection and see the nested structure as well in speckle frontend. We have updated our images and we got exception in the following method line 154:

BaseObjectSerializerV2.cs > PreserializeObject(object obj, bool computeClosures = false, DetachInfo inheritedDetachInfo = default(DetachInfo))

That’s why we have inherited our object and child objects from Base to solve the issue. However,we get now an external exception which is thrown in the SpeckleCore2 assembly during Send operation and can’t see the stack trace.

How it looks like before:

Is there a way to send custom types as property of the commit root object as before?

Hey Baris,

That shouldn’t be the case, especially if you’re inheriting from Base…

What version/commit of SpeckleCore2 are you using?
Can you share some code with are reproducible example?
Are you able to debug and get the exception being thrown?

1 Like

Hey Matteo,

I am using Speckle.Core 2.2.25 nuget package. I have replaced the nuget package by project reference now and found the problem:

However, we are sending same simple Autodesk architecture model as before. We have just inherited 1 parent and 2 child object from Base class.

Hi @Baris, just put an “@” in front of “data”. So basically:

baseObject["@data"] = ekkodaleObjects;

This will tell the serialiser to detach the objects from the base, and that error should go away. There’s more info on this here:

https://speckle.guide/dev/decomposition.html#dynamic-detachment

3 Likes

Hi @dimitrie,

Works like a charm.

Thank you very much for your support!

1 Like