Vixen
02b45cc4
csharp
public sealed class ProjectAssemblies

The project's own code, built and loaded so the editor can see what it declares.

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

Remarks

The fourth seam, and the one that makes the other three about a game rather than about the engine. A behaviour is authorable because a generator declared it and a bridge draws it — but only for assemblies the editor already references. This is what puts a script somebody wrote this morning in the Add Component menu.

⚠ The context is PluginLoadContext, which already solved every hard part of this. Collectible, so a rebuild can replace it; Vixen.* resolved against the host, so the project's Behavior is the editor's Behavior and not a same-named stranger; and the entry assembly read into memory rather than mapped, so the next build can overwrite the file it just loaded. Reusing it is not thrift — a second context that got any of those wrong would fail in exactly the ways its remarks describe.

⚠ Loading an assembly does not run its module initializers. The runtime defers them to the first access of the module, and nothing here accesses anything — so a project whose behaviours register from a [ModuleInitializer] would load, hold them, and declare nothing. Load runs the module constructor by hand, which is ComponentsView.Prime's problem meeting the same answer from the other side.

⚠ Unloading evicts before it unloads, and the order is the whole of it. A binder left in SceneComponentRegistry or SceneBehaviorRegistry names a type in the context being dropped — which keeps that context alive, so the unload never completes and the next build cannot overwrite the file. See Unload.

⚠ What a caller must do first is take the live instances off. This knows nothing about scenes; a behaviour authored into one is an object of a type that is about to stop existing, and ISceneBehaviorBinder.Save is how its values cross the gap. The editor does that around its call — see EditorApplication.BuildProjectCode.

Fields and properties (3)

  • public static TimeSpan Timeout

    How long a build may take before it is given up on.

  • public Assembly? Loaded

    The assembly currently loaded, or if none is.

  • public string? Project

    The project's own .csproj, or if it has none.

Methods (4)

  • public ProjectAssemblies(ProjectPaths project)

    Watches one project's code.

  • public bool Unload()

    Forgets the loaded assembly's declarations and drops its context.

  • public ProjectBuild Reload()

    Builds the project's code and loads what came out.

  • public Assembly Load(string assemblyPath)

    Loads an already-built assembly into a context of its own.

Used by (2)

  • EditorApplicationVixen.Editor.App
  • ProjectAssemblyTestsVixen.Editor.App.Tests