Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow external references and fix closures #174

Merged
merged 4 commits into from
Nov 19, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/Speckle.Sdk/Serialisation/V2/Send/ObjectSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, object?> ret =
new()
Expand All @@ -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:
Expand Down