Conversation
Thanks for your contribution! 🤗 (1 / 4)The build and test process is starting. This may take a while. Packing complete! 📦 (2 / 4)You can download the NuGet packages for this build here. 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) |
There was a problem hiding this comment.
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
OnTextPaintPropertyChangedwhen the incoming paint isnull. - 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 = nulltransition 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.
fixes #2116