diff --git a/RecodeItGUI/GUI/Main.cs b/RecodeItGUI/GUI/Main.cs index a486c88..83313d0 100644 --- a/RecodeItGUI/GUI/Main.cs +++ b/RecodeItGUI/GUI/Main.cs @@ -818,7 +818,7 @@ public partial class ReCodeItForm : Form AutoMapperFPBox.Items.Add(fp); } - foreach (var mp in settings.MethodParamaterBlackList) + foreach (var mp in settings.MethodParameterBlackList) { AutoMapperMethodBox.Items.Add(mp); } @@ -908,7 +908,7 @@ public partial class ReCodeItForm : Form { AutoMapperMethodBox.Items.Add(AutoMapperMethodTextBox.Text); - AppSettings.AutoMapper.MethodParamaterBlackList.Add(AutoMapperMethodTextBox.Text); + AppSettings.AutoMapper.MethodParameterBlackList.Add(AutoMapperMethodTextBox.Text); DataProvider.SaveAppSettings(); AutoMapperMethodTextBox.Clear(); @@ -919,7 +919,7 @@ public partial class ReCodeItForm : Form { if (AutoMapperMethodBox.SelectedItem != null) { - AppSettings.AutoMapper.MethodParamaterBlackList + AppSettings.AutoMapper.MethodParameterBlackList .RemoveAt(AutoMapperMethodBox.SelectedIndex); AutoMapperMethodBox.Items diff --git a/RecodeItLib/Dumper/DumperClass.cs b/RecodeItLib/Dumper/DumperClass.cs index 6df6998..9e4654f 100644 --- a/RecodeItLib/Dumper/DumperClass.cs +++ b/RecodeItLib/Dumper/DumperClass.cs @@ -225,8 +225,8 @@ public class DumperClass // as of 01/11/24 firstMethod returns true, so its now only 2 instructions, was 55 (this may change, BSG have byppassed their own SSL checks atm) if (firstMethod?.Body.Instructions.Count != 2 || secondMethod?.Body.Instructions.Count != 14) { - Logger.Log($"Instruction count has changed, method with 'certificate' as a param - before: 51, now: {firstMethod.Body.Instructions.Count}, " + - $"method with 'certificateData' as a param - before: 14, now: {secondMethod.Body.Instructions.Count}", ConsoleColor.Red); + Logger.Log($"Instruction count has changed, method with 'certificate' as a param - before: 51, now: {firstMethod?.Body.Instructions.Count}, " + + $"method with 'certificateData' as a param - before: 14, now: {secondMethod?.Body.Instructions.Count}", ConsoleColor.Red); } if (methods.Count() != 2) @@ -266,41 +266,41 @@ public class DumperClass if (method == null || method.Body.Instructions.Count != 23) { - Logger.Log($"RunValidation Instructions count has changed from 23 to {method.Body.Instructions.Count}"); + Logger.Log($"RunValidation Instructions count has changed from 23 to {method?.Body.Instructions.Count}"); } if (method2 == null || method2.Body.Instructions.Count != 171) { - Logger.Log($"RunValidation's MoveNext Instructions count has changed from 171 to {method2.Body.Instructions.Count}"); + Logger.Log($"RunValidation's MoveNext Instructions count has changed from 171 to {method2?.Body.Instructions.Count}"); } // Clear these from the body of each method respectively - method.Body.Instructions.Clear(); - method2.Body.Instructions.Clear(); - method2.Body.Variables.Clear(); - method2.Body.ExceptionHandlers.Clear(); + method?.Body.Instructions.Clear(); + method2?.Body.Instructions.Clear(); + method2?.Body.Variables.Clear(); + method2?.Body.ExceptionHandlers.Clear(); - var liList = DumpyILHelper.GetRunValidationInstructions(method, _gameModule, _msModule, _gameImporter); - var liList2 = DumpyILHelper.GetRunValidationInstructionsMoveNext(method2, _gameModule, _msModule, _gameImporter); + var liList = DumpyILHelper.GetRunValidationInstructions(method!, _gameModule!, _msModule!, _gameImporter); + var liList2 = DumpyILHelper.GetRunValidationInstructionsMoveNext(method2!, _gameModule!, _msModule!, _gameImporter); foreach (var instruction in liList) { - method.Body.Instructions.Add(instruction); + method?.Body.Instructions.Add(instruction); } foreach (var instruction in liList2) { - method2.Body.Instructions.Add(instruction); + method2?.Body.Instructions.Add(instruction); } - var ins = Instruction.Create(OpCodes.Leave_S, method2.Body.Instructions[14]); // Create instruction to jump to index 14 - var ins1 = Instruction.Create(OpCodes.Leave_S, method2.Body.Instructions.Last()); // Create instruction to jump to last index + var ins = Instruction.Create(OpCodes.Leave_S, method2?.Body.Instructions[14]); // Create instruction to jump to index 14 + var ins1 = Instruction.Create(OpCodes.Leave_S, method2?.Body.Instructions.Last()); // Create instruction to jump to last index - method2.Body.Instructions.InsertAfter(method2.Body.Instructions[5], ins); // Instruction to jump from 5 to 14 - method2.Body.Instructions.InsertAfter(method2.Body.Instructions[14], ins1); // Instruction to jump from 14 to last index + method2?.Body.Instructions.InsertAfter(method2.Body.Instructions[5], ins); // Instruction to jump from 5 to 14 + method2?.Body.Instructions.InsertAfter(method2.Body.Instructions[14], ins1); // Instruction to jump from 14 to last index // Add exception handler to method body - method2.Body.ExceptionHandlers.Add(DumpyILHelper.GetExceptionHandler(method2, _gameImporter, _msModule)); + method2?.Body.ExceptionHandlers.Add(DumpyILHelper.GetExceptionHandler(method2, _gameImporter, _msModule!)); } private void SetDumpyTaskCode(TypeDef type) @@ -312,13 +312,13 @@ public class DumperClass Logger.Log($"MainMenu is null or isnt 62 instructions, SOMETHING HAD CHANGED!", ConsoleColor.Red); } - var liList = DumpyILHelper.GetDumpyTaskInstructions(method,_dumpModule, _gameImporter); + var liList = DumpyILHelper.GetDumpyTaskInstructions(method!,_dumpModule!, _gameImporter); - var index = method.Body.Instructions.First(x => x.OpCode == OpCodes.Ret); + var index = method?.Body.Instructions.First(x => x.OpCode == OpCodes.Ret); foreach (var item in liList) { - method.Body.Instructions.InsertBefore(index, item); + method?.Body.Instructions.InsertBefore(index!, item); } } @@ -335,19 +335,19 @@ public class DumperClass if (method == null || method.Body.Instructions.Count != 152) { - Logger.Log($"EnsureConsistency Instructions count has changed from 152 to {method.Body.Instructions.Count}", ConsoleColor.Red); + Logger.Log($"EnsureConsistency Instructions count has changed from 152 to {method?.Body.Instructions.Count}", ConsoleColor.Red); } // clear these from the method body - method.Body.Instructions.Clear(); - method.Body.Variables.Clear(); - method.Body.ExceptionHandlers.Clear(); + method?.Body.Instructions.Clear(); + method?.Body.Variables.Clear(); + method?.Body.ExceptionHandlers.Clear(); - var liList = DumpyILHelper.GetEnsureConsistencyInstructions(method, _checkerModule, _msModule, _checkImporter); + var liList = DumpyILHelper.GetEnsureConsistencyInstructions(method!, _checkerModule!, _msModule!, _checkImporter); foreach (var li in liList) { - method.Body.Instructions.Add(li); + method?.Body.Instructions.Add(li); } } @@ -364,19 +364,19 @@ public class DumperClass if (method == null || method.Body.Instructions.Count != 101) { - Logger.Log($"EnsureConsistencySingle Instructions count has changed from 101 to {method.Body.Instructions.Count}", ConsoleColor.Red); + Logger.Log($"EnsureConsistencySingle Instructions count has changed from 101 to {method?.Body.Instructions.Count}", ConsoleColor.Red); } // clear these from the method body - method.Body.Instructions.Clear(); - method.Body.Variables.Clear(); - method.Body.ExceptionHandlers.Clear(); + method?.Body.Instructions.Clear(); + method?.Body.Variables.Clear(); + method?.Body.ExceptionHandlers.Clear(); - var liList = DumpyILHelper.GetEnsureConsistencyInstructions(method, _checkerModule, _msModule, _checkImporter); + var liList = DumpyILHelper.GetEnsureConsistencyInstructions(method!, _checkerModule!, _msModule!, _checkImporter); foreach (var li in liList) { - method.Body.Instructions.Add(li); + method?.Body.Instructions.Add(li); } } } \ No newline at end of file diff --git a/RecodeItLib/Models/AppSettingsModel.cs b/RecodeItLib/Models/AppSettingsModel.cs index ab9121f..d69c723 100644 --- a/RecodeItLib/Models/AppSettingsModel.cs +++ b/RecodeItLib/Models/AppSettingsModel.cs @@ -7,9 +7,9 @@ namespace ReCodeIt.Models; /// public class Settings { - private AppSettings _appSettings; + private AppSettings? _appSettings; - public AppSettings AppSettings + public AppSettings? AppSettings { get { return _appSettings; } set @@ -19,9 +19,9 @@ public class Settings } } - private RemapperSettings _remapper; + private RemapperSettings? _remapper; - public RemapperSettings Remapper + public RemapperSettings? Remapper { get { return _remapper; } set @@ -31,9 +31,9 @@ public class Settings } } - private AutoMapperSettings _autoMapper; + private AutoMapperSettings? _autoMapper; - public AutoMapperSettings AutoMapper + public AutoMapperSettings? AutoMapper { get { return _autoMapper; } set @@ -89,7 +89,7 @@ public class AppSettings /// public class RemapperSettings { - private string _assemblyPath; + private string _assemblyPath = string.Empty; /// /// Path to the assembly we want to remap @@ -104,7 +104,7 @@ public class RemapperSettings } } - private string _outputPath; + private string _outputPath = string.Empty; /// /// Path including the filename and extension we want to write the changes to @@ -119,7 +119,7 @@ public class RemapperSettings } } - private string _mappingPath; + private string _mappingPath = string.Empty; /// /// Path to the mapping file @@ -149,9 +149,9 @@ public class RemapperSettings } } - private MappingSettings _mappingSettings; + private MappingSettings? _mappingSettings; - public MappingSettings MappingSettings + public MappingSettings? MappingSettings { get { return _mappingSettings; } set @@ -172,7 +172,7 @@ public class RemapperSettings /// public class AutoMapperSettings { - private string _assemblyPath; + private string _assemblyPath = string.Empty; /// /// Path to the assembly we want to remap @@ -187,7 +187,7 @@ public class AutoMapperSettings } } - private string _outputPath; + private string _outputPath = string.Empty; /// /// Path including the filename and extension we want to write the changes to @@ -248,9 +248,9 @@ public class AutoMapperSettings } } - private MappingSettings _mappingSettings; + private MappingSettings? _mappingSettings; - public MappingSettings MappingSettings + public MappingSettings? MappingSettings { get { return _mappingSettings; } set @@ -260,7 +260,7 @@ public class AutoMapperSettings } } - private List _typesToIgnore; + private List _typesToIgnore = []; /// /// Any member name you want to ignore while iterating through the assembly @@ -275,7 +275,7 @@ public class AutoMapperSettings } } - private List _tokensToMatch; + private List _tokensToMatch = []; /// /// The auto mapper will look for these tokens in class names and prioritize those @@ -290,7 +290,7 @@ public class AutoMapperSettings } } - private List _propertyFieldBlacklist; + private List _propertyFieldBlacklist = []; /// /// Property or fields names to ignore in the automap, these are case sanitized so case does not matter @@ -305,17 +305,17 @@ public class AutoMapperSettings } } - private List _methodParamaterBlackList; + private List _methodParameterBlackList = []; /// /// method parameter names to ignore in the automap, these are case sanitized so case does not matter /// - public List MethodParamaterBlackList + public List MethodParameterBlackList { - get { return _methodParamaterBlackList; } + get { return _methodParameterBlackList; } set { - _methodParamaterBlackList = value; + _methodParameterBlackList = value; Save(); } } diff --git a/RecodeItLib/Models/CrossCompilerProjectModel.cs b/RecodeItLib/Models/CrossCompilerProjectModel.cs deleted file mode 100644 index bee5090..0000000 --- a/RecodeItLib/Models/CrossCompilerProjectModel.cs +++ /dev/null @@ -1,71 +0,0 @@ -namespace ReCodeIt.Models; - -public class CrossCompilerProjectModel -{ - #region REQUIRED_ON_CREATION - - /// - /// The path of the original assembly - /// - /// (Required on creation) - /// - public string OriginalAssemblyPath { get; set; } - - /// - /// The path to the working directory vs project - /// - /// (Required on creation) - /// - public string VisualStudioSolutionPath { get; set; } - - /// - /// The path to the dependency folder for the active solution. Also where the remapped dll is - /// built to and replaced - /// - /// (Required on creation) - /// - public string VisualStudioDependencyPath { get; set; } - - /// - /// This is where the final dll is built to - /// - /// (Required on creation) - /// - public string BuildDirectory { get; set; } - - #endregion REQUIRED_ON_CREATION - - /// - /// The path to the working directory vs project - /// - public string VisualStudioSolutionDirectoryPath => Path.GetDirectoryName(VisualStudioSolutionPath)!; - - public string ProjectDllName => SolutionName.Replace(".sln", ".dll"); - - public string OriginalAssemblyDllName => Path.GetFileName(OriginalAssemblyPath); - - /// - /// Name of the solution - /// - public string SolutionName => Path.GetFileName(VisualStudioSolutionPath); - - /// - /// Remapped output hash - /// - public string OriginalAssemblyHash { get; set; } - - /// - /// Remapped output hash - /// - public string RemappedAssemblyHash { get; set; } - - /// - /// Key: Remapped name, value: old name - /// - public Dictionary ChangedTypes { get; set; } = []; - - /// - /// Remap models used on this project - /// - public List RemapModels { get; set; } = []; -} \ No newline at end of file diff --git a/RecodeItLib/Models/ItemTemplateModel.cs b/RecodeItLib/Models/ItemTemplateModel.cs index c1066b8..e8cd4c0 100644 --- a/RecodeItLib/Models/ItemTemplateModel.cs +++ b/RecodeItLib/Models/ItemTemplateModel.cs @@ -2,8 +2,8 @@ public class ItemTemplateModel { - public string _id; - public string _name; - public string _parent; - public string _type; + public string? _id; + public string? _name; + public string? _parent; + public string? _type; } \ No newline at end of file diff --git a/RecodeItLib/Models/RemapModel.cs b/RecodeItLib/Models/RemapModel.cs index e2c7bf8..8b93771 100644 --- a/RecodeItLib/Models/RemapModel.cs +++ b/RecodeItLib/Models/RemapModel.cs @@ -27,7 +27,7 @@ public class RemapModel /// This is the final chosen type we will use to remap /// [JsonIgnore] - public TypeDef TypePrimeCandidate { get; set; } + public TypeDef? TypePrimeCandidate { get; set; } public string NewTypeName { get; set; } = string.Empty; diff --git a/RecodeItLib/Remapper/DeObfuscator.cs b/RecodeItLib/Remapper/DeObfuscator.cs index ca610f4..a7a81bc 100644 --- a/RecodeItLib/Remapper/DeObfuscator.cs +++ b/RecodeItLib/Remapper/DeObfuscator.cs @@ -60,7 +60,6 @@ public static class Deobfuscator : $"--un-name \"!^<>[a-z0-9]$&!^<>[a-z0-9]__.*$&![A-Z][A-Z]\\$<>.*$&^[a-zA-Z_<{{$][a-zA-Z_0-9<>{{}}$.`-]*$\" \"{assemblyPath}\" --strtyp delegate --strtok \"{token}\""; var executablePath = Path.Combine(AppContext.BaseDirectory, "de4dot", "de4dot-x64.exe"); - var two = 2; var process = Process.Start(executablePath, cmd); process.WaitForExit(); diff --git a/RecodeItLib/Remapper/Publicizer.cs b/RecodeItLib/Remapper/Publicizer.cs index dc72173..ad842d0 100644 --- a/RecodeItLib/Remapper/Publicizer.cs +++ b/RecodeItLib/Remapper/Publicizer.cs @@ -5,12 +5,14 @@ namespace ReCodeIt.ReMapper; internal static class SPTPublicizer { - private static ModuleDefMD MainModule; + private static ModuleDefMD? MainModule; public static void PublicizeClasses(ModuleDefMD definition, bool isLauncher = false) { var types = definition.GetTypes(); + MainModule = definition; + foreach (var type in types) { if (type.IsNested) continue; // Nested types are handled when publicizing the parent type @@ -124,7 +126,7 @@ internal static class SPTPublicizer if (type.BaseType != null && !type.BaseType.Name.Contains("Object")) { var baseTypeDefinition = MainModule?.Find(type.BaseType).ResolveTypeDef(); - var baseTypeInterfaces = GetFlattenedInterfacesRecursive(baseTypeDefinition); + var baseTypeInterfaces = GetFlattenedInterfacesRecursive(baseTypeDefinition!); if (baseTypeInterfaces.Any()) { diff --git a/RecodeItLib/Remapper/ReCodeItRemapper.cs b/RecodeItLib/Remapper/ReCodeItRemapper.cs index 0d5c162..0d29cc7 100644 --- a/RecodeItLib/Remapper/ReCodeItRemapper.cs +++ b/RecodeItLib/Remapper/ReCodeItRemapper.cs @@ -26,7 +26,7 @@ public class ReCodeItRemapper private static readonly Stopwatch Stopwatch = new(); - private RemapperSettings Settings => DataProvider.Settings.Remapper; + private RemapperSettings? Settings => DataProvider.Settings?.Remapper; private string OutPath { get; set; } = string.Empty; @@ -71,7 +71,7 @@ public class ReCodeItRemapper cleanedName = $"{cleanedName}-cleaned.dll"; var newPath = Path.GetDirectoryName(assemblyPath); - newPath = Path.Combine(newPath, cleanedName); + newPath = Path.Combine(newPath!, cleanedName); Console.WriteLine($"Cleaning assembly: {newPath}"); @@ -119,7 +119,7 @@ public class ReCodeItRemapper Task.WaitAll(renameTasks.ToArray()); // Don't publicize and unseal until after the remapping, so we can use those as search parameters - if (Settings.MappingSettings.Publicize) + if (Settings!.MappingSettings!.Publicize) { Logger.Log("Publicizing classes...", ConsoleColor.Yellow); @@ -160,7 +160,7 @@ public class ReCodeItRemapper /// Mapping to score private void ScoreMapping(RemapModel mapping, IEnumerable types) { - var tokens = DataProvider.Settings.AutoMapper.TokensToMatch; + var tokens = DataProvider.Settings?.AutoMapper?.TokensToMatch; if (mapping.UseForceRename) { @@ -171,7 +171,7 @@ public class ReCodeItRemapper // Filter down nested objects if (mapping.SearchParams.IsNested is false or null) { - types = types.Where(type => tokens.Any(token => type.Name.StartsWith(token))); + types = types.Where(type => tokens!.Any(token => type.Name.StartsWith(token))); } // Run through a series of filters and report an error if all types are filtered out. @@ -477,13 +477,13 @@ public class ReCodeItRemapper .GetField("TypeTable") .GetValue(templateMappingClass); - BuildAssociationFromTable(typeTable, "ItemClass"); + BuildAssociationFromTable(typeTable!, "ItemClass"); var templateTypeTable = (Dictionary)templateMappingClass .GetField("TemplateTypeTable") .GetValue(templateMappingClass); - BuildAssociationFromTable(templateTypeTable, "TemplateClass"); + BuildAssociationFromTable(templateTypeTable!, "TemplateClass"); } private void BuildAssociationFromTable(Dictionary table, string extName) @@ -558,18 +558,18 @@ public class ReCodeItRemapper /// private void WriteAssembly() { - var moduleName = Module.Name; + var moduleName = Module?.Name; var dllName = "-cleaned-remapped.dll"; - if (Settings.MappingSettings.Publicize) + if (Settings!.MappingSettings!.Publicize) { dllName = "-cleaned-remapped-publicized.dll"; } - OutPath = Path.Combine(OutPath, moduleName.Replace(".dll", dllName)); + OutPath = Path.Combine(OutPath, moduleName?.Replace(".dll", dllName)); try { - Module.Write(OutPath); + Module!.Write(OutPath); } catch (Exception e) { @@ -581,7 +581,7 @@ public class ReCodeItRemapper Hollow(); var hollowedDir = Path.GetDirectoryName(OutPath); - var hollowedPath = Path.Combine(hollowedDir, "Assembly-CSharp-hollowed.dll"); + var hollowedPath = Path.Combine(hollowedDir!, "Assembly-CSharp-hollowed.dll"); try { @@ -595,9 +595,9 @@ public class ReCodeItRemapper DisplayEndBanner(hollowedPath); - if (DataProvider.Settings.Remapper.MappingPath != string.Empty) + if (DataProvider.Settings?.Remapper?.MappingPath != string.Empty) { - DataProvider.UpdateMapping(DataProvider.Settings.Remapper.MappingPath.Replace("mappings.", "mappings-new."), _remaps); + DataProvider.UpdateMapping(DataProvider.Settings!.Remapper!.MappingPath.Replace("mappings.", "mappings-new."), _remaps); } Stopwatch.Reset(); @@ -612,7 +612,7 @@ public class ReCodeItRemapper /// private void Hollow() { - foreach (var type in Module.GetTypes()) + foreach (var type in Module!.GetTypes()) { foreach (var method in type.Methods.Where(m => m.HasBody)) { diff --git a/RecodeItLib/Remapper/RenameHelper.cs b/RecodeItLib/Remapper/RenameHelper.cs index f590fa0..e0eaa2b 100644 --- a/RecodeItLib/Remapper/RenameHelper.cs +++ b/RecodeItLib/Remapper/RenameHelper.cs @@ -6,7 +6,7 @@ namespace ReCodeIt.ReMapper; internal static class RenameHelper { - private static List TokensToMatch => DataProvider.Settings.AutoMapper.TokensToMatch; + private static List? TokensToMatch => DataProvider.Settings?.AutoMapper?.TokensToMatch; /// /// Only used by the manual remapper, should probably be removed @@ -17,9 +17,9 @@ internal static class RenameHelper public static void RenameAll(IEnumerable types, RemapModel remap) { // Rename all fields and properties first - if (DataProvider.Settings.Remapper.MappingSettings.RenameFields) + if (DataProvider.Settings!.Remapper!.MappingSettings!.RenameFields) { - if (remap.TypePrimeCandidate == null) + if (remap.TypePrimeCandidate is null) { Logger.Log($"Unable to rename {remap.NewTypeName} as TypePrimeCandidate value is null/empty, skipping", ConsoleColor.Red); return; @@ -34,7 +34,7 @@ internal static class RenameHelper if (DataProvider.Settings.Remapper.MappingSettings.RenameProperties) { RenameAllProperties( - remap.TypePrimeCandidate.Name.String, + remap!.TypePrimeCandidate!.Name.String, remap.NewTypeName, types); } @@ -42,7 +42,7 @@ internal static class RenameHelper FixMethods(types, remap); RenameType(types, remap); - //Logger.Log($"{remap.TypePrimeCandidate.Name.String} Renamed.", ConsoleColor.Green); + Logger.Log($"{remap!.TypePrimeCandidate!.Name.String} Renamed.", ConsoleColor.Green); } private static void FixMethods( @@ -52,7 +52,7 @@ internal static class RenameHelper foreach (var type in typesToCheck) { var methods = type.Methods - .Where(method => method.Name.StartsWith(remap.TypePrimeCandidate.Name.String)); + .Where(method => method.Name.StartsWith(remap!.TypePrimeCandidate!.Name.String)); foreach (var method in methods) { @@ -68,8 +68,7 @@ internal static class RenameHelper /// /// /// - /// - public static IEnumerable RenameAllFields( + private static void RenameAllFields( string oldTypeName, string newTypeName, @@ -78,7 +77,7 @@ internal static class RenameHelper foreach (var type in typesToCheck) { var fields = type.Fields - .Where(field => field.Name.IsFieldOrPropNameInList(TokensToMatch)); + .Where(field => field.Name.IsFieldOrPropNameInList(TokensToMatch!)); if (!fields.Any()) { continue; } @@ -103,8 +102,6 @@ internal static class RenameHelper } } } - - return typesToCheck; } private static void UpdateAllTypeFieldMemberRefs(IEnumerable typesToCheck, FieldDef newDef, string oldName) @@ -139,7 +136,7 @@ internal static class RenameHelper /// /// /// - public static void RenameAllProperties( + private static void RenameAllProperties( string oldTypeName, string newTypeName, IEnumerable typesToCheck) @@ -147,7 +144,7 @@ internal static class RenameHelper foreach (var type in typesToCheck) { var properties = type.Properties - .Where(prop => prop.Name.IsFieldOrPropNameInList(TokensToMatch)); + .Where(prop => prop.Name.IsFieldOrPropNameInList(TokensToMatch!)); if (!properties.Any()) { continue; } @@ -187,10 +184,10 @@ internal static class RenameHelper { if (type.HasNestedTypes) { - RenameType(type.NestedTypes, remap); + RenameType(type.NestedTypes, remap!); } - if (remap.TypePrimeCandidate.Name is null) { continue; } + if (remap?.TypePrimeCandidate?.Name is null) { continue; } if (remap.SearchParams.IsNested is true && type.IsNested && type.Name == remap.TypePrimeCandidate.Name) diff --git a/RecodeItLib/Utils/DataProvider.cs b/RecodeItLib/Utils/DataProvider.cs index 1fdcb45..08835ea 100644 --- a/RecodeItLib/Utils/DataProvider.cs +++ b/RecodeItLib/Utils/DataProvider.cs @@ -22,7 +22,7 @@ public static class DataProvider public static List Remaps { get; set; } = []; public static Dictionary? ItemTemplates { get; private set; } - public static Settings Settings { get; private set; } + public static Settings? Settings { get; private set; } public static void LoadAppSettings() { @@ -91,11 +91,11 @@ public static class DataProvider Formatting = Formatting.Indented }; - var path = Settings.Remapper.MappingPath; + var path = Settings?.Remapper?.MappingPath; var jsonText = JsonConvert.SerializeObject(Remaps, settings); - File.WriteAllText(path, jsonText); + File.WriteAllText(path!, jsonText); Logger.Log($"Mapping File Saved To {path}"); } diff --git a/RecodeItLib/Utils/Logger.cs b/RecodeItLib/Utils/Logger.cs index 055fe68..6a2bac9 100644 --- a/RecodeItLib/Utils/Logger.cs +++ b/RecodeItLib/Utils/Logger.cs @@ -128,7 +128,7 @@ public static class Logger } private class LogMessage { - public object Message { get; init; } + public object? Message { get; init; } public ConsoleColor Color { get; init; } public bool Silent { get; init; } public int ThreadId { get; init; }