refactor(core): harden PluginLoader per code review
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)
This commit is contained in:
parent
a7f0732026
commit
f6a57cbc6c
4 changed files with 45 additions and 8 deletions
|
|
@ -1,11 +1,20 @@
|
|||
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,
|
||||
string? Error)
|
||||
AssemblyLoadContext? LoadContext,
|
||||
Exception? Error)
|
||||
{
|
||||
public bool Success => Plugin is not null && Error is null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue