Skip to content

Add optional factory delegate support to IPluginStyleInclusion#125

Merged
mdwigley merged 1 commit intoenterlucent:mainfrom
mdwigley:issue#117-mdwigley
Oct 13, 2025
Merged

Add optional factory delegate support to IPluginStyleInclusion#125
mdwigley merged 1 commit intoenterlucent:mainfrom
mdwigley:issue#117-mdwigley

Conversation

@mdwigley
Copy link
Member

Description

This change extends PluginStyleIncludeDescriptor with an optional Func<IStyle> factory.

The bootstrapper has been updated to handle both:

  • URI‑based StyleInclude resources (existing behavior, unchanged).
  • Factory‑produced styles (new behavior).

Factory styles are deduplicated by type to prevent multiple injections of the same theme.

This enables scenarios like shipping FluentAvalonia 2 (FA2) as a plugin rather than hard‑coding it in the host application.

Related Issue

Motivation and Context

Previously, only XAML resources could be included via ResourceUri.
Some libraries (e.g. FA2) require programmatic initialization.
Adding a factory delegate allows plugins to contribute styles and themes that cannot be expressed as static XAML includes.
This keeps the host app lean and makes theming pluggable.

How Has This Been Tested?

  • Verified with a mock plugin that injects a simple TextBlock style via factory (all text turned red as expected).
  • Verified with a mock plugin that injects a FluentAvaloniaTheme via factory (theme applied successfully).
  • Confirmed that existing URI‑based includes continue to load without change.

Screenshots (if appropriate):

N/A

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Asset change (adds or updates icons, templates, or other assets)
  • Documentation change (adds or updates documentation)
  • Plugin change (adds or updates a plugin)

Checklist:

  • I have read the CONTRIBUTING document.
  • My change requires a change to the core logic.
    • I have linked the project issue above.
  • My change requires a change to the assets.
    • I have linked the asset issue above.
  • My change requires a change to the documentation.
    • I have linked the documentation issue above.
  • My change requires a change to a plugin.
    • I have linked the plugin issue above.

@mdwigley mdwigley self-assigned this Oct 13, 2025
@mdwigley mdwigley moved this to In review in PlugHub Timeline Oct 13, 2025
@mdwigley mdwigley merged commit 0aa311b into enterlucent:main Oct 13, 2025
3 checks passed
@github-project-automation github-project-automation bot moved this from In review to Done in PlugHub Timeline Oct 13, 2025
@mdwigley mdwigley deleted the issue#117-mdwigley branch October 13, 2025 21:46
@mdwigley mdwigley added the approved Change issue has been accepted for implementation label Oct 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Change issue has been accepted for implementation

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Support Factory Lambda for Avalonia Style Injection

1 participant