Skip to content

Conversation

@jfversluis
Copy link
Member

Description of Change

This PR updates AppThemeResourceExtension to not use IProvideParentValues, 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 AppThemeResourceExtension we're not OK with making public.

Therefore, this PR explores an alternative implementation that does not use IProvideParentValues

@jfversluis jfversluis added the area/extensions Issue/Discussion/PR that has to do with Extensions label Apr 22, 2025
@jfversluis jfversluis requested a review from Copilot April 22, 2025 20:37

This comment was marked as outdated.

@jfversluis jfversluis marked this pull request as ready for review April 24, 2025 15:06
@dotnet-policy-service dotnet-policy-service bot added stale The author has not responded in over 30 days help wanted This proposal has been approved and is ready to be implemented labels May 25, 2025
@jfversluis jfversluis removed help wanted This proposal has been approved and is ready to be implemented stale The author has not responded in over 30 days labels Jun 3, 2025
bijington
bijington previously approved these changes Jun 5, 2025
@TheCodeTraveler TheCodeTraveler requested a review from Copilot June 5, 2025 21:29
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

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 RequireService attribute to use IProvideValueTarget and IRootObjectProvider.
  • Reimplemented ProvideValue to search resources via visual tree traversal, root object, then application resources.
  • Added TryFindResourceInVisualElement helper and adjusted exception messages; also fixed a typo in AppThemeObject.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 (diffentdifferent)
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 IResourcesProvider and supports ResourceDictionary lookups. 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.

Copy link
Collaborator

@TheCodeTraveler TheCodeTraveler left a comment

Choose a reason for hiding this comment

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

Thanks Gerald!

@TheCodeTraveler TheCodeTraveler merged commit ee08ac2 into main Jun 5, 2025
8 of 10 checks passed
@TheCodeTraveler TheCodeTraveler deleted the appthemeext-nointernals branch June 5, 2025 21:42
@github-actions github-actions bot locked and limited conversation to collaborators Jun 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area/extensions Issue/Discussion/PR that has to do with Extensions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants