Merge pull request #305 from specklesystems/dev
.NET Build and Publish / build (push) Has been cancelled
.NET Build and Publish / build (push) Has been cancelled
Dev to Main
This commit is contained in:
@@ -69,6 +69,10 @@ public sealed class SerializeProcess(
|
||||
NodeInfo
|
||||
>();
|
||||
|
||||
private readonly Pool<List<Task<Dictionary<Id, NodeInfo>>>> _taskResultPool = Pools.CreateListPool<
|
||||
Task<Dictionary<Id, NodeInfo>>
|
||||
>();
|
||||
|
||||
private long _objectCount;
|
||||
private long _objectsFound;
|
||||
|
||||
@@ -163,7 +167,7 @@ public sealed class SerializeProcess(
|
||||
|
||||
try
|
||||
{
|
||||
var tasks = new List<Task<Dictionary<Id, NodeInfo>>>();
|
||||
var tasks = _taskResultPool.Get();
|
||||
foreach (var child in baseChildFinder.GetChildren(obj))
|
||||
{
|
||||
// tmp is necessary because of the way closures close over loop variables
|
||||
@@ -190,30 +194,27 @@ public sealed class SerializeProcess(
|
||||
return EMPTY_CLOSURES;
|
||||
}
|
||||
|
||||
List<Dictionary<Id, NodeInfo>> taskClosures = new();
|
||||
Dictionary<Id, NodeInfo>[] taskClosures = [];
|
||||
if (tasks.Count > 0)
|
||||
{
|
||||
var currentTasks = tasks.ToList();
|
||||
do
|
||||
//get child results
|
||||
var childTask = Task.WhenAll(tasks);
|
||||
await Task.WhenAny(childTask, Task.Delay(Timeout.InfiniteTimeSpan, _processSource.Token)).ConfigureAwait(false);
|
||||
if (childTask.IsFaulted)
|
||||
{
|
||||
//grab when any Task is done and see if we're cancelling
|
||||
var t = await Task.WhenAny(currentTasks).ConfigureAwait(false);
|
||||
if (t.IsCanceled)
|
||||
if (childTask.Exception is not null)
|
||||
{
|
||||
return EMPTY_CLOSURES;
|
||||
RecordException(childTask.Exception);
|
||||
}
|
||||
if (t.IsFaulted)
|
||||
{
|
||||
if (t.Exception is not null)
|
||||
{
|
||||
RecordException(t.Exception);
|
||||
}
|
||||
return EMPTY_CLOSURES;
|
||||
}
|
||||
taskClosures.Add(t.Result);
|
||||
currentTasks.Remove(t);
|
||||
} while (currentTasks.Count > 0);
|
||||
return EMPTY_CLOSURES;
|
||||
}
|
||||
if (!childTask.IsCompleted)
|
||||
{
|
||||
return EMPTY_CLOSURES;
|
||||
}
|
||||
taskClosures = childTask.Result;
|
||||
}
|
||||
_taskResultPool.Return(tasks);
|
||||
|
||||
if (_processSource.Token.IsCancellationRequested)
|
||||
{
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"applicationId": null,
|
||||
"displayValue": null,
|
||||
"id": "15168a13ce3f336dee9aa1807cbf375c",
|
||||
"name": null,
|
||||
"properties": null,
|
||||
"speckle_type": "Objects.Data.DataObject:Objects.Data.ArcgisObject",
|
||||
"type": null,
|
||||
"units": null
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"applicationId": null,
|
||||
"displayValue": null,
|
||||
"elements": null,
|
||||
"id": "bf80e8a10eca2264f11c39bae42538da",
|
||||
"level": null,
|
||||
"name": null,
|
||||
"properties": null,
|
||||
"speckle_type": "Objects.Data.DataObject:Objects.Data.ArchicadObject",
|
||||
"type": null
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"applicationId": null,
|
||||
"baseCurves": null,
|
||||
"displayValue": null,
|
||||
"elements": null,
|
||||
"id": "76b7634117981a9fb9d3cffca5464f26",
|
||||
"name": null,
|
||||
"properties": null,
|
||||
"speckle_type": "Objects.Data.DataObject:Objects.Data.Civil3dObject",
|
||||
"type": null,
|
||||
"units": null
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"applicationId": null,
|
||||
"displayValue": null,
|
||||
"id": "a1567a1cf10417294c93b70bf5ca97c1",
|
||||
"name": null,
|
||||
"properties": null,
|
||||
"speckle_type": "Objects.Data.DataObject"
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"applicationId": null,
|
||||
"displayValue": null,
|
||||
"elements": null,
|
||||
"id": "39d4deaa7cd20e7004812304f41a68d5",
|
||||
"name": null,
|
||||
"properties": null,
|
||||
"speckle_type": "Objects.Data.DataObject:Objects.Data.EtabsObject",
|
||||
"type": null,
|
||||
"units": null
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"applicationId": null,
|
||||
"displayValue": null,
|
||||
"id": "fbda4ea7bb1b3722ca28e97573742a4e",
|
||||
"name": null,
|
||||
"properties": null,
|
||||
"speckle_type": "Objects.Data.DataObject:Objects.Data.NavisworksObject",
|
||||
"units": null
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"applicationId": null,
|
||||
"category": null,
|
||||
"displayValue": null,
|
||||
"elements": null,
|
||||
"family": null,
|
||||
"id": "7e285508a71c55589bbc053451f687d2",
|
||||
"level": null,
|
||||
"location": null,
|
||||
"name": null,
|
||||
"properties": null,
|
||||
"speckle_type": "Objects.Data.DataObject:Objects.Data.RevitObject",
|
||||
"type": null,
|
||||
"units": null
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"applicationId": null,
|
||||
"displayValue": null,
|
||||
"elements": null,
|
||||
"id": "c07f15678d8b4a48a7ecab9eb30e69a8",
|
||||
"name": null,
|
||||
"properties": null,
|
||||
"speckle_type": "Objects.Data.DataObject:Objects.Data.TeklaObject",
|
||||
"type": null,
|
||||
"units": null
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using System.Collections.Concurrent;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Speckle.Objects.Data;
|
||||
using Speckle.Objects.Geometry;
|
||||
using Speckle.Sdk.Models;
|
||||
using Speckle.Sdk.Serialisation;
|
||||
using Speckle.Sdk.Serialisation.V2;
|
||||
using Speckle.Sdk.Serialisation.V2.Send;
|
||||
|
||||
namespace Speckle.Sdk.Serialization.Tests;
|
||||
|
||||
public class DataObjectTests
|
||||
{
|
||||
private readonly ISerializeProcessFactory _factory;
|
||||
|
||||
public DataObjectTests()
|
||||
{
|
||||
var serviceCollection = new ServiceCollection();
|
||||
serviceCollection.AddSpeckleSdk(new("Tests", "test"), "v3", typeof(TestClass).Assembly, typeof(Polyline).Assembly);
|
||||
var serviceProvider = serviceCollection.BuildServiceProvider();
|
||||
|
||||
_factory = serviceProvider.GetRequiredService<ISerializeProcessFactory>();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(typeof(ArcgisObject))]
|
||||
[InlineData(typeof(ArchicadObject))]
|
||||
[InlineData(typeof(Civil3dObject))]
|
||||
[InlineData(typeof(DataObject))]
|
||||
[InlineData(typeof(EtabsObject))]
|
||||
[InlineData(typeof(NavisworksObject))]
|
||||
[InlineData(typeof(RevitObject))]
|
||||
[InlineData(typeof(TeklaObject))]
|
||||
public async Task ValidateDataObject(Type type)
|
||||
{
|
||||
Base x = (Base)(Activator.CreateInstance(type) ?? throw new Exception("Could not create instance of " + type.Name));
|
||||
|
||||
var json = new ConcurrentDictionary<Id, Json>();
|
||||
await using var serializeProcess = _factory.CreateSerializeProcess(
|
||||
new MemoryJsonCacheManager(json),
|
||||
new DummyServerObjectManager(),
|
||||
null,
|
||||
default,
|
||||
new SerializeProcessOptions(true, true, false, true)
|
||||
);
|
||||
await serializeProcess.Serialize(x);
|
||||
await VerifyJson(json.Single().Value.Value).UseParameters(type);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user