Skip to content

Upgrade to SkiaSharp 4 for Microcharts 3.0 - #384

Merged
follesoe merged 9 commits into
mainfrom
feature/skiasharp-4
Oct 20, 2026
Merged

follesoe merged 9 commits into
mainfrom
feature/skiasharp-4

Conversation

@follesoe

@follesoe follesoe commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Opens the Microcharts 3.0 line: the whole solution now targets SkiaSharp 4.153.1, versioned as 3.0.0-preview.

Because main was first migrated to the v4-compatible APIs that already exist in SkiaSharp 3 (0268ceb), the actual upgrade diff is small:

  • Remove the SKPaint-based MeasureLabels/MeasureLabel overloads in LegacyPointChart — SkiaSharp 4 removes SKPaint.TextSize, so a paint can no longer carry text sizing. The SKFont-based overloads remain.
  • Bump every SkiaSharp reference to 4.153.1 (Skia m153), now centralized as a single SkiaSharpVersion property in Sources/Directory.Build.props, consumed by all csproj files and fed into the meta-package nuspec as $skiasharpversion$. Future bumps are a one-line change.
  • Migrate path construction to SKPathBuilder (LineChart, RadarChart, both gauge charts, RadialHelpers) — SkiaSharp 4 obsoletes the SKPath mutation methods; SKPathBuilder mirrors them one for one, and SKPathBuilder does not exist in SkiaSharp 3, so this part is v3-only by necessity. Also fixes two line-chart paths that were never disposed.
  • publish.yml keeps the -preview marker in the CI version suffix (3.0.0-preview.<run>); previously the run-number suffix replaced it, which would have made prerelease packages look stable on the feed.
  • Pin the CI toolchain to .NET SDK 10.0.401, workload set 10.0.401 (iOS 26.5, MAUI 10.0.20) and Xcode 26.6. Newer workload sets bring the iOS 27 workload, which needs Xcode 27 (not on macos-26), and would raise the Microsoft.Maui.Controls floor of the published Microcharts.Maui package.

The full solution (library, platform wrappers, samples) builds with zero errors and zero warnings, dotnet pack produces correctly-versioned 3.0.0-preview packages with resolved nuspec dependencies, and the MAUI sample was verified visually on the iOS simulator (line charts with gradients and splines, Y-axis labels, value labels, legends all render identically to v2).

That simulator check was done on 4.150.1. The later bumps to 4.152.1 and 4.153.1 were each checked with a headless macOS render of all 66 sample charts at two sizes, and the output was pixel-identical to the previous version. On 4.153.1 the full solution again builds in Release with zero errors and zero warnings, the packed Microcharts.Maui depends on SkiaSharp.Views.Maui.Controls 4.153.1, and CI passes on both runners. The only breaking change listed for 4.153 (Linux font fallback) is not covered by these checks.

🤖 Generated with Claude Code

follesoe and others added 3 commits July 21, 2026 16:46
SkiaSharp 4 removes SKPaint.TextSize, so a paint can no longer carry
text sizing. The SKFont-based MeasureLabels/MeasureLabel remain.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The SkiaSharp version is now a single SkiaSharpVersion property in
Directory.Build.props, consumed by every project and fed into the
meta-package nuspec as $skiasharpversion$. CI builds keep the -preview
marker in their version suffix so prerelease packages can't be mistaken
for a stable release on the feed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
SkiaSharp 4 obsoletes the SKPath mutation methods; SKPathBuilder is the
replacement and mirrors them one for one, so path construction is
unchanged. Detached paths and builders are now disposed, fixing two
leaked line-chart paths.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@follesoe follesoe added this to the v3.0.0 milestone Jul 21, 2026
@follesoe
follesoe requested a review from Copilot July 21, 2026 14:47
@follesoe follesoe self-assigned this Jul 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Microcharts for the 3.0 preview line by moving the solution to the SkiaSharp 4.x package family and adapting drawing code to SkiaSharp 4 API changes (notably SKPathBuilder), while centralizing versioning in shared build props and preserving prerelease version suffixing in CI publishing.

Changes:

  • Centralize SkiaSharp package versions via SkiaSharpVersion in Sources/Directory.Build.props and update all project references + metapackage nuspec to consume it.
  • Replace mutable SKPath construction with SKPathBuilder + Detach() in charts/helpers that build paths.
  • Remove legacy SKPaint-based label measurement overloads and adjust publish workflow to keep -preview.<run> suffixing.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Sources/Microcharts/Microcharts.csproj Switch SkiaSharp reference to $(SkiaSharpVersion)
Sources/Microcharts/Helpers/RadialHelpers.cs Use SKPathBuilder for sector paths (plus small cleanups needed)
Sources/Microcharts/Charts/RadialGaugeChart.cs Build gauge arc path via SKPathBuilder
Sources/Microcharts/Charts/RadarChart.cs Build clip path via SKPathBuilder
Sources/Microcharts/Charts/LineChart.cs Build line/area paths via SKPathBuilder and fix disposal; needs guard for all-null series area fill
Sources/Microcharts/Charts/Legacy/LegacyPointChart.cs Remove SKPaint-based MeasureLabel(s) overloads
Sources/Microcharts/Charts/HalfRadialGaugeChart.cs Build gauge arc paths via SKPathBuilder
Sources/Microcharts.Samples.Maui/Microcharts.Samples.Maui.csproj Switch SkiaSharp.Views.Maui.Controls reference to $(SkiaSharpVersion)
Sources/Microcharts.Samples.iOS/Microcharts.Samples.iOS.csproj Switch SkiaSharp.Views reference to $(SkiaSharpVersion)
Sources/Microcharts.Samples.Android/Microcharts.Samples.Android.csproj Switch SkiaSharp.Views reference to $(SkiaSharpVersion)
Sources/Microcharts.Metapackage/Microcharts.Metapackage.nuspec Replace hardcoded SkiaSharp deps with $skiasharpversion$ token
Sources/Microcharts.Metapackage/Microcharts.Metapackage.csproj Feed skiasharpversion=$(SkiaSharpVersion) into nuspec properties
Sources/Microcharts.Maui/Microcharts.Maui.csproj Switch SkiaSharp.Views.Maui.Controls reference to $(SkiaSharpVersion)
Sources/Microcharts.iOS/Microcharts.iOS.csproj Switch SkiaSharp.Views reference to $(SkiaSharpVersion)
Sources/Microcharts.Droid/Microcharts.Droid.csproj Switch SkiaSharp.Views reference to $(SkiaSharpVersion)
Sources/Directory.Build.props Set 3.0.0-preview defaults + add SkiaSharpVersion property
.github/workflows/publish.yml Preserve -preview.<run> prerelease suffixing during publish builds

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Sources/Microcharts/Charts/LineChart.cs Resolved
DrawNullPoint pushes an SKPoint(float.MinValue, float.MinValue) placeholder
so the point list stays index-aligned with the entries. When every entry in
a serie is null the DrawLineArea loop never adds a point, leaving lastPoint
on that sentinel, and the trailing LineTo/Close built a degenerate fill path
spanning float.MinValue. Bail out before closing the path instead.

Also drop two unused locals from CreateSectorPath and fix a duplicated word
in the comment above the full-circle branch.

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

Copy link
Copy Markdown
Contributor Author

All three Copilot review comments are addressed in 297649c, and the individual threads have been replied to and resolved.

Finding Resolution
RadialHelpers.cs — duplicated word in comment Now reads // if the sector is a full circle, then do that.
RadialHelpers.cs — unused sectorCenterAngle / cectorCenterRadius Both removed, along with the orphaned // get the radius bits comment. Nothing downstream read them, so the change is behaviour-neutral.
LineChart.cs — DrawLineArea on an all-null serie Added an early return when isFirst is still true after the loop, so the degenerate fill path is never built.

On the last one: DrawNullPoint pushes new SKPoint(float.MinValue, float.MinValue) as a placeholder so the point list stays index-aligned with the entries. For a serie where every entry is null the loop body always continues, leaving lastPoint on that sentinel, and the trailing LineTo/Close produced a fill path spanning float.MinValue.

Note that none of the three are SKPathBuilder regressions — they all predate this PR, and SKPath handled the leading LineTo identically. Since all three fixes are equally valid against SkiaSharp 3, the commit has also been cherry-picked onto main (55e4aab) so the v4 branch keeps carrying only genuinely v4-specific changes. The main version resolves the RadialHelpers.cs overlap back to SKPath; the LineChart.cs hunk is identical on both branches.

dotnet build Sources/Microcharts/Microcharts.csproj -c Release succeeds with 0 warnings on both branches across all four target frameworks.

follesoe and others added 5 commits July 27, 2026 15:47
# Conflicts:
#	Sources/Microcharts/Helpers/RadialHelpers.cs
4.152.1 is the latest stable SkiaSharp and brings the Skia m151 and m152
engine updates plus the m152 GlyphData fix. Neither line lists breaking
changes, and the Microsoft.Maui.Controls floor stays at 10.0.20.
Headless renders of every sample chart are pixel-identical to 4.150.1.

Also update CLAUDE.md, which still described the library as built on
SkiaSharp 3.x.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
CI installed the newest 10.0.x SDK and workloads, so it drifted with every
.NET release. Workload sets from 10.0.401.1 on ship the iOS 27 workload,
which needs Xcode 27, and the macos-26 runner tops out at Xcode 26.6. They
also move $(MauiVersion) to 10.0.110, which would silently raise the
Microsoft.Maui.Controls floor of the published Microcharts.Maui package.

Pin SDK 10.0.401 and workload set 10.0.401 (iOS 26.5.10318, MAUI 10.0.20)
in both workflows, and Xcode 26.6 in the PR build. This is the exact
toolchain the last green PR build used. Install the four workloads in one
command so they all come from the pinned set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4.153.1 is the latest stable SkiaSharp. It moves the engine to Skia m153
and turns off RAW and DNG image decoding, which Microcharts does not use.
The only listed breaking change is Linux font fallback, which may now pick
a different face for text drawn without an explicit typeface. The
Microsoft.Maui.Controls floor stays at 10.0.20. Headless renders of every
sample chart on macOS are pixel-identical to 4.152.1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The configured SkiaSharp version differs from the stated validation target, requiring human confirmation of the cross-platform validation baseline.

1 open issue
3 resolved since last review

Review effort: Balanced

Comment thread Sources/Directory.Build.props Resolved
@follesoe
follesoe merged commit cc6caf1 into main Oct 20, 2026
3 checks passed
@follesoe
follesoe deleted the feature/skiasharp-4 branch October 20, 2026 06:01
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.

2 participants