From c73fda08dcd163e3e1a16af9834032ca47f5b9cd Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Tue, 19 Nov 2024 13:20:32 +0000 Subject: [PATCH 1/2] allow external references and fix closures --- src/Speckle.Sdk/Serialisation/V2/Send/ObjectSerializer.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Speckle.Sdk/Serialisation/V2/Send/ObjectSerializer.cs b/src/Speckle.Sdk/Serialisation/V2/Send/ObjectSerializer.cs index a98b7c44..2b5f4d24 100644 --- a/src/Speckle.Sdk/Serialisation/V2/Send/ObjectSerializer.cs +++ b/src/Speckle.Sdk/Serialisation/V2/Send/ObjectSerializer.cs @@ -107,6 +107,13 @@ private void SerializeProperty(object? obj, JsonWriter writer, PropertyAttribute ["referencedId"] = r.referencedId, ["__closure"] = r.closure, }; + //references can be externally provided and need to know the ids in the closure and reference here + //AddClosure can take the same value twice + foreach (var kvp in r.closure.Empty()) + { + AddClosure(kvp.Key); + } + AddClosure(r.referencedId); SerializeProperty(ret, writer); break; case Base b: From 66a5109b28e90777e0b8dd81ab68104c7c925305 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Tue, 19 Nov 2024 13:43:54 +0000 Subject: [PATCH 2/2] fix comment --- src/Speckle.Sdk/Serialisation/V2/Send/ObjectSerializer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Speckle.Sdk/Serialisation/V2/Send/ObjectSerializer.cs b/src/Speckle.Sdk/Serialisation/V2/Send/ObjectSerializer.cs index 2b5f4d24..cd1b28c8 100644 --- a/src/Speckle.Sdk/Serialisation/V2/Send/ObjectSerializer.cs +++ b/src/Speckle.Sdk/Serialisation/V2/Send/ObjectSerializer.cs @@ -98,7 +98,7 @@ private void SerializeProperty(object? obj, JsonWriter writer, PropertyAttribute { // Start with object references so they're not captured by the Base class case below // Note: this change was needed as we've made the ObjectReference type inherit from Base for - // the purpose of the "do not convert unchanged previously converted objects" POC. + // the purpose of the send object (connector/conversion level) caching. case ObjectReference r: Dictionary ret = new()