Skip to content

Read AppInfo entries by identifier instead of fixed positions - #46

Merged
mahach666 merged 1 commit into
mainfrom
fix/11-appinfo-entries
Nov 16, 2026
Merged

mahach666 merged 1 commit into
mainfrom
fix/11-appinfo-entries

Conversation

@mahach666

Copy link
Copy Markdown
Contributor

Fixes #11

Problem

The UTF-16 AcDb:AppInfo layout stores a 32-bit entry count followed by that many entries, each a 16-byte identifier and a length-prefixed string. AppInfoParser.TryParseUnicode assumed exactly one notice entry and one product XML entry and skipped the identifiers as checksums. Sections with one entry (notice only) ran past the end, the ANSI fallback threw, and the section was reported as truncated. Sections that did parse took Version from the XML build_version, so DwgAppInfo.Version stayed empty even when the file had a dedicated version entry.

Change

  • Read the declared entry count and loop over the entries.
  • Map each string by its 16-byte identifier: version (1BD848F3...), notice (B8D0F025...) and product XML (E8E09651...).
  • Skip unknown identifiers instead of treating them as fixed positions.
  • Version now comes from the version entry; the XML build_version attribute remains the fallback when the entry is absent.
  • A genuinely truncated section still throws, so the document-level truncation diagnostic is unchanged.

Tests

  • Synthetic one-entry section with a notice only parses without falling back to ANSI.
  • Three-entry section maps version, notice and product XML correctly.
  • Entry order does not matter, and the explicit version entry wins over the XML attribute.
  • Unknown identifiers are skipped.
  • The existing XML-fallback test now uses the real identifiers.

Verification

  • dotnet build DwgIO.slnx -c Release: succeeded.
  • dotnet test DwgIO.slnx -c Release --no-build with the AC1024 sample folder: 80 passed, 0 skipped, 0 failed on net8.0 and net10.0.
  • AppInfo_IdentifiesProducer against 668 supported drawings (AC1024/AC1027/AC1032) from C:\Users\maxah\Downloads: passed on net8.0 and net10.0.
  • The 698-file AppInfo scan covered counts 1/2/3, all three identifiers, and entries in varying order; the R2007-only files that the container does not support yet were excluded from the fixture run.

The UTF-16 AppInfo layout stores an entry count followed by 16-byte identifier and string pairs. The parser assumed exactly one comment and one product XML entry, so one-entry sections ran past the end and Version stayed empty when the version entry was present.

Loop over the declared count, map version, notice and product XML by their stable identifiers, skip unknown entries, and fall back to the XML build_version when no version entry exists.
@mahach666
mahach666 merged commit 0cd2f8b into main Nov 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AppInfo is read as two fixed entries, so one-entry drawings fail and Version stays empty

1 participant