Repository navigation
Remove stale generated files when an element is renamed or deleted - #314
Merged
Merged
Conversation
GenerateToDisk now records the files each code generator wrote in a per-generator manifest in the output directory, and on the next run deletes the recorded files it no longer produces. Files it never wrote, including hand-written ones and other generators' output, are untouched. Closes #288 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017diBTKdccitjf28kU2Syfq
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YNKVuFTzTt8TiFb94MS4eW
Main now checks every destination stays inside the output directory and reports a write it cannot make as WriteFailed. Both checks run before stale files are removed, and creating the output directory and writing the manifest report a failure the same way rather than throwing. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9FBXHS37WoAF87LDY2ZVV
The unknown-option check refused every option on validate, so `validate --no-data` failed once both changes reached main. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017diBTKdccitjf28kU2Syfq
|
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.



Requested by Matt · project thread
Before: when you renamed or deleted a class, enum, interface or semantic type and generated again, the old file (for example
Item.g.csorPacket.gen.hpp) stayed in the output directory. It kept compiling a type the schema no longer declares.After:
GenerateToDiskremoves the files it wrote last time and no longer produces, and its message says how many it removed. A file it never wrote is left alone. That covers hand-written files and the output of other generators sharing the directory.SchemaGenerationResult.RemovedFileslists what was removed.How: each generator writes a small manifest,
.<generator name>.schema-generated, in its output directory, listing the files it wrote. The next run deletes manifest entries that are missing from the new output before it writes anything, so a rename that only changes case still leaves the new file on a case-insensitive file system. An entry that is rooted, or that resolves outside the output directory, is ignored. A file that cannot be deleted is reported in the message and kept in the manifest so the next run retries it. The first run after upgrading has no manifest, so it removes nothing. Renaming a generator starts it with an empty record, for the same reason.Tests cover a rename, a deletion, a case-only rename, an untouched hand-written file, and manifest entries that escape the directory. A C++ test covers the rename too. Without the delete, the rename and deletion tests fail.
Closes #288
Generated by Claude Code