diff --git a/Directory.Packages.props b/Directory.Packages.props index d86ca569..3088b120 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -13,7 +13,7 @@ - + @@ -29,9 +29,10 @@ + - + \ No newline at end of file diff --git a/src/Speckle.Objects/GIS/GisPointFeature.cs b/src/Speckle.Objects/GIS/GisPointFeature.cs index 57493268..33327083 100644 --- a/src/Speckle.Objects/GIS/GisPointFeature.cs +++ b/src/Speckle.Objects/GIS/GisPointFeature.cs @@ -1,4 +1,3 @@ -using Speckle.Newtonsoft.Json; using Speckle.Objects.Geometry; using Speckle.Sdk.Models; @@ -9,7 +8,8 @@ public class GisPointFeature : Base, IGisFeature, IDisplayValue> { public required Base attributes { get; set; } - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public required List geometry { get => displayValue; diff --git a/src/Speckle.Objects/GIS/GisPolylineFeature.cs b/src/Speckle.Objects/GIS/GisPolylineFeature.cs index 2f4b578d..e8b0cb63 100644 --- a/src/Speckle.Objects/GIS/GisPolylineFeature.cs +++ b/src/Speckle.Objects/GIS/GisPolylineFeature.cs @@ -1,4 +1,3 @@ -using Speckle.Newtonsoft.Json; using Speckle.Objects.Geometry; using Speckle.Sdk.Models; @@ -9,7 +8,8 @@ public class GisPolylineFeature : Base, IGisFeature, IDisplayValue geometry { get => displayValue; diff --git a/src/Speckle.Objects/Geometry/Arc.cs b/src/Speckle.Objects/Geometry/Arc.cs index 2add9143..ae8b1a1b 100644 --- a/src/Speckle.Objects/Geometry/Arc.cs +++ b/src/Speckle.Objects/Geometry/Arc.cs @@ -1,4 +1,3 @@ -using Speckle.Newtonsoft.Json; using Speckle.Objects.Other; using Speckle.Objects.Primitive; using Speckle.Sdk.Common; @@ -42,19 +41,25 @@ public class Arc : Base, IHasBoundingBox, ICurve, ITransformable /// /// OBSOLETE - This is just here for backwards compatibility. /// - [JsonIgnore, Obsolete("start angle should be calculated from arc startpoint and plane if needed", true)] + [Obsolete("start angle should be calculated from arc startpoint and plane if needed", true)] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public double? startAngle { get; set; } /// /// OBSOLETE - This is just here for backwards compatibility. /// - [JsonIgnore, Obsolete("end angle should be calculated from arc endpoint and plane if needed", true)] + [Obsolete("end angle should be calculated from arc endpoint and plane if needed", true)] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public double? endAngle { get; set; } /// /// OBSOLETE - This is just here for backwards compatibility. /// - [JsonIgnore, Obsolete("Refer to measure instead", true)] + [Obsolete("Refer to measure instead", true)] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public double angleRadians { get; set; } /// @@ -81,7 +86,9 @@ public class Arc : Base, IHasBoundingBox, ICurve, ITransformable /// /// OBSOLETE - This is just here for backwards compatibility. /// - [JsonIgnore, Obsolete("Area property does not belong on an arc", true)] + [Obsolete("Area property does not belong on an arc", true)] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public double area { get; set; } /// diff --git a/src/Speckle.Objects/Geometry/Box.cs b/src/Speckle.Objects/Geometry/Box.cs index ea91cce6..4e6ca8e0 100644 --- a/src/Speckle.Objects/Geometry/Box.cs +++ b/src/Speckle.Objects/Geometry/Box.cs @@ -1,4 +1,3 @@ -using Speckle.Newtonsoft.Json; using Speckle.Objects.Primitive; using Speckle.Sdk.Common; using Speckle.Sdk.Models; @@ -11,7 +10,9 @@ namespace Speckle.Objects.Geometry; [SpeckleType("Objects.Geometry.Box")] public class Box : Base, IHasVolume, IHasArea, IHasBoundingBox { - [JsonIgnore, Obsolete("Use plane property instead", true)] + [Obsolete("Use plane property instead", true)] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public Plane basePlane { get => plane; @@ -49,7 +50,9 @@ public Plane basePlane /// public double area => 2 * (xSize.Length * ySize.Length + xSize.Length * zSize.Length + ySize.Length * zSize.Length); - [JsonIgnore, Obsolete("Boxs should not have a bounding box", true)] + [Obsolete("Boxs should not have a bounding box", true)] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public Box? bbox { get; } /// diff --git a/src/Speckle.Objects/Geometry/Brep.cs b/src/Speckle.Objects/Geometry/Brep.cs index df201c32..6d323258 100644 --- a/src/Speckle.Objects/Geometry/Brep.cs +++ b/src/Speckle.Objects/Geometry/Brep.cs @@ -1,5 +1,4 @@ using System.Runtime.Serialization; -using Speckle.Newtonsoft.Json; using Speckle.Objects.Other; using Speckle.Objects.Primitive; using Speckle.Sdk.Common; @@ -25,7 +24,9 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable< /// /// Gets or sets the list of surfaces in this instance. /// - [JsonIgnore] + + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public required List Surfaces { get; set; } /// @@ -68,7 +69,9 @@ public List SurfacesValue /// /// Gets or sets the list of 3-dimensional curves in this instance. /// - [JsonIgnore] + + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public required List Curve3D { get; set; } /// @@ -93,7 +96,9 @@ public List Curve3DValues /// /// Gets or sets the list of 2-dimensional UV curves in this instance. /// - [JsonIgnore] + + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public required List Curve2D { get; set; } /// @@ -118,7 +123,9 @@ public List Curve2DValues /// /// Gets or sets the list of vertices in this instance. /// - [JsonIgnore] + + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public required List Vertices { get; set; } /// @@ -158,7 +165,9 @@ public List VerticesValue /// /// Gets or sets the list of edges in this instance. /// - [JsonIgnore] + + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public required List Edges { get; set; } /// @@ -232,7 +241,9 @@ public List EdgesValue /// /// Gets or sets the list of closed UV loops in this instance. /// - [JsonIgnore] + + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public required List Loops { get; set; } /// @@ -288,7 +299,9 @@ public List LoopsValue /// /// Gets or sets the list of UV trim segments for each surface in this instance. /// - [JsonIgnore] + + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public required List Trims { get; set; } /// @@ -354,7 +367,9 @@ public List TrimsValue /// /// Gets or sets the list of faces in this instance. /// - [JsonIgnore] + + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public required List Faces { get; set; } /// diff --git a/src/Speckle.Objects/Geometry/BrepEdge.cs b/src/Speckle.Objects/Geometry/BrepEdge.cs index b2009157..b8de26fd 100644 --- a/src/Speckle.Objects/Geometry/BrepEdge.cs +++ b/src/Speckle.Objects/Geometry/BrepEdge.cs @@ -1,4 +1,3 @@ -using Speckle.Newtonsoft.Json; using Speckle.Objects.Primitive; using Speckle.Sdk.Models; @@ -10,7 +9,8 @@ namespace Speckle.Objects.Geometry; [SpeckleType("Objects.Geometry.BrepEdge")] public class BrepEdge : Base { - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public required Brep Brep { get; set; } public required int Curve3dIndex { get; set; } @@ -22,15 +22,19 @@ public class BrepEdge : Base public required Interval Domain { get; set; } - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public Point StartVertex => Brep.Vertices[StartIndex]; - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public Point EndVertex => Brep.Vertices[EndIndex]; - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public IEnumerable Trims => TrimIndices.Select(i => Brep.Trims[i]); - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public ICurve Curve => Brep.Curve3D[Curve3dIndex]; } diff --git a/src/Speckle.Objects/Geometry/BrepFace.cs b/src/Speckle.Objects/Geometry/BrepFace.cs index 748f65d8..ec3c241c 100644 --- a/src/Speckle.Objects/Geometry/BrepFace.cs +++ b/src/Speckle.Objects/Geometry/BrepFace.cs @@ -1,4 +1,3 @@ -using Speckle.Newtonsoft.Json; using Speckle.Sdk.Models; namespace Speckle.Objects.Geometry; @@ -9,7 +8,8 @@ namespace Speckle.Objects.Geometry; [SpeckleType("Objects.Geometry.BrepFace")] public class BrepFace : Base { - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public required Brep Brep { get; set; } public required int SurfaceIndex { get; set; } @@ -17,12 +17,15 @@ public class BrepFace : Base public required int OuterLoopIndex { get; set; } public required bool OrientationReversed { get; set; } - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public BrepLoop OuterLoop => Brep.Loops[OuterLoopIndex]; - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public Surface Surface => Brep.Surfaces[SurfaceIndex]; - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public List Loops => LoopIndices.Select(i => Brep.Loops[i]).ToList(); } diff --git a/src/Speckle.Objects/Geometry/BrepLoop.cs b/src/Speckle.Objects/Geometry/BrepLoop.cs index 095e1b7b..82ae8faa 100644 --- a/src/Speckle.Objects/Geometry/BrepLoop.cs +++ b/src/Speckle.Objects/Geometry/BrepLoop.cs @@ -1,4 +1,3 @@ -using Speckle.Newtonsoft.Json; using Speckle.Sdk.Models; namespace Speckle.Objects.Geometry; @@ -9,16 +8,19 @@ namespace Speckle.Objects.Geometry; [SpeckleType("Objects.Geometry.BrepLoop")] public class BrepLoop : Base { - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public required Brep Brep { get; set; } public required int FaceIndex { get; set; } public required List TrimIndices { get; set; } public required BrepLoopType Type { get; set; } - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public BrepFace Face => Brep.Faces[FaceIndex]; - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public List Trims => TrimIndices.Select(i => Brep.Trims[i]).ToList(); } diff --git a/src/Speckle.Objects/Geometry/BrepTrim.cs b/src/Speckle.Objects/Geometry/BrepTrim.cs index 267a7454..1622226c 100644 --- a/src/Speckle.Objects/Geometry/BrepTrim.cs +++ b/src/Speckle.Objects/Geometry/BrepTrim.cs @@ -1,4 +1,3 @@ -using Speckle.Newtonsoft.Json; using Speckle.Objects.Primitive; using Speckle.Sdk.Models; @@ -10,7 +9,8 @@ namespace Speckle.Objects.Geometry; [SpeckleType("Objects.Geometry.BrepTrim")] public class BrepTrim : Base { - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public required Brep Brep { get; set; } public required int EdgeIndex { get; set; } public required int StartIndex { get; set; } @@ -24,15 +24,19 @@ public class BrepTrim : Base public required Interval Domain { get; set; } - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public BrepFace Face => Brep.Faces[FaceIndex]; - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public BrepLoop Loop => Brep.Loops[LoopIndex]; - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public BrepEdge? Edge => EdgeIndex != -1 ? Brep.Edges[EdgeIndex] : null; - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public ICurve Curve2d => Brep.Curve2D[CurveIndex]; } diff --git a/src/Speckle.Objects/Geometry/ControlPoint.cs b/src/Speckle.Objects/Geometry/ControlPoint.cs index fd942e35..ba2e9911 100644 --- a/src/Speckle.Objects/Geometry/ControlPoint.cs +++ b/src/Speckle.Objects/Geometry/ControlPoint.cs @@ -1,5 +1,4 @@ using System.Diagnostics.CodeAnalysis; -using Speckle.Newtonsoft.Json; using Speckle.Objects.Other; using Speckle.Sdk.Models; @@ -23,7 +22,10 @@ public ControlPoint(double x, double y, double z, double w, string units, string /// OBSOLETE - This is just here for backwards compatibility. /// [ - JsonProperty(NullValueHandling = NullValueHandling.Ignore), + Speckle.Newtonsoft.Json.JsonProperty(NullValueHandling = Speckle.Newtonsoft.Json.NullValueHandling.Ignore), + System.Text.Json.Serialization.JsonIgnore( + Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull + ), Obsolete("Access coordinates using XYZ and weight fields", true) ] private new List value diff --git a/src/Speckle.Objects/Geometry/Line.cs b/src/Speckle.Objects/Geometry/Line.cs index 2fe90022..486d883a 100644 --- a/src/Speckle.Objects/Geometry/Line.cs +++ b/src/Speckle.Objects/Geometry/Line.cs @@ -1,5 +1,4 @@ using System.Diagnostics.CodeAnalysis; -using Speckle.Newtonsoft.Json; using Speckle.Objects.Other; using Speckle.Objects.Primitive; using Speckle.Sdk.Common; @@ -34,7 +33,9 @@ public Line(IList coordinates, string units, string? applicationId = nul /// OBSOLETE - This is just here for backwards compatibility. /// You should not use this for anything. /// - [JsonIgnore, Obsolete("Area should not be on the line class", true)] + [Obsolete("Area should not be on the line class", true)] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public double area => 0; public required string units { get; set; } @@ -102,7 +103,10 @@ public static Line FromList(IReadOnlyList list) /// You should not use this for anything. Access coordinates using start and end point. /// [ - JsonProperty(NullValueHandling = NullValueHandling.Ignore), + Speckle.Newtonsoft.Json.JsonProperty(NullValueHandling = Speckle.Newtonsoft.Json.NullValueHandling.Ignore), + System.Text.Json.Serialization.JsonIgnore( + Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull + ), Obsolete("Access coordinates using start and end point", true) ] public List? value diff --git a/src/Speckle.Objects/Geometry/Mesh.cs b/src/Speckle.Objects/Geometry/Mesh.cs index 64079c69..7aa707d6 100644 --- a/src/Speckle.Objects/Geometry/Mesh.cs +++ b/src/Speckle.Objects/Geometry/Mesh.cs @@ -1,4 +1,3 @@ -using Speckle.Newtonsoft.Json; using Speckle.Objects.Other; using Speckle.Sdk; using Speckle.Sdk.Common; @@ -87,10 +86,13 @@ public bool TransformTo(Transform transform, out ITransformable transformed) #region Convenience Methods - [JsonIgnore] + + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public int VerticesCount => vertices.Count / 3; - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public int TextureCoordinatesCount => textureCoordinates.Count / 2; /// diff --git a/src/Speckle.Objects/Geometry/Point.cs b/src/Speckle.Objects/Geometry/Point.cs index 9911ce73..f6276074 100644 --- a/src/Speckle.Objects/Geometry/Point.cs +++ b/src/Speckle.Objects/Geometry/Point.cs @@ -1,5 +1,4 @@ using System.Diagnostics.CodeAnalysis; -using Speckle.Newtonsoft.Json; using Speckle.Objects.Other; using Speckle.Sdk.Common; using Speckle.Sdk.Models; @@ -233,7 +232,13 @@ public Point(Vector _) { } /// /// Gets or sets the coordinates of the /// - [JsonProperty(NullValueHandling = NullValueHandling.Ignore), Obsolete("Use x,y,z properties instead", true)] + [ + Speckle.Newtonsoft.Json.JsonProperty(NullValueHandling = Speckle.Newtonsoft.Json.NullValueHandling.Ignore), + System.Text.Json.Serialization.JsonIgnore( + Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull + ), + Obsolete("Use x,y,z properties instead", true) + ] public List value { get => null!; diff --git a/src/Speckle.Objects/Geometry/Vector.cs b/src/Speckle.Objects/Geometry/Vector.cs index 83114648..433ba334 100644 --- a/src/Speckle.Objects/Geometry/Vector.cs +++ b/src/Speckle.Objects/Geometry/Vector.cs @@ -1,5 +1,4 @@ using System.Diagnostics.CodeAnalysis; -using Speckle.Newtonsoft.Json; using Speckle.Objects.Other; using Speckle.Sdk.Common; using Speckle.Sdk.Models; @@ -57,7 +56,9 @@ public Vector(double x, double y, double z, string units, string? applicationId /// Gets the Euclidean length of this vector. /// /// Length of the vector. - [JsonIgnore] + + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public double Length => Math.Sqrt(DotProduct(this, this)); /// @@ -226,7 +227,10 @@ public Vector(Point point, string? applicationId = null) { } /// Gets or sets the coordinates of the vector /// [ - JsonProperty(NullValueHandling = NullValueHandling.Ignore), + Speckle.Newtonsoft.Json.JsonProperty(NullValueHandling = Speckle.Newtonsoft.Json.NullValueHandling.Ignore), + System.Text.Json.Serialization.JsonIgnore( + Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull + ), Obsolete("Use X,Y,Z fields to access coordinates instead", true) ] public List value diff --git a/src/Speckle.Objects/Other/RenderMaterial.cs b/src/Speckle.Objects/Other/RenderMaterial.cs index b114399a..9f735479 100644 --- a/src/Speckle.Objects/Other/RenderMaterial.cs +++ b/src/Speckle.Objects/Other/RenderMaterial.cs @@ -1,5 +1,4 @@ using System.Drawing; -using Speckle.Newtonsoft.Json; using Speckle.Sdk.Models; using Speckle.Sdk.Models.Proxies; @@ -25,14 +24,16 @@ public class RenderMaterial : Base public int emissive { get; set; } = Color.Black.ToArgb(); - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public Color diffuseColor { get => Color.FromArgb(diffuse); set => diffuse = value.ToArgb(); } - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public Color emissiveColor { get => Color.FromArgb(emissive); diff --git a/src/Speckle.Objects/Primitive/Interval.cs b/src/Speckle.Objects/Primitive/Interval.cs index 0ffcfc79..012bb305 100644 --- a/src/Speckle.Objects/Primitive/Interval.cs +++ b/src/Speckle.Objects/Primitive/Interval.cs @@ -1,4 +1,3 @@ -using Speckle.Newtonsoft.Json; using Speckle.Sdk.Models; namespace Speckle.Objects.Primitive; @@ -9,7 +8,8 @@ public class Interval : Base public required double start { get; set; } public required double end { get; set; } - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public double Length => Math.Abs((end) - (start)); public override string ToString() diff --git a/src/Speckle.Objects/packages.lock.json b/src/Speckle.Objects/packages.lock.json index e0eab833..9b218112 100644 --- a/src/Speckle.Objects/packages.lock.json +++ b/src/Speckle.Objects/packages.lock.json @@ -168,8 +168,8 @@ }, "System.Buffers": { "type": "Transitive", - "resolved": "4.4.0", - "contentHash": "AwarXzzoDwX6BgrhjoJsk6tUezZEozOT5Y9QKF94Gl4JK91I4PIIBkBco9068Y9/Dra8Dkbie99kXB8+1BaYKw==" + "resolved": "4.5.1", + "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" }, "System.ComponentModel.Annotations": { "type": "Transitive", @@ -178,18 +178,18 @@ }, "System.Memory": { "type": "Transitive", - "resolved": "4.5.3", - "contentHash": "3oDzvc/zzetpTKWMShs1AADwZjQ/36HnsufHRPcOjyRAAMLDlu2iD33MBI2opxnezcVUtXyqDXXjoFMOU9c7SA==", + "resolved": "4.5.4", + "contentHash": "1MbJTHS1lZ4bS4FmsJjnuGJOu88ZzTT2rLvrhW7Ygic+pC0NWA+3hgAen0HRdsocuQXCkUTdFn9yHJJhsijDXw==", "dependencies": { - "System.Buffers": "4.4.0", + "System.Buffers": "4.5.1", "System.Numerics.Vectors": "4.4.0", - "System.Runtime.CompilerServices.Unsafe": "4.5.2" + "System.Runtime.CompilerServices.Unsafe": "4.5.3" } }, "System.Numerics.Vectors": { "type": "Transitive", - "resolved": "4.4.0", - "contentHash": "UiLzLW+Lw6HLed1Hcg+8jSRttrbuXv7DANVj0DkL9g6EnnzbL75EB7EWsw5uRbhxd/4YdG8li5XizGWepmG3PQ==" + "resolved": "4.5.0", + "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" }, "System.Reactive": { "type": "Transitive", @@ -211,8 +211,8 @@ }, "System.Runtime.CompilerServices.Unsafe": { "type": "Transitive", - "resolved": "4.5.3", - "contentHash": "3TIsJhD1EiiT0w2CcDMN/iSSwnNnsrnbzeVHSKkaEgV85txMprmuO+Yq2AdSbeVGcg28pdNDTPK87tJhX7VFHw==" + "resolved": "5.0.0", + "contentHash": "ZD9TMpsmYJLrxbbmdvhwt9YEgG5WntEnZ/d1eH8JBX9LBp+Ju8BSBhUGbZMNVHHomWo2KVImJhTDl2hIgw/6MA==" }, "System.Runtime.InteropServices.WindowsRuntime": { "type": "Transitive", @@ -222,6 +222,14 @@ "System.Runtime": "4.3.0" } }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "EEslUvHKll1ftizbn20mX3Ix/l4Ygk/bdJ2LY6/X6FlGaP0RIhKMo9nS6JIGnKKT6KBP2PGj6JC3B9/ZF6ErqQ==", + "dependencies": { + "System.Memory": "4.5.4" + } + }, "System.Threading.Tasks.Extensions": { "type": "Transitive", "resolved": "4.5.4", @@ -241,7 +249,8 @@ "Microsoft.Extensions.Logging": "[2.2.0, )", "Speckle.DoubleNumerics": "[4.0.1, )", "Speckle.Newtonsoft.Json": "[13.0.2, )", - "Speckle.Sdk.Dependencies": "[1.0.0, )" + "Speckle.Sdk.Dependencies": "[1.0.0, )", + "System.Text.Json": "[5.0.0, )" } }, "speckle.sdk.dependencies": { @@ -312,6 +321,21 @@ "requested": "[13.0.2, )", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "System.Text.Json": { + "type": "CentralTransitive", + "requested": "[5.0.0, )", + "resolved": "5.0.0", + "contentHash": "+luxMQNZ2WqeffBU7Ml6njIvxc8169NW2oU+ygNudXQGZiarjE7DOtN7bILiQjTZjkmwwRZGTtLzmdrSI/Ustw==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "5.0.0", + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "5.0.0", + "System.Text.Encodings.Web": "5.0.0", + "System.Threading.Tasks.Extensions": "4.5.4" + } } }, "net8.0": { @@ -484,13 +508,15 @@ "type": "Project", "dependencies": { "GraphQL.Client": "[6.0.0, )", + "Microsoft.Bcl.AsyncInterfaces": "[5.0.0, )", "Microsoft.CSharp": "[4.7.0, )", "Microsoft.Data.Sqlite": "[7.0.5, )", "Microsoft.Extensions.DependencyInjection.Abstractions": "[2.2.0, )", "Microsoft.Extensions.Logging": "[2.2.0, )", "Speckle.DoubleNumerics": "[4.0.1, )", "Speckle.Newtonsoft.Json": "[13.0.2, )", - "Speckle.Sdk.Dependencies": "[1.0.0, )" + "Speckle.Sdk.Dependencies": "[1.0.0, )", + "System.Text.Json": "[5.0.0, )" } }, "speckle.sdk.dependencies": { @@ -507,6 +533,12 @@ "System.Reactive": "5.0.0" } }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "CentralTransitive", + "requested": "[5.0.0, )", + "resolved": "5.0.0", + "contentHash": "W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==" + }, "Microsoft.CSharp": { "type": "CentralTransitive", "requested": "[4.7.0, )", @@ -552,6 +584,12 @@ "requested": "[13.0.2, )", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "System.Text.Json": { + "type": "CentralTransitive", + "requested": "[5.0.0, )", + "resolved": "5.0.0", + "contentHash": "+luxMQNZ2WqeffBU7Ml6njIvxc8169NW2oU+ygNudXQGZiarjE7DOtN7bILiQjTZjkmwwRZGTtLzmdrSI/Ustw==" } } } diff --git a/src/Speckle.Sdk/Api/Operations/Operations.Serialize.cs b/src/Speckle.Sdk/Api/Operations/Operations.Serialize.cs index 075776f2..25bd64c9 100644 --- a/src/Speckle.Sdk/Api/Operations/Operations.Serialize.cs +++ b/src/Speckle.Sdk/Api/Operations/Operations.Serialize.cs @@ -1,5 +1,4 @@ using System.Diagnostics.CodeAnalysis; -using Speckle.Newtonsoft.Json; using Speckle.Sdk.Logging; using Speckle.Sdk.Models; using Speckle.Sdk.Serialisation; @@ -35,7 +34,6 @@ public string Serialize(Base value, CancellationToken cancellationToken = defaul /// /// /// was null - /// was not valid JSON /// cannot be deserialised to type /// contains closure references (see Remarks) public async Task DeserializeAsync(string value, CancellationToken cancellationToken = default) diff --git a/src/Speckle.Sdk/Host/TypeLoader.cs b/src/Speckle.Sdk/Host/TypeLoader.cs index 18159abe..88dd094c 100644 --- a/src/Speckle.Sdk/Host/TypeLoader.cs +++ b/src/Speckle.Sdk/Host/TypeLoader.cs @@ -1,6 +1,5 @@ using System.Collections.Concurrent; using System.Reflection; -using Speckle.Newtonsoft.Json; using Speckle.Sdk.Models; namespace Speckle.Sdk.Host; @@ -14,13 +13,19 @@ public static class TypeLoader private static ConcurrentDictionary s_cachedTypes = new(); private static ConcurrentDictionary s_fullTypeStrings = new(); - private static ConcurrentDictionary s_jsonPropertyAttribute = new(); + private static ConcurrentDictionary< + PropertyInfo, + Speckle.Newtonsoft.Json.JsonPropertyAttribute? + > s_jsonPropertyAttribute = new(); private static ConcurrentDictionary> s_propInfoCache = new(); public static IEnumerable Types => s_availableTypes; - public static JsonPropertyAttribute? GetJsonPropertyAttribute(PropertyInfo property) => - s_jsonPropertyAttribute.GetOrAdd(property, p => p.GetCustomAttribute(true)); + public static Speckle.Newtonsoft.Json.JsonPropertyAttribute? GetJsonPropertyAttribute(PropertyInfo property) => + s_jsonPropertyAttribute.GetOrAdd( + property, + p => p.GetCustomAttribute(true) + ); public static void Initialize(params Assembly[] assemblies) { diff --git a/src/Speckle.Sdk/Models/Base.cs b/src/Speckle.Sdk/Models/Base.cs index d68e31e7..65da9363 100644 --- a/src/Speckle.Sdk/Models/Base.cs +++ b/src/Speckle.Sdk/Models/Base.cs @@ -2,7 +2,6 @@ using System.Collections; using System.Diagnostics.CodeAnalysis; using System.Reflection; -using Speckle.Newtonsoft.Json; using Speckle.Newtonsoft.Json.Linq; using Speckle.Sdk.Common; using Speckle.Sdk.Helpers; @@ -99,7 +98,9 @@ private static long CountDescendants(Base @base, ISet parsed) foreach (var prop in typedProps.Where(p => p.CanRead)) { bool isIgnored = - prop.IsDefined(typeof(ObsoleteAttribute), true) || prop.IsDefined(typeof(JsonIgnoreAttribute), true); + prop.IsDefined(typeof(ObsoleteAttribute), true) + || prop.IsDefined(typeof(Speckle.Newtonsoft.Json.JsonIgnoreAttribute), true) + || prop.IsDefined(typeof(System.Text.Json.Serialization.JsonIgnoreAttribute), true); if (isIgnored) { continue; diff --git a/src/Speckle.Sdk/Models/Blob.cs b/src/Speckle.Sdk/Models/Blob.cs index ad6706b8..f34bb42e 100644 --- a/src/Speckle.Sdk/Models/Blob.cs +++ b/src/Speckle.Sdk/Models/Blob.cs @@ -1,13 +1,13 @@ #nullable disable using System.Runtime.Serialization; -using Speckle.Newtonsoft.Json; namespace Speckle.Sdk.Models; [SpeckleType("Speckle.Core.Models.Blob")] public class Blob : Base { - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public static int LocalHashPrefixLength => 20; private string _filePath; diff --git a/src/Speckle.Sdk/Models/DynamicBase.cs b/src/Speckle.Sdk/Models/DynamicBase.cs index 483bda4a..5ba1edbb 100644 --- a/src/Speckle.Sdk/Models/DynamicBase.cs +++ b/src/Speckle.Sdk/Models/DynamicBase.cs @@ -1,6 +1,5 @@ using System.Dynamic; using System.Reflection; -using Speckle.Newtonsoft.Json; using Speckle.Sdk.Common; using Speckle.Sdk.Host; @@ -273,7 +272,9 @@ public static IEnumerable GetInstanceMembers(Type t) /// Gets the dynamically added property names only. /// /// - [JsonIgnore] + + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public IReadOnlyCollection DynamicPropertyKeys => _properties.Keys; } diff --git a/src/Speckle.Sdk/Serialisation/V2/Receive/DeserializeProcess.cs b/src/Speckle.Sdk/Serialisation/V2/Receive/DeserializeProcess.cs index 1db2e0a4..60167628 100644 --- a/src/Speckle.Sdk/Serialisation/V2/Receive/DeserializeProcess.cs +++ b/src/Speckle.Sdk/Serialisation/V2/Receive/DeserializeProcess.cs @@ -132,7 +132,11 @@ private Base Deserialise(string id, string json) return baseObject; } +#if NETSTANDARD2_0 var deserializer = objectDeserializerFactory.Create(_baseCache); +#else + var deserializer = objectDeserializerFactory.Create2(_baseCache, _options); +#endif return deserializer.Deserialize(json); } } diff --git a/src/Speckle.Sdk/Serialisation/V2/Receive/DictionaryConverter.cs b/src/Speckle.Sdk/Serialisation/V2/Receive/DictionaryConverter.cs index f1b1e07d..3368cf6c 100644 --- a/src/Speckle.Sdk/Serialisation/V2/Receive/DictionaryConverter.cs +++ b/src/Speckle.Sdk/Serialisation/V2/Receive/DictionaryConverter.cs @@ -1,5 +1,4 @@ using System.Reflection; -using Speckle.Newtonsoft.Json; using Speckle.Sdk.Common; using Speckle.Sdk.Host; using Speckle.Sdk.Models; @@ -34,8 +33,8 @@ public static Base Dict2Base(Dictionary dictObj, bool skipInval if (entry.Value == null) { // Check for JsonProperty(NullValueHandling = NullValueHandling.Ignore) attribute - JsonPropertyAttribute? attr = TypeLoader.GetJsonPropertyAttribute(value); - if (attr is { NullValueHandling: NullValueHandling.Ignore }) + Speckle.Newtonsoft.Json.JsonPropertyAttribute? attr = TypeLoader.GetJsonPropertyAttribute(value); + if (attr is { NullValueHandling: Speckle.Newtonsoft.Json.NullValueHandling.Ignore }) { continue; } diff --git a/src/Speckle.Sdk/Serialisation/V2/Receive/ObjectDeserializer2.cs b/src/Speckle.Sdk/Serialisation/V2/Receive/ObjectDeserializer2.cs new file mode 100644 index 00000000..96871a4e --- /dev/null +++ b/src/Speckle.Sdk/Serialisation/V2/Receive/ObjectDeserializer2.cs @@ -0,0 +1,159 @@ +#if !NETSTANDARD2_0 +using System.Text; +using System.Text.Json; +using Speckle.Sdk.Common; +using Speckle.Sdk.Dependencies; +using Speckle.Sdk.Models; + +namespace Speckle.Sdk.Serialisation.V2.Receive; + +public sealed class ObjectDeserializer2( + IReadOnlyDictionary references, + DeserializeOptions? options = null +) : IObjectDeserializer +{ + /// The JSON string of the object to be deserialized + /// A typed object deserialized from the + /// was null + /// cannot be deserialised to type + // /// did not contain the required json objects (closures) + public Base Deserialize(string objectJson) + { + if (objectJson is null) + { + throw new ArgumentNullException(nameof(objectJson), $"Cannot deserialize {nameof(objectJson)}, value was null"); + } + // Apparently this automatically parses DateTimes in strings if it matches the format: + // JObject doc1 = JObject.Parse(objectJson); + + // This is equivalent code that doesn't parse datetimes: + var reader = new Utf8JsonReader(Encoding.UTF8.GetBytes(objectJson)); + + Base? converted; + try + { + reader.Read(); + converted = (Base)ReadObject(ref reader).NotNull(); + } + catch (Exception ex) when (!ex.IsFatal() && ex is not OperationCanceledException) + { + throw new SpeckleDeserializeException("Failed to deserialize", ex); + } + + return converted; + } + + private List ReadArrayAsync(ref Utf8JsonReader reader) + { + reader.Read(); + List retList = new(); + while (reader.TokenType != JsonTokenType.EndArray) + { + object? convertedValue = ReadProperty(ref reader); + if (convertedValue is DataChunk chunk) + { + retList.AddRange(chunk.data); + } + else + { + retList.Add(convertedValue); + } + reader.Read(); //goes to next + } + return retList; + } + + private object? ReadObject(ref Utf8JsonReader reader) + { + reader.Read(); + Dictionary dict = Pools.ObjectDictionaries.Get(); + while (reader.TokenType != JsonTokenType.EndObject) + { + switch (reader.TokenType) + { + case JsonTokenType.PropertyName: + { + var propName = reader.GetString().NotNull(); + reader.Read(); //goes prop value + object? convertedValue = ReadProperty(ref reader); + dict[propName] = convertedValue; + reader.Read(); //goes to next + } + break; + default: + throw new InvalidOperationException( + $"Unknown {reader.TokenType} with {Encoding.UTF8.GetString(reader.ValueSpan)}" + ); + } + } + + if (!dict.TryGetValue(DictionaryConverter.TYPE_DISCRIMINATOR, out object? speckleType)) + { + return dict; + } + + if (speckleType as string == "reference" && dict.TryGetValue("referencedId", out object? referencedId)) + { + var objId = (string)referencedId.NotNull(); + if (references.TryGetValue(objId, out Base? closure)) + { + return closure; + } + + if (options is null || options.ThrowOnMissingReferences) + { + throw new InvalidOperationException($"missing reference: {objId}"); + } + //since we don't throw on missing references, return null + return null; + } + + var b = DictionaryConverter.Dict2Base(dict, options?.SkipInvalidConverts ?? false); + Pools.ObjectDictionaries.Return(dict); + return b; + } + + private object? ReadProperty(ref Utf8JsonReader reader) + { + switch (reader.TokenType) + { + case JsonTokenType.Null: + case JsonTokenType.None: + return null; + case JsonTokenType.True: + case JsonTokenType.False: + return reader.GetBoolean(); + case JsonTokenType.Number: + if (reader.TryGetInt64(out var longValue)) + { + return longValue; + } + if (reader.TryGetDouble(out double d)) + { + // This is behaviour carried over from v2 to facilitate large numbers from Python + // This is quite hacky, as it's a bit questionable exactly what numbers are supported, and with what tolerance + // For this reason, this can be considered undocumented behaviour, and is only for values within the range of a 64bit integer. + return d; + } + + throw new ArgumentException( + $"Found an unsupported integer type {reader.TokenType} with value {reader.GetString()}" + ); + case JsonTokenType.String: + if (reader.TryGetDateTime(out var dateTime)) + { + return dateTime; + } + return reader.GetString(); + case JsonTokenType.StartArray: + return ReadArrayAsync(ref reader); + case JsonTokenType.StartObject: + var dict = ReadObject(ref reader); + return dict; + + default: + throw new ArgumentException("Json value not supported: " + reader.TokenType); + } + } +} +#endif diff --git a/src/Speckle.Sdk/Serialisation/V2/Receive/ObjectDeserializerFactory.cs b/src/Speckle.Sdk/Serialisation/V2/Receive/ObjectDeserializerFactory.cs index 1b13836d..f69a8f77 100644 --- a/src/Speckle.Sdk/Serialisation/V2/Receive/ObjectDeserializerFactory.cs +++ b/src/Speckle.Sdk/Serialisation/V2/Receive/ObjectDeserializerFactory.cs @@ -8,4 +8,11 @@ public class ObjectDeserializerFactory : IObjectDeserializerFactory { public IObjectDeserializer Create(IReadOnlyDictionary references, DeserializeOptions? options = null) => new ObjectDeserializer(references, SpeckleObjectSerializerPool.Instance, options); + +#if !NETSTANDARD2_0 + public IObjectDeserializer Create2( + IReadOnlyDictionary references, + DeserializeOptions? options = null + ) => new ObjectDeserializer2(references, options); +#endif } diff --git a/src/Speckle.Sdk/Speckle.Sdk.csproj b/src/Speckle.Sdk/Speckle.Sdk.csproj index 602f180d..3937fd47 100644 --- a/src/Speckle.Sdk/Speckle.Sdk.csproj +++ b/src/Speckle.Sdk/Speckle.Sdk.csproj @@ -37,11 +37,14 @@ + + - + + diff --git a/src/Speckle.Sdk/packages.lock.json b/src/Speckle.Sdk/packages.lock.json index 03e98959..0f7e2340 100644 --- a/src/Speckle.Sdk/packages.lock.json +++ b/src/Speckle.Sdk/packages.lock.json @@ -105,6 +105,21 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, + "System.Text.Json": { + "type": "Direct", + "requested": "[5.0.0, )", + "resolved": "5.0.0", + "contentHash": "+luxMQNZ2WqeffBU7Ml6njIvxc8169NW2oU+ygNudXQGZiarjE7DOtN7bILiQjTZjkmwwRZGTtLzmdrSI/Ustw==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "5.0.0", + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4", + "System.Numerics.Vectors": "4.5.0", + "System.Runtime.CompilerServices.Unsafe": "5.0.0", + "System.Text.Encodings.Web": "5.0.0", + "System.Threading.Tasks.Extensions": "4.5.4" + } + }, "GraphQL.Client.Abstractions": { "type": "Transitive", "resolved": "6.0.0", @@ -234,8 +249,8 @@ }, "System.Buffers": { "type": "Transitive", - "resolved": "4.4.0", - "contentHash": "AwarXzzoDwX6BgrhjoJsk6tUezZEozOT5Y9QKF94Gl4JK91I4PIIBkBco9068Y9/Dra8Dkbie99kXB8+1BaYKw==" + "resolved": "4.5.1", + "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" }, "System.ComponentModel.Annotations": { "type": "Transitive", @@ -244,18 +259,18 @@ }, "System.Memory": { "type": "Transitive", - "resolved": "4.5.3", - "contentHash": "3oDzvc/zzetpTKWMShs1AADwZjQ/36HnsufHRPcOjyRAAMLDlu2iD33MBI2opxnezcVUtXyqDXXjoFMOU9c7SA==", + "resolved": "4.5.4", + "contentHash": "1MbJTHS1lZ4bS4FmsJjnuGJOu88ZzTT2rLvrhW7Ygic+pC0NWA+3hgAen0HRdsocuQXCkUTdFn9yHJJhsijDXw==", "dependencies": { - "System.Buffers": "4.4.0", + "System.Buffers": "4.5.1", "System.Numerics.Vectors": "4.4.0", - "System.Runtime.CompilerServices.Unsafe": "4.5.2" + "System.Runtime.CompilerServices.Unsafe": "4.5.3" } }, "System.Numerics.Vectors": { "type": "Transitive", - "resolved": "4.4.0", - "contentHash": "UiLzLW+Lw6HLed1Hcg+8jSRttrbuXv7DANVj0DkL9g6EnnzbL75EB7EWsw5uRbhxd/4YdG8li5XizGWepmG3PQ==" + "resolved": "4.5.0", + "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" }, "System.Reactive": { "type": "Transitive", @@ -277,8 +292,8 @@ }, "System.Runtime.CompilerServices.Unsafe": { "type": "Transitive", - "resolved": "4.5.3", - "contentHash": "3TIsJhD1EiiT0w2CcDMN/iSSwnNnsrnbzeVHSKkaEgV85txMprmuO+Yq2AdSbeVGcg28pdNDTPK87tJhX7VFHw==" + "resolved": "5.0.0", + "contentHash": "ZD9TMpsmYJLrxbbmdvhwt9YEgG5WntEnZ/d1eH8JBX9LBp+Ju8BSBhUGbZMNVHHomWo2KVImJhTDl2hIgw/6MA==" }, "System.Runtime.InteropServices.WindowsRuntime": { "type": "Transitive", @@ -288,6 +303,14 @@ "System.Runtime": "4.3.0" } }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "EEslUvHKll1ftizbn20mX3Ix/l4Ygk/bdJ2LY6/X6FlGaP0RIhKMo9nS6JIGnKKT6KBP2PGj6JC3B9/ZF6ErqQ==", + "dependencies": { + "System.Memory": "4.5.4" + } + }, "System.Threading.Tasks.Extensions": { "type": "Transitive", "resolved": "4.5.4", @@ -318,6 +341,12 @@ "System.Reactive": "5.0.0" } }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "Direct", + "requested": "[5.0.0, )", + "resolved": "5.0.0", + "contentHash": "W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==" + }, "Microsoft.CSharp": { "type": "Direct", "requested": "[4.7.0, )", @@ -386,6 +415,12 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, + "System.Text.Json": { + "type": "Direct", + "requested": "[5.0.0, )", + "resolved": "5.0.0", + "contentHash": "+luxMQNZ2WqeffBU7Ml6njIvxc8169NW2oU+ygNudXQGZiarjE7DOtN7bILiQjTZjkmwwRZGTtLzmdrSI/Ustw==" + }, "GraphQL.Client.Abstractions": { "type": "Transitive", "resolved": "6.0.0", diff --git a/tests/Speckle.Objects.Tests.Unit/ModelPropertySupportedTypes.cs b/tests/Speckle.Objects.Tests.Unit/ModelPropertySupportedTypes.cs index 5820a071..457f8a41 100644 --- a/tests/Speckle.Objects.Tests.Unit/ModelPropertySupportedTypes.cs +++ b/tests/Speckle.Objects.Tests.Unit/ModelPropertySupportedTypes.cs @@ -1,7 +1,6 @@ using System.Drawing; using NUnit.Framework; using Speckle.DoubleNumerics; -using Speckle.Newtonsoft.Json; using Speckle.Sdk.Host; using Speckle.Sdk.Models; using Speckle.Sdk.Serialisation; @@ -68,7 +67,12 @@ public void TestObjects() { foreach ((string _, Type type, List _) in TypeLoader.Types) { - var members = DynamicBase.GetInstanceMembers(type).Where(p => !p.IsDefined(typeof(JsonIgnoreAttribute), true)); + var members = DynamicBase + .GetInstanceMembers(type) + .Where(p => + !p.IsDefined(typeof(Speckle.Newtonsoft.Json.JsonIgnoreAttribute), true) + && !p.IsDefined(typeof(System.Text.Json.Serialization.JsonIgnoreAttribute), true) + ); foreach (var prop in members) { diff --git a/tests/Speckle.Objects.Tests.Unit/packages.lock.json b/tests/Speckle.Objects.Tests.Unit/packages.lock.json index 973a8574..12013a41 100644 --- a/tests/Speckle.Objects.Tests.Unit/packages.lock.json +++ b/tests/Speckle.Objects.Tests.Unit/packages.lock.json @@ -274,13 +274,15 @@ "type": "Project", "dependencies": { "GraphQL.Client": "[6.0.0, )", + "Microsoft.Bcl.AsyncInterfaces": "[5.0.0, )", "Microsoft.CSharp": "[4.7.0, )", "Microsoft.Data.Sqlite": "[7.0.5, )", "Microsoft.Extensions.DependencyInjection.Abstractions": "[2.2.0, )", "Microsoft.Extensions.Logging": "[2.2.0, )", "Speckle.DoubleNumerics": "[4.0.1, )", "Speckle.Newtonsoft.Json": "[13.0.2, )", - "Speckle.Sdk.Dependencies": "[1.0.0, )" + "Speckle.Sdk.Dependencies": "[1.0.0, )", + "System.Text.Json": "[5.0.0, )" } }, "speckle.sdk.dependencies": { @@ -297,6 +299,12 @@ "System.Reactive": "5.0.0" } }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "CentralTransitive", + "requested": "[5.0.0, )", + "resolved": "5.0.0", + "contentHash": "W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==" + }, "Microsoft.CSharp": { "type": "CentralTransitive", "requested": "[4.7.0, )", @@ -342,6 +350,12 @@ "requested": "[13.0.2, )", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "System.Text.Json": { + "type": "CentralTransitive", + "requested": "[5.0.0, )", + "resolved": "5.0.0", + "contentHash": "+luxMQNZ2WqeffBU7Ml6njIvxc8169NW2oU+ygNudXQGZiarjE7DOtN7bILiQjTZjkmwwRZGTtLzmdrSI/Ustw==" } } } diff --git a/tests/Speckle.Sdk.Serialization.Testing/packages.lock.json b/tests/Speckle.Sdk.Serialization.Testing/packages.lock.json index 6f507f12..65a3fa34 100644 --- a/tests/Speckle.Sdk.Serialization.Testing/packages.lock.json +++ b/tests/Speckle.Sdk.Serialization.Testing/packages.lock.json @@ -338,13 +338,15 @@ "type": "Project", "dependencies": { "GraphQL.Client": "[6.0.0, )", + "Microsoft.Bcl.AsyncInterfaces": "[5.0.0, )", "Microsoft.CSharp": "[4.7.0, )", "Microsoft.Data.Sqlite": "[7.0.5, )", "Microsoft.Extensions.DependencyInjection.Abstractions": "[2.2.0, )", "Microsoft.Extensions.Logging": "[2.2.0, )", "Speckle.DoubleNumerics": "[4.0.1, )", "Speckle.Newtonsoft.Json": "[13.0.2, )", - "Speckle.Sdk.Dependencies": "[1.0.0, )" + "Speckle.Sdk.Dependencies": "[1.0.0, )", + "System.Text.Json": "[5.0.0, )" } }, "speckle.sdk.dependencies": { @@ -390,8 +392,8 @@ "Microsoft.Bcl.AsyncInterfaces": { "type": "CentralTransitive", "requested": "[5.0.0, )", - "resolved": "1.1.0", - "contentHash": "1Am6l4Vpn3/K32daEqZI+FFr96OlZkgwK2LcT3pZ2zWubR5zTPW3/FkO1Rat9kb7oQOa4rxgl9LJHc5tspCWfg==" + "resolved": "5.0.0", + "contentHash": "W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==" }, "Microsoft.CSharp": { "type": "CentralTransitive", @@ -438,6 +440,12 @@ "requested": "[13.0.2, )", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "System.Text.Json": { + "type": "CentralTransitive", + "requested": "[5.0.0, )", + "resolved": "5.0.0", + "contentHash": "+luxMQNZ2WqeffBU7Ml6njIvxc8169NW2oU+ygNudXQGZiarjE7DOtN7bILiQjTZjkmwwRZGTtLzmdrSI/Ustw==" } } } diff --git a/tests/Speckle.Sdk.Serialization.Tests/Speckle.Sdk.Serialization.Tests.csproj b/tests/Speckle.Sdk.Serialization.Tests/Speckle.Sdk.Serialization.Tests.csproj index ce4c686e..269646a0 100644 --- a/tests/Speckle.Sdk.Serialization.Tests/Speckle.Sdk.Serialization.Tests.csproj +++ b/tests/Speckle.Sdk.Serialization.Tests/Speckle.Sdk.Serialization.Tests.csproj @@ -13,6 +13,7 @@ + diff --git a/tests/Speckle.Sdk.Serialization.Tests/packages.lock.json b/tests/Speckle.Sdk.Serialization.Tests/packages.lock.json index 973a8574..03e48aa7 100644 --- a/tests/Speckle.Sdk.Serialization.Tests/packages.lock.json +++ b/tests/Speckle.Sdk.Serialization.Tests/packages.lock.json @@ -68,6 +68,12 @@ "resolved": "0.9.6", "contentHash": "HKH7tYrYYlCK1ct483hgxERAdVdMtl7gUKW9ijWXxA1UsYR4Z+TrRHYmzZ9qmpu1NnTycSrp005NYM78GDKV1w==" }, + "Speckle.Newtonsoft.Json": { + "type": "Direct", + "requested": "[13.0.2, )", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, "DiffEngine": { "type": "Transitive", "resolved": "11.3.0", @@ -274,13 +280,15 @@ "type": "Project", "dependencies": { "GraphQL.Client": "[6.0.0, )", + "Microsoft.Bcl.AsyncInterfaces": "[5.0.0, )", "Microsoft.CSharp": "[4.7.0, )", "Microsoft.Data.Sqlite": "[7.0.5, )", "Microsoft.Extensions.DependencyInjection.Abstractions": "[2.2.0, )", "Microsoft.Extensions.Logging": "[2.2.0, )", "Speckle.DoubleNumerics": "[4.0.1, )", "Speckle.Newtonsoft.Json": "[13.0.2, )", - "Speckle.Sdk.Dependencies": "[1.0.0, )" + "Speckle.Sdk.Dependencies": "[1.0.0, )", + "System.Text.Json": "[5.0.0, )" } }, "speckle.sdk.dependencies": { @@ -297,6 +305,12 @@ "System.Reactive": "5.0.0" } }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "CentralTransitive", + "requested": "[5.0.0, )", + "resolved": "5.0.0", + "contentHash": "W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==" + }, "Microsoft.CSharp": { "type": "CentralTransitive", "requested": "[4.7.0, )", @@ -337,11 +351,11 @@ "resolved": "4.0.1", "contentHash": "MzEQ1Im0zTja+tEsdRIk/WlPiKqb22NmTOJcR1ZKm/mz46pezyyID3/wRz6vJUELMpSLnG7LhsxBL+nxbr7V0w==" }, - "Speckle.Newtonsoft.Json": { + "System.Text.Json": { "type": "CentralTransitive", - "requested": "[13.0.2, )", - "resolved": "13.0.2", - "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + "requested": "[5.0.0, )", + "resolved": "5.0.0", + "contentHash": "+luxMQNZ2WqeffBU7Ml6njIvxc8169NW2oU+ygNudXQGZiarjE7DOtN7bILiQjTZjkmwwRZGTtLzmdrSI/Ustw==" } } } diff --git a/tests/Speckle.Sdk.Tests.Integration/packages.lock.json b/tests/Speckle.Sdk.Tests.Integration/packages.lock.json index 8fc495de..99264f73 100644 --- a/tests/Speckle.Sdk.Tests.Integration/packages.lock.json +++ b/tests/Speckle.Sdk.Tests.Integration/packages.lock.json @@ -268,13 +268,15 @@ "type": "Project", "dependencies": { "GraphQL.Client": "[6.0.0, )", + "Microsoft.Bcl.AsyncInterfaces": "[5.0.0, )", "Microsoft.CSharp": "[4.7.0, )", "Microsoft.Data.Sqlite": "[7.0.5, )", "Microsoft.Extensions.DependencyInjection.Abstractions": "[2.2.0, )", "Microsoft.Extensions.Logging": "[2.2.0, )", "Speckle.DoubleNumerics": "[4.0.1, )", "Speckle.Newtonsoft.Json": "[13.0.2, )", - "Speckle.Sdk.Dependencies": "[1.0.0, )" + "Speckle.Sdk.Dependencies": "[1.0.0, )", + "System.Text.Json": "[5.0.0, )" } }, "speckle.sdk.dependencies": { @@ -289,6 +291,7 @@ "NUnit3TestAdapter": "[4.6.0, )", "Shouldly": "[4.2.1, )", "Speckle.DoubleNumerics": "[4.0.1, )", + "Speckle.Newtonsoft.Json": "[13.0.2, )", "Speckle.Sdk": "[1.0.0, )", "altcover": "[8.9.3, )" } @@ -304,6 +307,12 @@ "System.Reactive": "5.0.0" } }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "CentralTransitive", + "requested": "[5.0.0, )", + "resolved": "5.0.0", + "contentHash": "W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==" + }, "Microsoft.CSharp": { "type": "CentralTransitive", "requested": "[4.7.0, )", @@ -358,6 +367,12 @@ "requested": "[13.0.2, )", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "System.Text.Json": { + "type": "CentralTransitive", + "requested": "[5.0.0, )", + "resolved": "5.0.0", + "contentHash": "+luxMQNZ2WqeffBU7Ml6njIvxc8169NW2oU+ygNudXQGZiarjE7DOtN7bILiQjTZjkmwwRZGTtLzmdrSI/Ustw==" } } } diff --git a/tests/Speckle.Sdk.Tests.Performance/packages.lock.json b/tests/Speckle.Sdk.Tests.Performance/packages.lock.json index ee12cf74..70bb80ec 100644 --- a/tests/Speckle.Sdk.Tests.Performance/packages.lock.json +++ b/tests/Speckle.Sdk.Tests.Performance/packages.lock.json @@ -356,13 +356,15 @@ "type": "Project", "dependencies": { "GraphQL.Client": "[6.0.0, )", + "Microsoft.Bcl.AsyncInterfaces": "[5.0.0, )", "Microsoft.CSharp": "[4.7.0, )", "Microsoft.Data.Sqlite": "[7.0.5, )", "Microsoft.Extensions.DependencyInjection.Abstractions": "[2.2.0, )", "Microsoft.Extensions.Logging": "[2.2.0, )", "Speckle.DoubleNumerics": "[4.0.1, )", "Speckle.Newtonsoft.Json": "[13.0.2, )", - "Speckle.Sdk.Dependencies": "[1.0.0, )" + "Speckle.Sdk.Dependencies": "[1.0.0, )", + "System.Text.Json": "[5.0.0, )" } }, "speckle.sdk.dependencies": { @@ -382,8 +384,8 @@ "Microsoft.Bcl.AsyncInterfaces": { "type": "CentralTransitive", "requested": "[5.0.0, )", - "resolved": "1.1.0", - "contentHash": "1Am6l4Vpn3/K32daEqZI+FFr96OlZkgwK2LcT3pZ2zWubR5zTPW3/FkO1Rat9kb7oQOa4rxgl9LJHc5tspCWfg==" + "resolved": "5.0.0", + "contentHash": "W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==" }, "Microsoft.CSharp": { "type": "CentralTransitive", @@ -430,6 +432,12 @@ "requested": "[13.0.2, )", "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, + "System.Text.Json": { + "type": "CentralTransitive", + "requested": "[5.0.0, )", + "resolved": "5.0.0", + "contentHash": "+luxMQNZ2WqeffBU7Ml6njIvxc8169NW2oU+ygNudXQGZiarjE7DOtN7bILiQjTZjkmwwRZGTtLzmdrSI/Ustw==" } } } diff --git a/tests/Speckle.Sdk.Tests.Unit/Host/TestKit.cs b/tests/Speckle.Sdk.Tests.Unit/Host/TestKit.cs index c3cd1b7b..60385f05 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Host/TestKit.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Host/TestKit.cs @@ -1,4 +1,3 @@ -using Speckle.Newtonsoft.Json; using Speckle.Sdk.Models; namespace Speckle.Sdk.Tests.Unit.Host; @@ -105,7 +104,8 @@ public class Mesh : Base { public List Faces = new(); - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public List Points = new(); public List Vertices @@ -132,7 +132,8 @@ public interface ICurve [SpeckleType("Speckle.Core.Tests.Unit.Kits.Polyline")] public class Polyline : Base, ICurve { - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public List Points { get; set; } = new(); public List Vertices diff --git a/tests/Speckle.Sdk.Tests.Unit/Serialisation/JsonIgnoreAttributeTests.cs b/tests/Speckle.Sdk.Tests.Unit/Serialisation/JsonIgnoreAttributeTests.cs index 686245a0..4ab4ddda 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Serialisation/JsonIgnoreAttributeTests.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Serialisation/JsonIgnoreAttributeTests.cs @@ -9,7 +9,7 @@ namespace Speckle.Sdk.Tests.Unit.Serialisation; /// -/// Tests that the leads to properties being ignored both from the final JSON output, +/// Tests that the leads to properties being ignored both from the final JSON output, /// But also from the id calculation /// [TestOf(typeof(SpeckleObjectSerializer))] @@ -86,20 +86,26 @@ public static IEnumerable IgnoredCompoundTestCases() [SpeckleType("Speckle.Sdk.Test.Unit.Serialisation.IgnoredCompoundTest")] public sealed class IgnoredCompoundTest(string ignoredPayload, string expectedPayload) : Base { - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public Base ShouldBeIgnored => new IgnoreTest(ignoredPayload, expectedPayload) { ["override"] = ignoredPayload }; public Base ShouldBeIncluded => new IgnoreTest(ignoredPayload, expectedPayload); - [JsonIgnore, DetachProperty] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] + [DetachProperty] public Base ShouldBeIgnoredDetached => ShouldBeIgnored; [DetachProperty] public Base ShouldBeIncludedDetached => ShouldBeIncluded; - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public List ShouldBeIgnoredList => [ShouldBeIgnored]; - [JsonIgnore, DetachProperty] + [DetachProperty] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public List ShouldBeIgnoredDetachedList => ShouldBeIgnoredList; public List ShouldBeIncludedList => [ShouldBeIncluded]; @@ -111,7 +117,8 @@ public sealed class IgnoredCompoundTest(string ignoredPayload, string expectedPa [SpeckleType("Speckle.Sdk.Tests.Unit.Serialisation.IgnoreTest")] public sealed class IgnoreTest(string shouldBeIgnoredPayload, string shouldBeIncludedPayload) : Base { - [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public string ShouldBeIgnored => shouldBeIgnoredPayload; public string ShouldBeIncluded => shouldBeIncludedPayload; diff --git a/tests/Speckle.Sdk.Tests.Unit/Speckle.Sdk.Tests.Unit.csproj b/tests/Speckle.Sdk.Tests.Unit/Speckle.Sdk.Tests.Unit.csproj index 76529a53..4a0442e5 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Speckle.Sdk.Tests.Unit.csproj +++ b/tests/Speckle.Sdk.Tests.Unit/Speckle.Sdk.Tests.Unit.csproj @@ -14,6 +14,7 @@ + diff --git a/tests/Speckle.Sdk.Tests.Unit/packages.lock.json b/tests/Speckle.Sdk.Tests.Unit/packages.lock.json index 5cb51559..dc667412 100644 --- a/tests/Speckle.Sdk.Tests.Unit/packages.lock.json +++ b/tests/Speckle.Sdk.Tests.Unit/packages.lock.json @@ -83,6 +83,12 @@ "resolved": "0.9.6", "contentHash": "HKH7tYrYYlCK1ct483hgxERAdVdMtl7gUKW9ijWXxA1UsYR4Z+TrRHYmzZ9qmpu1NnTycSrp005NYM78GDKV1w==" }, + "Speckle.Newtonsoft.Json": { + "type": "Direct", + "requested": "[13.0.2, )", + "resolved": "13.0.2", + "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + }, "DiffEngine": { "type": "Transitive", "resolved": "11.3.0", @@ -283,13 +289,15 @@ "type": "Project", "dependencies": { "GraphQL.Client": "[6.0.0, )", + "Microsoft.Bcl.AsyncInterfaces": "[5.0.0, )", "Microsoft.CSharp": "[4.7.0, )", "Microsoft.Data.Sqlite": "[7.0.5, )", "Microsoft.Extensions.DependencyInjection.Abstractions": "[2.2.0, )", "Microsoft.Extensions.Logging": "[2.2.0, )", "Speckle.DoubleNumerics": "[4.0.1, )", "Speckle.Newtonsoft.Json": "[13.0.2, )", - "Speckle.Sdk.Dependencies": "[1.0.0, )" + "Speckle.Sdk.Dependencies": "[1.0.0, )", + "System.Text.Json": "[5.0.0, )" } }, "speckle.sdk.dependencies": { @@ -306,6 +314,12 @@ "System.Reactive": "5.0.0" } }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "CentralTransitive", + "requested": "[5.0.0, )", + "resolved": "5.0.0", + "contentHash": "W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==" + }, "Microsoft.CSharp": { "type": "CentralTransitive", "requested": "[4.7.0, )", @@ -340,11 +354,11 @@ "Microsoft.Extensions.Options": "2.2.0" } }, - "Speckle.Newtonsoft.Json": { + "System.Text.Json": { "type": "CentralTransitive", - "requested": "[13.0.2, )", - "resolved": "13.0.2", - "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" + "requested": "[5.0.0, )", + "resolved": "5.0.0", + "contentHash": "+luxMQNZ2WqeffBU7Ml6njIvxc8169NW2oU+ygNudXQGZiarjE7DOtN7bILiQjTZjkmwwRZGTtLzmdrSI/Ustw==" } } }