diff --git a/Directory.Packages.props b/Directory.Packages.props
index 09f082e2..6d1dd95c 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -8,6 +8,7 @@
+
@@ -26,7 +27,6 @@
-
diff --git a/src/Speckle.Objects/packages.lock.json b/src/Speckle.Objects/packages.lock.json
index 601bfa28..a9e35e79 100644
--- a/src/Speckle.Objects/packages.lock.json
+++ b/src/Speckle.Objects/packages.lock.json
@@ -222,6 +222,14 @@
"System.Runtime": "4.3.0"
}
},
+ "System.Threading.Tasks.Extensions": {
+ "type": "Transitive",
+ "resolved": "4.5.4",
+ "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==",
+ "dependencies": {
+ "System.Runtime.CompilerServices.Unsafe": "4.5.3"
+ }
+ },
"speckle.sdk": {
"type": "Project",
"dependencies": {
@@ -230,13 +238,13 @@
"Microsoft.Data.Sqlite": "[7.0.7, )",
"Microsoft.Extensions.DependencyInjection.Abstractions": "[2.2.0, )",
"Microsoft.Extensions.Logging": "[2.2.0, )",
+ "Microsoft.Extensions.ObjectPool": "[8.0.8, )",
"Microsoft.IO.RecyclableMemoryStream": "[3.0.1, )",
"Polly": "[7.2.3, )",
"Polly.Contrib.WaitAndRetry": "[1.1.1, )",
"Polly.Extensions.Http": "[3.0.0, )",
"Speckle.DoubleNumerics": "[4.0.1, )",
- "Speckle.Newtonsoft.Json": "[13.0.2, )",
- "System.Threading.Tasks.Extensions": "[4.5.4, )"
+ "Speckle.Newtonsoft.Json": "[13.0.2, )"
}
},
"GraphQL.Client": {
@@ -284,6 +292,12 @@
"Microsoft.Extensions.Options": "2.2.0"
}
},
+ "Microsoft.Extensions.ObjectPool": {
+ "type": "CentralTransitive",
+ "requested": "[8.0.8, )",
+ "resolved": "8.0.8",
+ "contentHash": "wnjTFjEvvSbOs3iMfl6CeJcUgPHZMYUB9uAQbGQGxGwVRl4GydNpMSkVntTzoi7AqQeYumU9yDSNeVbpq+ebow=="
+ },
"Microsoft.IO.RecyclableMemoryStream": {
"type": "CentralTransitive",
"requested": "[3.0.1, )",
@@ -325,15 +339,6 @@
"requested": "[13.0.2, )",
"resolved": "13.0.2",
"contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA=="
- },
- "System.Threading.Tasks.Extensions": {
- "type": "CentralTransitive",
- "requested": "[4.5.4, )",
- "resolved": "4.5.4",
- "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==",
- "dependencies": {
- "System.Runtime.CompilerServices.Unsafe": "4.5.3"
- }
}
},
"net8.0": {
@@ -510,13 +515,13 @@
"Microsoft.Data.Sqlite": "[7.0.7, )",
"Microsoft.Extensions.DependencyInjection.Abstractions": "[2.2.0, )",
"Microsoft.Extensions.Logging": "[2.2.0, )",
+ "Microsoft.Extensions.ObjectPool": "[8.0.8, )",
"Microsoft.IO.RecyclableMemoryStream": "[3.0.1, )",
"Polly": "[7.2.3, )",
"Polly.Contrib.WaitAndRetry": "[1.1.1, )",
"Polly.Extensions.Http": "[3.0.0, )",
"Speckle.DoubleNumerics": "[4.0.1, )",
- "Speckle.Newtonsoft.Json": "[13.0.2, )",
- "System.Threading.Tasks.Extensions": "[4.5.4, )"
+ "Speckle.Newtonsoft.Json": "[13.0.2, )"
}
},
"GraphQL.Client": {
@@ -564,6 +569,12 @@
"Microsoft.Extensions.Options": "2.2.0"
}
},
+ "Microsoft.Extensions.ObjectPool": {
+ "type": "CentralTransitive",
+ "requested": "[8.0.8, )",
+ "resolved": "8.0.8",
+ "contentHash": "wnjTFjEvvSbOs3iMfl6CeJcUgPHZMYUB9uAQbGQGxGwVRl4GydNpMSkVntTzoi7AqQeYumU9yDSNeVbpq+ebow=="
+ },
"Microsoft.IO.RecyclableMemoryStream": {
"type": "CentralTransitive",
"requested": "[3.0.1, )",
@@ -602,12 +613,6 @@
"requested": "[13.0.2, )",
"resolved": "13.0.2",
"contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA=="
- },
- "System.Threading.Tasks.Extensions": {
- "type": "CentralTransitive",
- "requested": "[4.5.4, )",
- "resolved": "4.5.4",
- "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg=="
}
}
}
diff --git a/src/Speckle.Sdk/Helpers/SpeckleObjectSerializer2Pool.cs b/src/Speckle.Sdk/Helpers/SpeckleObjectSerializer2Pool.cs
index 449e70ff..1d16213d 100644
--- a/src/Speckle.Sdk/Helpers/SpeckleObjectSerializer2Pool.cs
+++ b/src/Speckle.Sdk/Helpers/SpeckleObjectSerializer2Pool.cs
@@ -1,4 +1,5 @@
using System.Buffers;
+using Microsoft.Extensions.ObjectPool;
using Microsoft.IO;
using Speckle.Newtonsoft.Json;
using Speckle.Sdk.Common;
@@ -38,4 +39,19 @@ private class SerializerPool(ArrayPool pool) : IArrayPool
public void Return(T[]? array) => pool.Return(array.NotNull());
}
+
+
+ public ObjectPool>
+ DictPool { get; }= new DefaultObjectPoolProvider().Create(new DictPoolPolicy());
+
+ private class DictPoolPolicy : PooledObjectPolicy>
+ {
+ public override Dictionary Create() => new Dictionary(StringComparer.OrdinalIgnoreCase);
+
+ public override bool Return(Dictionary obj)
+ {
+ obj.Clear();
+ return true;
+ }
+ }
}
diff --git a/src/Speckle.Sdk/Serialisation/SpeckleObjectDeserializer2.cs b/src/Speckle.Sdk/Serialisation/SpeckleObjectDeserializer2.cs
new file mode 100644
index 00000000..03dec3c0
--- /dev/null
+++ b/src/Speckle.Sdk/Serialisation/SpeckleObjectDeserializer2.cs
@@ -0,0 +1,352 @@
+using System.Collections.Concurrent;
+using System.Numerics;
+using System.Reflection;
+using Speckle.Newtonsoft.Json;
+using Speckle.Sdk.Common;
+using Speckle.Sdk.Helpers;
+using Speckle.Sdk.Host;
+using Speckle.Sdk.Models;
+using Speckle.Sdk.Serialisation.Utilities;
+using Speckle.Sdk.Transports;
+
+namespace Speckle.Sdk.Serialisation;
+
+public sealed class SpeckleObjectDeserializer2
+{
+ public SpeckleObjectSerializer2Pool Pool { get; } = SpeckleObjectSerializer2Pool.Instance;
+ private bool _isBusy;
+ private readonly object _callbackLock = new();
+ private readonly object?[] _invokeNull = [null];
+
+ // id -> Base if already deserialized or id -> Task