• 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/CRC32StreamHandler.cs
1
using System.IO;
2

3
namespace ACadSharp.IO.DWG
4
{
5
        internal class CRC32StreamHandler : Stream
6
        {
7
                public override bool CanRead => _stream.CanRead;
×
UNCOV
8
                public override bool CanSeek => _stream.CanSeek;
×
9
                public override bool CanWrite => _stream.CanWrite;
×
10
                public override long Length => _stream.Length;
×
11
                public override long Position
12
                {
UNCOV
13
                        get => _stream.Position;
×
UNCOV
14
                        set => _stream.Position = value;
×
15
                }
16

17
                private Stream _stream;
18

UNCOV
19
                public uint Seed => ~_seed;
×
20

21
                private uint _seed;
22

23
                /// <summary>
24
                /// Constructor that creates a magic sequence given an array of bytes.
25
                /// </summary>
26
                /// <param name="arr">Array of 108 bytes</param>
27
                /// <param name="seed"></param>
UNCOV
28
                public CRC32StreamHandler(byte[] arr, uint seed)
×
UNCOV
29
                {
×
UNCOV
30
                        int randSeed = 1;
×
31

UNCOV
32
                        for (int index = 0; index < arr.Length; ++index)
×
UNCOV
33
                        {
×
UNCOV
34
                                randSeed *= 0x343fd;
×
UNCOV
35
                                randSeed += 0x269ec3;
×
36

UNCOV
37
                                byte values = (byte)(randSeed >> 0x10);
×
UNCOV
38
                                arr[index] = (byte)(arr[index] ^ (uint)values);
×
UNCOV
39
                        }
×
40

UNCOV
41
                        _stream = new MemoryStream(arr);
×
42

UNCOV
43
                        _seed = ~seed;
×
UNCOV
44
                }
×
45

UNCOV
46
                public CRC32StreamHandler(Stream stream, uint seed)
×
UNCOV
47
                {
×
UNCOV
48
                        _stream = stream;
×
49
                        //Reverse the bits
UNCOV
50
                        _seed = ~seed;
×
UNCOV
51
                }
×
52

53
                public override void Flush()
UNCOV
54
                {
×
UNCOV
55
                        _stream.Flush();
×
UNCOV
56
                }
×
57

58
                public override int Read(byte[] buffer, int offset, int count)
UNCOV
59
                {
×
UNCOV
60
                        int nbytes = _stream.Read(buffer, offset, count);
×
UNCOV
61
                        int length = offset + count;
×
62

UNCOV
63
                        for (int index = offset; index < length; ++index)
×
UNCOV
64
                        {
×
UNCOV
65
                                _seed = _seed >> 8 ^ CRC.Crc32Table[((int)_seed ^ buffer[index]) & byte.MaxValue];
×
UNCOV
66
                        }
×
67

UNCOV
68
                        return nbytes;
×
UNCOV
69
                }
×
70
                
71
                public override long Seek(long offset, SeekOrigin origin)
72
                {
×
73
                        return _stream.Seek(offset, origin);
×
74
                }
×
75
                
76
                public override void SetLength(long value)
77
                {
×
78
                        _stream.SetLength(value);
×
79
                }
×
80

81
                public override void Write(byte[] buffer, int offset, int count)
UNCOV
82
                {
×
UNCOV
83
                        int num = offset + count;
×
84

UNCOV
85
                        for (int index = offset; index < num; ++index)
×
UNCOV
86
                                _seed = _seed >> 8 ^ CRC.Crc32Table[((int)_seed ^ buffer[index]) & byte.MaxValue];
×
87

UNCOV
88
                        _stream.Write(buffer, offset, count);
×
UNCOV
89
                }
×
90
        }
91
}
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