public sealed class PluginLoadContextOne plugin's assemblies, loaded so that they can be thrown away again.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Collectible, which is the whole point. A plugin author who has to restart the editor to see a change has a ten-second edit cycle and stops iterating; one whose plugin can be unloaded and reloaded in place has the cycle the rest of the editor has. Doc 11 asks for exactly this, and it is the reason Vixen.Editor.App is not NativeAOT — a collectible context and an ahead-of-time-compiled process are not compatible ideas.
⚠ Anything shared with the host resolves to the host's copy, and getting this wrong is the classic failure. If a plugin's folder contains Vixen.Editor.Plugin.dll and this context loads it, the plugin's IEditorPlugin is a different type from the host's — same name, same assembly name, different load context — so the cast in the loader fails with a message that reads like a lie ("cannot cast IEditorPlugin to IEditorPlugin"). The rule below prevents it: an assembly the host already has, or any Vixen.*, comes from the default context.
⚠ The entry assembly is read into memory rather than mapped from disk. LoadFromAssemblyPath holds the file open until the context is collected, which on Windows means the developer's next build fails to write the DLL it has just been asked to reload. Its own dependencies are mapped, so a plugin that changes a library beside itself still needs a restart — that is a shadow-copy feature and this is not it, but the file a plugin author rebuilds ten times an hour is the one that is free.
The .deps.json beside the assembly is what resolves everything else, through AssemblyDependencyResolver — the same file dotnet build writes with no work from the plugin author, and the same mechanism that finds the right native library for the running RID.
Fields and properties (2)
public const string SharedPrefixAssemblies with this prefix always come from the host.
public string AssemblyPathThe plugin's assembly.
Methods (5)
public PluginLoadContext(string assemblyPath, string? name = null)Opens a context for one plugin.
public Assembly LoadPlugin()Loads the plugin's own assembly into this context.
public bool IsShared(string? name)Whether an assembly is one the host owns rather than one the plugin brings.
protected override Assembly? Load(AssemblyName assemblyName)When overridden in a derived class, allows an assembly to be resolved based on its AssemblyName.
protected override nint LoadUnmanagedDll(string unmanagedDllName)
Used by (4)
- EditorScriptsVixen.Editor.Scripts
- LoadedPluginVixen.Editor.Plugin
- PluginHostVixen.Editor.Plugin
- ProjectAssembliesVixen.Editor.App