using StellaOps.Plugin.Security; using System; using System.Collections.Generic; using System.IO; namespace StellaOps.Plugin.Hosting; public sealed class PluginHostOptions { private readonly List _additionalPrefixes = new(); private readonly List _pluginOrder = new(); private readonly List _searchPatterns = new(); /// /// Optional base directory used for resolving relative plugin paths. Defaults to . /// public string? BaseDirectory { get; set; } /// /// Directory that contains plugin assemblies. Relative values are resolved against . /// Defaults to {PrimaryPrefix}.PluginBinaries when a primary prefix is provided, otherwise PluginBinaries. /// public string? PluginsDirectory { get; set; } /// /// Primary prefix used to discover plugin assemblies. If not supplied, the entry assembly name is used. /// public string? PrimaryPrefix { get; set; } /// /// Additional prefixes that should be considered when building search patterns. /// public IList AdditionalPrefixes => _additionalPrefixes; /// /// Explicit plugin ordering expressed as assembly names without extension. /// Entries that are not discovered will be reported in . /// public IList PluginOrder => _pluginOrder; /// /// Optional explicit search patterns. When empty, they are derived from prefix settings. /// public IList SearchPatterns => _searchPatterns; /// /// When true (default) the plugin directory will be created if it does not exist. /// public bool EnsureDirectoryExists { get; set; } = true; /// /// Controls whether sub-directories should be scanned. Defaults to true. /// public bool RecursiveSearch { get; set; } = true; /// /// The host application version used for plugin compatibility checking. /// When set, plugins with will be validated. /// public Version? HostVersion { get; set; } /// /// Whether to enforce version compatibility checking. Defaults to true. /// When false, incompatible plugins will be loaded with a warning. /// public bool EnforceVersionCompatibility { get; set; } = true; /// /// Whether plugins must declare a . Defaults to true. /// When true, plugins without the version attribute will be rejected. /// This is recommended for production deployments to ensure all plugins are properly versioned. /// public bool RequireVersionAttribute { get; set; } = true; /// /// Whether to enforce strict major version checking. Defaults to true. /// When true and a plugin does not specify MaximumHostVersion, the loader assumes /// the plugin only supports host versions with the same major version as MinimumHostVersion. /// This prevents loading plugins designed for host 1.x on host 2.x without explicit compatibility declaration. /// public bool StrictMajorVersionCheck { get; set; } = true; /// /// The signature verifier to use for plugin validation. /// Defaults to (no verification). /// Set to for production use. /// public IPluginSignatureVerifier? SignatureVerifier { get; set; } /// /// Whether to enforce signature verification. Defaults to false. /// When true and is set, plugins without valid signatures will be rejected. /// public bool EnforceSignatureVerification { get; set; } internal string ResolveBaseDirectory() => string.IsNullOrWhiteSpace(BaseDirectory) ? AppContext.BaseDirectory : Path.GetFullPath(BaseDirectory); }