Skip to content

Skip generated icons by file name, not by full path - #117

Merged
matt-edmondson merged 1 commit into
mainfrom
claude/exciting-albattani-fru842-116
Sep 26, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
claude/exciting-albattani-fru842-116

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #116

The defect

Directory.GetFiles returns full paths, and IconHelper.cs:119 tested the whole string:

if (file.Contains(".new.png"))

So a directory anywhere above the input could decide that every file below it had already been generated. The contract has never been about paths — README.md:265 and CLAUDE.md:107 both say names: "Files whose names contain .new.png are skipped".

The failure is the worst shape a batch tool can have: total, silent, and reported as success. Nothing is written, nothing is logged per file, and the process exits 0.

The change

if (Path.GetFileName(file).Contains(".new.png", StringComparison.Ordinal))

Ordinal, not the OrdinalIgnoreCase the issue suggests. string.Contains(string) is already ordinal, so Ordinal is what the code does today made explicit, and the fix stays confined to the reported defect. Case-insensitivity would be a second, independent behaviour change: .new.png is not a marker the tool ever writes — nothing in the codebase produces it, it is purely a user-facing convention that README.md documents — so the tool's own output settles nothing about whether Already.New.PNG should be skipped. On Linux those are distinct files. That call is worth its own issue rather than riding along in a path-versus-name fix.

Tests

Two, because the obvious over-correction here is to stop matching on names as well:

test catches
SkipsOnTheFileNameRatherThanTheContainingPath the defect — two ordinary files under icons.new.png.dir/in, both expected to be written
SkipsOnTheFileNameEvenBelowAMatchingPath a fix that drops the check entirely — a marked and an unmarked file in that same directory, one written

The second matters because the first passes if the skip is simply deleted. Together they pin the check to exactly the name.

Proved failing without the fix. Reverting only IconHelper/IconHelper.cs and keeping both tests takes the suite from 8 failures to 10 — the two new ones, and nothing else moves:

failed SkipsOnTheFileNameRatherThanTheContainingPath (81ms)
failed SkipsOnTheFileNameEvenBelowAMatchingPath (2ms)
  total: 75   failed: 10   succeeded: 65

Verification

  • dotnet build IconHelper.sln -c Release — succeeded, 0 warnings, 0 errors (this repo runs analyzers as errors)
  • dotnet test IconHelper.sln -c Release — 75 total, 67 passed, 8 failed

About those 8 failures

They are all GoldMasterTests.OutputMatchesTheGoldMaster, and they are not caused by this change — unmodified main gives 73 total, 65 passed, the same 8 failed.

The cause is this container, not the repository: the gold master fixtures under IconHelper.Test/GoldMaster/Input/ are Git LFS objects, git-lfs is not installed here, and a shallow clone therefore leaves them as pointer files. file reports them as ASCII text beginning version https://git-lfs.github.com/spec/v1. ImageSharp cannot decode a pointer file, ProcessDirectory counts it as a failure, and every case trips its Assert.AreEqual(1, result.Written) guard.

Nothing in this change touches decoding or the gold master path, and CI, which materializes LFS content, should see all 75 green. Flagging it rather than leaving it to be rediscovered: any agent working this repository in a container without git-lfs will see these 8 failures and should not read them as a regression.

🤖 Generated with Claude Code

https://claude.ai/code/session_012betVHk3gFcj5RYkEe4vrm


Generated by Claude Code

Directory.GetFiles hands back full paths, so testing the whole string for
".new.png" let a directory anywhere above the input decide that every file
below it was already generated. An input path containing that substring in
a parent folder -- a user name, a date stamp, a project name -- processed
nothing and still exited 0.

The documented contract, in README.md and CLAUDE.md alike, has always been
about file names: "Files whose names contain .new.png are skipped". The
check now matches that.

Fixes #116

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012betVHk3gFcj5RYkEe4vrm
Comment thread IconHelper.Test/ProcessDirectoryTests.cs
Comment thread IconHelper.Test/ProcessDirectoryTests.cs
Comment thread IconHelper.Test/ProcessDirectoryTests.cs
Comment thread IconHelper.Test/ProcessDirectoryTests.cs
Comment thread IconHelper.Test/ProcessDirectoryTests.cs
Comment thread IconHelper.Test/ProcessDirectoryTests.cs
Comment thread IconHelper.Test/ProcessDirectoryTests.cs
Comment thread IconHelper.Test/ProcessDirectoryTests.cs
Comment thread IconHelper.Test/ProcessDirectoryTests.cs
Comment thread IconHelper.Test/ProcessDirectoryTests.cs
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 0abe33d into main Sep 26, 2026
12 checks passed
@matt-edmondson
matt-edmondson deleted the claude/exciting-albattani-fru842-116 branch September 26, 2026 00:51
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.

".new.png" skip check matches the full input path, not the file name — an input directory path containing that substring silently skips every file

2 participants