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

DomCR / ACadSharp / 12619114630

05 Jan 2025 11:27AM UTC coverage: 75.645% (+0.6%) from 75.001%
12619114630

Pull #490

github

web-flow
Merge 01b5ca4aa into 0d0db0394
Pull Request #490: Issue 474 header defaults

5217 of 7612 branches covered (68.54%)

Branch coverage included in aggregate %.

129 of 157 new or added lines in 5 files covered. (82.17%)

581 existing lines in 13 files now uncovered.

20882 of 26890 relevant lines covered (77.66%)

39172.96 hits per line

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

88.64
/src/ACadSharp/IO/DXF/DxfStreamReader/DxfStreamReaderBase.cs
1
using ACadSharp.Exceptions;
2
using System;
3
using System.IO;
4

5
namespace ACadSharp.IO.DXF
6
{
7
        internal abstract class DxfStreamReaderBase : IDxfStreamReader
8
        {
9
                public DxfCode DxfCode { get; protected set; }
18,856,468✔
10

11
                public GroupCodeValueType GroupCodeValue { get; protected set; }
7,343,667✔
12

13
                public int Code { get { return (int)this.DxfCode; } }
31,261,512✔
14

15
                public object Value { get; protected set; }
6,782,676✔
16

17
                public virtual int Position { get; protected set; }
3,516,680✔
18

19
                public string ValueRaw { get; protected set; }
8,346,692✔
20

21
                public string ValueAsString
22
                {
23
                        get
24
                        {
1,446,021✔
25
                                return this.Value.ToString()
1,446,021✔
26
                                        .Replace("^J", "\n")
1,446,021✔
27
                                        .Replace("^M", "\r")
1,446,021✔
28
                                        .Replace("^I", "\t")
1,446,021✔
29
                                        .Replace("^ ", "^");
1,446,021✔
30
                        }
1,446,021✔
31
                }
32

33
                public bool ValueAsBool { get { return Convert.ToBoolean(this.Value); } }
58,737✔
34

35
                public short ValueAsShort { get { return Convert.ToInt16(this.Value); } }
94,077✔
36

37
                public ushort ValueAsUShort { get { return Convert.ToUInt16(this.Value); } }
21,597✔
38

39
                public int ValueAsInt { get { return Convert.ToInt32(this.Value); } }
568,119✔
40

41
                public long ValueAsLong { get { return Convert.ToInt64(this.Value); } }
×
42

43
                public double ValueAsDouble { get { return Convert.ToDouble(this.Value); } }
432,633✔
44

45
                public double ValueAsAngle { get { return (double)(Convert.ToDouble(this.Value) * MathUtils.RadToDegFactor); } }
2,376✔
46

47
                public ulong ValueAsHandle { get { return (ulong)this.Value; } }
706,578✔
48

49
                public byte[] ValueAsBinaryChunk { get { return this.Value as byte[]; } }
6✔
50

51
                protected abstract Stream baseStream { get; }
52

53
                public virtual void ReadNext()
54
                {
3,410,818✔
55
                        this.DxfCode = this.readCode();
3,410,818✔
56
                        this.GroupCodeValue = ACadSharp.GroupCodeValue.TransformValue(this.Code);
3,410,818✔
57
                        this.Value = this.transformValue(this.GroupCodeValue);
3,410,818✔
58
                }
3,410,818✔
59

60
                public bool Find(string dxfEntry)
61
                {
276✔
62
                        this.Start();
276✔
63

64
                        do
65
                        {
96,621✔
66
                                this.ReadNext();
96,621✔
67
                        }
96,621✔
68
                        while (this.ValueAsString != dxfEntry && (this.ValueAsString != DxfFileToken.EndOfFile));
96,621✔
69

70
                        return this.ValueAsString == dxfEntry;
276✔
71
                }
276✔
72

73
                public void ExpectedCode(int code)
74
                {
174✔
75
                        this.ReadNext();
174✔
76

77
                        if (this.Code != code)
174!
UNCOV
78
                        {
×
UNCOV
79
                                throw new DxfException(code, this.Position);
×
80
                        }
81
                }
174✔
82

83
                public override string ToString()
UNCOV
84
                {
×
UNCOV
85
                        return $"{Code} | {Value}";
×
UNCOV
86
                }
×
87

88
                public virtual void Start()
89
                {
716✔
90
                        this.DxfCode = DxfCode.Invalid;
716✔
91
                        this.Value = string.Empty;
716✔
92

93
                        this.baseStream.Position = 0;
716✔
94

95
                        this.Position = 0;
716✔
96
                }
716✔
97

98
                protected abstract DxfCode readCode();
99

100
                protected abstract string readStringLine();
101

102
                protected abstract double lineAsDouble();
103

104
                protected abstract short lineAsShort();
105

106
                protected abstract int lineAsInt();
107

108
                protected abstract long lineAsLong();
109

110
                protected abstract ulong lineAsHandle();
111

112
                protected abstract byte[] lineAsBinaryChunk();
113

114
                protected abstract bool lineAsBool();
115

116
                private object transformValue(GroupCodeValueType code)
117
                {
3,410,818✔
118
                        switch (code)
3,410,818!
119
                        {
120
                                case GroupCodeValueType.String:
121
                                case GroupCodeValueType.Comment:
122
                                case GroupCodeValueType.ExtendedDataString:
123
                                        return this.readStringLine();
1,040,560✔
124
                                case GroupCodeValueType.Point3D:
125
                                case GroupCodeValueType.Double:
126
                                case GroupCodeValueType.ExtendedDataDouble:
127
                                        return this.lineAsDouble();
861,314✔
128
                                case GroupCodeValueType.Byte:
129
                                case GroupCodeValueType.Int16:
130
                                case GroupCodeValueType.ExtendedDataInt16:
131
                                        return this.lineAsShort();
653,044✔
132
                                case GroupCodeValueType.Int32:
133
                                case GroupCodeValueType.ExtendedDataInt32:
134
                                        return this.lineAsInt();
453,817✔
135
                                case GroupCodeValueType.Int64:
136
                                        return this.lineAsLong();
459✔
137
                                case GroupCodeValueType.Handle:
138
                                case GroupCodeValueType.ObjectId:
139
                                case GroupCodeValueType.ExtendedDataHandle:
140
                                        return this.lineAsHandle();
319,861✔
141
                                case GroupCodeValueType.Bool:
142
                                        return this.lineAsBool();
32,615✔
143
                                case GroupCodeValueType.Chunk:
144
                                case GroupCodeValueType.ExtendedDataChunk:
145
                                        return this.lineAsBinaryChunk();
49,148✔
146
                                case GroupCodeValueType.None:
147
                                default:
UNCOV
148
                                        throw new DxfException((int)code, this.Position);
×
149
                        }
150
                }
3,410,818✔
151
        }
152
}
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