Skip to content

Commit

Permalink
Merge pull request #40 from specklesystems/claire/collections-refactor
Browse files Browse the repository at this point in the history
refactor(Collections): changes namespace of collections and adds interfaces
  • Loading branch information
clairekuang authored Jul 17, 2024
2 parents 580521f + a16bc4e commit 5f83798
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
12 changes: 12 additions & 0 deletions src/Speckle.Core/Models/Collections/Interfaces.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
Original file line number Diff line number Diff line change
@@ -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() { }

Expand Down
1 change: 1 addition & 0 deletions src/Speckle.Core/Models/CommitObjectBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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;
Expand Down
1 change: 1 addition & 0 deletions src/Speckle.Core/Models/Extensions/BaseExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Speckle.Core.Models.Collections;

namespace Speckle.Core.Models.Extensions;

Expand Down
10 changes: 5 additions & 5 deletions src/Speckle.Core/Speckle.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand All @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion src/Speckle.Objects/GIS/RasterLayer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Collections.Generic;
using Speckle.Core.Models;
using Speckle.Core.Models.Collections;

namespace Objects.GIS;

Expand Down
1 change: 1 addition & 0 deletions src/Speckle.Objects/GIS/VectorLayer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Speckle.Core.Models;
using Speckle.Core.Models.Collections;

namespace Objects.GIS;

Expand Down
4 changes: 2 additions & 2 deletions src/Speckle.Objects/Organization/Deprecated/Collection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

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

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -43,11 +44,11 @@ public void TraverseWithPath()
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" }));

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 5f83798

Please sign in to comment.