Skip to content

feat: Expose PushRequestedThemeForSubTreeByName/PopRequestedThemeForSubTreeByName as public API - #23219

Merged
agneszitte merged 1 commit into
masterfrom
dev/agzi/expose-theme-context-api
May 7, 2026
Merged

agneszitte merged 1 commit into
masterfrom
dev/agzi/expose-theme-context-api

Conversation

@agneszitte

@agneszitte agneszitte commented May 6, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds public string-accepting overloads of the internal theme-stack methods on ResourceDictionary, marked with [EditorBrowsable(EditorBrowsableState.Never)].

This allows external packages (e.g. CSharpMarkup's ThemeBindingProvider) to manage the theme context without resorting to reflection, which is fragile, trim-unsafe, and breaks when internals change.

What

  • ResourceDictionary.PushRequestedThemeForSubTreeByName(string theme) — pushes the named theme onto the resolution stack
  • ResourceDictionary.PopRequestedThemeForSubTreeByName() — pops the current theme from the stack

Both delegate to the existing internal Themes.PushRequestedThemeForSubTree/PopRequestedThemeForSubTree methods, leveraging the implicit string → ResourceKey conversion.

Why

The CSharpMarkup ThemeBindingProvider (PR unoplatform/uno.csharpmarkup#881) initially uses reflection as a first draft to call internal PushRequestedThemeForSubTree/PopRequestedThemeForSubTree. Reviewers @MartinZikmund and @dr1rrb requested that it would be best to expose a public API from Uno.UI instead.

Design decisions

  • string parameter instead of ResourceKey: The ResourceKey struct lives inside internal class SpecializedResourceDictionary, making it inaccessible to external consumers. The implicit conversion handles bridging internally.
  • ByName suffix: Distinguishes from the existing internal ResourceKey-accepting overloads.
  • [EditorBrowsable(Never)]: Keeps IntelliSense clean while allowing direct invocation by framework-aware packages.

Copilot AI review requested due to automatic review settings May 6, 2026 16:31
@agneszitte
agneszitte requested a review from MartinZikmund May 6, 2026 16:31
…ubTreeByName as public API

Adds public string-accepting overloads of the internal theme-stack methods on ResourceDictionary, marked with [EditorBrowsable(Never)]. This allows external packages (e.g. CSharpMarkup) to manage the theme context without reflection.
@unodevops

Copy link
Copy Markdown
Contributor

@agneszitte
agneszitte requested review from Copilot and removed request for Copilot May 6, 2026 18:12
@agneszitte
agneszitte merged commit 09de71a into master May 7, 2026
53 checks passed
@agneszitte
agneszitte deleted the dev/agzi/expose-theme-context-api branch May 7, 2026 02:25
@agneszitte

Copy link
Copy Markdown
Member Author

@Mergifyio backport release/stable/6.6

@mergify

mergify Bot commented May 11, 2026 •

Copy link
Copy Markdown
Contributor

backport release/stable/6.6

✅ Backports have been created

Details

agneszitte added a commit that referenced this pull request May 11, 2026
…6.6/pr-23219

feat: Expose PushRequestedThemeForSubTreeByName/PopRequestedThemeForSubTreeByName as public API (backport #23219)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants