Skip to content

Commit

Permalink
Merge branch 'dev' into gis_objects_cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
JR-Morgan authored Jan 10, 2025
2 parents 106f073 + 14d9598 commit 40a11ef
Show file tree
Hide file tree
Showing 137 changed files with 4,139 additions and 2,631 deletions.
2 changes: 0 additions & 2 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<Project>
<PropertyGroup Condition="'$(IsTestProject)' == 'true'">
<AnalysisMode>Recommended</AnalysisMode>
<NoWarn>
$(NoWarn);
<!-- Things we need to test -->
Expand All @@ -9,7 +8,6 @@
<!-- Analysers that provide no tangeable value to a test project -->
CA5394;CA2007;CA1852;CA1819;CA1711;CA1063;CA1816;CA2234;CS8618;CA1054;CA1810;CA2208;CA1019;CA1831;
</NoWarn>
<EnforceCodeStyleInBuild>false</EnforceCodeStyleInBuild>
</PropertyGroup>

<Target Name="DeepClean">
Expand Down
22 changes: 10 additions & 12 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
<Project>
<ItemGroup>
<PackageVersion Include="altcover" Version="8.9.3" />
<PackageVersion Include="altcover" Version="9.0.1" />
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
<PackageVersion Include="Bullseye" Version="5.0.0" />
<PackageVersion Include="FluentAssertions" Version="7.0.0" />
<PackageVersion Include="GraphQL.Client" Version="6.0.0" />
<PackageVersion Include="Glob" Version="1.1.9" />
<PackageVersion Include="ILRepack.FullAuto" Version="1.6.0" />
<PackageVersion Include="Microsoft.CSharp" Version="4.7.0" />
<!-- Keep at exactly 7.0.5 for side by side with V2 -->
<PackageVersion Include="Microsoft.Data.Sqlite" Version="7.0.5" />
<PackageVersion Include="Microsoft.Extensions.ObjectPool" Version="8.0.10" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="Microsoft.Extensions.ObjectPool" Version="9.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.2.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="2.2.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="2.2.0" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="5.0.0" />
<PackageVersion Include="Moq" Version="4.20.70" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageVersion Include="NUnit" Version="4.2.2" />
<PackageVersion Include="NUnit.Analyzers" Version="4.2.0" />
<PackageVersion Include="Open.ChannelExtensions" Version="8.5.0" />
<PackageVersion Include="Open.ChannelExtensions" Version="9.0.0" />
<PackageVersion Include="Polly" Version="7.2.3" />
<PackageVersion Include="Polly.Contrib.WaitAndRetry" Version="1.1.1" />
<PackageVersion Include="Polly.Extensions.Http" Version="3.0.0" />
<PackageVersion Include="Shouldly" Version="4.2.1" />
<PackageVersion Include="Speckle.Newtonsoft.Json" Version="13.0.2" />
<PackageVersion Include="Speckle.DoubleNumerics" Version="4.0.1" />
<PackageVersion Include="SimpleExec" Version="12.0.0" />
<PackageVersion Include="Speckle.Objects" Version="3.1.0-dev.109" />
<PackageVersion Include="System.Threading.Channels" Version="8.0.0" />
<GlobalPackageReference Include="PolySharp" Version="1.14.1" />
<PackageVersion Include="System.Threading.Channels" Version="9.0.0" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.0" />
<GlobalPackageReference Include="PolySharp" Version="1.15.0" />
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<GlobalPackageReference Include="GitVersion.MsBuild" Version="5.12.0" />
<GlobalPackageReference Include="Speckle.InterfaceGenerator" Version="0.9.6" />
Expand Down
20 changes: 8 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
<h1 align="center">
<img src="https://user-images.githubusercontent.com/2679513/131189167-18ea5fe1-c578-47f6-9785-3748178e4312.png" width="150px"/><br/>
Speckle | Sharp | SDK
</h1>
![Speckle Box](/logo.png)
Speckle | Sharp | SDK
=================================================================================================================================

