diff --git a/build/common.props b/build/common.props index 30182339..a30c8835 100644 --- a/build/common.props +++ b/build/common.props @@ -5,7 +5,7 @@ 1.0.0 - 2.9.14 + 2.9.15 2.2.2 3.2.0.77 @@ -18,7 +18,7 @@ 1.1.0.104 3.0.0.142 5.0.226 - 14.0.0.91 + 14.0.0.93 diff --git a/changelog.txt b/changelog.txt index 0a3dfb03..55bbef48 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,8 @@ --------------------------------------------------------------------------------------------------- +Version: 2.9.15 +Game Versions: v1.0.x,v1.1.x,v1.2.x +* Fixed a regression that prevented crash reports from being shown +--------------------------------------------------------------------------------------------------- Version: 2.9.14 Game Versions: v1.0.x,v1.1.x,v1.2.x * Fixed a possible crash related to trace logging diff --git a/src/Bannerlord.ButterLib.Implementation/Bannerlord.ButterLib.Implementation.csproj b/src/Bannerlord.ButterLib.Implementation/Bannerlord.ButterLib.Implementation.csproj index eceda439..d148d7e8 100644 --- a/src/Bannerlord.ButterLib.Implementation/Bannerlord.ButterLib.Implementation.csproj +++ b/src/Bannerlord.ButterLib.Implementation/Bannerlord.ButterLib.Implementation.csproj @@ -5,7 +5,6 @@ net472;net6.0-windows latest enable - x64 false false diff --git a/src/Bannerlord.ButterLib.Implementation/DistanceMatrix/DistanceMatrixSubSystem.cs b/src/Bannerlord.ButterLib.Implementation/DistanceMatrix/DistanceMatrixSubSystem.cs index 36f89a3f..a019a14a 100644 --- a/src/Bannerlord.ButterLib.Implementation/DistanceMatrix/DistanceMatrixSubSystem.cs +++ b/src/Bannerlord.ButterLib.Implementation/DistanceMatrix/DistanceMatrixSubSystem.cs @@ -51,11 +51,11 @@ public void Disable() IsEnabled = false; } - public IReadOnlyCollection> Declarations { get; } = new SubSystemSettingsDeclaration[] - { + public IReadOnlyCollection> Declarations { get; } = + [ new SubSystemSettingsPropertyBool( "{=MSJe8ih4yp}Consider Villages", "{=kvR54SiOFn}Allow villages to be used for built-in distance matrix calculations. May negatively affect performance.", - x => x.ConsiderVillages), - }; + x => x.ConsiderVillages) + ]; } \ No newline at end of file diff --git a/src/Bannerlord.ButterLib.Implementation/HotKeys/HotKeyCategoryContainer.cs b/src/Bannerlord.ButterLib.Implementation/HotKeys/HotKeyCategoryContainer.cs index 239a9b93..8197eac8 100644 --- a/src/Bannerlord.ButterLib.Implementation/HotKeys/HotKeyCategoryContainer.cs +++ b/src/Bannerlord.ButterLib.Implementation/HotKeys/HotKeyCategoryContainer.cs @@ -24,15 +24,15 @@ internal sealed class HotKeyCategoryContainer : GameKeyContext public HotKeyCategoryContainer(string categoryId, string categoryName, IEnumerable keys) : base(categoryId, ListCapacity) { var keyCategoryName = Module.CurrentModule.GlobalTextManager.AddGameText("str_key_category_name"); - keyCategoryName.AddVariationWithId(categoryId, new TextObject(categoryName), new List()); + keyCategoryName.AddVariationWithId(categoryId, new TextObject(categoryName), []); var keyName = Module.CurrentModule.GlobalTextManager.AddGameText("str_key_name"); var keyDesc = Module.CurrentModule.GlobalTextManager.AddGameText("str_key_description"); foreach (var key in keys) { var variationId = $"{categoryId}_{(GameKeyDefinition) key.Id}"; - keyName.AddVariationWithId(variationId, new TextObject(key.DisplayName), new List()); - keyDesc.AddVariationWithId(variationId, new TextObject(key.Description), new List()); + keyName.AddVariationWithId(variationId, new TextObject(key.DisplayName), []); + keyDesc.AddVariationWithId(variationId, new TextObject(key.Description), []); RegisterGameKey(new GameKey(key.Id, key.Uid, categoryId, key.DefaultKey, key.Category)); } } diff --git a/src/Bannerlord.ButterLib.Implementation/HotKeys/HotKeyManagerImplementation.cs b/src/Bannerlord.ButterLib.Implementation/HotKeys/HotKeyManagerImplementation.cs index f6be56f0..3f581428 100644 --- a/src/Bannerlord.ButterLib.Implementation/HotKeys/HotKeyManagerImplementation.cs +++ b/src/Bannerlord.ButterLib.Implementation/HotKeys/HotKeyManagerImplementation.cs @@ -17,13 +17,13 @@ namespace Bannerlord.ButterLib.Implementation.HotKeys; internal sealed class HotKeyManagerImplementation : HotKeyManager { - internal static readonly List GlobalContainerStorage = new(); - internal static readonly List GlobalHotKeyStorage = new(); + internal static readonly List GlobalContainerStorage = []; + internal static readonly List GlobalHotKeyStorage = []; private int _currentId = 0; // To prevent collision with the game private readonly string _modName; private readonly string _categoryName; - private readonly List _instanceHotKeys = new(); + private readonly List _instanceHotKeys = []; internal HotKeyManagerImplementation(string modName, string categoryName = "") { @@ -54,7 +54,7 @@ public override IReadOnlyList Build() #if v100 || v101 || v102 || v103 || v110 || v111 || v112 || v113 || v114 || v115 || v116 TWHotKeyManager.RegisterInitialContexts(new[] { hotKeyCategoryContainer }, true); #elif v120 || v121 || v122 || v123 || v124 || v125 || v126 || v127 || v128 || v129 || v1210 || v1211 - TWHotKeyManager.RegisterInitialContexts(TWHotKeyManager.GetAllCategories().ToList().Concat(new[] { hotKeyCategoryContainer }), true); + TWHotKeyManager.RegisterInitialContexts(TWHotKeyManager.GetAllCategories().ToList().Concat([hotKeyCategoryContainer]), true); #else #error DEFINE #endif diff --git a/src/Bannerlord.ButterLib.Implementation/MBSubModuleBaseExtended/Patches/MBGameManagerPatch.cs b/src/Bannerlord.ButterLib.Implementation/MBSubModuleBaseExtended/Patches/MBGameManagerPatch.cs index 9774c13f..9e703b04 100644 --- a/src/Bannerlord.ButterLib.Implementation/MBSubModuleBaseExtended/Patches/MBGameManagerPatch.cs +++ b/src/Bannerlord.ButterLib.Implementation/MBSubModuleBaseExtended/Patches/MBGameManagerPatch.cs @@ -68,14 +68,20 @@ public static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable("TaleWorlds.SaveSystem.TypeExtensions:IsContainer", new[] { typeof(Type) }); + AccessTools2.GetDelegate("TaleWorlds.SaveSystem.TypeExtensions:IsContainer", [typeof(Type)]); private static MethodInfo? TargetTypeMethod(string name) => AccessTools2.Method($"TaleWorlds.SaveSystem.Definition.DefinitionContext:{name}"); - private static readonly Patch[] Patches = new Patch[] - { + private static readonly Patch[] Patches = + [ new PrefixPatch(nameof(AddBasicTypeDefinitionPrefix), TargetTypeMethod("AddBasicTypeDefinition")), new PrefixPatch(nameof(AddClassDefinitionPrefix), TargetTypeMethod("AddClassDefinition")), new PrefixPatch(nameof(AddContainerDefinitionPrefix), TargetTypeMethod("AddContainerDefinition")), @@ -70,8 +70,8 @@ internal static bool Disable(Harmony harmony) new PrefixPatch(nameof(AddInterfaceDefinitionPrefix), TargetTypeMethod("AddInterfaceDefinition")), new PrefixPatch(nameof(AddRootClassDefinitionPrefix), TargetTypeMethod("AddRootClassDefinition")), new PrefixPatch(nameof(AddStructDefinitionPrefix), TargetTypeMethod("AddStructDefinition")), - new ConstructContainerDefinitionPrefixPatch(), - }; + new ConstructContainerDefinitionPrefixPatch() + ]; // PATCH METHODS diff --git a/src/Bannerlord.ButterLib.Implementation/SaveSystem/Patches/TypeExtensionsPatch.cs b/src/Bannerlord.ButterLib.Implementation/SaveSystem/Patches/TypeExtensionsPatch.cs index 2e8bc8cb..5010e4d1 100644 --- a/src/Bannerlord.ButterLib.Implementation/SaveSystem/Patches/TypeExtensionsPatch.cs +++ b/src/Bannerlord.ButterLib.Implementation/SaveSystem/Patches/TypeExtensionsPatch.cs @@ -51,7 +51,7 @@ internal static bool Disable(Harmony harmony) } private static readonly Type? TargetType = AccessTools2.TypeByName("TaleWorlds.SaveSystem.TypeExtensions"); - private static readonly Type[] TargetMethodParams = { typeof(Type), typeof(ContainerType).MakeByRefType() }; + private static readonly Type[] TargetMethodParams = [typeof(Type), typeof(ContainerType).MakeByRefType()]; private static readonly MethodInfo? TargetMethod = AccessTools2.Method(TargetType!, "IsContainer", TargetMethodParams); private static readonly MethodInfo? PatchMethod = SymbolExtensions2.GetMethodInfo((Type x, ContainerType y, bool z) => IsContainerPrefix(x, out y, ref z)); diff --git a/src/Bannerlord.ButterLib.sln b/src/Bannerlord.ButterLib.sln index 6bdb4d4a..ad7f56a0 100644 --- a/src/Bannerlord.ButterLib.sln +++ b/src/Bannerlord.ButterLib.sln @@ -148,60 +148,60 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MBSubModuleBaseExtended", " EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Beta_Debug|x64 = Beta_Debug|x64 - Beta_Release|x64 = Beta_Release|x64 - Stable_Debug|x64 = Stable_Debug|x64 - Stable_Release|x64 = Stable_Release|x64 + Beta_Release|Any CPU = Beta_Release|Any CPU + Stable_Release|Any CPU = Stable_Release|Any CPU + Stable_Debug|Any CPU = Stable_Debug|Any CPU + Beta_Debug|Any CPU = Beta_Debug|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1339A1C0-C2F0-4491-91BB-D49C00332F68}.Beta_Debug|x64.ActiveCfg = Beta_Debug|Any CPU - {1339A1C0-C2F0-4491-91BB-D49C00332F68}.Beta_Debug|x64.Build.0 = Beta_Debug|Any CPU - {1339A1C0-C2F0-4491-91BB-D49C00332F68}.Beta_Release|x64.ActiveCfg = Beta_Release|Any CPU - {1339A1C0-C2F0-4491-91BB-D49C00332F68}.Beta_Release|x64.Build.0 = Beta_Release|Any CPU - {1339A1C0-C2F0-4491-91BB-D49C00332F68}.Stable_Debug|x64.ActiveCfg = Stable_Debug|Any CPU - {1339A1C0-C2F0-4491-91BB-D49C00332F68}.Stable_Debug|x64.Build.0 = Stable_Debug|Any CPU - {1339A1C0-C2F0-4491-91BB-D49C00332F68}.Stable_Release|x64.ActiveCfg = Stable_Release|Any CPU - {1339A1C0-C2F0-4491-91BB-D49C00332F68}.Stable_Release|x64.Build.0 = Stable_Release|Any CPU - {17BE8506-B22B-4705-A777-C862888DA1F5}.Beta_Debug|x64.ActiveCfg = Debug|x64 - {17BE8506-B22B-4705-A777-C862888DA1F5}.Beta_Debug|x64.Build.0 = Debug|x64 - {17BE8506-B22B-4705-A777-C862888DA1F5}.Beta_Release|x64.ActiveCfg = Release|x64 - {17BE8506-B22B-4705-A777-C862888DA1F5}.Beta_Release|x64.Build.0 = Release|x64 - {17BE8506-B22B-4705-A777-C862888DA1F5}.Stable_Debug|x64.ActiveCfg = Debug|x64 - {17BE8506-B22B-4705-A777-C862888DA1F5}.Stable_Debug|x64.Build.0 = Debug|x64 - {17BE8506-B22B-4705-A777-C862888DA1F5}.Stable_Release|x64.ActiveCfg = Release|x64 - {17BE8506-B22B-4705-A777-C862888DA1F5}.Stable_Release|x64.Build.0 = Release|x64 - {C2FEF2CB-356C-4045-948D-F0755ABA6378}.Beta_Debug|x64.ActiveCfg = Beta_Debug|x64 - {C2FEF2CB-356C-4045-948D-F0755ABA6378}.Beta_Debug|x64.Build.0 = Beta_Debug|x64 - {C2FEF2CB-356C-4045-948D-F0755ABA6378}.Beta_Release|x64.ActiveCfg = Beta_Release|x64 - {C2FEF2CB-356C-4045-948D-F0755ABA6378}.Beta_Release|x64.Build.0 = Beta_Release|x64 - {C2FEF2CB-356C-4045-948D-F0755ABA6378}.Stable_Debug|x64.ActiveCfg = Stable_Debug|x64 - {C2FEF2CB-356C-4045-948D-F0755ABA6378}.Stable_Debug|x64.Build.0 = Stable_Debug|x64 - {C2FEF2CB-356C-4045-948D-F0755ABA6378}.Stable_Release|x64.ActiveCfg = Stable_Release|x64 - {C2FEF2CB-356C-4045-948D-F0755ABA6378}.Stable_Release|x64.Build.0 = Stable_Release|x64 - {CC56F4AA-1C6F-4B20-9DA3-79A30E1F6734}.Beta_Debug|x64.ActiveCfg = Beta_Debug|x64 - {CC56F4AA-1C6F-4B20-9DA3-79A30E1F6734}.Beta_Debug|x64.Build.0 = Beta_Debug|x64 - {CC56F4AA-1C6F-4B20-9DA3-79A30E1F6734}.Beta_Release|x64.ActiveCfg = Beta_Release|x64 - {CC56F4AA-1C6F-4B20-9DA3-79A30E1F6734}.Beta_Release|x64.Build.0 = Beta_Release|x64 - {CC56F4AA-1C6F-4B20-9DA3-79A30E1F6734}.Stable_Debug|x64.ActiveCfg = Stable_Debug|x64 - {CC56F4AA-1C6F-4B20-9DA3-79A30E1F6734}.Stable_Debug|x64.Build.0 = Stable_Debug|x64 - {CC56F4AA-1C6F-4B20-9DA3-79A30E1F6734}.Stable_Release|x64.ActiveCfg = Stable_Release|x64 - {CC56F4AA-1C6F-4B20-9DA3-79A30E1F6734}.Stable_Release|x64.Build.0 = Stable_Release|x64 - {451849FC-0522-493D-B0DF-9538ABDBE56D}.Beta_Debug|x64.ActiveCfg = Beta_Debug|x64 - {451849FC-0522-493D-B0DF-9538ABDBE56D}.Beta_Debug|x64.Build.0 = Beta_Debug|x64 - {451849FC-0522-493D-B0DF-9538ABDBE56D}.Beta_Release|x64.ActiveCfg = Beta_Release|x64 - {451849FC-0522-493D-B0DF-9538ABDBE56D}.Beta_Release|x64.Build.0 = Beta_Release|x64 - {451849FC-0522-493D-B0DF-9538ABDBE56D}.Stable_Debug|x64.ActiveCfg = Stable_Debug|x64 - {451849FC-0522-493D-B0DF-9538ABDBE56D}.Stable_Debug|x64.Build.0 = Stable_Debug|x64 - {451849FC-0522-493D-B0DF-9538ABDBE56D}.Stable_Release|x64.ActiveCfg = Stable_Release|x64 - {451849FC-0522-493D-B0DF-9538ABDBE56D}.Stable_Release|x64.Build.0 = Stable_Release|x64 - {5C1705E2-CC31-4215-A4CE-7A8AFF6D9BC3}.Beta_Debug|x64.ActiveCfg = Beta_Debug|x64 - {5C1705E2-CC31-4215-A4CE-7A8AFF6D9BC3}.Beta_Debug|x64.Build.0 = Beta_Debug|x64 - {5C1705E2-CC31-4215-A4CE-7A8AFF6D9BC3}.Beta_Release|x64.ActiveCfg = Beta_Release|x64 - {5C1705E2-CC31-4215-A4CE-7A8AFF6D9BC3}.Beta_Release|x64.Build.0 = Beta_Release|x64 - {5C1705E2-CC31-4215-A4CE-7A8AFF6D9BC3}.Stable_Debug|x64.ActiveCfg = Stable_Debug|x64 - {5C1705E2-CC31-4215-A4CE-7A8AFF6D9BC3}.Stable_Debug|x64.Build.0 = Stable_Debug|x64 - {5C1705E2-CC31-4215-A4CE-7A8AFF6D9BC3}.Stable_Release|x64.ActiveCfg = Stable_Release|x64 - {5C1705E2-CC31-4215-A4CE-7A8AFF6D9BC3}.Stable_Release|x64.Build.0 = Stable_Release|x64 + {5C1705E2-CC31-4215-A4CE-7A8AFF6D9BC3}.Stable_Release|Any CPU.ActiveCfg = Stable_Release|Any CPU + {5C1705E2-CC31-4215-A4CE-7A8AFF6D9BC3}.Stable_Release|Any CPU.Build.0 = Stable_Release|Any CPU + {5C1705E2-CC31-4215-A4CE-7A8AFF6D9BC3}.Beta_Release|Any CPU.ActiveCfg = Beta_Release|Any CPU + {5C1705E2-CC31-4215-A4CE-7A8AFF6D9BC3}.Beta_Release|Any CPU.Build.0 = Beta_Release|Any CPU + {5C1705E2-CC31-4215-A4CE-7A8AFF6D9BC3}.Stable_Debug|Any CPU.ActiveCfg = Stable_Debug|Any CPU + {5C1705E2-CC31-4215-A4CE-7A8AFF6D9BC3}.Stable_Debug|Any CPU.Build.0 = Stable_Debug|Any CPU + {5C1705E2-CC31-4215-A4CE-7A8AFF6D9BC3}.Beta_Debug|Any CPU.ActiveCfg = Beta_Debug|Any CPU + {5C1705E2-CC31-4215-A4CE-7A8AFF6D9BC3}.Beta_Debug|Any CPU.Build.0 = Beta_Debug|Any CPU + {1339A1C0-C2F0-4491-91BB-D49C00332F68}.Stable_Release|Any CPU.ActiveCfg = Stable_Release|Any CPU + {1339A1C0-C2F0-4491-91BB-D49C00332F68}.Stable_Release|Any CPU.Build.0 = Stable_Release|Any CPU + {1339A1C0-C2F0-4491-91BB-D49C00332F68}.Beta_Release|Any CPU.ActiveCfg = Beta_Release|Any CPU + {1339A1C0-C2F0-4491-91BB-D49C00332F68}.Beta_Release|Any CPU.Build.0 = Beta_Release|Any CPU + {1339A1C0-C2F0-4491-91BB-D49C00332F68}.Stable_Debug|Any CPU.ActiveCfg = Stable_Debug|Any CPU + {1339A1C0-C2F0-4491-91BB-D49C00332F68}.Stable_Debug|Any CPU.Build.0 = Stable_Debug|Any CPU + {1339A1C0-C2F0-4491-91BB-D49C00332F68}.Beta_Debug|Any CPU.ActiveCfg = Beta_Debug|Any CPU + {1339A1C0-C2F0-4491-91BB-D49C00332F68}.Beta_Debug|Any CPU.Build.0 = Beta_Debug|Any CPU + {CC56F4AA-1C6F-4B20-9DA3-79A30E1F6734}.Stable_Release|Any CPU.ActiveCfg = Stable_Release|Any CPU + {CC56F4AA-1C6F-4B20-9DA3-79A30E1F6734}.Stable_Release|Any CPU.Build.0 = Stable_Release|Any CPU + {CC56F4AA-1C6F-4B20-9DA3-79A30E1F6734}.Beta_Release|Any CPU.ActiveCfg = Beta_Release|Any CPU + {CC56F4AA-1C6F-4B20-9DA3-79A30E1F6734}.Beta_Release|Any CPU.Build.0 = Beta_Release|Any CPU + {CC56F4AA-1C6F-4B20-9DA3-79A30E1F6734}.Stable_Debug|Any CPU.ActiveCfg = Stable_Debug|Any CPU + {CC56F4AA-1C6F-4B20-9DA3-79A30E1F6734}.Stable_Debug|Any CPU.Build.0 = Stable_Debug|Any CPU + {CC56F4AA-1C6F-4B20-9DA3-79A30E1F6734}.Beta_Debug|Any CPU.ActiveCfg = Beta_Debug|Any CPU + {CC56F4AA-1C6F-4B20-9DA3-79A30E1F6734}.Beta_Debug|Any CPU.Build.0 = Beta_Debug|Any CPU + {451849FC-0522-493D-B0DF-9538ABDBE56D}.Stable_Release|Any CPU.ActiveCfg = Stable_Release|Any CPU + {451849FC-0522-493D-B0DF-9538ABDBE56D}.Stable_Release|Any CPU.Build.0 = Stable_Release|Any CPU + {451849FC-0522-493D-B0DF-9538ABDBE56D}.Beta_Release|Any CPU.ActiveCfg = Beta_Release|Any CPU + {451849FC-0522-493D-B0DF-9538ABDBE56D}.Beta_Release|Any CPU.Build.0 = Beta_Release|Any CPU + {451849FC-0522-493D-B0DF-9538ABDBE56D}.Stable_Debug|Any CPU.ActiveCfg = Stable_Debug|Any CPU + {451849FC-0522-493D-B0DF-9538ABDBE56D}.Stable_Debug|Any CPU.Build.0 = Stable_Debug|Any CPU + {451849FC-0522-493D-B0DF-9538ABDBE56D}.Beta_Debug|Any CPU.ActiveCfg = Beta_Debug|Any CPU + {451849FC-0522-493D-B0DF-9538ABDBE56D}.Beta_Debug|Any CPU.Build.0 = Beta_Debug|Any CPU + {C2FEF2CB-356C-4045-948D-F0755ABA6378}.Stable_Release|Any CPU.ActiveCfg = Stable_Release|Any CPU + {C2FEF2CB-356C-4045-948D-F0755ABA6378}.Stable_Release|Any CPU.Build.0 = Stable_Release|Any CPU + {C2FEF2CB-356C-4045-948D-F0755ABA6378}.Beta_Release|Any CPU.ActiveCfg = Beta_Release|Any CPU + {C2FEF2CB-356C-4045-948D-F0755ABA6378}.Beta_Release|Any CPU.Build.0 = Beta_Release|Any CPU + {C2FEF2CB-356C-4045-948D-F0755ABA6378}.Stable_Debug|Any CPU.ActiveCfg = Stable_Debug|Any CPU + {C2FEF2CB-356C-4045-948D-F0755ABA6378}.Stable_Debug|Any CPU.Build.0 = Stable_Debug|Any CPU + {C2FEF2CB-356C-4045-948D-F0755ABA6378}.Beta_Debug|Any CPU.ActiveCfg = Beta_Debug|Any CPU + {C2FEF2CB-356C-4045-948D-F0755ABA6378}.Beta_Debug|Any CPU.Build.0 = Beta_Debug|Any CPU + {17BE8506-B22B-4705-A777-C862888DA1F5}.Beta_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {17BE8506-B22B-4705-A777-C862888DA1F5}.Beta_Debug|Any CPU.Build.0 = Debug|Any CPU + {17BE8506-B22B-4705-A777-C862888DA1F5}.Beta_Release|Any CPU.ActiveCfg = Release|Any CPU + {17BE8506-B22B-4705-A777-C862888DA1F5}.Beta_Release|Any CPU.Build.0 = Release|Any CPU + {17BE8506-B22B-4705-A777-C862888DA1F5}.Stable_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {17BE8506-B22B-4705-A777-C862888DA1F5}.Stable_Debug|Any CPU.Build.0 = Debug|Any CPU + {17BE8506-B22B-4705-A777-C862888DA1F5}.Stable_Release|Any CPU.ActiveCfg = Release|Any CPU + {17BE8506-B22B-4705-A777-C862888DA1F5}.Stable_Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Bannerlord.ButterLib/Bannerlord.ButterLib.csproj b/src/Bannerlord.ButterLib/Bannerlord.ButterLib.csproj index e367f016..20e7c37c 100644 --- a/src/Bannerlord.ButterLib/Bannerlord.ButterLib.csproj +++ b/src/Bannerlord.ButterLib/Bannerlord.ButterLib.csproj @@ -3,7 +3,6 @@ net472;net6.0-windows;netstandard2.0 - x64 latest enable true diff --git a/src/Bannerlord.ButterLib/ButterLibSubModule.Services.cs b/src/Bannerlord.ButterLib/ButterLibSubModule.Services.cs index 64842877..5ce36fdd 100644 --- a/src/Bannerlord.ButterLib/ButterLibSubModule.Services.cs +++ b/src/Bannerlord.ButterLib/ButterLibSubModule.Services.cs @@ -10,7 +10,7 @@ namespace Bannerlord.ButterLib; public sealed partial class ButterLibSubModule { public static bool CanBeConfigured { get; private set; } = true; - private static List> BeforeInitialization { get; } = new(); + private static List> BeforeInitialization { get; } = []; /// /// The only way to inject your stuff before ButterLib will start it's initialization diff --git a/src/Bannerlord.ButterLib/DynamicAPI/DynamicApiProvider.cs b/src/Bannerlord.ButterLib/DynamicAPI/DynamicAPIProvider.cs similarity index 96% rename from src/Bannerlord.ButterLib/DynamicAPI/DynamicApiProvider.cs rename to src/Bannerlord.ButterLib/DynamicAPI/DynamicAPIProvider.cs index 22628b11..ffda8ef3 100644 --- a/src/Bannerlord.ButterLib/DynamicAPI/DynamicApiProvider.cs +++ b/src/Bannerlord.ButterLib/DynamicAPI/DynamicAPIProvider.cs @@ -24,16 +24,16 @@ private record MethodInfoWithAttribute(MethodInfo MethodInfo, CustomAttributeDat private delegate object DynamicAPIObjectActivator(); - private static readonly HashSet PossibleClassNames = new() - { + private static readonly HashSet PossibleClassNames = + [ "Bannerlord.ButterLib.DynamicAPI.DynamicAPIClassAttribute", - "Bannerlord.DynamicAPI.DynamicAPIClassAttribute", - }; - private static readonly HashSet PossibleMethodNames = new() - { + "Bannerlord.DynamicAPI.DynamicAPIClassAttribute" + ]; + private static readonly HashSet PossibleMethodNames = + [ "Bannerlord.ButterLib.DynamicAPI.DynamicAPIMethodAttribute", - "Bannerlord.DynamicAPI.DynamicAPIMethodAttribute", - }; + "Bannerlord.DynamicAPI.DynamicAPIMethodAttribute" + ]; private static readonly ConcurrentDictionary CachedActivators = new(); internal static Dictionary? APIClasses; @@ -104,7 +104,7 @@ internal static void Initialize() } catch (Exception) { - return Enumerable.Empty(); + return []; } }) .OfType() diff --git a/src/Bannerlord.ButterLib/ExceptionHandler/BEWPatch.cs b/src/Bannerlord.ButterLib/ExceptionHandler/BEWPatch.cs index a9a3097a..a584a065 100644 --- a/src/Bannerlord.ButterLib/ExceptionHandler/BEWPatch.cs +++ b/src/Bannerlord.ButterLib/ExceptionHandler/BEWPatch.cs @@ -49,9 +49,9 @@ internal record ExceptionIdentifier(Type Type, string? StackTrace, string Messag public static ExceptionIdentifier FromException(Exception e) => new(e.GetType(), e.StackTrace, e.Message); } - internal static readonly HashSet SuppressedExceptions = new(); + internal static readonly HashSet SuppressedExceptions = []; - private static readonly string[] BEW = { "org.calradia.admiralnelson.betterexceptionwindow" }; + private static readonly string[] BEW = ["org.calradia.admiralnelson.betterexceptionwindow"]; private static readonly MethodInfo? ManagedApplicationTickMethod = AccessTools2.Method("TaleWorlds.DotNet.Managed:ApplicationTick"); diff --git a/src/Bannerlord.ButterLib/ExceptionHandler/ExceptionReporter.cs b/src/Bannerlord.ButterLib/ExceptionHandler/ExceptionReporter.cs index cd57f550..819de1cc 100644 --- a/src/Bannerlord.ButterLib/ExceptionHandler/ExceptionReporter.cs +++ b/src/Bannerlord.ButterLib/ExceptionHandler/ExceptionReporter.cs @@ -53,35 +53,35 @@ public static void Show(Exception exception) var harmonyProvider = new HarmonyProvider(); var crashReportRendererUtilities = new CrashReportRendererUtilities(); - var crashReport = CrashReportInfo.Create(exception, metadata, filter, helper, helper, helper, harmonyProvider); - var crashReportModel = CrashReportInfo.ToModel(crashReport, helper, helper, helper, helper, helper, helper); - var logSources = GetLogSources().ToArray(); - try - { - CrashReportImGui.ShowAndWait(crashReportModel, logSources, crashReportRendererUtilities); - } - catch (Exception ex) - { + var crashReport = CrashReportInfo.Create(exception, metadata, filter, helper, helper, helper, harmonyProvider); + var crashReportModel = CrashReportInfo.ToModel(crashReport, helper, helper, helper, helper, helper, helper); + var logSources = GetLogSources().ToArray(); try { + CrashReportImGui.ShowAndWait(crashReportModel, logSources, crashReportRendererUtilities); + } + catch (Exception ex) + { + try + { #if NET472 || (NET6_0 && WINDOWS) - var forms = new CrashReportWinForms(crashReportModel, logSources, crashReportRendererUtilities); - forms.ShowDialog(); + var forms = new CrashReportWinForms(crashReportModel, logSources, crashReportRendererUtilities); + forms.ShowDialog(); #endif - } - catch (Exception ex2) - { - throw new AggregateException(ex, ex2); + } + catch (Exception ex2) + { + throw new AggregateException(ex, ex2); + } } } - } private static IEnumerable GetLogSources() { var now = DateTimeOffset.Now; - foreach (var logSource in ButterLibSubModule.ServiceProvider?.GetService>() ?? Enumerable.Empty()) + foreach (var logSource in ButterLibSubModule.ServiceProvider?.GetService>() ?? []) { switch (logSource) { diff --git a/src/Bannerlord.ButterLib/ExceptionHandler/Utils/CreatorZip.cs b/src/Bannerlord.ButterLib/ExceptionHandler/Utils/CreatorZip.cs index 4514f420..d7bc68b0 100644 --- a/src/Bannerlord.ButterLib/ExceptionHandler/Utils/CreatorZip.cs +++ b/src/Bannerlord.ButterLib/ExceptionHandler/Utils/CreatorZip.cs @@ -1,4 +1,4 @@ -using BUTR.CrashReport.Models; +using BUTR.CrashReport.Models; using BUTR.CrashReport.Renderer.Zip; using Newtonsoft.Json; diff --git a/src/Bannerlord.ButterLib/ExceptionHandler/Utils/MiniDump.cs b/src/Bannerlord.ButterLib/ExceptionHandler/Utils/MiniDump.cs index ac96b83d..ec8138f6 100644 --- a/src/Bannerlord.ButterLib/ExceptionHandler/Utils/MiniDump.cs +++ b/src/Bannerlord.ButterLib/ExceptionHandler/Utils/MiniDump.cs @@ -13,12 +13,6 @@ internal static class MiniDump { internal static class DbgHelpNativeMethods { -#if X64 - private const int CONTEXT_SIZE = 1232; -#else - private const int CONTEXT_SIZE = 716; -#endif - [DllImport("dbghelp.dll", CallingConvention = CallingConvention.Winapi, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool MiniDumpWriteDump(IntPtr hProcess, uint ProcessId, SafeHandle hFile, MINIDUMP_TYPE DumpType, @@ -27,7 +21,7 @@ public static extern bool MiniDumpWriteDump(IntPtr hProcess, uint ProcessId, Saf ref readonly MINIDUMP_CALLBACK_INFORMATION CallbackParam); [Flags] - public enum MINIDUMP_TYPE : int + public enum MINIDUMP_TYPE { MiniDumpNormal = 0x00000000, MiniDumpWithDataSegs = 0x00000001, @@ -78,13 +72,6 @@ public enum MINIDUMP_TYPE : int MiniDumpScanMemory, } - [StructLayout(LayoutKind.Sequential, Pack = 4)] - public struct EXCEPTION_POINTERS - { - public IntPtr ExceptionRecord; - public byte[] ContextRecord; - } - [StructLayout(LayoutKind.Sequential, Pack = 4)] public struct MINIDUMP_EXCEPTION_INFORMATION { @@ -94,64 +81,20 @@ public struct MINIDUMP_EXCEPTION_INFORMATION public bool ClientPointers; } - public enum MINIDUMP_STREAM_TYPE : uint - { - UnusedStream = 0, - ReservedStream0 = 1, - ReservedStream1 = 2, - ThreadListStream = 3, - ModuleListStream = 4, - MemoryListStream = 5, - ExceptionStream = 6, - SystemInfoStream = 7, - ThreadExListStream = 8, - Memory64ListStream = 9, - CommentStreamA = 10, - CommentStreamW = 11, - HandleDataStream = 12, - FunctionTableStream = 13, - UnloadedModuleListStream = 14, - MiscInfoStream = 15, - MemoryInfoListStream = 16, - ThreadInfoListStream = 17, - HandleOperationListStream = 18, - LastReservedStream = 0xffff - } - - [StructLayout(LayoutKind.Sequential, Pack = 4)] public struct MINIDUMP_USER_STREAM { - public MINIDUMP_STREAM_TYPE Type; + public uint Type; public uint BufferSize; public IntPtr Buffer; } - [StructLayout(LayoutKind.Sequential, Pack = 4)] public struct MINIDUMP_USER_STREAM_INFORMATION { - public MINIDUMP_USER_STREAM_INFORMATION(params MINIDUMP_USER_STREAM[] streams) - { - UserStreamCount = (uint) streams.Length; - int sizeOfStream = Marshal.SizeOf(typeof(MINIDUMP_USER_STREAM)); - UserStreamArray = Marshal.AllocHGlobal((int) (UserStreamCount * sizeOfStream)); - for (int i = 0; i < streams.Length; ++i) - { - Marshal.StructureToPtr(streams[i], UserStreamArray + (i * sizeOfStream), false); - } - } - - public void Delete() - { - Marshal.FreeHGlobal(UserStreamArray); - UserStreamCount = 0; - UserStreamArray = IntPtr.Zero; - } - public uint UserStreamCount; - public IntPtr UserStreamArray; + public MINIDUMP_USER_STREAM[] UserStreamArray; } - public enum MINIDUMP_CALLBACK_TYPE : uint + public enum MINIDUMP_CALLBACK_TYPE { ModuleCallback, ThreadCallback, @@ -170,8 +113,7 @@ public enum MINIDUMP_CALLBACK_TYPE : uint ReadMemoryFailureCallback, SecondaryFlagsCallback } - - [StructLayout(LayoutKind.Sequential, Pack = 4)] + public struct VS_FIXEDFILEINFO { public uint dwSignature; @@ -189,29 +131,33 @@ public struct VS_FIXEDFILEINFO public uint dwFileDateLS; } - [StructLayout(LayoutKind.Sequential, Pack = 4)] public struct MINIDUMP_THREAD_CALLBACK { public uint ThreadId; public IntPtr ThreadHandle; - public unsafe fixed byte Context[CONTEXT_SIZE]; - public uint SizeOfContext; - public ulong StackBase; - public ulong StackEnd; + public uint Pad; + //public CONTEXT Context; + //public uint SizeOfContext; + //public ulong StackBase; + //public ulong StackEnd; } - [StructLayout(LayoutKind.Sequential, Pack = 4)] public struct MINIDUMP_THREAD_EX_CALLBACK { - public MINIDUMP_THREAD_CALLBACK BasePart; - public ulong BackingStoreBase; - public ulong BackingStoreEnd; + public uint ThreadId; + public IntPtr ThreadHandle; + public uint Pad; + //public CONTEXT Context; + //public uint SizeOfContext; + //public ulong StackBase; + //public ulong StackEnd; + //public ulong BackingStoreBase; + //public ulong BackingStoreEnd; } - [StructLayout(LayoutKind.Sequential, Pack = 4)] public struct MINIDUMP_MODULE_CALLBACK { - public IntPtr FullPath; // This is a PCWSTR + public IntPtr FullPath; public ulong BaseOfImage; public uint SizeOfImage; public uint CheckSum; @@ -228,41 +174,44 @@ public struct MINIDUMP_INCLUDE_THREAD_CALLBACK public uint ThreadId; } - [StructLayout(LayoutKind.Sequential, Pack = 4)] public struct MINIDUMP_INCLUDE_MODULE_CALLBACK { public ulong BaseOfImage; } - - [StructLayout(LayoutKind.Explicit)] + + public struct MINIDUMP_IO_CALLBACK + { + public IntPtr Handle; + public ulong Offset; + public IntPtr Buffer; + public uint BufferBytes; + } + public struct MINIDUMP_CALLBACK_INPUT { -#if X64 - const int CallbackTypeOffset = 4 + 8; -#else - const int CallbackTypeOffset = 4 + 4; -#endif - const int UnionOffset = CallbackTypeOffset + 4; - - [FieldOffset(0)] + [StructLayout(LayoutKind.Explicit)] + public struct UNION + { + [FieldOffset(0)] + public int Status; // HRESULT + [FieldOffset(0)] + public MINIDUMP_THREAD_CALLBACK Thread; + [FieldOffset(0)] + public MINIDUMP_THREAD_EX_CALLBACK ThreadEx; + [FieldOffset(0)] + public MINIDUMP_MODULE_CALLBACK Module; + [FieldOffset(0)] + public MINIDUMP_INCLUDE_THREAD_CALLBACK IncludeThread; + [FieldOffset(0)] + public MINIDUMP_INCLUDE_MODULE_CALLBACK IncludeModule; + [FieldOffset(0)] + public MINIDUMP_IO_CALLBACK Io; + } + public uint ProcessId; - [FieldOffset(4)] public IntPtr ProcessHandle; - [FieldOffset(CallbackTypeOffset)] public MINIDUMP_CALLBACK_TYPE CallbackType; - - [FieldOffset(UnionOffset)] - public int Status; // HRESULT - [FieldOffset(UnionOffset)] - public MINIDUMP_THREAD_CALLBACK Thread; - [FieldOffset(UnionOffset)] - public MINIDUMP_THREAD_EX_CALLBACK ThreadEx; - [FieldOffset(UnionOffset)] - public MINIDUMP_MODULE_CALLBACK Module; - [FieldOffset(UnionOffset)] - public MINIDUMP_INCLUDE_THREAD_CALLBACK IncludeThread; - [FieldOffset(UnionOffset)] - public MINIDUMP_INCLUDE_MODULE_CALLBACK IncludeModule; + public UNION Union; } [Flags] @@ -371,7 +320,7 @@ private static bool Filter(IntPtr CallbackParam, ref MINIDUMP_CALLBACK_INPUT Cal case MINIDUMP_CALLBACK_TYPE.IncludeThreadCallback: { var info = Marshal.PtrToStructure(CallbackParam); - return CallbackInput.IncludeThread.ThreadId == info.ThreadId; + return CallbackInput.Union.IncludeThread.ThreadId == info.ThreadId; } case MINIDUMP_CALLBACK_TYPE.ModuleCallback: { diff --git a/src/Bannerlord.ButterLib/ImplementationLoaderSubModule.cs b/src/Bannerlord.ButterLib/ImplementationLoaderSubModule.cs index 59718672..e59fbaa0 100644 --- a/src/Bannerlord.ButterLib/ImplementationLoaderSubModule.cs +++ b/src/Bannerlord.ButterLib/ImplementationLoaderSubModule.cs @@ -125,7 +125,7 @@ private static IEnumerable LoadAllImplementations(ILogger? logg catch (Exception e) when (e is ReflectionTypeLoadException) { logger?.LogError(e, "Implementation {Name} is not compatible with the current game!", Path.GetFileName(a.Location)); - return Enumerable.Empty(); + return []; } }).ToList(); diff --git a/src/Bannerlord.ButterLib/Logger/Extensions/LoggerExtensions.cs b/src/Bannerlord.ButterLib/Logger/Extensions/LoggerExtensions.cs index 3b8aa985..fd08c4f0 100644 --- a/src/Bannerlord.ButterLib/Logger/Extensions/LoggerExtensions.cs +++ b/src/Bannerlord.ButterLib/Logger/Extensions/LoggerExtensions.cs @@ -18,9 +18,9 @@ public static class LoggerExtensions private class LogValuesFormatter { private const string NullValue = "(null)"; - private static readonly object[] EmptyArray = Array.Empty(); + private static readonly object[] EmptyArray = []; private readonly string _format; - private readonly List _valueNames = new(); + private readonly List _valueNames = []; public LogValuesFormatter(string format) { diff --git a/src/Bannerlord.ButterLib/Logger/ReverseTextReader.cs b/src/Bannerlord.ButterLib/Logger/ReverseTextReader.cs index 97a6e12f..6cb06827 100644 --- a/src/Bannerlord.ButterLib/Logger/ReverseTextReader.cs +++ b/src/Bannerlord.ButterLib/Logger/ReverseTextReader.cs @@ -44,7 +44,7 @@ public ReverseTextReader(Stream stream, Encoding encoding) throw new InvalidOperationException("The specified stream needs to support reading to be read backwards."); // Set the current position to the end of the file _stream.Position = _stream.Length; - _leftoverBuffer = Array.Empty(); + _leftoverBuffer = []; } #endregion diff --git a/src/Bannerlord.ButterLib/SaveSystem/TaleWorldsContractResolverBase.cs b/src/Bannerlord.ButterLib/SaveSystem/TaleWorldsContractResolverBase.cs index 70a0512f..6715aecf 100644 --- a/src/Bannerlord.ButterLib/SaveSystem/TaleWorldsContractResolverBase.cs +++ b/src/Bannerlord.ButterLib/SaveSystem/TaleWorldsContractResolverBase.cs @@ -11,7 +11,7 @@ public class TaleWorldsContractResolverBase : DefaultContractResolver { protected delegate bool IsContainerDelegate(Type type); protected static readonly IsContainerDelegate? _isContainerDelegate = - AccessTools2.GetDelegate("TaleWorlds.SaveSystem.TypeExtensions:IsContainer", new[] { typeof(Type) }); + AccessTools2.GetDelegate("TaleWorlds.SaveSystem.TypeExtensions:IsContainer", [typeof(Type)]); protected static bool IsContainerFallback(Type type) { diff --git a/src/Bannerlord.ButterLib/SubModuleWrappers2/MBSubModuleBaseListWrapper.cs b/src/Bannerlord.ButterLib/SubModuleWrappers2/MBSubModuleBaseListWrapper.cs index 39e78102..bf67025e 100644 --- a/src/Bannerlord.ButterLib/SubModuleWrappers2/MBSubModuleBaseListWrapper.cs +++ b/src/Bannerlord.ButterLib/SubModuleWrappers2/MBSubModuleBaseListWrapper.cs @@ -12,7 +12,7 @@ namespace Bannerlord.ButterLib.SubModuleWrappers2; /// public class MBSubModuleBaseListWrapper : MBSubModuleBase { - protected readonly List _subModules = new(); + protected readonly List _subModules = []; public IReadOnlyList SubModules => _subModules.AsReadOnly(); public new virtual void OnSubModuleLoad() diff --git a/tests/Bannerlord.ButterLib.HotKeys.Test/Bannerlord.ButterLib.HotKeys.Test.csproj b/tests/Bannerlord.ButterLib.HotKeys.Test/Bannerlord.ButterLib.HotKeys.Test.csproj index 56d8b2e6..50cf3f0e 100644 --- a/tests/Bannerlord.ButterLib.HotKeys.Test/Bannerlord.ButterLib.HotKeys.Test.csproj +++ b/tests/Bannerlord.ButterLib.HotKeys.Test/Bannerlord.ButterLib.HotKeys.Test.csproj @@ -5,7 +5,6 @@ net472 9.0 enable - x64 Stable_Debug;Stable_Release;Beta_Debug;Beta_Release $(DefineConstants);$(GameVersionConstant) diff --git a/tests/Bannerlord.ButterLib.Implementation.Tests/Bannerlord.ButterLib.Implementation.Tests.csproj b/tests/Bannerlord.ButterLib.Implementation.Tests/Bannerlord.ButterLib.Implementation.Tests.csproj index 7418318b..6ff554a0 100644 --- a/tests/Bannerlord.ButterLib.Implementation.Tests/Bannerlord.ButterLib.Implementation.Tests.csproj +++ b/tests/Bannerlord.ButterLib.Implementation.Tests/Bannerlord.ButterLib.Implementation.Tests.csproj @@ -5,7 +5,6 @@ net472 latest enable - x64 Stable_Debug;Stable_Release;Beta_Debug;Beta_Release $(DefineConstants);$(GameVersionConstant) diff --git a/tests/Bannerlord.ButterLib.Implementation.Tests/DependencyInjectionTests.cs b/tests/Bannerlord.ButterLib.Implementation.Tests/DependencyInjectionTests.cs index e24620f9..5903340b 100644 --- a/tests/Bannerlord.ButterLib.Implementation.Tests/DependencyInjectionTests.cs +++ b/tests/Bannerlord.ButterLib.Implementation.Tests/DependencyInjectionTests.cs @@ -61,7 +61,7 @@ private static bool MockedGetConfigName(ref string __result) [MethodImpl(MethodImplOptions.NoInlining)] private static bool MockedGetModuleNames(ref string[] __result) { - __result = Array.Empty(); + __result = []; return false; } diff --git a/tests/Bannerlord.ButterLib.ObjectSystem.Test/Bannerlord.ButterLib.ObjectSystem.Test.csproj b/tests/Bannerlord.ButterLib.ObjectSystem.Test/Bannerlord.ButterLib.ObjectSystem.Test.csproj index 18dc22d8..68211b65 100644 --- a/tests/Bannerlord.ButterLib.ObjectSystem.Test/Bannerlord.ButterLib.ObjectSystem.Test.csproj +++ b/tests/Bannerlord.ButterLib.ObjectSystem.Test/Bannerlord.ButterLib.ObjectSystem.Test.csproj @@ -5,7 +5,6 @@ net472 9.0 enable - x64 Stable_Debug;Stable_Release;Beta_Debug;Beta_Release $(DefineConstants);$(GameVersionConstant) diff --git a/tests/Bannerlord.ButterLib.Tests/Bannerlord.ButterLib.Tests.csproj b/tests/Bannerlord.ButterLib.Tests/Bannerlord.ButterLib.Tests.csproj index 007f8478..6f6aa4f4 100644 --- a/tests/Bannerlord.ButterLib.Tests/Bannerlord.ButterLib.Tests.csproj +++ b/tests/Bannerlord.ButterLib.Tests/Bannerlord.ButterLib.Tests.csproj @@ -5,7 +5,6 @@ net472 latest enable - x64 Stable_Debug;Stable_Release;Beta_Debug;Beta_Release $(DefineConstants);$(GameVersionConstant) diff --git a/tests/Bannerlord.ButterLib.Tests/SaveSystem/JsonSerializationTests.cs b/tests/Bannerlord.ButterLib.Tests/SaveSystem/JsonSerializationTests.cs index 37989e7a..36af8a74 100644 --- a/tests/Bannerlord.ButterLib.Tests/SaveSystem/JsonSerializationTests.cs +++ b/tests/Bannerlord.ButterLib.Tests/SaveSystem/JsonSerializationTests.cs @@ -89,7 +89,7 @@ IEnumerable Filter(IEnumerable types) } catch (Exception) { - return Enumerable.Empty(); + return []; } }) .ToList(); @@ -158,7 +158,7 @@ IEnumerable Filter(Type[] types) } catch (Exception) { - return Enumerable.Empty(); + return []; } }) .ToList();