Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into fix-external-refs
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhathcock committed Nov 19, 2024
2 parents 9b1df3f + 604e141 commit 73d65b5
Show file tree
Hide file tree
Showing 22 changed files with 244 additions and 249 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"csharpier": {
"version": "0.29.2",
"version": "0.30.1",
"commands": [
"dotnet-csharpier"
],
Expand Down
38 changes: 18 additions & 20 deletions src/Speckle.Objects/Geometry/Arc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,15 @@ public bool TransformTo(Transform transform, out Arc transformed)
midPoint.TransformTo(transform, out Point transformedMidpoint);
endPoint.TransformTo(transform, out Point transformedEndPoint);
plane.TransformTo(transform, out Plane pln);
Arc arc =
new()
{
startPoint = transformedStartPoint,
endPoint = transformedEndPoint,
midPoint = transformedMidpoint,
plane = pln,
domain = domain,
units = units,
};
Arc arc = new()
{
startPoint = transformedStartPoint,
endPoint = transformedEndPoint,
midPoint = transformedMidpoint,
plane = pln,
domain = domain,
units = units,
};
transformed = arc;
return true;
}
Expand Down Expand Up @@ -150,16 +149,15 @@ public List<double> ToList()
public static Arc FromList(List<double> list)
{
string units = Units.GetUnitFromEncoding(list[^1]);
Arc arc =
new()
{
domain = new Interval { start = list[6], end = list[7] },
units = units,
plane = Plane.FromList(list.GetRange(8, 13)),
startPoint = Point.FromList(list.GetRange(21, 3), units),
midPoint = Point.FromList(list.GetRange(24, 3), units),
endPoint = Point.FromList(list.GetRange(27, 3), units),
};
Arc arc = new()
{
domain = new Interval { start = list[6], end = list[7] },
units = units,
plane = Plane.FromList(list.GetRange(8, 13)),
startPoint = Point.FromList(list.GetRange(21, 3), units),
midPoint = Point.FromList(list.GetRange(24, 3), units),
endPoint = Point.FromList(list.GetRange(27, 3), units),
};

arc.plane.units = arc.units;
return arc;
Expand Down
21 changes: 10 additions & 11 deletions src/Speckle.Objects/Geometry/Polycurve.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,16 @@ public bool TransformTo(Transform transform, out ITransformable polycurve)
/// <returns>A <see cref="Polycurve"/> with the same shape as the provided polyline.</returns>
public static implicit operator Polycurve(Polyline polyline)
{
Polycurve polycurve =
new()
{
segments = new(),
units = polyline.units,
area = polyline.area,
domain = polyline.domain,
closed = polyline.closed,
bbox = polyline.bbox,
length = polyline.length,
};
Polycurve polycurve = new()
{
segments = new(),
units = polyline.units,
area = polyline.area,
domain = polyline.domain,
closed = polyline.closed,
bbox = polyline.bbox,
length = polyline.length,
};

var points = polyline.GetPoints();
for (var i = 0; i < points.Count - 1; i++)
Expand Down
46 changes: 22 additions & 24 deletions src/Speckle.Sdk/Api/GraphQL/Resources/CommentResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,17 @@ query CommentThreads($projectId: String!, $commentId: String!, $repliesLimit: In
}
""";

GraphQLRequest request =
new()
GraphQLRequest request = new()
{
Query = QUERY,
Variables = new
{
Query = QUERY,
Variables = new
{
commentId,
projectId,
repliesLimit,
repliesCursor,
},
};
commentId,
projectId,
repliesLimit,
repliesCursor,
},
};

var response = await _client
.ExecuteGraphQLRequest<RequiredResponse<RequiredResponse<Comment>>>(request, cancellationToken)
Expand Down Expand Up @@ -157,20 +156,19 @@ query CommentThreads($projectId: String!, $cursor: String, $limit: Int!, $filter
}
""";

GraphQLRequest request =
new()
GraphQLRequest request = new()
{
Query = QUERY,
Variables = new
{
Query = QUERY,
Variables = new
{
projectId,
cursor,
limit,
filter,
repliesLimit,
repliesCursor,
},
};
projectId,
cursor,
limit,
filter,
repliesLimit,
repliesCursor,
},
};

var response = await _client
.ExecuteGraphQLRequest<RequiredResponse<RequiredResponse<ProjectCommentCollection>>>(request, cancellationToken)
Expand Down
21 changes: 10 additions & 11 deletions src/Speckle.Sdk/Api/GraphQL/Resources/ModelResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,17 @@ query ProjectGetWithModels($projectId: String!, $modelsLimit: Int!, $modelsCurso
}
}
""";
GraphQLRequest request =
new()
GraphQLRequest request = new()
{
Query = QUERY,
Variables = new
{
Query = QUERY,
Variables = new
{
projectId,
modelsLimit,
modelsCursor,
modelsFilter,
},
};
projectId,
modelsLimit,
modelsCursor,
modelsFilter,
},
};

var response = await _client
.ExecuteGraphQLRequest<RequiredResponse<RequiredResponse<ResourceCollection<Model>>>>(request, cancellationToken)
Expand Down
21 changes: 10 additions & 11 deletions src/Speckle.Sdk/Api/GraphQL/Resources/ProjectResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,17 @@ query ProjectGetWithModels($projectId: String!, $modelsLimit: Int!, $modelsCurso
}
}
""";
GraphQLRequest request =
new()
GraphQLRequest request = new()
{
Query = QUERY,
Variables = new
{
Query = QUERY,
Variables = new
{
projectId,
modelsLimit,
modelsCursor,
modelsFilter,
},
};
projectId,
modelsLimit,
modelsCursor,
modelsFilter,
},
};

