-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expose DispatcherExtensions so it could be used outside of Maui as well #30488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: net10.0
Are you sure you want to change the base?
Conversation
Hey there @@Vignesh-SF3580! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
There was a problem hiding this 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 exposes new DispatcherExtensions
methods so they can be used outside of .NET MAUI and updates the Public API accordingly.
- Adds
DispatchIfRequired
and multipleDispatchIfRequiredAsync
overloads toDispatcherExtensions
- Updates unit tests to cover all new extension overloads
- Removes duplicate dispatcher helpers in
Controls
and adds necessary using directives
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/Core/src/Dispatching/DispatcherExtensions.cs | Added new DispatchIfRequired and various DispatchIfRequiredAsync extension methods |
src/Core/tests/UnitTests/Dispatching/DispatcherTests.cs | Added 14 new facts to verify each overload of the new extension methods |
src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt | Registered the new extension methods in the Public API |
src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt | Registered the new extension methods in the Public API |
src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt | Registered the new extension methods in the Public API |
src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt | Registered the new extension methods in the Public API |
src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt | Registered the new extension methods in the Public API |
src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt | Registered the new extension methods in the Public API |
src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt | Registered the new extension methods in the Public API |
src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt | Registered the new extension methods in the Public API |
src/Controls/src/Core/Handlers/Items/Android/ItemsSources/ObservableItemsSource.cs | Added using Microsoft.Maui.Dispatching; to use shared dispatcher extensions |
src/Controls/src/Core/Handlers/Items/Android/ItemsSources/ObservableGroupedSource.cs | Added using Microsoft.Maui.Dispatching; to use shared dispatcher extensions |
src/Controls/src/Core/DispatcherExtensions.cs | Removed local DispatchIfRequired* implementations in favor of the shared ones in Core |
src/Controls/src/Core/BindingExpression.cs | Added using Microsoft.Maui.Dispatching; |
src/Controls/src/Core/AppThemeBinding.cs | Added using Microsoft.Maui.Dispatching; |
Comments suppressed due to low confidence (4)
src/Core/src/Dispatching/DispatcherExtensions.cs:97
- New public extension methods require corresponding updates to the official documentation (under /docs) to describe DispatchIfRequired and its overloads.
public static void DispatchIfRequired(this IDispatcher dispatcher, Action action)
src/Core/src/Dispatching/DispatcherExtensions.cs:112
- Fill in the
<param>
and<returns>
XML comments for the DispatchIfRequiredAsync overloads to clearly document parameters and return values.
/// <param name="dispatcher"></param>
src/Controls/src/Core/BindingExpression.cs:13
- [nitpick] This using directive appears unused in this file; consider removing it to keep imports clean.
using Microsoft.Maui.Dispatching;
src/Controls/src/Core/AppThemeBinding.cs:6
- [nitpick] This using directive appears unused in this file; consider removing it to keep imports clean.
using Microsoft.Maui.Dispatching;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some build errors:
C:\a\_work\1\s\src\Controls\src\Core\Platform\Windows\CollectionView\GroupedItemTemplateCollection.cs(83,26): error CS1061: 'IDispatcher' does not contain a definition for 'DispatchIfRequired' and no accessible extension method 'DispatchIfRequired' accepting a first argument of type 'IDispatcher' could be found (are you missing a using directive or an assembly reference?) [C:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net10.0-windows10.0.19041.0]
C:\a\_work\1\s\src\Controls\src\Core\Platform\Windows\CollectionView\ObservableItemTemplateCollection.cs(146,26): error CS1061: 'IDispatcher' does not contain a definition for 'DispatchIfRequired' and no accessible extension method 'DispatchIfRequired' accepting a first argument of type 'IDispatcher' could be found (are you missing a using directive or an assembly reference?) [C:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net10.0-windows10.0.19041.0]
C:\Users\cloudtest\.nuget\packages\microsoft.windowsappsdk\1.7.250606001\buildTransitive\Microsoft.UI.Xaml.Markup.Compiler.interop.targets(845,9): error MSB3073: The command ""C:\Users\cloudtest\.nuget\packages\microsoft.windowsappsdk\1.7.250606001\buildTransitive\..\tools\net6.0\..\net472\XamlCompiler.exe" "C:\a\_work\1\s\artifacts\obj\Controls.Core\Release\net10.0-windows10.0.19041.0\\input.json" "C:\a\_work\1\s\artifacts\obj\Controls.Core\Release\net10.0-windows10.0.19041.0\\output.json"" exited with code 1. [C:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net10.0-windows10.0.19041.0]
C:\a\_work\1\s\src\Compatibility\Core\src\iOS\VisualElementTracker.cs(347,21): error CS1061: 'IDispatcher' does not contain a definition for 'DispatchIfRequired' and no accessible extension method 'DispatchIfRequired' accepting a first argument of type 'IDispatcher' could be found (are you missing a using directive or an assembly reference?) [C:\a\_work\1\s\src\Compatibility\Core\src\Compatibility.csproj::TargetFramework=net10.0-ios18.5]
C:\a\_work\1\s\src\Compatibility\Core\src\iOS\VisualElementTracker.cs(347,21): error CS1061: 'IDispatcher' does not contain a definition for 'DispatchIfRequired' and no accessible extension method 'DispatchIfRequired' accepting a first argument of type 'IDispatcher' could be found (are you missing a using directive or an assembly reference?) [C:\a\_work\1\s\src\Compatibility\Core\src\Compatibility.csproj::TargetFramework=net10.0-maccatalyst18.5]
C:\a\_work\1\s\src\Controls\src\Core\Platform\Windows\CollectionView\ObservableItemTemplateCollection.cs(146,26): error CS1061: 'IDispatcher' does not contain a definition for 'DispatchIfRequired' and no accessible extension method 'DispatchIfRequired' accepting a first argument of type 'IDispatcher' could be found (are you missing a using directive or an assembly reference?) [C:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net10.0-windows10.0.20348.0]
C:\a\_work\1\s\src\Controls\src\Core\Platform\Windows\CollectionView\GroupedItemTemplateCollection.cs(83,26): error CS1061: 'IDispatcher' does not contain a definition for 'DispatchIfRequired' and no accessible extension method 'DispatchIfRequired' accepting a first argument of type 'IDispatcher' could be found (are you missing a using directive or an assembly reference?) [C:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net10.0-windows10.0.20348.0]
C:\Users\cloudtest\.nuget\packages\microsoft.windowsappsdk\1.7.250606001\buildTransitive\Microsoft.UI.Xaml.Markup.Compiler.interop.targets(845,9): error MSB3073: The command ""C:\Users\cloudtest\.nuget\packages\microsoft.windowsappsdk\1.7.250606001\buildTransitive\..\tools\net6.0\..\net472\XamlCompiler.exe" "C:\a\_work\1\s\artifacts\obj\Controls.Core\Release\net10.0-windows10.0.20348.0\\input.json" "C:\a\_work\1\s\artifacts\obj\Controls.Core\Release\net10.0-windows10.0.20348.0\\output.json"" exited with code 1. [C:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net10.0-windows10.0.20348.0]
C:\a\_work\1\s\src\Compatibility\Core\src\Android\CollectionView\ObservableGroupedSource.cs(235,35): error CS1061: 'IDispatcher' does not contain a definition for 'DispatchIfRequired' and no accessible extension method 'DispatchIfRequired' accepting a first argument of type 'IDispatcher' could be found (are you missing a using directive or an assembly reference?) [C:\a\_work\1\s\src\Compatibility\Core\src\Compatibility.csproj::TargetFramework=net10.0-android36.0]
C:\a\_work\1\s\src\Compatibility\Core\src\Android\CollectionView\ObservableItemsSource.cs(94,26): error CS1061: 'IDispatcher' does not contain a definition for 'DispatchIfRequired' and no accessible extension method 'DispatchIfRequired' accepting a first argument of type 'IDispatcher' could be found (are you missing a using directive or an assembly reference?) [C:\a\_work\1\s\src\Compatibility\Core\src\Compatibility.csproj::TargetFramework=net10.0-android36.0]
10 Error(s)
Could you review it?
@jsuarezruiz I’ve resolved the build errors. Please let me know if any further changes are required. |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
Exposing the DispatcherExtensions so it could be used outside of Maui as well.
Issues Fixed
Fixes #29258