Skip to content

Write non-finite geometry as JSON null and export files atomically - #44

Merged
mahach666 merged 4 commits into
mainfrom
fix/9-json-nonfinite
Nov 16, 2026
Merged

mahach666 merged 4 commits into
mainfrom
fix/9-json-nonfinite

Conversation

@mahach666

@mahach666 mahach666 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #9

Geometry containing NaN or infinity now exports those values as JSON null and records a diagnostic. Finite values retain the existing six-decimal rounding. The CLI reports unexpected errors without a stack trace.

File export writes to a temporary file in the destination directory and atomically moves it into place. When overwriting an existing file, its Windows access rules or Unix mode are applied to the temporary file before writing JSON. Access-right failures abort before replacement. The move is the final operation: access rules are not reapplied afterward, so a copied ACL that denies permission changes cannot turn a successful replacement into an error.

Tests cover non-finite and finite geometry, temporary-file cleanup, failed replacement, exact Windows DACL preservation, overwrite when ACL changes are denied, and abort when the destination ACL cannot be read.

Validation:

  • dotnet build DwgIO.slnx -c Release: passed with no warnings or errors.
  • dotnet test DwgIO.slnx -c Release --no-build with private AC1024/AC1027/AC1032 fixtures: 83 passed, 0 failed, 0 skipped on both net8.0 and net10.0.
  • The ACL-change-denied regression failed on both target frameworks before the fix and passes afterward.
  • dotnet format DwgIO.slnx --verify-no-changes --no-restore for the changed files: passed.
  • A local integration branch combining PRs Exclude DICTIONARY records from the entity inventory #43-Accept small section size overshoot and zero-fill the tail #47 built without warnings and passed 104 tests on both target frameworks after resolving the overlapping section-read signature and test helper.

Windows ACL behavior was exercised locally. Unix access modes were not exercised locally.

DwgJsonExporter now checks each geometry value with double.IsFinite: finite values keep the existing six-decimal rounding, non-finite values are written as JSON null and reported through DwgDocument.Diagnostics. WriteFile writes to a temporary file next to the target and moves it into place, so a failed export leaves neither a partial target file nor a temporary file. The CLI prints unexpected failures as a single line instead of a stack trace.
Copy the existing file's DACL (Windows) or mode (Unix) onto the
temporary export before writing, and re-apply after the atomic
replace, so overwriting a protected JSON file keeps its rights.
Reading or applying the existing DACL (Windows) or mode (Unix)
is mandatory when overwriting: propagate failures instead of
falling back to directory-inherited rights, so a protected file
is never silently replaced. Add a regression test that denies
READ_CONTROL and asserts the original is kept with no temp left.
@mahach666
mahach666 merged commit 6ee38a6 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.

JSON export fails on NaN or infinite values and leaves a truncated output file

1 participant