diff --git a/.github/workflows/coveralls.yml b/.github/workflows/coveralls.yml index 79558af2..dfb04c3b 100644 --- a/.github/workflows/coveralls.yml +++ b/.github/workflows/coveralls.yml @@ -33,4 +33,4 @@ jobs: uses: coverallsapp/github-action@v2 with: github-token: ${{ github.token }} - files: src/ACadSharp.Tests/TestResults/coverage.info src/CSUtilities/CSUtilities.Tests/TestResults/coverage.info src/CSUtilities/CSMath.Tests/TestResults/coverage.info \ No newline at end of file + files: src/ACadSharp.Tests/TestResults/coverage.net6.0.info src/CSUtilities/CSUtilities.Tests/TestResults/coverage.info src/CSUtilities/CSMath.Tests/TestResults/coverage.info \ No newline at end of file diff --git a/src/ACadSharp.Tests/ACadSharp.Tests.csproj b/src/ACadSharp.Tests/ACadSharp.Tests.csproj index 87ef2728..909e6657 100644 --- a/src/ACadSharp.Tests/ACadSharp.Tests.csproj +++ b/src/ACadSharp.Tests/ACadSharp.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net6.0;net48 true diff --git a/src/ACadSharp.Tests/Common/DocumentIntegrity.cs b/src/ACadSharp.Tests/Common/DocumentIntegrity.cs index af98270b..ed257c2c 100644 --- a/src/ACadSharp.Tests/Common/DocumentIntegrity.cs +++ b/src/ACadSharp.Tests/Common/DocumentIntegrity.cs @@ -88,6 +88,7 @@ public void AssertBlockRecords(CadDocument doc) public void AssertDocumentContent(CadDocument doc) { +#if !NETFRAMEWORK this._document = doc; CadDocumentTree tree = System.Text.Json.JsonSerializer.Deserialize( File.ReadAllText(Path.Combine(_folder, $"{doc.Header.Version}_tree.json")) @@ -105,10 +106,12 @@ public void AssertDocumentContent(CadDocument doc) this.assertTableContent(doc.UCSs, tree.UCSsTable); this.assertTableContent(doc.Views, tree.ViewsTable); this.assertTableContent(doc.VPorts, tree.VPortsTable); +#endif } public void AssertDocumentTree(CadDocument doc) { +#if !NETFRAMEWORK this._document = doc; CadDocumentTree tree = System.Text.Json.JsonSerializer.Deserialize( File.ReadAllText(Path.Combine(_folder, $"{doc.Header.Version}_tree.json")) @@ -116,6 +119,7 @@ public void AssertDocumentTree(CadDocument doc) this.assertTableTree(doc.BlockRecords, tree.BlocksTable); this.assertTableTree(doc.Layers, tree.LayersTable); +#endif } private void assertTable(CadDocument doc, Table table) diff --git a/src/ACadSharp.Tests/Entities/ArcTests.cs b/src/ACadSharp.Tests/Entities/ArcTests.cs index ce201169..713e8dd1 100644 --- a/src/ACadSharp.Tests/Entities/ArcTests.cs +++ b/src/ACadSharp.Tests/Entities/ArcTests.cs @@ -18,15 +18,23 @@ public void CreateFromBulgeTest() XY center = MathUtils.GetCenter(start, end, bulge, out double radius); +#if NETFRAMEWORK + center = MathHelper.FixZero(center); +#endif + Assert.Equal(XY.Zero, center); - Assert.Equal(1, radius); + Assert.Equal(1, radius, TestVariables.DecimalPrecision); Arc arc = Arc.CreateFromBulge(start, end, bulge); +#if NETFRAMEWORK + arc.Center = MathHelper.FixZero(arc.Center); +#endif + Assert.Equal(XYZ.Zero, arc.Center); - Assert.Equal(1, arc.Radius); - Assert.Equal(0, arc.StartAngle); - Assert.Equal(Math.PI / 2, arc.EndAngle); + Assert.Equal(1, arc.Radius, TestVariables.DecimalPrecision); + Assert.Equal(0, arc.StartAngle, TestVariables.DecimalPrecision); + Assert.Equal(Math.PI / 2, arc.EndAngle, TestVariables.DecimalPrecision); } [Fact] @@ -52,14 +60,22 @@ public void GetCenter() XY center = MathUtils.GetCenter(start, end, bulge); +#if NETFRAMEWORK + center = MathHelper.FixZero(center); +#endif + Assert.Equal(XY.Zero, center); Arc arc = Arc.CreateFromBulge(start, end, bulge); +#if NETFRAMEWORK + arc.Center = MathHelper.FixZero(arc.Center); +#endif + Assert.Equal(XYZ.Zero, arc.Center); - Assert.Equal(1, arc.Radius); - Assert.Equal(0, arc.StartAngle); - Assert.Equal(Math.PI / 2, arc.EndAngle); + Assert.Equal(1, arc.Radius, TestVariables.DecimalPrecision); + Assert.Equal(0, arc.StartAngle, TestVariables.DecimalPrecision); + Assert.Equal(Math.PI / 2, arc.EndAngle, TestVariables.DecimalPrecision); } [Fact] diff --git a/src/ACadSharp.Tests/IO/DXF/DxfReaderTests.cs b/src/ACadSharp.Tests/IO/DXF/DxfReaderTests.cs index 0ce31e18..8d4ef764 100644 --- a/src/ACadSharp.Tests/IO/DXF/DxfReaderTests.cs +++ b/src/ACadSharp.Tests/IO/DXF/DxfReaderTests.cs @@ -126,7 +126,7 @@ public override void AssertDocumentTree(FileModel test) doc = reader.Read(); } - if(doc.Header.Version < ACadVersion.AC1012) + if (doc.Header.Version < ACadVersion.AC1012) { //Older version do not keep the handles for tables and other objects like block_records return; @@ -135,6 +135,7 @@ public override void AssertDocumentTree(FileModel test) this._docIntegrity.AssertDocumentTree(doc); } +#if !NETFRAMEWORK [Theory] [MemberData(nameof(DxfAsciiFiles))] [MemberData(nameof(DxfBinaryFiles))] @@ -161,5 +162,6 @@ public void IsBinaryTest(FileModel test) } } } +#endif } } \ No newline at end of file diff --git a/src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs b/src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs index adf78481..b8301937 100644 --- a/src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs +++ b/src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs @@ -1172,7 +1172,7 @@ private CadTemplate readBlockVisibilityParameter() for (int i = 0; i < totalEntitiesCount; i++) { var handle = this.handleReference(); - template.TotalEntityHandles.Add(handle, null); + template.EntityHandles.Add(handle); } // DXF 92 Sub blocks count (no property) diff --git a/src/ACadSharp/IO/Templates/BlockVisibilityParameterTemplate.cs b/src/ACadSharp/IO/Templates/BlockVisibilityParameterTemplate.cs index b5ac7e8f..c74627b4 100644 --- a/src/ACadSharp/IO/Templates/BlockVisibilityParameterTemplate.cs +++ b/src/ACadSharp/IO/Templates/BlockVisibilityParameterTemplate.cs @@ -3,37 +3,43 @@ using ACadSharp.Entities; using ACadSharp.Objects; -namespace ACadSharp.IO.Templates { +namespace ACadSharp.IO.Templates +{ - internal class BlockVisibilityParameterTemplate : CadTemplate { + internal class BlockVisibilityParameterTemplate : CadTemplate + { public BlockVisibilityParameterTemplate(BlockVisibilityParameter cadObject) - : base(cadObject) { + : base(cadObject) + { } - public IDictionary TotalEntityHandles { get; } = new Dictionary(); + public List EntityHandles { get; } = new (); public IDictionary> SubBlockHandles { get; } = new Dictionary>(); - public override void Build(CadDocumentBuilder builder) { + public override void Build(CadDocumentBuilder builder) + { base.Build(builder); - foreach (var cadObjectHandle in this.TotalEntityHandles) { - ulong handle = cadObjectHandle.Key; - if (builder.TryGetCadObject(handle, out Entity entity)) { - this.TotalEntityHandles[handle] = entity; + foreach (var handle in this.EntityHandles) + { + if (builder.TryGetCadObject(handle, out Entity entity)) + { this.CadObject.Entities.Add(entity); } } - foreach (var subGroup in this.CadObject.SubBlocks) { - if (this.SubBlockHandles.TryGetValue(subGroup, out IList subBlockHandles)) { - foreach (ulong handle in subBlockHandles) { - if (this.TotalEntityHandles.TryGetValue(handle, out Entity entity)) { + foreach (var subGroup in this.CadObject.SubBlocks) + { + if (this.SubBlockHandles.TryGetValue(subGroup, out IList subBlockHandles)) + { + foreach (ulong handle in subBlockHandles) + { + if (builder.TryGetCadObject(handle, out Entity entity)) + { subGroup.Entities.Add(entity); } - else if (builder.TryGetCadObject(handle, out Entity entityX)) { - } } } } diff --git a/src/ACadSharp/MathUtils.cs b/src/ACadSharp/MathUtils.cs index 5f9af3ef..effb2c87 100644 --- a/src/ACadSharp/MathUtils.cs +++ b/src/ACadSharp/MathUtils.cs @@ -3,6 +3,7 @@ namespace ACadSharp { + [Obsolete("Use CSMath.MathHelper instead.")] public static class MathUtils { /// diff --git a/src/CSUtilities b/src/CSUtilities index 6c803a09..84df804d 160000 --- a/src/CSUtilities +++ b/src/CSUtilities @@ -1 +1 @@ -Subproject commit 6c803a09bcfdcc8a5aa3fc40fb5ec2f794cf373d +Subproject commit 84df804dbcf5dd93138568b75fa36124ff5cdd60