Update AppThemeResourceExtension to not use IProvideParentValues#2639
Merged
TheCodeTraveler merged 5 commits intomainfrom Jun 5, 2025
Merged
Update AppThemeResourceExtension to not use IProvideParentValues#2639TheCodeTraveler merged 5 commits intomainfrom
TheCodeTraveler merged 5 commits intomainfrom
Conversation
bijington
previously approved these changes
Jun 5, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
Updates AppThemeResourceExtension to remove its reliance on the internal IProvideParentValues interface by introducing a custom resource lookup that leverages IProvideValueTarget, IRootObjectProvider, and application‐level resources.
- Replaced the
RequireServiceattribute to useIProvideValueTargetandIRootObjectProvider. - Reimplemented
ProvideValueto search resources via visual tree traversal, root object, then application resources. - Added
TryFindResourceInVisualElementhelper and adjusted exception messages; also fixed a typo inAppThemeObject.shared.cs.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/CommunityToolkit.Maui/Extensions/AppThemeResourceExtension.shared.cs | Swap out IProvideParentValues dependency and implement new lookup logic |
| src/CommunityToolkit.Maui/Essentials/AppTheme/AppThemeObject.shared.cs | Corrected spelling in XML doc comment (diffent → different) |
Comments suppressed due to low confidence (1)
src/CommunityToolkit.Maui/Extensions/AppThemeResourceExtension.shared.cs:88
- The summary only mentions visual tree traversal, but the method also checks the element itself for
IResourcesProviderand supportsResourceDictionarylookups. Update the doc comment to accurately describe all lookup paths.
/// Attempts to locate a resource by walking up the visual tree from a target object.
src/CommunityToolkit.Maui/Extensions/AppThemeResourceExtension.shared.cs
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
This PR updates
AppThemeResourceExtensionto not useIProvideParentValues, which is internal to .NET MAUI.At the .NET MAUI side we're exploring to remove the InternalsVisibleTo for the Toolkit since it shouldn't be necessary.
Most APIs there will be removed with the Popup v2 implementation (yay), the rest are being used in AvatarView and we're OK to make those public on the .NET MAUI side for .NET 10, but the one used in
AppThemeResourceExtensionwe're not OK with making public.Therefore, this PR explores an alternative implementation that does not use
IProvideParentValues