diff --git a/src/Bannerlord.ModuleManager.Models/Issues/ModuleIssueV2.cs b/src/Bannerlord.ModuleManager.Models/Issues/ModuleIssueV2.cs index 87904c1..1a1baa1 100644 --- a/src/Bannerlord.ModuleManager.Models/Issues/ModuleIssueV2.cs +++ b/src/Bannerlord.ModuleManager.Models/Issues/ModuleIssueV2.cs @@ -115,6 +115,50 @@ DependentModuleMetadata Dependency ApplicationVersionRange.Empty); } +/// +/// Represents an issue where the `Bannerlord Software Extender` (BLSE) is missing. +/// +/// The module with the missing dependency +/// The missing dependency module +/// +/// This issue occurs when a mod requires the `Bannerlord Software Extender` (BLSE) +/// but it is not installed. +/// +/// Example scenario: +/// ```xml +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// ``` +/// If `BLSE` is not installed at all, this issue will be raised if `SimpleTournaments` is enabled. +/// +#if !BANNERLORDBUTRMODULEMANAGER_PUBLIC +internal +#else +public +# endif + sealed record ModuleMissingBLSEDependencyIssue( + ModuleInfoExtended Module, + DependentModuleMetadata Dependency + ) : ModuleIssueV2(Module) +{ + public override string ToString() => $"Missing Bannerlord Software Extender"; + public override LegacyModuleIssue ToLegacy() => new( + Module, + Dependency.Id, + ModuleIssueType.MissingBLSE, + ToString(), + ApplicationVersionRange.Empty); +} + /// /// Represents an issue where a required dependency module is missing AND an exact version was specified /// diff --git a/src/Bannerlord.ModuleManager.Models/ModuleIssueType.cs b/src/Bannerlord.ModuleManager.Models/ModuleIssueType.cs index 5048785..6c07173 100644 --- a/src/Bannerlord.ModuleManager.Models/ModuleIssueType.cs +++ b/src/Bannerlord.ModuleManager.Models/ModuleIssueType.cs @@ -56,6 +56,8 @@ enum ModuleIssueType MissingModuleName, DependencyIsNull, DependencyMissingModuleId, + + MissingBLSE, } #nullable restore diff --git a/src/Bannerlord.ModuleManager/ModuleUtilities.cs b/src/Bannerlord.ModuleManager/ModuleUtilities.cs index 2cb5e16..1f59598 100644 --- a/src/Bannerlord.ModuleManager/ModuleUtilities.cs +++ b/src/Bannerlord.ModuleManager/ModuleUtilities.cs @@ -273,7 +273,7 @@ public static IEnumerable ValidateModuleEx( bool validateDependencies = true) { var visited = new HashSet(); - foreach (var issue in ValidateModuleEx(modules, targetModule, visited, isSelected, isValid)) + foreach (var issue in ValidateModuleEx(modules, targetModule, visited, isSelected, isValid, validateDependencies)) { yield return issue; } @@ -427,7 +427,10 @@ private static IEnumerable ValidateModuleDependenciesEx( if (!modules.Any(x => string.Equals(x.Id, metadata.Id, StringComparison.Ordinal))) { - if (metadata.Version != ApplicationVersion.Empty) + // For BLSE, there is a special case, + if (metadata.Id is "BLSE.LoadingInterceptor" or "BLSE.AssemblyResolver") + yield return new ModuleMissingBLSEDependencyIssue(targetModule, metadata); + else if (metadata.Version != ApplicationVersion.Empty) yield return new ModuleMissingExactVersionDependencyIssue(targetModule, metadata); else if (metadata.VersionRange != ApplicationVersionRange.Empty) yield return new ModuleMissingVersionRangeDependencyIssue(targetModule, metadata); @@ -600,8 +603,12 @@ public static IEnumerable ValidateLoadOrderEx( if (metadataIdx == -1) { + // For BLSE, there is a special case, + if (metadata.Id is "BLSE.LoadingInterceptor" or "BLSE.AssemblyResolver") + yield return new ModuleMissingBLSEDependencyIssue(targetModule, metadata); + // If the dependency lacks an Id, it's not valid - if (!string.IsNullOrWhiteSpace(metadata.Id) && !metadata.IsOptional) + else if (!string.IsNullOrWhiteSpace(metadata.Id) && !metadata.IsOptional) { if (metadata.Version != ApplicationVersion.Empty) yield return new ModuleMissingExactVersionDependencyIssue(targetModule, metadata);