Repository navigation
Make the unknown-type JSON round-trip test independent of hash table order - #585
Merged
Merged
Conversation
…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
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.
Problem
JsonUnknownTypeTests.ProjectWithUnknownTypesCanBeSavedAndReadAgainfails 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 writesColorListbeforeLayerList, and the entity references (#12vs#15) and type indices shift with it. Both files describe the same project, so the format never promised byte-identical output.Change
Describeround 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.JsonProxyTypewrote that back as a property of the unknown object. It is now skipped like the other serializer properties ($Type,$TypeIndex, ...), asUserDataalready does. Release builds were not affected.Tests
Jsontests pass in Debug and Release (42 tests each, net8.0, Linux).JsonUnknownTypeTestspassed in 30 of 30 separate runs; before this change the test failed about once in 15 runs.Generated by Claude Code