diff --git a/src/Bannerlord.LauncherManager.Native/Bindings.LauncherManager.cs b/src/Bannerlord.LauncherManager.Native/Bindings.LauncherManager.cs index f7c5dd0..be0fced 100644 --- a/src/Bannerlord.LauncherManager.Native/Bindings.LauncherManager.cs +++ b/src/Bannerlord.LauncherManager.Native/Bindings.LauncherManager.cs @@ -179,8 +179,10 @@ public static unsafe partial class Bindings if (p_handle is null || LauncherManagerHandlerNative.FromPointer(p_handle) is not { } handler) return return_value_json.AsError(BUTR.NativeAOT.Shared.Utils.Copy("Handler is null or wrong!", false), false); - var files = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_files, CustomSourceGenerationContext.StringArray); - var moduleInfos = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_module_infos, CustomSourceGenerationContext.ModuleInfoExtendedWithMetadataArray); + var files = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_files, CustomSourceGenerationContext.StringArray) + .Where(x => x is not null).ToArray();; + var moduleInfos = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_module_infos, CustomSourceGenerationContext.ModuleInfoExtendedWithMetadataArray) + .Where(x => x is not null).ToArray();; var result = handler.InstallModuleContent(files, moduleInfos); Logger.LogOutput(result); diff --git a/src/Bannerlord.LauncherManager.Native/Bindings.ModuleManager.cs b/src/Bannerlord.LauncherManager.Native/Bindings.ModuleManager.cs index 2ca37fa..2673eb9 100644 --- a/src/Bannerlord.LauncherManager.Native/Bindings.ModuleManager.cs +++ b/src/Bannerlord.LauncherManager.Native/Bindings.ModuleManager.cs @@ -32,7 +32,8 @@ public static unsafe partial class Bindings Logger.LogInput(p_source); try { - var source = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_source, CustomSourceGenerationContext.ModuleInfoExtendedArray); + var source = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_source, CustomSourceGenerationContext.ModuleInfoExtendedArray) + .Where(x => x is not null).ToArray();; var result = ModuleSorter.Sort(source).ToArray(); @@ -52,7 +53,8 @@ public static unsafe partial class Bindings Logger.LogInput(p_source, p_options); try { - var source = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_source, CustomSourceGenerationContext.ModuleInfoExtendedArray); + var source = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_source, CustomSourceGenerationContext.ModuleInfoExtendedArray) + .Where(x => x is not null).ToArray();; var options = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_options, CustomSourceGenerationContext.ModuleSorterOptions); var result = ModuleSorter.Sort(source, options).ToArray(); @@ -74,7 +76,8 @@ public static unsafe partial class Bindings Logger.LogInput(p_source, p_module); try { - var source = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_source, CustomSourceGenerationContext.ModuleInfoExtendedArray); + var source = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_source, CustomSourceGenerationContext.ModuleInfoExtendedArray) + .Where(x => x is not null).ToArray();; var module = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_module, CustomSourceGenerationContext.ModuleInfoExtended); var result = ModuleUtilities.AreDependenciesPresent(source, module); @@ -96,7 +99,8 @@ public static unsafe partial class Bindings Logger.LogInput(p_source, p_module); try { - var source = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_source, CustomSourceGenerationContext.ModuleInfoExtendedArray); + var source = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_source, CustomSourceGenerationContext.ModuleInfoExtendedArray) + .Where(x => x is not null).ToArray();; var module = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_module, CustomSourceGenerationContext.ModuleInfoExtended); var result = ModuleUtilities.GetDependencies(source, module).ToArray(); @@ -117,7 +121,8 @@ public static unsafe partial class Bindings Logger.LogInput(p_source, p_module, p_options); try { - var source = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_source, CustomSourceGenerationContext.ModuleInfoExtendedArray); + var source = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_source, CustomSourceGenerationContext.ModuleInfoExtendedArray) + .Where(x => x is not null).ToArray();; var module = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_module, CustomSourceGenerationContext.ModuleInfoExtended); var options = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_options, CustomSourceGenerationContext.ModuleSorterOptions); @@ -142,7 +147,8 @@ public static unsafe partial class Bindings Logger.LogInput(p_modules, p_target_module); try { - var modules = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_modules, CustomSourceGenerationContext.ModuleInfoExtendedArray); + var modules = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_modules, CustomSourceGenerationContext.ModuleInfoExtendedArray) + .Where(x => x is not null).ToArray(); var targetModule = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_target_module, CustomSourceGenerationContext.ModuleInfoExtended); var isSelected = Marshal.GetDelegateForFunctionPointer(new IntPtr(p_is_selected)); @@ -177,7 +183,8 @@ public static unsafe partial class Bindings Logger.LogInput(p_modules, p_target_module); try { - var modules = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_modules, CustomSourceGenerationContext.ModuleInfoExtendedArray); + var modules = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_modules, CustomSourceGenerationContext.ModuleInfoExtendedArray) + .Where(x => x is not null).ToArray();; var targetModule = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_target_module, CustomSourceGenerationContext.ModuleInfoExtended); var result = ModuleUtilities.ValidateLoadOrder(modules, targetModule).ToArray(); @@ -207,7 +214,8 @@ public static unsafe partial class Bindings Logger.LogInput(p_module, p_target_module); try { - var modules = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_module, CustomSourceGenerationContext.ModuleInfoExtendedArray); + var modules = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_module, CustomSourceGenerationContext.ModuleInfoExtendedArray) + .Where(x => x is not null).ToArray();; var targetModule = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_target_module, CustomSourceGenerationContext.ModuleInfoExtended); var getSelected = Marshal.GetDelegateForFunctionPointer(new IntPtr(p_get_selected)); @@ -287,7 +295,8 @@ public static unsafe partial class Bindings Logger.LogInput(p_module, p_target_module); try { - var modules = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_module, CustomSourceGenerationContext.ModuleInfoExtendedArray); + var modules = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_module, CustomSourceGenerationContext.ModuleInfoExtendedArray) + .Where(x => x is not null).ToArray();; var targetModule = BUTR.NativeAOT.Shared.Utils.DeserializeJson(p_target_module, CustomSourceGenerationContext.ModuleInfoExtended); var getSelected = Marshal.GetDelegateForFunctionPointer(new IntPtr(p_get_selected)); @@ -388,7 +397,7 @@ public static unsafe partial class Bindings var result = new ModuleInfoExtendedWithPath(module, new string(param_string.ToSpan(p_path))); Logger.LogOutput(result); - return return_value_json.AsValue(result, CustomSourceGenerationContext.ModuleInfoExtended, false); + return return_value_json.AsValue(result, CustomSourceGenerationContext.ModuleInfoExtendedWithPath, false); } catch (Exception e) { @@ -406,10 +415,10 @@ public static unsafe partial class Bindings doc.LoadXml(new string(param_string.ToSpan(p_xml_content))); var module = ModuleInfoExtended.FromXml(doc); - var result = new ModuleInfoExtendedWithMetadata(module, Enum.TryParse(new string(param_string.ToSpan(p_path)), out var e) ? e : ModuleProviderType.Default, new string(param_string.ToSpan(p_path))); + var result = new ModuleInfoExtendedWithMetadata(module, Enum.TryParse(new string(param_string.ToSpan(p_module_provider)), out var e) ? e : ModuleProviderType.Default, new string(param_string.ToSpan(p_path))); Logger.LogOutput(result); - return return_value_json.AsValue(result, CustomSourceGenerationContext.ModuleInfoExtended, false); + return return_value_json.AsValue(result, CustomSourceGenerationContext.ModuleInfoExtendedWithMetadata, false); } catch (Exception e) { diff --git a/src/Bannerlord.LauncherManager/Bannerlord.LauncherManager.csproj b/src/Bannerlord.LauncherManager/Bannerlord.LauncherManager.csproj index 8584db1..0867f1b 100644 --- a/src/Bannerlord.LauncherManager/Bannerlord.LauncherManager.csproj +++ b/src/Bannerlord.LauncherManager/Bannerlord.LauncherManager.csproj @@ -23,7 +23,7 @@ - + diff --git a/src/Bannerlord.LauncherManager/Utils/ModuleIssueRenderer.cs b/src/Bannerlord.LauncherManager/Utils/ModuleIssueRenderer.cs index f632609..2a4efb8 100644 --- a/src/Bannerlord.LauncherManager/Utils/ModuleIssueRenderer.cs +++ b/src/Bannerlord.LauncherManager/Utils/ModuleIssueRenderer.cs @@ -57,6 +57,9 @@ private static string Version(ApplicationVersionRange version) => version == App ModuleIssueType.DependencyNotLoadedAfterThis => new BUTRTextObject("{=2ALJB7z2}'{SOURCEID}' should be loaded after '{TARGETID}'") .SetTextVariable("ID", issue.SourceId), + + // TODO: + // Add new overloads _ => throw new ArgumentOutOfRangeException() };