<p align="center"><a href="https://twitter.com/SpeckleSystems"><img src="https://img.shields.io/twitter/follow/SpeckleSystems?style=social" alt="Twitter Follow"></a> <a href="https://speckle.community"><img src="https://img.shields.io/discourse/users?server=https%3A%2F%2Fspeckle.community&amp;style=flat-square&amp;logo=discourse&amp;logoColor=white" alt="Community forum users"></a> <a href="https://speckle.systems"><img src="https://img.shields.io/badge/https://-speckle.systems-royalblue?style=flat-square" alt="website"></a> <a href="https://speckle.guide/dev/"><img src="https://img.shields.io/badge/docs-speckle.guide-orange?style=flat-square&amp;logo=read-the-docs&amp;logoColor=white" alt="docs"></a></p>
[![Twitter Follow](https://img.shields.io/twitter/follow/SpeckleSystems?style=social)](https://twitter.com/SpeckleSystems) [![Community forum users](https://img.shields.io/discourse/users?server=https%3A%2F%2Fspeckle.community&style=flat-square&logo=discourse&logoColor=white)](https://speckle.community) [![website](https://img.shields.io/badge/https://-speckle.systems-royalblue?style=flat-square)](https://speckle.systems) [![docs](https://img.shields.io/badge/docs-speckle.guide-orange?style=flat-square&logo=read-the-docs&logoColor=white)](https://speckle.guide/dev/)

> Speckle is the first AEC data hub that connects with your favorite AEC tools. Speckle exists to overcome the challenges of working in a fragmented industry where communication, creative workflows, and the exchange of data are often hindered by siloed software and processes. It is here to make the industry better.
> Speckle is the first AEC data hub that connects with your favorite AEC tools. Speckle exists to overcome the challenges of working in a fragmented industry where communication, creative workflows, and the exchange of data are often hindered by siloed software and processes. It is here to make the industry better.
<h3 align="center">
.NET SDK, Tests, and Objects
</h3>
### .NET SDK, Tests, and Objects

<p align="center"><a href="https://codecov.io/gh/specklesystems/speckle-sharp-sdk"><img src="https://codecov.io/gh/specklesystems/speckle-sharp-sdk/graph/badge.svg?token=TTM5OGr38m" alt="Codecov"></a></p>

<br/>
[![Codecov](https://codecov.io/gh/specklesystems/speckle-sharp-sdk/graph/badge.svg?token=TTM5OGr38m)](https://codecov.io/gh/specklesystems/speckle-sharp-sdk)

> [!WARNING]
> This is an early beta release, not meant for use in production! We're working to stabilise the 3.0 API, and until then there will be breaking changes. You have been warned!
Expand All @@ -24,6 +19,7 @@ This repo is the home of our next-generation Speckle .NET SDK. It uses .NET Stan

- **SDK**
- [`Speckle.Sdk`](https://github.com/specklesystems/speckle-sharp-sdk/tree/dev/src/Speckle.Sdk): Transports, serialization, API wrappers, and logging.
- [`Speckle.Sdk.Dependencies`](https://github.com/specklesystems/speckle-sharp-sdk/tree/dev/src/Speckle.Sdk.Dependencies): Dependencies and code that shouldn't cause conflicts in Host Apps. This uses [IL Repack](https://github.com/gluck/il-repack) to merge together and interalized only to be used by Speckle.
- **Speckle Objects**
- [`Speckle.Objects`](https://github.com/specklesystems/speckle-sharp-sdk/tree/dev/src/Speckle.Objects): The Speckle Objects classes used for conversions.
- **Tests**
Expand Down
6 changes: 3 additions & 3 deletions build/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
},
"PolySharp": {
"type": "Direct",
"requested": "[1.14.1, )",
"resolved": "1.14.1",
"contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ=="
"requested": "[1.15.0, )",
"resolved": "1.15.0",
"contentHash": "FbU0El+EEjdpuIX4iDbeS7ki1uzpJPx8vbqOzEtqnl1GZeAGJfq+jCbxeJL2y0EPnUNk8dRnnqR2xnYXg9Tf+g=="
},
"SimpleExec": {
"type": "Direct",
Expand Down
Binary file modified logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 1 addition & 7 deletions src/Speckle.Objects/Data/ArcgisObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,10 @@ namespace Speckle.Objects.Data;
/// Represents a ArcGIS.Core.CoreObjectsBase object in ArcGIS
/// </summary>
[SpeckleType("Objects.Data.ArcgisObject")]
public class ArcgisObject : Base, IGisObject
public class ArcgisObject : DataObject, IGisObject
{
public required string name { get; set; }
public required string type { get; set; }

[DetachProperty]
public required List<Base> displayValue { get; set; }

public required Dictionary<string, object?> properties { get; set; }

public required string units { get; set; }

IReadOnlyList<Base> IDisplayValue<IReadOnlyList<Base>>.displayValue => displayValue;
Expand Down
10 changes: 1 addition & 9 deletions src/Speckle.Objects/Data/Civil3dObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ namespace Speckle.Objects.Data;
/// Represents an Autodesk.Civil.DatabaseServices.Entity object in Civil3d
/// </summary>
[SpeckleType("Objects.Data.Civil3dObject")]
public class Civil3dObject : Base, ICivilObject
public class Civil3dObject : DataObject, ICivilObject
{
public required string name { get; set; }
public required string type { get; set; }

/// <summary>
Expand All @@ -22,14 +21,7 @@ public class Civil3dObject : Base, ICivilObject
[DetachProperty]
public required List<Base> elements { get; set; }

[DetachProperty]
public required List<Base> displayValue { get; set; }

public required Dictionary<string, object?> properties { get; set; }

public required string units { get; set; }

IReadOnlyList<Base> ICivilObject.elements => elements;

IReadOnlyList<Base> IDisplayValue<IReadOnlyList<Base>>.displayValue => displayValue;
}
8 changes: 1 addition & 7 deletions src/Speckle.Objects/Data/EtabsObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ namespace Speckle.Objects.Data;
/// Represents a wrapper object in ETABS
/// </summary>
[SpeckleType("Objects.Data.EtabsObject")]
public class EtabsObject : Base, ICsiObject
public class EtabsObject : DataObject, ICsiObject
{
public required string name { get; set; }
public required string type { get; set; }

/// <summary>
Expand All @@ -17,11 +16,6 @@ public class EtabsObject : Base, ICsiObject
[DetachProperty]
public required List<EtabsObject> elements { get; set; }

[DetachProperty]
public required List<Base> displayValue { get; set; }

public required Dictionary<string, object?> properties { get; set; }

public required string units { get; set; }

IReadOnlyList<ICsiObject> ICsiObject.elements => elements;
Expand Down
9 changes: 1 addition & 8 deletions src/Speckle.Objects/Data/NavisworksObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,8 @@ namespace Speckle.Objects.Data;
/// Represents a "first selectable ancestor" Navisworks.ModelItem object in Navisworks
/// </summary>
[SpeckleType("Objects.Data.NavisworksObject")]
public class NavisworksObject : Base, INavisworksObject
public class NavisworksObject : DataObject, INavisworksObject
{
public required string name { get; set; }

[DetachProperty]
public required List<Base> displayValue { get; set; }

public required Dictionary<string, object?> properties { get; set; }

public required string units { get; set; }

IReadOnlyList<Base> IDisplayValue<IReadOnlyList<Base>>.displayValue => displayValue;
Expand Down
11 changes: 1 addition & 10 deletions src/Speckle.Objects/Data/RevitObject.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Speckle.Objects.Geometry;
using Speckle.Sdk.Models;

namespace Speckle.Objects.Data;
Expand All @@ -7,9 +6,8 @@ namespace Speckle.Objects.Data;
/// Represents an Autodesk.Revit.DB.Element object in Revit
/// </summary>
[SpeckleType("Objects.Data.RevitObject")]
public class RevitObject : Base, IRevitObject
public class RevitObject : DataObject, IRevitObject
{
public required string name { get; set; }
public required string type { get; set; }
public required string family { get; set; }
public required string category { get; set; }
Expand All @@ -25,14 +23,7 @@ public class RevitObject : Base, IRevitObject
[DetachProperty]
public required List<RevitObject> elements { get; set; }

[DetachProperty]
public required List<Mesh> displayValue { get; set; }

public required Dictionary<string, object?> properties { get; set; }

public required string units { get; set; }

IReadOnlyList<IRevitObject> IRevitObject.elements => elements;

IReadOnlyList<Base> IDisplayValue<IReadOnlyList<Base>>.displayValue => displayValue;
}
8 changes: 1 addition & 7 deletions src/Speckle.Objects/Data/TeklaObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ namespace Speckle.Objects.Data;
/// Represents an Tekla.Structures.Model.ModelObject object in Tekla Structures
/// </summary>
[SpeckleType("Objects.Data.TeklaObject")]
public class TeklaObject : Base, ITeklaObject
public class TeklaObject : DataObject, ITeklaObject
{
public required string name { get; set; }
public required string type { get; set; }

/// <summary>
Expand All @@ -17,11 +16,6 @@ public class TeklaObject : Base, ITeklaObject
[DetachProperty]
public required List<TeklaObject> elements { get; set; }

[DetachProperty]
public required List<Base> displayValue { get; set; }

public required Dictionary<string, object?> properties { get; set; }

public required string units { get; set; }

IReadOnlyList<ITeklaObject> ITeklaObject.elements => elements;
Expand Down
2 changes: 1 addition & 1 deletion src/Speckle.Objects/Interfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public interface IProperties : ISpeckleObject
Dictionary<string, object?> properties { get; }
}

public interface IDataObject : ISpeckleObject, IProperties, IDisplayValue<IReadOnlyList<Base>>
public interface IDataObject : IProperties, IDisplayValue<IReadOnlyList<Base>>
{
/// <summary>
/// The name of the object, primarily used to decorate the object for consumption in frontend and other apps
Expand Down
12 changes: 6 additions & 6 deletions src/Speckle.Objects/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
},
"PolySharp": {
"type": "Direct",
"requested": "[1.14.1, )",
"resolved": "1.14.1",
"contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ=="
"requested": "[1.15.0, )",
"resolved": "1.15.0",
"contentHash": "FbU0El+EEjdpuIX4iDbeS7ki1uzpJPx8vbqOzEtqnl1GZeAGJfq+jCbxeJL2y0EPnUNk8dRnnqR2xnYXg9Tf+g=="
},
"Speckle.InterfaceGenerator": {
"type": "Direct",
Expand Down Expand Up @@ -333,9 +333,9 @@
},
"PolySharp": {
"type": "Direct",
"requested": "[1.14.1, )",
"resolved": "1.14.1",
"contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ=="
"requested": "[1.15.0, )",
"resolved": "1.15.0",
"contentHash": "FbU0El+EEjdpuIX4iDbeS7ki1uzpJPx8vbqOzEtqnl1GZeAGJfq+jCbxeJL2y0EPnUNk8dRnnqR2xnYXg9Tf+g=="
},
"Speckle.InterfaceGenerator": {
"type": "Direct",
Expand Down
5 changes: 5 additions & 0 deletions src/Speckle.Sdk.Dependencies/Collections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ public static class Collections
public static IReadOnlyDictionary<TKey, TValue> Freeze<TKey, TValue>(this IDictionary<TKey, TValue> source)
where TKey : notnull => source.ToFrozenDictionary();
}

public static class EnumerableExtensions
{
public static IEnumerable<int> RangeFrom(int from, int to) => Enumerable.Range(from, to - from + 1);
}
49 changes: 48 additions & 1 deletion src/Speckle.Sdk.Dependencies/Pools.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using System.Text;
using System.Collections.Concurrent;
using System.Text;
using Microsoft.Extensions.ObjectPool;

namespace Speckle.Sdk.Dependencies;

public static class Pools
{
public const int DefaultCapacity = 50;

public static Pool<Dictionary<string, object?>> ObjectDictionaries { get; } = new(new ObjectDictionaryPolicy());

private sealed class ObjectDictionaryPolicy : IPooledObjectPolicy<Dictionary<string, object?>>
Expand All @@ -20,4 +23,48 @@ public bool Return(Dictionary<string, object?> obj)

public static Pool<StringBuilder> StringBuilders { get; } =
new(new StringBuilderPooledObjectPolicy() { MaximumRetainedCapacity = 100 * 1024 * 1024 });

private sealed class ObjectDictionaryPolicy<TKey, TValue> : IPooledObjectPolicy<Dictionary<TKey, TValue>>
where TKey : notnull
{
public Dictionary<TKey, TValue> Create() => new(DefaultCapacity);

public bool Return(Dictionary<TKey, TValue> obj)
{
obj.Clear();
return true;
}
}

private sealed class ObjectConcurrentDictionaryPolicy<TKey, TValue>
: IPooledObjectPolicy<ConcurrentDictionary<TKey, TValue>>
where TKey : notnull
{
public ConcurrentDictionary<TKey, TValue> Create() => new(Environment.ProcessorCount, DefaultCapacity);

public bool Return(ConcurrentDictionary<TKey, TValue> obj)
{
obj.Clear();
return true;
}
}

private sealed class ObjectListPolicy<T> : IPooledObjectPolicy<List<T>>
{
public List<T> Create() => new(DefaultCapacity);

public bool Return(List<T> obj)
{
obj.Clear();
return true;
}
}

public static Pool<List<T>> CreateListPool<T>() => new(new ObjectListPolicy<T>());

public static Pool<Dictionary<TKey, TValue>> CreateDictionaryPool<TKey, TValue>()
where TKey : notnull => new(new ObjectDictionaryPolicy<TKey, TValue>());

public static Pool<ConcurrentDictionary<TKey, TValue>> CreateConcurrentDictionaryPool<TKey, TValue>()
where TKey : notnull => new(new ObjectConcurrentDictionaryPolicy<TKey, TValue>());
}
33 changes: 33 additions & 0 deletions src/Speckle.Sdk.Dependencies/Serialization/Batch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System.Buffers;
using Speckle.Sdk.Dependencies;

namespace Speckle.Sdk.Serialisation.V2.Send;

public sealed class Batch<T> : IHasSize, IMemoryOwner<T>
where T : IHasSize
{
private static readonly Pool<List<T>> _pool = Pools.CreateListPool<T>();
#pragma warning disable IDE0032
private readonly List<T> _items = _pool.Get();
private int _batchSize;
#pragma warning restore IDE0032

public void Add(T item)
{
_items.Add(item);
_batchSize += item.Size;
}

public void TrimExcess()
{
_items.TrimExcess();
_batchSize = _items.Sum(x => x.Size);
}

public int Size => _batchSize;
public List<T> Items => _items;

public void Dispose() => _pool.Return(_items);

public Memory<T> Memory => new(_items.ToArray());
}
Loading

0 comments on commit 40a11ef

Please sign in to comment.