Repository navigation
Read full-width packed 16- and 32-bit integers little-endian - #41
Merged
Merged
Conversation
The full-width form of packed shorts and packed integers was read with its bytes reversed. Entity records that store a colour, extended data size or reactor count in that form were then decoded from the wrong bit position, which failed the record or produced NaN and absurd coordinates. Read both forms byte by byte, low byte first, as raw 32-bit integers already are. Tests cover the full-width forms (aligned and unaligned), the unchanged short forms, and the object type of pre-R2010 records, which goes through the same reader. Fixes #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes and why
Fixes #7. The full-width form (tag 00) of packed shorts and packed integers was read with
ReadBits(16)/ReadBits(32), which puts the first byte in the most significant position. These values are stored little-endian. Entity records that hold a colour, extended data size or reactor count in that form were then decoded from the wrong bit position. Such records failed, or decoded with NaN, infinite or absurd coordinates. Some JSON exports failed on the NaN values.ReadPackedShortandReadPackedIntnow read the full-width form byte by byte, low byte first, the same wayReadRawUInt32reads raw integers. The short forms (tags 01, 10, 11) are unchanged. The object type of pre-R2010 records goes throughReadPackedShortand is corrected as well.Tests added in
BitReaderTests:Four of the new tests fail on the old reader. The short-form test passes on both.
How it was checked
dotnet build DwgIO.slnx -c Releasehas no warningsdotnet testpasses: 69 passed and 7 skipped (fixture tests) on net8.0 and net10.0. With private drawings, the same 7 fixture tests fail as onmain, for already known reasons: AppInfo is read as two fixed entries, so one-entry drawings fail and Version stays empty #11, AcDb:Classes is rejected when its declared size is a few bytes larger than its pages hold #12 and Fixture tests fail when DWGIO_TEST_FILES contains drawings of an unsupported version #17.dwgio inspectoutput of the same drawings before and after are identical, or the differences are listed and intended:inspect.Notes for review: