Skip to content

Commit d2df0c8

Browse files
authored
Merge pull request #516 from DomCR/issue-515_net-framework-fix
Issue 515 net framework fix
2 parents 41c47b7 + f1515dc commit d2df0c8

File tree

9 files changed

+56
-27
lines changed

9 files changed

+56
-27
lines changed

.github/workflows/coveralls.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ jobs:
3333
uses: coverallsapp/github-action@v2
3434
with:
3535
github-token: ${{ github.token }}
36-
files: src/ACadSharp.Tests/TestResults/coverage.info src/CSUtilities/CSUtilities.Tests/TestResults/coverage.info src/CSUtilities/CSMath.Tests/TestResults/coverage.info
36+
files: src/ACadSharp.Tests/TestResults/coverage.net6.0.info src/CSUtilities/CSUtilities.Tests/TestResults/coverage.info src/CSUtilities/CSMath.Tests/TestResults/coverage.info

src/ACadSharp.Tests/ACadSharp.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFrameworks>net6.0;net48</TargetFrameworks>
55

66
<!-- Enable the MSTest runner, this is an opt-in feature -->
77
<EnableMSTestRunner>true</EnableMSTestRunner>

src/ACadSharp.Tests/Common/DocumentIntegrity.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public void AssertBlockRecords(CadDocument doc)
8888

8989
public void AssertDocumentContent(CadDocument doc)
9090
{
91+
#if !NETFRAMEWORK
9192
this._document = doc;
9293
CadDocumentTree tree = System.Text.Json.JsonSerializer.Deserialize<CadDocumentTree>(
9394
File.ReadAllText(Path.Combine(_folder, $"{doc.Header.Version}_tree.json"))
@@ -105,17 +106,20 @@ public void AssertDocumentContent(CadDocument doc)
105106
this.assertTableContent(doc.UCSs, tree.UCSsTable);
106107
this.assertTableContent(doc.Views, tree.ViewsTable);
107108
this.assertTableContent(doc.VPorts, tree.VPortsTable);
109+
#endif
108110
}
109111

110112
public void AssertDocumentTree(CadDocument doc)
111113
{
114+
#if !NETFRAMEWORK
112115
this._document = doc;
113116
CadDocumentTree tree = System.Text.Json.JsonSerializer.Deserialize<CadDocumentTree>(
114117
File.ReadAllText(Path.Combine(_folder, $"{doc.Header.Version}_tree.json"))
115118
);
116119

117120
this.assertTableTree(doc.BlockRecords, tree.BlocksTable);
118121
this.assertTableTree(doc.Layers, tree.LayersTable);
122+
#endif
119123
}
120124

121125
private void assertTable<T>(CadDocument doc, Table<T> table)

src/ACadSharp.Tests/Entities/ArcTests.cs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,23 @@ public void CreateFromBulgeTest()
1818

1919
XY center = MathUtils.GetCenter(start, end, bulge, out double radius);
2020

21+
#if NETFRAMEWORK
22+
center = MathHelper.FixZero(center);
23+
#endif
24+
2125
Assert.Equal(XY.Zero, center);
22-
Assert.Equal(1, radius);
26+
Assert.Equal(1, radius, TestVariables.DecimalPrecision);
2327

2428
Arc arc = Arc.CreateFromBulge(start, end, bulge);
2529

30+
#if NETFRAMEWORK
31+
arc.Center = MathHelper.FixZero(arc.Center);
32+
#endif
33+
2634
Assert.Equal(XYZ.Zero, arc.Center);
27-
Assert.Equal(1, arc.Radius);
28-
Assert.Equal(0, arc.StartAngle);
29-
Assert.Equal(Math.PI / 2, arc.EndAngle);
35+
Assert.Equal(1, arc.Radius, TestVariables.DecimalPrecision);
36+
Assert.Equal(0, arc.StartAngle, TestVariables.DecimalPrecision);
37+
Assert.Equal(Math.PI / 2, arc.EndAngle, TestVariables.DecimalPrecision);
3038
}
3139

3240
[Fact]
@@ -52,14 +60,22 @@ public void GetCenter()
5260

5361
XY center = MathUtils.GetCenter(start, end, bulge);
5462

63+
#if NETFRAMEWORK
64+
center = MathHelper.FixZero(center);
65+
#endif
66+
5567
Assert.Equal(XY.Zero, center);
5668

5769
Arc arc = Arc.CreateFromBulge(start, end, bulge);
5870