var response = await _client
.ExecuteGraphQLRequest<RequiredResponse<ProjectWithModels>>(request, cancellationToken)
Expand Down
23 changes: 11 additions & 12 deletions src/Speckle.Sdk/Api/GraphQL/Resources/VersionResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,18 @@ query VersionGetVersions($projectId: String!, $modelId: String!, $limit: Int!, $
}
""";

GraphQLRequest request =
new()
GraphQLRequest request = new()
{
Query = QUERY,
Variables = new
{
Query = QUERY,
Variables = new
{
projectId,
modelId,
limit,
cursor,
filter,
},
};
projectId,
modelId,
limit,
cursor,
filter,
},
};

var response = await _client
.ExecuteGraphQLRequest<RequiredResponse<RequiredResponse<RequiredResponse<ResourceCollection<Version>>>>>(
Expand Down
15 changes: 7 additions & 8 deletions src/Speckle.Sdk/Api/Operations/Operations.Receive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,13 @@ CancellationToken cancellationToken
}

// Setup Serializer
SpeckleObjectDeserializer serializer =
new()
{
ReadTransport = localTransport,
OnProgressAction = internalProgressAction,
CancellationToken = cancellationToken,
BlobStorageFolder = (remoteTransport as IBlobCapableTransport)?.BlobStorageFolder,
};
SpeckleObjectDeserializer serializer = new()
{
ReadTransport = localTransport,
OnProgressAction = internalProgressAction,
CancellationToken = cancellationToken,
BlobStorageFolder = (remoteTransport as IBlobCapableTransport)?.BlobStorageFolder,
};

// Try Local Receive
string? objString = await LocalReceive(objectId, localTransport).ConfigureAwait(false);
Expand Down
14 changes: 12 additions & 2 deletions src/Speckle.Sdk/Common/Units.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,18 @@ public static class Units
/// <summary>US Survey foot, now not supported by Speckle, kept privately for backwards compatibility</summary>
private const string USFeet = "us_ft";

internal static readonly List<string> SupportedUnits =
new() { Millimeters, Centimeters, Meters, Kilometers, Inches, Feet, Yards, Miles, None };
internal static readonly List<string> SupportedUnits = new()
{
Millimeters,
Centimeters,
Meters,
Kilometers,
Inches,
Feet,
Yards,
Miles,
None,
};

/// <param name="unit"></param>
/// <returns><see langword="true"/> if <paramref name="unit"/> is a recognised/supported unit string, otherwise <see langword="false"/></returns>
Expand Down
18 changes: 9 additions & 9 deletions src/Speckle.Sdk/Serialisation/SpeckleObjectSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,12 @@ private void SerializeProperty(
// Note: this change was needed as we've made the ObjectReference type inherit from Base for
// the purpose of the "do not convert unchanged previously converted objects" POC.
case ObjectReference r:
Dictionary<string, object?> ret =
new()
{
["speckle_type"] = r.speckle_type,
["referencedId"] = r.referencedId,
["__closure"] = r.closure,
};
Dictionary<string, object?> ret = new()
{
["speckle_type"] = r.speckle_type,
["referencedId"] = r.referencedId,
["__closure"] = r.closure,
};
if (r.closure is not null)
{
foreach (var kvp in r.closure)
Expand Down Expand Up @@ -301,8 +300,9 @@ private void SerializeProperty(
IReadOnlyCollection<string> dynamicProperties = baseObj.DynamicPropertyKeys;

// propertyName -> (originalValue, isDetachable, isChunkable, chunkSize)
Dictionary<string, (object?, PropertyAttributeInfo)> allProperties =
new(typedProperties.Count + dynamicProperties.Count);
Dictionary<string, (object?, PropertyAttributeInfo)> allProperties = new(
typedProperties.Count + dynamicProperties.Count
);

// Construct `allProperties`: Add typed properties
foreach ((PropertyInfo propertyInfo, PropertyAttributeInfo detachInfo) in typedProperties)
Expand Down
18 changes: 5 additions & 13 deletions src/Speckle.Sdk/Serialisation/V2/Send/ObjectSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,12 @@ private void SerializeProperty(object? obj, JsonWriter writer, PropertyAttribute
// Note: this change was needed as we've made the ObjectReference type inherit from Base for
// the purpose of the send object (connector/conversion level) caching.
case ObjectReference r:
Dictionary<string, object?> ret =
new()
{
["speckle_type"] = r.speckle_type,
["referencedId"] = r.referencedId,
["__closure"] = r.closure,
};
//references can be externally provided and need to know the ids in the closure and reference here
//AddClosure can take the same value twice
foreach (var kvp in r.closure.Empty())
Dictionary<string, object?> ret = new()
{
AddClosure(kvp.Key);
}
AddClosure(r.referencedId);
["speckle_type"] = r.speckle_type,
["referencedId"] = r.referencedId,
["__closure"] = r.closure,
};
SerializeProperty(ret, writer);
break;
case Base b:
Expand Down
7 changes: 5 additions & 2 deletions src/Speckle.Sdk/Serialisation/V2/ServerObjectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,11 @@ CancellationToken cancellationToken
{
cancellationToken.ThrowIfCancellationRequested();

using HttpRequestMessage message =
new() { RequestUri = new Uri($"/objects/{_streamId}", UriKind.Relative), Method = HttpMethod.Post };
using HttpRequestMessage message = new()
{
RequestUri = new Uri($"/objects/{_streamId}", UriKind.Relative),
Method = HttpMethod.Post,
};

MultipartFormDataContent multipart = new();

Expand Down
10 changes: 8 additions & 2 deletions src/Speckle.Sdk/Transports/ServerTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,14 @@ public async Task<string> CopyObjectAndChildren(string id, ITransport targetTran

CancellationToken.ThrowIfCancellationRequested();

using ParallelServerApi api =
new(_http, _activityFactory, BaseUri, AuthorizationToken, BlobStorageFolder, TimeoutSeconds);
using ParallelServerApi api = new(
_http,
_activityFactory,
BaseUri,
AuthorizationToken,
BlobStorageFolder,
TimeoutSeconds
);

var stopwatch = Stopwatch.StartNew();
api.CancellationToken = CancellationToken;
Expand Down
7 changes: 5 additions & 2 deletions src/Speckle.Sdk/Transports/ServerUtils/ServerAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,11 @@ private async Task UploadObjectsImpl(
{
CancellationToken.ThrowIfCancellationRequested();

using HttpRequestMessage message =
new() { RequestUri = new Uri($"/objects/{streamId}", UriKind.Relative), Method = HttpMethod.Post };
using HttpRequestMessage message = new()
{
RequestUri = new Uri($"/objects/{streamId}", UriKind.Relative),
Method = HttpMethod.Post,
};

MultipartFormDataContent multipart = new();

Expand Down
Loading

0 comments on commit 73d65b5

Please sign in to comment.