Addresses code quality review of a7f0732:
- LoadedPlugin now holds the AssemblyLoadContext explicitly so Task 10
can call Unload() for hot reload (Critical)
- LoadedPlugin.Error is Exception? to match PluginDiscoveryResult and
preserve stack traces; synthetic failures build FileNotFoundException
and InvalidOperationException (Important)
- PluginLoader falls back to ReflectionTypeLoadException.Types if
GetTypes() can't fully resolve (Important)
- Hardcoded abstractions assembly name is now a const (Minor)
20 lines
689 B
C#
20 lines
689 B
C#
using System.Runtime.Loader;
|
|
using AcDream.Plugin.Abstractions;
|
|
|
|
namespace AcDream.Core.Plugins;
|
|
|
|
/// <summary>
|
|
/// Outcome of a plugin load attempt.
|
|
/// <para>On success, <see cref="Plugin"/> is the instantiated plugin, <see cref="LoadContext"/>
|
|
/// owns its assembly, and <see cref="Error"/> is null.</para>
|
|
/// <para>On failure, <see cref="Plugin"/> and <see cref="LoadContext"/> are null and
|
|
/// <see cref="Error"/> describes what went wrong.</para>
|
|
/// </summary>
|
|
public sealed record LoadedPlugin(
|
|
PluginManifest Manifest,
|
|
IAcDreamPlugin? Plugin,
|
|
AssemblyLoadContext? LoadContext,
|
|
Exception? Error)
|
|
{
|
|
public bool Success => Plugin is not null && Error is null;
|
|
}
|