Vixen
02b45cc4
csharp
public sealed class PluginRegistrations

Everything one plugin added, and how to take each of it back out.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Unloading is undoing, and this is the undo stack. A collectible PluginLoadContext only collects once nothing outside it refers to anything inside it — and a command whose Run is a lambda over the plugin's own state is precisely such a reference, held by the editor's command registry. So a plugin that registered five things and was then unloaded without them being removed does not leak five entries; it leaks its whole assembly, permanently, with no error anywhere.

⚠ Undone in reverse order. The same reason an undo stack is: a plugin that registered a panel and then a menu entry naming its command would otherwise have the command taken away while a menu still names it. The menu builder survives that — an id nothing registered is skipped — but the general case does not, and reverse order costs nothing.

⚠ A failing undo does not stop the rest. One that threw halfway through would leave the plugin half-registered and its context uncollectable, which is strictly worse than the thing it was complaining about. Failures are collected into Failures and reported.

Fields and properties (3)

  • public int Count

    How many things are registered.

  • public List<Action<TimeSpan>> Updates

    What this plugin asked to have called once a frame. See OnUpdate.

  • public IReadOnlyList<Exception> Failures

    What went wrong while undoing, if anything.

Methods (2)

  • public void Add(Action action)

    Records something to undo when the plugin goes away.

  • public void Dispose()

    Takes everything back out.

Used by (3)

  • LoadedPluginVixen.Editor.Plugin
  • PluginContextVixen.Editor.Plugin
  • PluginHostVixen.Editor.Plugin