Skip to content

chore: replace ImageSharp with NetVips in the pathfinder tests - #304

Merged
erwan-joly merged 3 commits into
masterfrom
chore/netvips
Aug 23, 2026
Merged

chore: replace ImageSharp with NetVips in the pathfinder tests#304
erwan-joly merged 3 commits into
masterfrom
chore/netvips

Conversation

@erwan-joly

Copy link
Copy Markdown
Contributor

Follow-up to #302, which froze SixLabors at 3.x/2.x because ImageSharp 4 / Drawing 3 gate the Release build on a purchased licence key:

<ValidateLicenseTask ... ContinueOnError="$(Configuration.StartsWith('Debug'))" />

Freezing works but leaves us pinned to a library we can never upgrade. guvusocial-img-processor-svc already moved its image pipeline off ImageSharp to NetVips (3aa38fc), so this follows the same route.

Approach

The drawing here is a grid of axis-aligned cells — filled rects, a few glyphs, arrows. So MapCanvas composites against a plain RGBA byte buffer, and libvips is used only for the two parts that genuinely need a library: glyph rasterisation (Image.Text) and PNG encoding. That also removes SixLabors.Fonts and the system-font probing it needed, since fontconfig resolves sans itself.

Net effect on the tests is that they get shorter — the image.Mutate(ctx => …) wrappers and the five-line RichTextOptions blocks collapse into direct calls:

image.FillRect(x * Scale, y * Scale, Scale, Scale, color);
image.DrawTextCentered(centerX, centerY, text, Colors.Black);

140 insertions, 276 deletions.

Why this is safe

The approval checksums are unchanged. They are a SHA-256 over the listPixel cell colours, not over the rendered image — the PNG is documentation embedded in the approved markdown. So the tests assert exactly what they asserted before, and all 7 pass without touching a single .approved.md.

For that to hold the colour constants had to match ImageSharp's named values byte-for-byte, so I dumped them from ImageSharp 3.1.12 rather than assuming — Color.Green is 008000, not 00FF00, which is the one that would have silently broken the hashes.

Verification

  • dotnet test — 7/7 pass, no approved files changed
  • dotnet build -c Release — succeeds, no licence gate
  • Documentation PNGs regenerated and visually checked: arrowheads, centred labels, the glyphs and the blue distance gradient all render as before

Native packages are pulled for linux-x64 (CI), win-x64 and osx-arm64.

🤖 Generated with Claude Code

ImageSharp 4 / Drawing 3 gate the Release build on a purchased Six Labors
licence key, so the 3.x/2.x line was frozen and dependabot had to be told to
stop proposing majors it could never land. NetVips is what the image pipeline in
guvusocial-img-processor-svc moved to for the same reason of not wanting to be
on that upgrade path.

The drawing here is a grid of axis-aligned cells, so compositing is done against
a plain RGBA byte buffer in MapCanvas and libvips is used only for the two parts
that genuinely need a library: glyph rasterisation and PNG encoding. That also
drops SixLabors.Fonts and the system-font probing it needed.

The approval checksums are unchanged. They are computed from the listPixel cell
colours rather than from the rendered image, so the tests assert the same thing
they always did; only the documentation PNGs are regenerated. Colour constants
were taken from ImageSharp's own named values so the hashes still match, which
matters most for Green (008000, not 00FF00).

Also drops the SixLabors dependabot ignore block, now that nothing references
those packages.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@erwan-joly, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 18 minutes

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

Wait for the limit to reset, then comment @coderabbitai review or push new commits to the PR.

An organization admin can change what happens after included review limits in Billing.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 587c4de6-bd02-49a3-b62d-c3026e70e43a

📥 Commits

Reviewing files that changed from the base of the PR and between 014c043 and 8e6640a.

⛔ Files ignored due to path filters (5)
  • documentation/brushfire.png is excluded by !**/*.png
  • documentation/flow-field-path.png is excluded by !**/*.png
  • documentation/flow-field.png is excluded by !**/*.png
  • documentation/goal-based-pathfinder.png is excluded by !**/*.png
  • documentation/jump-point-search-pathfinder.png is excluded by !**/*.png
📒 Files selected for processing (7)
  • test/NosCore.PathFinder.Tests/BrushFireTests.cs
  • test/NosCore.PathFinder.Tests/FlowFieldTests.cs
  • test/NosCore.PathFinder.Tests/GoalBasedPathfinderTests.cs
  • test/NosCore.PathFinder.Tests/JumpPointSearchPathfinderTests.cs
  • test/NosCore.PathFinder.Tests/MapCanvas.cs
  • test/NosCore.PathFinder.Tests/NosCore.PathFinder.Tests.csproj
  • test/NosCore.PathFinder.Tests/TestHelper.cs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

erwan-joly and others added 2 commits August 23, 2026 14:59
It holds a managed byte[] and nothing else, so there was nothing to dispose -
the interface existed only to let the tests keep writing `using var`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…rom an instance method

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@erwan-joly
erwan-joly merged commit d25f915 into master Aug 23, 2026
3 checks passed
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.

1 participant