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

DomCR / ACadSharp / 17737836230

15 Sep 2025 03:12PM UTC coverage: 2.092% (-76.2%) from 78.245%
17737836230

push

github

web-flow
Merge pull request #790 from DomCR/addflag-refactor

addflag refactor

141 of 9225 branches covered (1.53%)

Branch coverage included in aggregate %.

0 of 93 new or added lines in 10 files covered. (0.0%)

24910 existing lines in 372 files now uncovered.

724 of 32119 relevant lines covered (2.25%)

5.76 hits per line

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

0.0
/src/ACadSharp/IO/DWG/CRC8StreamHandler.cs
1
using System.IO;
2

3
namespace ACadSharp.IO.DWG
4
{
5
        /// <summary>
6
        /// The DWG file format uses a modification of a standard cyclic redundancy check as an error detecting mechanism. <br/>
7
        /// This class checks the integrity of the file using this check.
8
        /// </summary>
9
        /// <remarks>
10
        /// This method is used extensively in pre-R13 files, but seems only to be used in the header for R13 and beyond.
11
        /// </remarks>
12
        internal class CRC8StreamHandler : Stream
13
        {
14
                public override bool CanRead => this._stream.CanRead;
×
15

UNCOV
16
                public override bool CanSeek => this._stream.CanSeek;
×
17

18
                public override bool CanWrite => this._stream.CanWrite;
×
19

20
                public override long Length => this._stream.Length;
×
21

22
                public override long Position
23
                {
UNCOV
24
                        get => this._stream.Position;
×
UNCOV
25
                        set => this._stream.Position = value;
×
26
                }
27

UNCOV
28
                public ushort Seed { get; private set; }
×
29

30
                private Stream _stream;
31

UNCOV
32
                public CRC8StreamHandler(Stream stream, ushort seed)
×
UNCOV
33
                {
×
UNCOV
34
                        this._stream = stream;
×
UNCOV
35
                        this.Seed = seed;
×
UNCOV
36
                }
×
37

38
                public override int Read(byte[] buffer, int offset, int count)
39
                {
×
40
                        int nbytes = this._stream.Read(buffer, offset, count);
×
41
                        int length = offset + count;
×
42

43
                        for (int index = offset; index < length; ++index)
×
44
                                this.Seed = decode(this.Seed, buffer[index]);
×
45

46
                        return nbytes;
×
47
                }
×
48

49
                public override void Flush() => this._stream.Flush();
×
50

51
                public override long Seek(long offset, SeekOrigin origin) => this._stream.Seek(offset, origin);
×
52

53
                public override void SetLength(long value) => this._stream.SetLength(value);
×
54

55
                public override void Write(byte[] buffer, int offset, int count)
UNCOV
56
                {
×
UNCOV
57
                        int length = offset + count;
×
58

UNCOV
59
                        for (int index = offset; index < length; ++index)
×
UNCOV
60
                                this.Seed = decode(this.Seed, buffer[index]);
×
61

UNCOV
62
                        this._stream.Write(buffer, offset, count);
×
UNCOV
63
                }
×
64

65
                public static ushort GetCRCValue(ushort seed, byte[] buffer, long startPos, long endPos)
UNCOV
66
                {
×
UNCOV
67
                        ushort currValue = seed;
×
UNCOV
68
                        int index = (int)startPos;
×
69

UNCOV
70
                        while (endPos-- > 0)
×
UNCOV
71
                        {
×
UNCOV
72
                                currValue = CRC8StreamHandler.decode(currValue, buffer[index]);
×
UNCOV
73
                                index++;
×
UNCOV
74
                        }
×
75

UNCOV
76
                        return currValue;
×
UNCOV
77
                }
×
78

79
                private static ushort decode(ushort key, byte value)
UNCOV
80
                {
×
UNCOV
81
                        int index = value ^ (byte)key;
×
UNCOV
82
                        key = (ushort)((uint)key >> 8 ^ CRC.CrcTable[index]);
×
UNCOV
83
                        return key;
×
UNCOV
84
                }
×
85
        }
86
}
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