Skip to content

Generate Images in C# Using SkiaSharp: net10.0, SkiaSharp 4.153.1, tests run in CI - #2263

Open
vladimir-pecanac-main wants to merge 1 commit into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/116572-csharp-generate-images-using-skiasharp
Open

vladimir-pecanac-main wants to merge 1 commit into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/116572-csharp-generate-images-using-skiasharp

Conversation

@vladimir-pecanac-main

Copy link
Copy Markdown
Collaborator

Sample for https://code-maze.com/csharp-generate-images-using-skiasharp/ (folder csharp-images/GenerateImagesInCSharpUsingSkiaSharp only).

Changes:

  • Both projects net8.0 to net10.0.
  • Test class SkiaSharpLibraryLiveTest renamed to ImageServiceTests. The CI test step filters FullyQualifiedName!~Live, so none of this folder's tests ever ran. They need no external resource.
  • SkiaSharp.NativeAssets.Linux added to Tests.csproj in the same commit: the SkiaSharp package carries only the Win32 and macOS native assets for net10.0, and CI runs on ubuntu-latest.
  • DrawSquareOnImage: coordinates of 0 are now accepted (the guard was <= 0, which rejected a square at the top-left corner). Size 0 or below is still rejected.
  • CreateBlankImage: throws ArgumentException for a width or height of 0 or below, so GivenInvalidDimensions_..._ThenThrowArgumentException now asserts ArgumentException instead of the bare Exception SkiaSharp throws.
  • Two tests added: a square drawn at (0, 0), and the layout of a new SKBitmap(400, 300) (ColorType equals SKImageInfo.PlatformColorType and Bgra8888, Premul, 4 bytes per pixel, RowBytes 1600, 120,000 pixels, non-zero GetPixels()).

Packages (re-queried on NuGet 2026-10-04, newest listed stable):

  • SkiaSharp 4.153.1
  • SkiaSharp.NativeAssets.Linux 4.153.1
  • Microsoft.NET.Test.Sdk 18.10.1
  • coverlet.collector 10.1.0
  • xunit 2.9.3
  • xunit.runner.visualstudio 4.0.0

Local: dotnet build -c Release 0 warnings, 0 errors; dotnet test 10 passed, 0 failed (SDK 10.0.302, runtime 10.0.10, Windows). dotnet list package --vulnerable --include-transitive: none.

- Retarget both projects to net10.0; SkiaSharp 2.88.8 to 4.153.1.
- Rename SkiaSharpLibraryLiveTest to ImageServiceTests so the CI filter
  on "Live" stops skipping all of its tests, and add
  SkiaSharp.NativeAssets.Linux to the test project in the same commit,
  because the SkiaSharp package ships no Linux native binary.
- DrawSquareOnImage accepts a square at coordinate 0 (the top-left
  corner is a valid pixel); a zero or negative size is still rejected.
- CreateBlankImage validates its dimensions and throws
  ArgumentException, so the test of that name asserts the type it names.
- Two tests added: a square at the origin, and the layout of a fresh
  SKBitmap (color type, alpha type, stride, buffer size).
- Test packages: Microsoft.NET.Test.Sdk 18.10.1, coverlet.collector
  10.1.0, xunit 2.9.3, xunit.runner.visualstudio 4.0.0.
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