formaui-net.Framework.Plugins 1.0.0-preview.27

Prefix Reserved
This is a prerelease version of formaui-net.Framework.Plugins.
dotnet add package formaui-net.Framework.Plugins --version 1.0.0-preview.27
                    
NuGet\Install-Package formaui-net.Framework.Plugins -Version 1.0.0-preview.27
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="formaui-net.Framework.Plugins" Version="1.0.0-preview.27" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="formaui-net.Framework.Plugins" Version="1.0.0-preview.27" />
                    
Directory.Packages.props
<PackageReference Include="formaui-net.Framework.Plugins" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add formaui-net.Framework.Plugins --version 1.0.0-preview.27
                    
#r "nuget: formaui-net.Framework.Plugins, 1.0.0-preview.27"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package formaui-net.Framework.Plugins@1.0.0-preview.27
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=formaui-net.Framework.Plugins&version=1.0.0-preview.27&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=formaui-net.Framework.Plugins&version=1.0.0-preview.27&prerelease
                    
Install as a Cake Tool

Forma.Framework.Plugins

A plugin registry for a feature that others extend. The feature declares its plugin contract, and the registry supplies the rest: registering plugins in order and under one another, configuring each through an options record, building every owner its own instances with their constructor arguments resolved, and disposing what it built.

Install

dotnet add package formaui-net.Framework.Plugins --prerelease
Type What it is
IPlugin An extension with an Id, unique among the plugins registered beside it; a feature's contract derives from it.
IPluginConfigurable<TOptions> Declares the options record a plugin's constructor takes.
PluginRegistry<TPlugin> What one owner registers, in order, with whatever each plugin registers under it.
PluginScope<TPlugin> One owner's built plugins, which it disposes.
PluginInstance<TPlugin> One built plugin, its Owner in the tree, and whether it IsAutonomous, governing its own lifetime.

Declaring plugins

A plugin has one public constructor. It takes its options record, other plugins in the same registry and the host's services:

using Forma.Framework.Plugins;

public interface IChartPlugin : IPlugin
{
    void Draw(Chart chart);
}

public sealed class GridOptions
{
    public int Step { get; set; } = 5;
}

public sealed class GridPlugin(GridOptions options, LinePlugin line) : IChartPlugin, IPluginConfigurable<GridOptions>
{
    public string Id => "grid";

    public void Draw(Chart chart) => chart.DrawGrid(line.Bounds, options.Step);
}

Registering

var registry = new PluginRegistry<IChartPlugin>()
    .Add<LinePlugin>(line => line
        .Add<LegendPlugin>()
        .Add<GridPlugin, GridOptions>(options => options.Step = 10))
    .Add<ExportPlugin>(_ => sharedExporter)
    .TryAdd<TooltipPlugin>();
Call What it registers
Add<TImplementation>(children) A plugin built from its constructor, with the plugins children registers under it.
Add<TImplementation, TOptions>(configure, children) A plugin that takes options; configure fills a new options record each time the registry is activated.
Add<TImplementation>(factory, children) A plugin the host creates from its IServiceProvider.
TryAdd<TImplementation>() A fallback, used only when the same registry has no Add of that type.

Registering a type again replaces the earlier registration in its place, together with whatever was registered under it.

Activating

Activate builds the registry's plugins for one owner, in registration order with each plugin followed by those under it:

await using var scope = registry.Activate(services);

foreach (var plugin in scope.Plugins)
{
    plugin.Draw(chart);
}

Each constructor parameter is taken from the first of these that supplies it:

  1. a plugin in the same registry, the nearest owner first, as one instance shared by everything that takes it;
  2. the registration's options record;
  3. the host's services;
  4. the parameter's default value.

A parameter none of them supplies, more than one public constructor, or two plugins taking each other throws an InvalidOperationException that names the plugin. The same type registered in two places is two plugins, each with its own options.

Disposing the scope disposes every plugin it built, through IAsyncDisposable or IDisposable. A plugin a factory created is autonomous and stays with the host to dispose.

License

Apache License 2.0, under the repository's LICENSE.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net11.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on formaui-net.Framework.Plugins:

Package Downloads
formaui-net.Framework.Composer.Extensibility

The contracts a FormaComposer plugin is written against: what a plugin contributes, what it reads of the composer while it runs, and what it can ask the composer to do.

formaui-net.Framework.Composer

The engine FormaComposer runs its plugins with: the description of a composer's plugins and the builders that write it, the catalog that picks the editor and the plugins in play, the registry that routes a command to the layer that runs it, the toolbar layout, the undo history, the status items and gutter markers, text operations, and document conversion.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-preview.27 47 12/3/2026
1.0.0-preview.26 53 12/3/2026
1.0.0-preview.25 63 12/2/2026
1.0.0-preview.24 65 12/1/2026
1.0.0-preview.23 88 11/30/2026
1.0.0-preview.22 82 11/30/2026
1.0.0-preview.21 87 11/29/2026
1.0.0-preview.20 93 11/26/2026
1.0.0-preview.19 94 11/26/2026
1.0.0-preview.18 87 11/26/2026
1.0.0-preview.17 80 11/26/2026
1.0.0-preview.16 77 11/24/2026
1.0.0-preview.15 76 11/23/2026
1.0.0-preview.14 80 11/23/2026
1.0.0-preview.13 82 11/21/2026
1.0.0-preview.12 81 11/20/2026
1.0.0-preview.11 87 11/18/2026
1.0.0-preview.10 83 11/17/2026
1.0.0-preview.9 110 11/17/2026
1.0.0-preview.8 93 11/17/2026
Loading failed

What this release changed is in Forma's changelog: https://github.com/FormaUI/Forma/blob/v1.0.0-preview.27/CHANGELOG.md