Skip to content

Restore a data source or code generator where it was (#141) - #143

Merged
matt-edmondson merged 1 commit into
mainfrom
claude/project-continuation-qgaxsq
Sep 5, 2026
Merged

Restore a data source or code generator where it was (#141)#143
matt-edmondson merged 1 commit into
mainfrom
claude/project-continuation-qgaxsq

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Closes #141.

The bug

Schema.RestoreDataSource and RestoreCodeGenerator append. So undoing a delete put the element back in the schema, but at the end — quietly reordering it. Order is part of the schema's meaning: it round-trips through the file and drives the order generated code is written in.

Classes, enums and members were already fixed, by remembering the index before the delete and moving the element back after the restore. Data sources and code generators could not be, because Schema exposed an ordered set for the first two (ClassSet, EnumSet) and nothing for the other two — the editor had nothing to reposition them with. That gap is what #141 records, and what the roadmap's decision 8 said was outstanding.

The fix

Schema now exposes DataSourceSet and CodeGeneratorSet, mirroring the existing pair exactly:

public SchemaChildSet<DataSource, DataSourceName> DataSourceSet => new(DataSourcesInternal);
public SchemaChildSet<SchemaCodeGenerator, CodeGeneratorName> CodeGeneratorSet => new(CodeGeneratorsInternal);

Additive public API — read-through views over the same collections the schema already serializes, so there is no second copy to diverge and no change to the on-disk format. The editor's two delete commands then take the same shape as the class and enum ones.

A note on the API decision

I raised this on #141 as the owner's call, because it puts new surface on a published package. I have gone ahead on the assumption that it is routine: the properties are additive rather than breaking, and exactly symmetric with ClassSet/EnumSet — the alternative shape (an index parameter on Restore*) would change existing signatures instead. If you would rather have that shape, say so and I will rework it.

Tests

Five in Schema.Test (new SchemaRootSetTests) — order through each set, IndexOf, the remove → restore → move sequence with the appended order asserted in between so the move is what is being tested, and that a repositioned data source survives a serialization round trip.

Two in SchemaEditor.Test that drive the real context menu: delete the middle of three, undo, and check all three are back in their original order. Deleting from the middle matters — at either end, appending on restore is indistinguishable from doing it correctly.

Both editor tests fail if the restore appends; I checked by making it append, one at a time.

304 library tests and 98 editor tests, 0 failures.

Also

Two stale entries in docs/ROADMAP.md, found while updating decision 8:

🤖 Generated with Claude Code

https://claude.ai/code/session_01Jc8o5zF3cmfCGjzWvQdGDE


Generated by Claude Code

`Schema.RestoreDataSource` and `RestoreCodeGenerator` append, so undoing a
delete put the element back in the schema but at the end - quietly reordering
it. Order is part of the schema's meaning: it round-trips through the file and
drives the order generated code is written in.

Classes, enums and members were already fixed by remembering the index and
moving the element back after the restore. Data sources and code generators
could not be, because `Schema` exposed an ordered set for the first two
(`ClassSet`, `EnumSet`) and nothing for the other two.

So it now exposes `DataSourceSet` and `CodeGeneratorSet`, mirroring the
existing pair exactly: additive, read-through views over the same collections
the schema serializes, with no change to the on-disk format. The editor's two
delete commands then take the same shape as the class and enum ones.

Tests: five in `Schema.Test` for the new sets - order, `IndexOf`, the
remove/restore/move sequence, and that a repositioned data source survives a
round trip - and two in `SchemaEditor.Test` that delete from the middle of
three and undo. Both editor tests fail if the restore appends; I checked by
making it append.

The roadmap's decision 8 said this was outstanding for these two kinds, and
listed #110 as the next thing to decide though it was closed by #129.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jc8o5zF3cmfCGjzWvQdGDE
@sonarqubecloud

sonarqubecloud Bot commented Sep 5, 2026

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 379f29d into main Sep 5, 2026
12 checks passed
@matt-edmondson
matt-edmondson deleted the claude/project-continuation-qgaxsq branch September 5, 2026 04:23
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.

Undoing a data source or code generator delete restores it at the end, reordering the schema

2 participants