Merge pull request #40 from specklesystems/claire/collections-refactor

refactor(Collections): changes namespace of collections and adds interfaces
This commit is contained in:
Claire Kuang
2024-07-17 15:09:11 +01:00
committed by GitHub
11 changed files with 30 additions and 13 deletions
@@ -1,6 +1,6 @@
using System.Collections.Generic;
namespace Speckle.Core.Models;
namespace Speckle.Core.Models.Collections;
/// <summary>
/// A simple container for organising objects within a model and preserving object hierarchy.
@@ -0,0 +1,12 @@
namespace Speckle.Core.Models.Collections;
/// <summary>
/// Represents a collection that has a <see cref="IHasColor.color"/>
/// </summary>
public interface IHasColor
{
/// <summary>
/// The argb int value of the collection color
/// </summary>
public int color { get; set; }
}
@@ -1,9 +1,9 @@
namespace Speckle.Core.Models;
namespace Speckle.Core.Models.Collections;
/// <summary>
/// A specialized collection that represents a CAD-app layer. We expect this to grow in the future with possibly other shared props.
/// </summary>
public class Layer : Collection
public class Layer : Collection, IHasColor
{
public Layer() { }
@@ -3,6 +3,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Speckle.Core.Logging;
using Speckle.Core.Models.Collections;
using Speckle.Core.Models.Extensions;
namespace Speckle.Core.Models;
@@ -2,6 +2,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Speckle.Core.Models.Collections;
namespace Speckle.Core.Models.Extensions;
+5 -5
View File
@@ -13,15 +13,15 @@
</PropertyGroup>
<ItemGroup>
<InternalsVisibleTo Include="Speckle.Core.Tests.Unit"/>
<InternalsVisibleTo Include="Speckle.Core.Tests.Integration"/>
<InternalsVisibleTo Include="Speckle.Core.Serialization.Tests"/>
<InternalsVisibleTo Include="Speckle.Core.Tests.Unit" />
<InternalsVisibleTo Include="Speckle.Core.Tests.Integration" />
<InternalsVisibleTo Include="Speckle.Core.Serialization.Tests" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="GraphQL.Client" />
<PackageReference Include="Microsoft.CSharp" />
<PackageReference Include="Polly"/>
<PackageReference Include="Polly" />
<PackageReference Include="Polly.Contrib.WaitAndRetry" />
<PackageReference Include="Polly.Extensions.Http" />
<PackageReference Include="Sentry" />
@@ -32,7 +32,7 @@
<PackageReference Include="Serilog.Sinks.Console" />
<PackageReference Include="Serilog.Sinks.Seq" />
<PackageReference Include="SerilogTimings" />
<PackageReference Include="Speckle.Newtonsoft.Json"/>
<PackageReference Include="Speckle.Newtonsoft.Json" />
<PackageReference Include="Microsoft.Data.Sqlite" />
<PackageReference Include="Speckle.DoubleNumerics" />
</ItemGroup>
+1 -1
View File
@@ -1,5 +1,5 @@
using System.Collections.Generic;
using Speckle.Core.Models;
using Speckle.Core.Models.Collections;
namespace Objects.GIS;
+1
View File
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Speckle.Core.Models;
using Speckle.Core.Models.Collections;
namespace Objects.GIS;
@@ -2,8 +2,8 @@ using System;
namespace Objects.Organization.Deprecated;
[Obsolete("Replaced by " + nameof(Speckle.Core.Models.Collection))]
public class Collection : Speckle.Core.Models.Collection
[Obsolete("Replaced by " + nameof(Speckle.Core.Models.Collections.Collection))]
public class Collection : Speckle.Core.Models.Collections.Collection
{
//Deserializer target for 2.13 Collection objects in the `Objects.Orgainzation` namespace
@@ -1,5 +1,6 @@
using NUnit.Framework;
using Speckle.Core.Models;
using Speckle.Core.Models.Collections;
using Speckle.Core.Models.Extensions;
namespace Speckle.Core.Tests.Unit.Models.Extensions;
@@ -43,11 +44,11 @@ public class BaseExtensionsTests
var basePaths = collection.TraverseWithPath((obj => obj is not Collection)).ToList();
Assert.That(basePaths.Count, Is.EqualTo(3));
Assert.That(basePaths[0].Item2.speckle_type, Is.EqualTo("Speckle.Core.Models.Collection"));
Assert.That(basePaths[0].Item2.speckle_type, Is.EqualTo("Speckle.Core.Models.Collections.Collection"));
Assert.That(basePaths[0].Item2["name"], Is.EqualTo("collection"));
Assert.That(basePaths[0].Item1, Is.EqualTo(new List<string>()));
Assert.That(basePaths[1].Item2.speckle_type, Is.EqualTo("Speckle.Core.Models.Collection"));
Assert.That(basePaths[1].Item2.speckle_type, Is.EqualTo("Speckle.Core.Models.Collections.Collection"));
Assert.That(basePaths[1].Item2["name"], Is.EqualTo("subCollection"));
Assert.That(basePaths[1].Item1, Is.EqualTo(new List<string>() { "collection" }));
@@ -1,6 +1,7 @@
using NUnit.Framework;
using Speckle.Core.Common;
using Speckle.Core.Models;
using Speckle.Core.Models.Collections;
using Speckle.Core.Models.GraphTraversal;
namespace Speckle.Core.Tests.Unit.Models.GraphTraversal;