71+
#if NETFRAMEWORK
72+
arc.Center = MathHelper.FixZero(arc.Center);
73+
#endif
74+
5975
Assert.Equal(XYZ.Zero, arc.Center);
60-
Assert.Equal(1, arc.Radius);
61-
Assert.Equal(0, arc.StartAngle);
62-
Assert.Equal(Math.PI / 2, arc.EndAngle);
76+
Assert.Equal(1, arc.Radius, TestVariables.DecimalPrecision);
77+
Assert.Equal(0, arc.StartAngle, TestVariables.DecimalPrecision);
78+
Assert.Equal(Math.PI / 2, arc.EndAngle, TestVariables.DecimalPrecision);
6379
}
6480

6581
[Fact]

src/ACadSharp.Tests/IO/DXF/DxfReaderTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public override void AssertDocumentTree(FileModel test)
126126
doc = reader.Read();
127127
}
128128

129-
if(doc.Header.Version < ACadVersion.AC1012)
129+
if (doc.Header.Version < ACadVersion.AC1012)
130130
{
131131
//Older version do not keep the handles for tables and other objects like block_records
132132
return;
@@ -135,6 +135,7 @@ public override void AssertDocumentTree(FileModel test)
135135
this._docIntegrity.AssertDocumentTree(doc);
136136
}
137137

138+
#if !NETFRAMEWORK
138139
[Theory]
139140
[MemberData(nameof(DxfAsciiFiles))]
140141
[MemberData(nameof(DxfBinaryFiles))]
@@ -161,5 +162,6 @@ public void IsBinaryTest(FileModel test)
161162
}
162163
}
163164
}
165+
#endif
164166
}
165167
}

src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,7 @@ private CadTemplate readBlockVisibilityParameter()
11721172
for (int i = 0; i < totalEntitiesCount; i++)
11731173
{
11741174
var handle = this.handleReference();
1175-
template.TotalEntityHandles.Add(handle, null);
1175+
template.EntityHandles.Add(handle);
11761176
}
11771177

11781178
// DXF 92 Sub blocks count (no property)

src/ACadSharp/IO/Templates/BlockVisibilityParameterTemplate.cs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,43 @@
33
using ACadSharp.Entities;
44
using ACadSharp.Objects;
55

6-
namespace ACadSharp.IO.Templates {
6+
namespace ACadSharp.IO.Templates
7+
{
78

8-
internal class BlockVisibilityParameterTemplate : CadTemplate<BlockVisibilityParameter> {
9+
internal class BlockVisibilityParameterTemplate : CadTemplate<BlockVisibilityParameter>
10+
{
911

1012
public BlockVisibilityParameterTemplate(BlockVisibilityParameter cadObject)
11-
: base(cadObject) {
13+
: base(cadObject)
14+
{
1215
}
1316

14-
public IDictionary<ulong, Entity> TotalEntityHandles { get; } = new Dictionary<ulong, Entity>();
17+
public List<ulong> EntityHandles { get; } = new ();
1518

1619
public IDictionary<BlockVisibilityParameter.SubBlock, IList<ulong>> SubBlockHandles { get; } = new Dictionary<BlockVisibilityParameter.SubBlock, IList<ulong>>();
1720

18-
public override void Build(CadDocumentBuilder builder) {
21+
public override void Build(CadDocumentBuilder builder)
22+
{
1923
base.Build(builder);
2024

21-
foreach (var cadObjectHandle in this.TotalEntityHandles) {
22-
ulong handle = cadObjectHandle.Key;
23-
if (builder.TryGetCadObject(handle, out Entity entity)) {
24-
this.TotalEntityHandles[handle] = entity;
25+
foreach (var handle in this.EntityHandles)
26+
{
27+
if (builder.TryGetCadObject(handle, out Entity entity))
28+
{
2529
this.CadObject.Entities.Add(entity);
2630
}
2731
}
2832

29-
foreach (var subGroup in this.CadObject.SubBlocks) {
30-
if (this.SubBlockHandles.TryGetValue(subGroup, out IList<ulong> subBlockHandles)) {
31-
foreach (ulong handle in subBlockHandles) {
32-
if (this.TotalEntityHandles.TryGetValue(handle, out Entity entity)) {
33+
foreach (var subGroup in this.CadObject.SubBlocks)
34+
{
35+
if (this.SubBlockHandles.TryGetValue(subGroup, out IList<ulong> subBlockHandles))
36+
{
37+
foreach (ulong handle in subBlockHandles)
38+
{
39+
if (builder.TryGetCadObject(handle, out Entity entity))
40+
{
3341
subGroup.Entities.Add(entity);
3442
}
35-
else if (builder.TryGetCadObject(handle, out Entity entityX)) {
36-
}
3743
}
3844
}
3945
}

src/ACadSharp/MathUtils.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace ACadSharp
55
{
6+
[Obsolete("Use CSMath.MathHelper instead.")]
67
public static class MathUtils
78
{
89
/// <summary>

src/CSUtilities

0 commit comments

Comments
 (0)