Skip to content

feat: Expose PushRequestedThemeForSubTreeByName/PopRequestedThemeForSubTreeByName as public API (backport #23219) - #23248

Merged
agneszitte merged 1 commit into
release/stable/6.6from
mergify/bp/release/stable/6.6/pr-23219
May 11, 2026
Merged

agneszitte merged 1 commit into
release/stable/6.6from
mergify/bp/release/stable/6.6/pr-23219

Conversation

@mergify

@mergify mergify Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

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.

…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.

(cherry picked from commit dafa218)
@agneszitte
agneszitte merged commit 352f7db into release/stable/6.6 May 11, 2026
7 of 10 checks passed
@agneszitte
agneszitte deleted the mergify/bp/release/stable/6.6/pr-23219 branch May 11, 2026 17:38
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.

1 participant