Skip to content

Make the unknown-type JSON round-trip test independent of hash table order - #585

Merged
dsn27 merged 1 commit into
masterfrom
claude/json-unknown-type-test-order
Dec 4, 2026
Merged

dsn27 merged 1 commit into
masterfrom
claude/json-unknown-type-test-order

Conversation

@dsn27

@dsn27 dsn27 commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

Problem

JsonUnknownTypeTests.ProjectWithUnknownTypesCanBeSavedAndReadAgain fails intermittently. It failed in the Windows CI run of #584, and it failed locally in about one run in 15.

The test saves a project, reads it back, saves it again and compares the two files byte for byte. The project's attribute lists and the user data are Hashtables. Their enumeration order is not defined and depends on the per-process string hash seed. Now and then the second save writes ColorList before LayerList, and the entity references (#12 vs #15) and type indices shift with it. Both files describe the same project, so the format never promised byte-identical output.

Change

  • Test: instead of comparing whole files, the test compares what it is about. It collects the objects of the unknown types, each with type name, assembly, type version and its own properties, sorted, and checks that all six come back unchanged after the second save. The other checks (each unknown type defined once, no duplicated type index, Describe round trip) are unchanged.
  • JsonProxyType: the new comparison showed that in DEBUG builds the reader adds §Index (the entity's position in the file) to every entity. JsonProxyType wrote that back as a property of the unknown object. It is now skipped like the other serializer properties ($Type, $TypeIndex, ...), as UserData already does. Release builds were not affected.

Tests

  • The Json tests pass in Debug and Release (42 tests each, net8.0, Linux).
  • JsonUnknownTypeTests passed in 30 of 30 separate runs; before this change the test failed about once in 15 runs.
  • Changing the expected count to 7 makes the test fail, so the new check is not vacuous. It lists the six objects of the two unknown types.

Generated by Claude Code

…order

ProjectWithUnknownTypesCanBeSavedAndReadAgain compared two saved files
byte for byte. The attribute lists of a project and the user data are
hash tables whose enumeration order is not defined and changes with the
per-process string hash seed, so the entities, their references and type
indices came out in a different order now and then (about one run in 15),
although both files describe the same project. The test now compares what
it is about: the objects of the unknown types, with type name, assembly,
type version and their own properties, independent of order.

This showed that in DEBUG builds the reader adds "§Index" to every entity
and JsonProxyType wrote it back as a property of the unknown object.
It is now skipped like the other properties of the serializer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T9C2KYWSC8fNbLDvhoEdJK
@dsn27
dsn27 merged commit 85a40e6 into master Dec 4, 2026
2 checks passed
@dsn27
dsn27 deleted the claude/json-unknown-type-test-order branch December 4, 2026 13:25
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.

2 participants