Repository navigation
Add SVG support for asset generation - #326
Conversation
Build Metrics ReportBinary Sizes
Test Results✅ 404 passed out of 404 tests in 369.4s (+2 tests, -13.0s vs. baseline) Test Coverage❌ 42% line coverage, 45.8% branch coverage · ✅ no change vs. baseline CLI Startup Time37ms median (x64, Updated 2026-03-13 19:22:22 UTC · commit |
There was a problem hiding this comment.
Pull request overview
Adds support for using SVG files as the source input to winapp manifest update-assets, rasterizing them to a bitmap so the existing asset generation pipeline can produce the required PNG assets (addresses #321).
Changes:
- Add
Svg.Skiadependency to enable SVG rasterization (via Skia). - Refactor image loading into a shared helper and add
.svghandling inImageAssetService. - Add test helper and new test cases covering SVG input to
update-assets.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/winapp-CLI/WinApp.Cli/WinApp.Cli.csproj | Adds Svg.Skia package reference to the CLI project. |
| src/winapp-CLI/Directory.Packages.props | Pins Svg.Skia version via central package management. |
| src/winapp-CLI/WinApp.Cli/Services/ImageAssetService.cs | Adds SVG decoding/rasterization path and centralizes source image loading logic. |
| src/winapp-CLI/WinApp.Cli.Tests/PngHelper.cs | Adds a helper to write a small SVG file used by tests. |
| src/winapp-CLI/WinApp.Cli.Tests/ManifestUpdateAssetsCommandTests.cs | Adds new tests for generating assets from an SVG input. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
…/dark them variants (#355) Expand manifest update-assets — full MRT asset coverage, ICO output, SVG direct rendering, light theme support Closes #321, closes #327 ## Summary Building on the SVG input support added in #326, this PR makes winapp manifest update-assets generate the complete set of assets that Windows (MRT) expects, adds ICO output, and introduces --light-image for light theme variants. ## What changed ### Expanded asset generation - 14 target sizes (was 5) for app icon: 16, 20, 24, 30, 32, 36, 40, 48, 60, 64, 72, 80, 96, 256 — both plated and unplated variants - 5 scale factors (was 2) for all assets: 100%, 125%, 150%, 200%, 400% - app.ico generated automatically — multi-resolution ICO (16, 24, 32, 48, 256) using PNG-encoded frames ### --light-image <path> option - Generates _altform-lightunplated variants for app icon targetsize assets - Generates _altform-colorful_theme-light variants for scale assets (tiles, store logo) - Accepts the same image as the main source (for apps with a single icon) or a separate light-optimized image ### SVG direct rendering - Introduced ImageSource abstraction that keeps SVG as vector data (SKPicture) through the entire pipeline - Each asset is rendered via SkiaSharp at the exact target size — no intermediate 1024px rasterization step - Raster inputs (PNG/JPG/ICO/BMP) continue using GDI+ bicubic scaling ### New naming convention for new projects - winapp init / manifest generate now use Microsoft's recommended names: AppList, MedTile, WideTile, StoreLogo - Existing projects keep their current names — update-assets reads names from the manifest - Dimension lookup in ManifestService recognizes both old and new naming ## Type of Change <!-- Keep the applicable line(s), delete the rest --> - ✨ New feature ## Checklist <!-- Delete the ones that do not apply to your changes --> - [x] New tests added for new functionality (if applicable) - [x] Tested locally on Windows - [x] Main [README.md](../README.md) updated (if applicable) - [x] [docs/usage.md](../docs/usage.md) updated (if CLI commands changed) - [x] Agent skill templates updated in `docs/fragments/skills/` (if CLI commands/workflows changed) --------- Co-authored-by: Nikola Metulev <[email protected]>
## Description SkiaSharp 2.88.9 bundles libexpat 2.6.4, affected by [CVE-2025-59375](https://nvd.nist.gov/vuln/detail/CVE-2025-59375) (memory-exhaustion DoS). `libSkiaSharp.dll` already ships in the CLI, and #799 makes SkiaSharp a public dependency of the Recording package, so the exposure reaches package consumers too. Worth saying up front: **the 2.88.9 pin was never a deliberate choice.** #326 added `Svg.Skia 3.4.1` and SkiaSharp came in transitively. #363 bumped to Svg.Skia 3.7.0, which was the newest stable at the time (4.0.0 shipped ten days later). #799 wrote the first explicit `SkiaSharp 2.88.9` line into `Directory.Packages.props` only because Central Package Management demands a `PackageVersion` once Recording referenced it directly, so it recorded what already resolved. No comment, doc, or issue ever justified the version. **The two must move together.** Svg.Skia is compiled against a specific SkiaSharp major but depends on it only by *minimum* version, so lifting SkiaSharp alone resolves, restores, and compiles cleanly, then fails the first time an SVG is rasterized. This goes to the latest stable of both: SkiaSharp 4.152.0 and Svg.Skia 5.2.3. SkiaSharp 4.x promoted the legacy members to errors, so six call sites move to the modern API. Both were migrated to the overloads that are non-obsolete in 3.x *and* 4.x, so the next major is not blocked on this again: - `UiScreenshotCommand` composite labels use `SKTypeface`/`SKFont` and the `SKTextAlign` `DrawText` overload, and `DrawImage` instead of `DrawBitmap`. - `UiRecordingService.ProcessFrame` passes `SKSamplingOptions(Linear, Mipmap.Linear)`, which is SkiaSharp's own mapping for the `SKFilterQuality.Medium` it replaces, so resample quality is unchanged by construction rather than by eyeball. ### One regression found and fixed Svg.Skia 5.x clamps a sizeless SVG to a 1x1 picture instead of reporting 0x0. That silently disabled the "invalid dimensions" guard, because the rasterized bounds can no longer tell "declares no size" from "is genuinely one pixel": ``` winapp manifest update-assets empty.svg before: error, "SVG image has invalid dimensions (0x0) ... valid viewBox or width/height" after (unfixed): exit 0, and 44 blank icons written ``` The guard now reads the declared `viewBox`/`width`/`height` off the document rather than the rasterizer's clamped bounds, which is both correct and no longer coupled to a rendering implementation detail. A `viewBox` alone is sufficient; failing that, width and height must be positive and absolute, since a percentage has no meaning when generating a fixed-size icon. ## Usage Example No CLI surface change; `docs/cli-schema.json` regenerates byte-identical. Behavior at the boundary is preserved, verified against the published NativeAOT binary: ```bash # viewBox-only SVG (no width/height) still works winapp manifest update-assets .\viewboxonly.svg # exit 0 # sizeless SVG still fails loudly instead of writing blank assets winapp manifest update-assets .\empty.svg # Error updating assets: SVG image has no usable dimensions: ...\empty.svg. # Ensure the SVG has a valid viewBox or width/height attributes. # exit 1 ``` ## Related Issue Fixes: #805 ## Type of Change - 🐛 Bug fix - 🔧 Config/build ## Checklist - [x] New tests added for new functionality (if applicable) - [x] Tested locally on Windows ## Screenshots / Demo The acceptance bar for a graphics-library major bump is "output visually unchanged", so this compares the three rendering paths this PR touches against a 2.88.9 build. The difference column is amplified 8x to make anything at all visible.  | Path | Identical pixels | Worst block drift | |---|---|---| | Screenshot label bar | **100%** (byte-identical) | 0.000 / 255 | | SVG icon 256px | 99.21% | 0.046 / 255 | | Recording frame (1024x768 to 320x240) | 3.66% | 0.319 / 255 | The recording frame is a deliberately adversarial case: a 7px checkerboard, which is the worst possible input for a resampler. Almost every pixel moves, but no channel moves more than 21/255 and the 30x30 block-average drift is 0.13%, so it is the resampler's kernel differing in the low bits, not a structural change. ## Additional Notes Two things reviewers should know: **`libHarfBuzzSharp.dll` now ships (~2 MB per architecture).** Svg.Skia 5.x takes a new dependency on HarfBuzzSharp for text shaping. Every packaging path copies by wildcard, so no script changes were needed, and it does **not** leak into either published NuGet package (Svg.Skia is CLI-only; Recording's nuspec was checked and declares only `SkiaSharp 4.152.0`). It will most likely need a new binskim entry in `.config/guardian/.gdnbaselines` alongside the existing `libSkiaSharp.dll` ones, and those signatures can only be produced by the Official pipeline, so expect one baseline follow-up after the first run. `libSkiaSharp.dll` itself grows from ~9 MB to ~13 MB; the two docs that quote that number are updated. **Dependabot is not currently offering these bumps at all.** The `skia` group added here is review hygiene, not a safety net: it keeps a Skia major out of a 20-package batch PR, since it needs hand migration. It would not have caught this. Open PR #855 bumps only `Microsoft.Windows.CsWin32` even though Svg.Skia 5.2.3 shipped Aug 27, well past the 7-day cooldown, and NuGet coverage only landed 2026-08-11 in #728, which is why 3.7.0 sat untouched since March. The thing that actually protects against a mismatched pair is `ImageAssetServiceTests` rasterizing a real SVG, which is why the new test covers the viewBox-only case the fixed guard could plausibly have broken. **Test results.** Release build is 0 warnings / 0 errors, which is the real proof the obsolete-API migration is complete since `TreatWarningsAsErrors` is Release-only. 6,455 CLI + 402 UI Automation + 63 analyzer + 62 NuGet Pester tests. The 14 failures are all environmental and none are in a Skia path: 11 `NugetServiceTests` need `api.nuget.org` (all 28 pass against the internal mirror), 1 tries to launch the arm64 `winapp.exe` on x64, and 2 are foreground-dependent. One of those, `RecordAsync_FirstScreenFrame_AcceptsAModalDialogTheTargetOwns`, was reproduced on unmodified `origin/main` and is pre-existing. ## AI Description <!-- ai-description-start --> _This section is auto-generated by AI when the PR is opened or updated. To opt out, delete this entire section including the marker comments._ <!-- ai-description-end --> --------- Co-authored-by: Copilot App <[email protected]> Copilot-Session: 9ab36938-7aa7-42c8-8173-ab0cf51ac113
Description
Adds the Svg library as a dependency, and detects svg files on manifest update-assets command, converting to a Bitmap to generate the new assets.
Usage Example
winapp manifest update-assets .\image.svgType of Change
Checklist
AI Description
This PR adds support for SVG files in the asset generation process of the winapp CLI. It includes the Svg.Skia library as a dependency and allows the
manifest update-assetscommand to convert SVG files into bitmap images when generating assets. This enhancement simplifies the process for developers looking to utilize SVG graphics in their applications.Usage example:
winapp manifest update-assets .\image.svg