What's wrong
GeneratorBase (SourceGeneratorToolkit/GeneratorBase.cs ~lines 70–76) groups the AdditionalTexts by file name and keeps the first non-empty one:
// A duplicate name means the same metadata reached the compilation twice; the first with
// content wins.
.GroupBy(file => file.FileName, StringComparer.Ordinal)
.ToDictionary(g => g.Key, g => g.FirstOrDefault(file => file.Text.Length > 0) ?? g.First(), ...)
The comment assumes both copies hold the same metadata. Nothing checks that. When two files share a name but have different content, one is dropped silently.
Repro (verified by driving CSharpGeneratorDriver directly against current main)
Give a generator that wants things.json two AdditionalTexts:
/a/Legacy/things.json defining Old
/a/Metadata/things.json defining New
The run reports 0 diagnostics and emits public class Old. Which file wins depends on item order. The easy ways to hit this are <AdditionalFiles Include="**/*.json" /> and a stale copy left in another folder.
GeneratorTestHarness can't show this, because it keys its input files by name.
Why it matters
The package's own rule, stated a few lines further down, is that producing no output or the wrong output with no explanation must always be reported. This path generates the wrong code with no explanation.
Suggested fix
When a group holds more than one non-empty file and their texts differ, report a diagnostic that names both paths. That could be a new overridable descriptor such as MetadataFileDuplicated, or MetadataParseFailed with a "supplied more than once: , " reason. Identical duplicates can stay silent, as they are today.
Acceptance criteria
- Two same-named metadata files with different content produce a diagnostic naming both paths.
- Two same-named files with identical content still produce none.
What's wrong
GeneratorBase(SourceGeneratorToolkit/GeneratorBase.cs~lines 70–76) groups the AdditionalTexts by file name and keeps the first non-empty one:The comment assumes both copies hold the same metadata. Nothing checks that. When two files share a name but have different content, one is dropped silently.
Repro (verified by driving
CSharpGeneratorDriverdirectly against current main)Give a generator that wants
things.jsontwo AdditionalTexts:/a/Legacy/things.jsondefiningOld/a/Metadata/things.jsondefiningNewThe run reports 0 diagnostics and emits
public class Old. Which file wins depends on item order. The easy ways to hit this are<AdditionalFiles Include="**/*.json" />and a stale copy left in another folder.GeneratorTestHarnesscan't show this, because it keys its input files by name.Why it matters
The package's own rule, stated a few lines further down, is that producing no output or the wrong output with no explanation must always be reported. This path generates the wrong code with no explanation.
Suggested fix
When a group holds more than one non-empty file and their texts differ, report a diagnostic that names both paths. That could be a new overridable descriptor such as
MetadataFileDuplicated, orMetadataParseFailedwith a "supplied more than once: , " reason. Identical duplicates can stay silent, as they are today.Acceptance criteria