Skip to content

[Testing] Added Tests for Issue31139 and DispatcherExtensions#31213

Merged
jfversluis merged 3 commits intoinflight/currentfrom
unknown repository
Aug 29, 2025
Merged

[Testing] Added Tests for Issue31139 and DispatcherExtensions#31213
jfversluis merged 3 commits intoinflight/currentfrom
unknown repository

Conversation

@ghost
Copy link

@ghost ghost commented Aug 18, 2025

Description of Change

This pull request introduces a new test case to verify that binding updates from a background thread are correctly marshaled to the UI thread, and adds comprehensive unit tests for dispatcher extension methods. The changes ensure that updates to UI-bound properties from background threads do not cause crashes and are properly reflected in the UI.

New test case for background thread binding updates

  • Added Issue31139 XAML page and corresponding view model to demonstrate and test property changes from a background thread, verifying that UI updates occur safely and as expected. [1] [2]
  • Introduced a UI test (Issue31139.cs) to automatically check that the status label updates to "Success" without crashing when the property changes on a background thread.

Unit tests for dispatcher extension methods

  • Added DispatcherExtensionsTest class with multiple unit tests to ensure that DispatchIfRequired and DispatchIfRequiredAsync behave correctly depending on whether dispatching is required, covering both synchronous and asynchronous scenarios.

Output

image image

Fixes #31185

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Aug 18, 2025
@dotnet-policy-service
Copy link
Contributor

Hey there @@anandhan-rajagopal! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Aug 18, 2025
@ghost ghost added the area-testing Unit tests, device tests label Aug 18, 2025
@ghost ghost marked this pull request as ready for review August 19, 2025 14:35
Copilot AI review requested due to automatic review settings August 19, 2025 14:35
@ghost ghost self-requested a review as a code owner August 19, 2025 14:35
@ghost ghost requested review from jfversluis and mattleibow August 19, 2025 14:35
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

This PR adds a UI test case for Issue 31139 to verify that property binding updates from background threads are correctly marshaled to the UI thread without causing crashes in .NET MAUI applications.

Key changes:

  • Creates a test page with a Label bound to a view model property that updates from a background thread
  • Implements an automated UI test that waits for the "Success" text to appear, confirming the binding mechanism works correctly
  • Uses proper threading patterns with INotifyPropertyChanged to simulate real-world background update scenarios

Reviewed Changes

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

File Description
src/Controls/tests/TestCases.HostApp/Issues/Issues31139.xaml XAML page with Label bound to Status property for testing background thread updates
src/Controls/tests/TestCases.HostApp/Issues/Issues31139.xaml.cs View model with background thread that updates Status property using INotifyPropertyChanged
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31139.cs NUnit test that verifies "Success" text appears within 3 seconds

@ghost ghost changed the title [Testing] Added UI test for Issue31139 related to Dispatcher [Testing] Added Tests for Issue31139 related to DispatcherExtensions Aug 20, 2025
@ghost ghost changed the title [Testing] Added Tests for Issue31139 related to DispatcherExtensions [Testing] Added Tests for Issue31139 and DispatcherExtensions Aug 20, 2025
@PureWeen
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jfversluis jfversluis changed the base branch from main to inflight/current August 29, 2025 12:07
@jfversluis jfversluis merged commit ba60e7a into dotnet:inflight/current Aug 29, 2025
129 checks passed
@jfversluis jfversluis added this to the .NET 9 SR11 milestone Aug 29, 2025
PureWeen pushed a commit that referenced this pull request Sep 8, 2025
Update issue string

Added more tests related to Dispatcher Extensions and addresssed copilot suggestions
@github-actions github-actions bot locked and limited conversation to collaborators Sep 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-testing Unit tests, device tests community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Testing] Write a test that would have accounted for "Expose DispatcherExtentions"

4 participants