• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DomCR / ACadSharp / 17971803124

24 Sep 2025 09:02AM UTC coverage: 75.575% (-2.9%) from 78.47%
17971803124

Pull #191

github

web-flow
Merge ed758394e into 3e0fc6cad
Pull Request #191: Solid3D entity

6490 of 9325 branches covered (69.6%)

Branch coverage included in aggregate %.

43 of 319 new or added lines in 10 files covered. (13.48%)

756 existing lines in 15 files now uncovered.

25073 of 32439 relevant lines covered (77.29%)

107448.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.96
/src/ACadSharp/IO/DXF/DxfStreamWriter/DxfStreamWriterBase.cs
1
using CSMath;
2
using CSUtilities.Converters;
3
using System;
4

5

6
namespace ACadSharp.IO.DXF
7
{
8
        internal abstract class DxfStreamWriterBase : IDxfStreamWriter
9
        {
10
                public bool WriteOptional { get; set; } = false;
3,412✔
11

12
                public void Write(DxfCode code, object value, DxfClassMap map = null)
13
                {
147,909✔
14
                        this.Write((int)code, value, map);
147,909✔
15
                }
147,909✔
16

17
                public void Write(DxfCode code, CSMath.IVector value, DxfClassMap map = null)
UNCOV
18
                {
×
UNCOV
19
                        this.Write((int)code, value, map);
×
UNCOV
20
                }
×
21

22
                public void Write(int code, CSMath.IVector value, DxfClassMap map = null)
23
                {
9,407✔
24
                        for (int i = 0; i < value.Dimension; i++)
68,612✔
25
                        {
24,899✔
26
                                this.Write(code + i * 10, value[i], map);
24,899✔
27
                        }
24,899✔
28
                }
9,407✔
29

30
                public void WriteTrueColor(int code, Color color, DxfClassMap map = null)
31
                {
141✔
32
                        byte[] arr = new byte[4];
141✔
33
                        arr[0] = (byte)color.B;
141✔
34
                        arr[1] = (byte)color.G;
141✔
35
                        arr[2] = (byte)color.R;
141✔
36
                        arr[3] = 0;
141✔
37

38
                        this.Write(code, LittleEndianConverter.Instance.ToInt32(arr), map);
141✔
39
                }
141✔
40

41
                public void WriteCmColor(int code, Color color, DxfClassMap map = null)
42
                {
945✔
43
                        if (GroupCodeValue.TransformValue(code) == GroupCodeValueType.Int16)
945!
44
                        {
×
45
                                //BS: Color Index
46
                                this.Write(code, Convert.ToInt16(color.GetApproxIndex()));
×
47
                        }
×
48
                        else
49
                        {
945✔
50
                                byte[] arr = new byte[4];
945✔
51

52
                                if (color.IsTrueColor)
945!
UNCOV
53
                                {
×
UNCOV
54
                                        arr[0] = (byte)color.B;
×
UNCOV
55
                                        arr[1] = (byte)color.G;
×
UNCOV
56
                                        arr[2] = (byte)color.R;
×
UNCOV
57
                                        arr[3] = 0b1100_0010;   //        0xC2
×
UNCOV
58
                                }
×
59
                                else
60
                                {
945✔
61
                                        arr[3] = 0b1100_0001;
945✔
62
                                        arr[0] = (byte)color.Index;
945✔
63
                                }
945✔
64

65
                                //BL: RGB value
66
                                this.Write(code, LittleEndianConverter.Instance.ToInt32(arr), map);
945✔
67
                        }
945✔
68
                }
945✔
69

70
                public void WriteHandle(int code, IHandledCadObject value, DxfClassMap map = null)
71
                {
5,747✔
72
                        if (value != null)
5,747✔
73
                        {
2,627✔
74
                                this.Write(code, value.Handle, map);
2,627✔
75
                        }
2,627✔
76
                }
5,747✔
77

78
                public void WriteName(int code, INamedCadObject value, DxfClassMap map = null)
79
                {
62✔
80
                        if (value != null)
62✔
81
                        {
50✔
82
                                this.Write(code, value.Name, map);
50✔
83
                        }
50✔
84
                }
62✔
85

86
                public void Write(int code, object value, DxfClassMap map = null)
87
                {
452,693✔
88
                        if (value == null)
452,693✔
89
                        {
4,252✔
90
                                return;
4,252✔
91
                        }
92

93
                        if (map != null && map.DxfProperties.TryGetValue(code, out DxfProperty prop))
448,441✔
94
                        {
90,210✔
95
                                if (prop.ReferenceType.HasFlag(DxfReferenceType.Optional) && !WriteOptional)
90,210!
96
                                {
×
97
                                        return;
×
98
                                }
99

100
                                if (prop.ReferenceType.HasFlag(DxfReferenceType.IsAngle))
90,210✔
101
                                {
1,959✔
102
                                        value = MathHelper.RadToDeg((double)value);
1,959✔
103
                                }
1,959✔
104
                        }
90,210✔
105

106
                        this.writeDxfCode(code);
448,441✔
107

108
                        if (value is string s)
448,441✔
109
                        {
172,571✔
110
                                s = s
172,571✔
111
                                        .Replace("^", "^ ")
172,571✔
112
                                        .Replace("\n", "^J")
172,571✔
113
                                        .Replace("\r", "^M")
172,571✔
114
                                        .Replace("\t", "^I");
172,571✔
115
                                this.writeValue(code, s);
172,571✔
116
                        }
172,571✔
117
                        else
118
                        {
275,870✔
119
                                this.writeValue(code, value);
275,870✔
120
                        }
275,870✔
121
                }
452,693✔
122

123
                /// <inheritdoc/>
124
                public abstract void Dispose();
125

126
                public abstract void Flush();
127

128
                public abstract void Close();
129

130
                protected abstract void writeDxfCode(int code);
131

132
                protected abstract void writeValue(int code, object value);
133
        }
134
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc