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
|
|
@ -10,6 +10,8 @@ namespace AcDream.Core.Plugins;
|
|||
/// </summary>
|
||||
internal sealed class PluginAssemblyLoadContext : AssemblyLoadContext
|
||||
{
|
||||
private const string AbstractionsAssemblyName = "AcDream.Plugin.Abstractions";
|
||||
|
||||
private readonly AssemblyDependencyResolver _resolver;
|
||||
|
||||
public PluginAssemblyLoadContext(string pluginDirectory, string pluginEntryPath)
|
||||
|
|
@ -21,7 +23,7 @@ internal sealed class PluginAssemblyLoadContext : AssemblyLoadContext
|
|||
protected override Assembly? Load(AssemblyName assemblyName)
|
||||
{
|
||||
// Share the abstractions assembly with the host — do NOT reload it in the plugin ALC
|
||||
if (assemblyName.Name == "AcDream.Plugin.Abstractions")
|
||||
if (assemblyName.Name == AbstractionsAssemblyName)
|
||||
return null;
|
||||
|
||||
var path = _resolver.ResolveAssemblyToPath(assemblyName);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue