Skip to content

Fix null context 2116#2118

Merged
beto-rodriguez merged 3 commits intodevfrom
fix-nullContext-2116
Mar 17, 2026
Merged

Fix null context 2116#2118
beto-rodriguez merged 3 commits intodevfrom
fix-nullContext-2116

Conversation

@beto-rodriguez
Copy link
Collaborator

fixes #2116

Copilot AI review requested due to automatic review settings March 17, 2026 15:09
@github-actions
Copy link

github-actions bot commented Mar 17, 2026

Thanks for your contribution! 🤗 (1 / 4)

The build and test process is starting. This may take a while.
You can find more details below as the process continues or at the actions tab.

Packing complete! 📦 (2 / 4)

You can download the NuGet packages for this build here.
The packages will be available for 30 days, you can either use them directly, or wait for this PR to be merged to have them published to NuGet.org.

Running tests 🧪 (3 / 4)

Tests are running now, you can monitor their progress below or at the actions tab.

Core ✅ | Snapshot ✅ | Windows ✅ | Linux ✅ | Mac ✅ | Browser ✅ | Android ✅ | iOS ✅

Test Results Summary (Passed) ✅ (4 / 4)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes the NullReferenceException reported in #2116 by making text-paint change handling resilient to null during view/DataContext teardown, and adds a cross-platform sample + UI test scenario to cover it.

Changes:

  • Prevent NRE in OnTextPaintPropertyChanged when the incoming paint is null.
  • Add “NullContext” sample views (WPF/WinUI/Maui/Avalonia) plus a shared ViewModel to reproduce the binding/DataContext-clear scenario.
  • Add a new shared UI test to validate charts survive a DataContext = null transition without crashing.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/SharedUITests/OtherTests.cs Adds a UI test intended to reproduce the null-context crash.
src/skiasharp/_Shared/SourceGenChart.sgp.cs Applies the null-safe access when setting PaintStyle for text paints.
samples/WinUISample/WinUISample/Samples/Test/NullContext/View.xaml.cs Adds a WinUI test view with a helper to clear DataContext.
samples/WinUISample/WinUISample/Samples/Test/NullContext/View.xaml Defines WinUI charts bound to paint properties affected by the bug.
samples/WPFSample/Test/NullContext/View.xaml.cs Adds a WPF test view with a helper to clear DataContext.
samples/WPFSample/Test/NullContext/View.xaml Defines WPF charts bound to paint properties affected by the bug.
samples/ViewModelsSamples/Test/NullContext/ViewModel.cs Provides paint-bound properties to trigger text paint property changed callbacks.
samples/MauiSample/Test/NullContext/View.xaml.cs Adds a MAUI test page with a helper to clear BindingContext.
samples/MauiSample/Test/NullContext/View.xaml Defines MAUI charts bound to paint properties affected by the bug.
samples/AvaloniaSample/Test/NullContext/View.axaml.cs Adds an Avalonia test view with a helper to clear DataContext and chart accessors.
samples/AvaloniaSample/Test/NullContext/View.axaml Defines Avalonia charts bound to paint properties affected by the bug.

💡 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.

@beto-rodriguez beto-rodriguez merged commit fa06928 into dev Mar 17, 2026
43 checks passed
@beto-rodriguez beto-rodriguez deleted the fix-nullContext-2116 branch March 17, 2026 17:37
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