Make a new entry match what MATLAB writes, in both .sldd formats - #44
Merged
Merged
Conversation
Every `createDefault` the Add gallery can reach was compared against a default MATLAB itself creates, in both the JSON-text and compressed-binary formats, by writing a 28-entry dictionary from the extension and having MATLAB open, re-set and re-save every entry. Four gaps came back, and this is all four. The variant-configuration section. `Simulink.VariantConfigurations` was listed under Configurations, which reads right — it is what the Variant Manager edits — and MATLAB refuses it there by name in both formats (SLDD:sldd:ValueClassNotAcceptedInSection). The error names the SECTION: a dictionary MATLAB writes carries its own entry of that class in the DESIGN namespace with IsDerived 0, beside the Parameters and Buses. Renaming the class moved the refusal by nothing, which is what pinned it. Configurations takes a ConfigSet and a ConfigSetRef and nothing else, and that is now a closed list with a test. The ConfigSetRef name. MATLAB enforces "entry name == the value's own Name" and now raises SLDD:sldd:EntryValueNameMismatch rather than silently renaming, so Name is written as a view of the entry name and the default is MATLAB's own, `Reference`. Two binary-only defects, both invisible to the text-path parity assertion that was supposed to cover this: The binary writer was not saveobj-aware. Three of the four classes whose whole state is one custom-save envelope came out carrying an invented `<P Name="Value" Class="char"/>` beside that envelope — a property none of those MATLAB classes has — in the binary flavour only. An empty struct or cell property survived the write and was destroyed by the read: its field names live in `<Field Name="…"/>`, which only an empty struct uses, so the reader fell through and answered an empty char. Opening a dictionary and saving it hollowed out every variant entry in it, ours or MATLAB's, into the shape that makes loadobj build an empty object. MATLAB's rewrite of our entries now lists the same envelope fields we write, in the same order, for all four classes, and reads Choices back as a 0x1 struct and VariantConditions as a 1x0 cell rather than as chars.
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.
Every
createDefaultthe Add gallery can reach, compared against a default MATLAB itself creates — in both the JSON-text and compressed-binary formats. Method: write a 28-entry dictionary from the extension in each format, then have MATLAB open it,setValueevery entry (so nothing passes through as an unread blob),saveChanges, and reopen. Four gaps came back; this is all four.The variant-configuration section
Simulink.VariantConfigurationswas listed under Configurations, which reads right — it is what the Variant Manager edits. MATLAB refuses it there by name, in both formats:The error names the section. A dictionary MATLAB writes carries its own entry of that class in the design namespace with
IsDerived0, beside the Parameters and Buses, andaddEntry(…, 'Design Data')is the call MATLAB accepts. Renaming the class moved the refusal by nothing, which is what pinned it on the section rather than the value. Configurations takes aConfigSetand aConfigSetRefand nothing else — now a closed list with a test, since a class added there is a claim about MATLAB that has to be measured.The ConfigSetRef name
MATLAB enforces "entry name == the value's own
Name", and now raisesSLDD:sldd:EntryValueNameMismatchrather than silently renaming.Nameis written as a view of the entry name, and the default is MATLAB's own:Reference.Two binary-only defects
Both were invisible to the text-path parity assertion that was supposed to cover exactly this, because it read only the text run.
<P Name="Value" Class="char"/>beside that envelope — a property none of those MATLAB classes has — in the binary flavour only. A property bag where the envelope belongs is the shape that has segfaulted MATLAB onSimulink.VariantVariablebefore.<Field Name="…"/>, which only an empty struct uses (a non-empty one states them through each<Element>), so the reader fell through and answered an empty char. Merely opening a dictionary and saving it hollowed out every variant entry in it — ours or MATLAB's — into the shape that makesloadobjbuild an empty object.Verification
MATLAB's rewrite of our entries now lists the same envelope fields we write, in the same order, for all four custom-saving classes, and reads
Choicesback as a0x1 structandVariantConditionsas a1x0 cellrather than as chars. Every entry loads in both formats with no rename and nothing lost (name census before and after MATLAB's own save, from a fresh reopen).npm run verify: 168 files / 4938 tests passed, 26 skipped. New suites:newEntryEnvelopeBothFormats.test.ts(20),createDefaultMatlabParity.test.ts, plus the section claim insectionNode.test.ts— the section move was a one-line edit that broke no test, which was the gap those close.