Repository navigation
Report same-named metadata files whose contents differ [patch] - #64
Merged
Merged
Conversation
GeneratorBase grouped AdditionalTexts by file name and kept the first with content, so a stale copy in another folder could silently replace the real metadata. When the copies differ, MetadataParseFailed is now reported with every path and none of them is used. Identical copies stay silent. Fixes #34 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW4i7FzmxvaxCZgeCwe
…data-names # Conflicts: # SourceGeneratorToolkit/GeneratorBase.cs
|
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.



GeneratorBasegrouped the AdditionalTexts by file name and kept the first one with content. The code comment assumed every copy held the same metadata, but nothing checked it. With/a/Legacy/things.jsonand/a/Metadata/things.jsonholding different entries, the run reported nothing and generated from whichever file was listed first.Now, when the non-empty files of one declared name differ:
MetadataParseFailedis reported for that name. The reason isit was supplied more than once with different contents: <path>, <path>.Generate, the same way a file that fails to parse produces no output.MetadataFileMissingis not reported as well.Identical copies, and an empty copy next to a full one, stay silent as before.
I reused the existing descriptor rather than adding a new abstract
MetadataFileDuplicated, so every existing consumer gets the diagnostic without a breaking change.MetadataFilegains an internalFilePathproperty, which replaces the private field it already had, so the diagnostic can name the paths. The README'sMetadataParseFailedrow and the property's XML doc now mention the case.Tests:
GeneratorHarnesskeys its files by name, so the new tests inGeneratorBaseTestsrunCSharpGeneratorDriverdirectly with two paths.SameNamedMetadataFilesWithDifferentContentsAreReportedWithBothPathsfails onmain(0 diagnostics) and passes with the change.SameNamedMetadataFilesWithIdenticalContentsAreNotReportedandAnEmptyDuplicateOfAMetadataFileIsNotAConflictcover the cases that stay silent.Fixes #34
Generated by Claude Code