Skip to content

Report an empty metadata file as unparseable, not missing - #24

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/23-empty-metadata-file
Sep 27, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/23-empty-metadata-file

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #23

What was wrong

GeneratorBase.Initialize filtered out additional files with no text (.Where(file => file.Text.Length > 0)) before looking them up by name. An empty things.json that was correctly wired up was therefore reported as MetadataFileMissing, with the message "not supplied as an AdditionalFile". That message points the user at their .csproj, when the real problem is the file's contents. A whitespace-only file got past the filter and correctly reported MetadataParseFailed, so the two cases behaved inconsistently.

Change

  • The filter is removed. An empty file, including one where GetText returned null, now reaches Deserialize and reports MetadataParseFailed.
  • When several files share a name, the one chosen is now the first file with content, falling back to the first file. That keeps the filter's old effect on duplicates, as the issue suggests.
  • A file that really is absent still reports MetadataFileMissing. AMissingMetadataFileIsReportedRatherThanSilentlyProducingNothing and AMultiFileGeneratorReportsEachFileThatIsAbsent still pass.

Behaviour change to review: AnEmptyMetadataFileCountsAsMissing came in with the initial extraction and pinned the old behaviour. It is replaced by AnEmptyMetadataFileIsReportedAsUnparseableNotMissing, which is the issue's acceptance test. It runs against both an empty and a whitespace-only file.

Tests

With GeneratorBase.cs reverted, the empty-file case fails. With the fix, the full suite passes: 49/49.

🤖 Generated with Claude Code

https://claude.ai/code/session_014jCUYfoRMwhybsUaSa1NFm


Generated by Claude Code

GeneratorBase dropped additional files with no text before looking them up
by name, so an empty things.json that was wired up correctly was reported
as MetadataFileMissing ("not supplied as an AdditionalFile"), pointing the
user at their .csproj instead of the file. Empty files now reach
Deserialize and report MetadataParseFailed, the same as whitespace-only
ones. Among duplicates of one name, a file with content is still preferred.

Fixes #23

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

Copy link
Copy Markdown

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.

An empty metadata AdditionalFile is reported as "not supplied" (MetadataFileMissing) instead of as a parse failure

2 participants