Improves the plugin system documentation, tests and conventions

- Documents the book metadata DTOs and the Book aggregate constructor parameters
- References ADR-0006 in the scan snapshot repository remarks, explaining the Dapper choice
- Extracts shared plugin entity fixtures and uses them in the plugin and metadata provider tests
- Moves PluginLoadResult to the Common DTO models, renaming it PluginLoadResultDto
- Replaces the duplicate Contracts plugin setting type with the shared kernel enum
- Removes the generated plugin view Designer file and its project wiring
- Drops redundant braces in the plugin repositories
This commit is contained in:
BinaryAlley committed 2026-08-12 13:58:47 -07:00
1 parent 42566dcf06
commit 3653ff5bd7
25 files changed
+168 -321

No files matched your search

@@ -14,6 +14,7 @@ using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.Library
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Queue;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Services.Jobs;
using Lumina.Infrastructure.Common.DomainEvents;
using Lumina.Infrastructure.Common.Models.DTO.Plugins;
using Lumina.Infrastructure.Core.Authentication;
using Lumina.Infrastructure.Core.Authorization;
using Lumina.Infrastructure.Core.Authorization.Policies.Common.Factory;
@@ -89,7 +90,7 @@ public static class InfrastructureLayerServices
// plugins: load the plugin assemblies from the plugins directory, register their services and provide the plugin manager
string pluginsDirectorySetting = configuration.GetSection(PluginsSettingsDto.SECTION_NAME)["Directory"] ?? "plugins";
string pluginsDirectory = Path.Combine(AppContext.BaseDirectory, pluginsDirectorySetting);
PluginLoadResult pluginLoadResult = PluginLoader.LoadPlugins(pluginsDirectory, services);
PluginLoadResultDto pluginLoadResult = PluginLoader.LoadPlugins(pluginsDirectory, services);
services.AddSingleton<IPluginManager>(new PluginManager(pluginLoadResult.Plugins));
services.AddScoped<IPluginSettingsStore, PluginSettingsStore>();
services.AddSingleton(serviceProvider => new PluginDetectionSyncJob(
@@ -0,0 +1,13 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Plugins.Contracts.Core.Plugins;
using System.Collections.Generic;
#endregion
namespace Lumina.Infrastructure.Common.Models.DTO.Plugins;
/// <summary>
/// Data transfer object for the result of loading the plugins from the plugins directory.
/// </summary>
/// <param name="Plugins">The plugins that were loaded successfully.</param>
/// <param name="Errors">The errors that occurred while loading the plugins.</param>
internal sealed record PluginLoadResultDto(IReadOnlyList<IPlugin> Plugins, IReadOnlyList<string> Errors);
@@ -1,4 +1,5 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Infrastructure.Common.Models.DTO.Plugins;
using Lumina.Plugins.Contracts.Core.Plugins;
using Microsoft.Extensions.DependencyInjection;
using System;
@@ -9,13 +10,6 @@ using System.Reflection;
namespace Lumina.Infrastructure.Core.Plugins;
/// <summary>
/// Result of loading the plugins from the plugins directory.
/// </summary>
/// <param name="Plugins">The plugins that were loaded successfully.</param>
/// <param name="Errors">The errors that occurred while loading the plugins.</param>
internal sealed record PluginLoadResult(IReadOnlyList<IPlugin> Plugins, IReadOnlyList<string> Errors);
/// <summary>
/// Loads the plugins from the plugins directory, discovers their descriptors and registers their services.
/// </summary>
@@ -27,13 +21,13 @@ internal static class PluginLoader
/// <param name="pluginsDirectory">The directory where the plugin assemblies are located.</param>
/// <param name="services">The service collection to which the plugin services are added.</param>
/// <returns>The result of loading the plugins.</returns>
public static PluginLoadResult LoadPlugins(string pluginsDirectory, IServiceCollection services)
public static PluginLoadResultDto LoadPlugins(string pluginsDirectory, IServiceCollection services)
{
List<IPlugin> plugins = [];
List<string> errors = [];
if (!Directory.Exists(pluginsDirectory))
return new PluginLoadResult(plugins, errors);
return new PluginLoadResultDto(plugins, errors);
foreach (string assemblyPath in Directory.EnumerateFiles(pluginsDirectory, "*.dll"))
{
@@ -60,6 +54,6 @@ internal static class PluginLoader
}
}
return new PluginLoadResult(plugins, errors);
return new PluginLoadResultDto(plugins, errors);
}
}