Skip to content

Align the engine with the IOExtend architecture and fix row text decoding - #45

Merged
mahach666 merged 4 commits into
mainfrom
feat/native-core-and-row-text
Nov 27, 2026
Merged

mahach666 merged 4 commits into
mainfrom
feat/native-core-and-row-text

Conversation

@mahach666

@mahach666 mahach666 commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

What changes and why

Native engine and IFC output. The organization's architecture keeps native decoding in the engine and target-format output apart. RvtIO and NwcIO compile the native engine and its scene adapter without the export sources; this change makes the same split.

  • The IFC output moves to src/TdbIO/Ifc: the exporter, the STEP writer, TeklaIfcExportOptions and the IFC methods of TeklaModel. With BuildNativeCoreOnly=true the engine is compiled without that folder and produces no package. CI compiles the engine and TdbIO.Scene this way in a separate artifact path. The regular build keeps the same public types.
  • The JSON of the object model stays in the engine, as in NwcIO.
  • dotnet pack compares the public API of both target frameworks with the published 0.1.0. An unintended difference fails the pack.
  • tools/pack-release.ps1 checks the TdbIO.Scene package before anything is pushed: the engine dependency is exactly the packed version and IOScene is a released version.
  • release.yml publishes the NuGet packages before it creates the GitHub release, and updates a release that an earlier run of the same tag left. This covers the failure order of A failed NuGet push leaves a GitHub release that blocks retrying the workflow #44. The workflow does not verify the expected set of packages yet, so the issue stays open.
  • README, CONTRIBUTING, docs/dependencies.md, docs/index.md and the changelog (new Unreleased section) describe the current scope: the object model, the exports, the approximate part geometry and the supported systems.

Text of table rows. The text values of table rows are single-byte in the code page of the system that saved the model. The typed decoders required valid UTF-8, so ReadModel() and tdbio export failed with invalid UTF-8 string on every model saved on a system with another code page.

  • Each value is now read as ASCII, UTF-8, code page 1251 or 1252, in that order. This is the order used for templates and reports without its byte order mark steps. A byte the chosen page does not define is an error at its offset in the row body.
  • TdbReadOptions.TextEncoding applies to table rows too. It reaches the rows through TableRow.TextEncoding, and the decoded row types with text take the encoding in Decode(ReadOnlySpan<byte>, Encoding).
  • The chunks of a string pool chain are joined as bytes and decoded as one value.
  • The choice between the two code pages counts bytes from 0xC0, which hold Cyrillic letters in 1251 and Latin letters with diacritics in 1252. A model saved with a Western European page needs its encoding given.
  • The field layouts of the typed decoders are not changed.

The change is two commits: the engine split, then the text of table rows.

How it was checked

  • dotnet build TdbIO.slnx -c Release has no warnings
  • dotnet test TdbIO.slnx -c Release passes: without private inputs 486 passed and 38 skipped of 524 in TdbIO.Tests, 6 of 6 in TdbIO.Scene.Tests, on .NET 8 and .NET 10
  • Output of tdbio info, tdbio tables and tdbio text on the same files is identical before and after: 94 runs on 47 private files of 9 kinds, byte for byte, with the same exit codes
  • No Tekla models, customer data or vendor files are added

With the private files, on .NET 8 and .NET 10: 523 passed, 0 failed, 1 skipped of 524 in TdbIO.Tests.

tdbio export before and after, this branch against main with the same IOScene 0.1.2:

  • The JSON of the object model is identical for every model the previous code could export.
  • The scene JSON differs only in CreatedAt. IFC differs only in the export time and the random GlobalIds of the site, the building, the storey and the relations.
  • Two models that the previous code could not export (invalid UTF-8 string, exit code 2) now export as JSON, scene JSON and IFC.

Also checked:

  • 15 new test cases: the encoding rule, the encoding reaching rows and the model, and the decoded text of a field in the vector tests (decoded_text_at_N_width_M in the private manifests).
  • Package validation passes. In a scratch copy with one public property made internal, dotnet pack fails with CP0002 for both target frameworks.
  • dotnet build src/TdbIO.Scene/TdbIO.Scene.csproj -c Release -p:BuildNativeCoreOnly=true --artifacts-path <folder> passes and produces no package.
  • tools/pack-release.ps1 run into a temporary folder: 10 artifacts, the checksums match, and the TdbIO.Scene package depends on TdbIO [0.1.0] and on IOScene [0.1.2, 0.2.0-0.0).
  • Each commit builds and passes the tests on its own.

The CI workflow ran on this pull request on Windows, Ubuntu and macOS: restore, build, tests and the native core check
passed on all three, and so did the package step with the API comparison on Windows. The release workflow has not run;
its changed file was checked for its structure only.

The IFC output is target-format output, not native decoding. Its sources
move to src/TdbIO/Ifc. With BuildNativeCoreOnly=true the engine is compiled
without that folder and produces no package; CI compiles the engine and
TdbIO.Scene this way in a separate artifact path. The regular build keeps
the same public types.

- Compare the public API of the library with the published 0.1.0 on pack.
- Check the TdbIO.Scene package in pack-release.ps1: the engine dependency
  is exactly the packed version and IOScene is a released version.
- Publish the NuGet packages before the GitHub release is created, and
  update a release that an earlier run of the same tag left.
- Document the library boundaries, the native core check, the export
  comparison and the current scope, and add an Unreleased section to the
  changelog.

Refs #44
The text values of table rows are single-byte in the code page of the
system that saved the model. The typed decoders required valid UTF-8, so
ReadModel() and tdbio export failed with "invalid UTF-8 string" on every
model saved on a system with another code page.

- Decode each value as ASCII, UTF-8, code page 1251 or 1252, in that order:
  the order used for templates and reports without its byte order mark
  steps. A byte the chosen page does not define is an error at its offset
  in the row body.
- Apply TdbReadOptions.TextEncoding to table rows too. It reaches the rows
  through TableRow.TextEncoding, and the decoded row types with text take
  the encoding in Decode(ReadOnlySpan<byte>, Encoding).
- Join the chunks of a string pool chain as bytes and decode them as one
  value.
- Test the rule, the encoding reaching rows and the model, and the decoded
  text of the private vectors.

The choice between the two code pages counts bytes from 0xC0, which hold
Cyrillic letters in 1251 and Latin letters with diacritics in 1252: a model
saved with a Western European page needs its encoding given.
A code page chosen for each value cannot read short values: "№5" holds one
byte from 0x80 and none from 0xC0, so in a model saved with code page 1251
it was read as code page 1252 ("¹5"), while the longer values of the same
row were read as 1251.

- Count the bytes from 0x80 of all the values of the typed tables that are
  neither ASCII nor UTF-8 at the end of the walk, and read those values in
  the one code page they choose. ASCII and UTF-8 values are read as before;
  Decode(body, Encoding) on a body alone still chooses per value.
- Accept --encoding for model databases and DBV@ files, and in tdbio
  export, so a model saved with a Western European page can be read.
- Name the position of an undecodable string pool chain as a byte of the
  joined chunks instead of an offset that looks like one of the file.
- Document StringPoolRow.Text as the text of one chunk.
- release.yml creates a release only when gh release view reports that it
  is missing, and stops on any other failure of the lookup.
Each read of the sections builds its own text rule, so rows from two
ReadTables() calls on one document compared unequal by reference. Compare
the encoding and the chosen code page instead.

State that the code page is chosen once for a model database only: the
sections of a DBV@ file have no table key, so there it is chosen for each
value.
@mahach666
mahach666 merged commit 29e7dd3 into main Nov 27, 2026
5 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.

1 participant