From b7630713849893ca3e46aa49ac0db08cc35750b9 Mon Sep 17 00:00:00 2001 From: Cj <161484149+CJ-SPT@users.noreply.github.com> Date: Sun, 29 Dec 2024 13:38:04 -0500 Subject: [PATCH] Clean up logging --- RecodeItLib/Remapper/ReCodeItRemapper.cs | 1 - RecodeItLib/Remapper/RenameHelper.cs | 13 +++------- .../Remapper/Search/FieldTypeFilters.cs | 1 - .../Remapper/Search/GenericTypeFilters.cs | 26 +------------------ .../Remapper/Search/MethodTypeFilters.cs | 1 - .../Remapper/Search/PropertyTypeFilters.cs | 1 - 6 files changed, 5 insertions(+), 38 deletions(-) diff --git a/RecodeItLib/Remapper/ReCodeItRemapper.cs b/RecodeItLib/Remapper/ReCodeItRemapper.cs index 083e6fb..d232118 100644 --- a/RecodeItLib/Remapper/ReCodeItRemapper.cs +++ b/RecodeItLib/Remapper/ReCodeItRemapper.cs @@ -71,7 +71,6 @@ public class ReCodeItRemapper tasks.Add( Task.Factory.StartNew(() => { - Logger.Log($"\nFinding best match for {remap.NewTypeName}...", ConsoleColor.Gray); ScoreMapping(remap, types); }) ); diff --git a/RecodeItLib/Remapper/RenameHelper.cs b/RecodeItLib/Remapper/RenameHelper.cs index 9f7f473..b7373da 100644 --- a/RecodeItLib/Remapper/RenameHelper.cs +++ b/RecodeItLib/Remapper/RenameHelper.cs @@ -88,9 +88,7 @@ internal static class RenameHelper // Dont need to do extra work if (field.Name == newFieldName) { continue; } - - Logger.Log($"Renaming field on type {type.Name} named `{field.Name}` with type `{field.FieldType.TypeName}` to `{newFieldName}`", ConsoleColor.Green); - + var oldName = field.Name.ToString(); field.Name = newFieldName; @@ -126,8 +124,7 @@ internal static class RenameHelper if (instr.Operand is MemberRef memRef && memRef.Name == oldName) { //if (!memRef.Name.IsFieldOrPropNameInList(TokensToMatch)) continue; - - Logger.Log($"Renaming MemRef in method {method.DeclaringType.Name}::{method.Name} from `{memRef.Name}` to `{newDef.Name}`", ConsoleColor.Yellow); + memRef.Name = newDef.Name; } } @@ -160,8 +157,7 @@ internal static class RenameHelper if (instr.Operand is FieldDef fieldDef && fieldDef.Name == oldName) { if (!fieldDef.Name.IsFieldOrPropNameInList(TokensToMatch)) continue; - - Logger.Log($"Renaming fieldDef in method {method.Name} from `{fieldDef.Name}` to `{newDef.Name}`", ConsoleColor.Yellow); + fieldDef.Name = newDef.Name; } } @@ -196,8 +192,7 @@ internal static class RenameHelper // Dont need to do extra work if (property.Name == newPropertyName) { continue; } - - Logger.Log($"Renaming property on type {type.Name} named `{property.Name}` with type `{property.PropertySig.RetType.TypeName}` to `{newPropertyName}`", ConsoleColor.Green); + property.Name = new UTF8String(newPropertyName); propertyCount++; diff --git a/RecodeItLib/Remapper/Search/FieldTypeFilters.cs b/RecodeItLib/Remapper/Search/FieldTypeFilters.cs index cf25166..5ce4073 100644 --- a/RecodeItLib/Remapper/Search/FieldTypeFilters.cs +++ b/RecodeItLib/Remapper/Search/FieldTypeFilters.cs @@ -69,7 +69,6 @@ internal static class FieldTypeFilters if (parms.FieldCount >= 0) { - Logger.Log("Matching field count", ConsoleColor.Yellow); types = types.Where(t => t.Fields.Count == parms.FieldCount); } diff --git a/RecodeItLib/Remapper/Search/GenericTypeFilters.cs b/RecodeItLib/Remapper/Search/GenericTypeFilters.cs index 34a996f..2dab59e 100644 --- a/RecodeItLib/Remapper/Search/GenericTypeFilters.cs +++ b/RecodeItLib/Remapper/Search/GenericTypeFilters.cs @@ -20,15 +20,12 @@ internal static class GenericTypeFilters { if (parms.IsNested is true) { - Logger.Log("IsNested Public", ConsoleColor.Yellow); - types = types.Where(t => t.IsNestedPublic); types = FilterNestedByName(types, parms); } else { - Logger.Log("IsPublic is true", ConsoleColor.Yellow); types = types.Where(t => t.IsPublic); } } @@ -36,8 +33,6 @@ internal static class GenericTypeFilters { if (parms.IsNested is true) { - Logger.Log("IsNested Private or family", ConsoleColor.Yellow); - types = types.Where(t => t.IsNestedPrivate || t.IsNestedFamily || t.IsNestedFamilyAndAssembly @@ -47,7 +42,6 @@ internal static class GenericTypeFilters } else { - Logger.Log("IsPublic is false", ConsoleColor.Yellow); types = types.Where(t => t.IsNotPublic); } } @@ -59,7 +53,6 @@ internal static class GenericTypeFilters { if (parms.NTParentName is not null) { - Logger.Log($"NT Parent: {parms.NTParentName}", ConsoleColor.Yellow); types = types.Where(t => t.DeclaringType.Name.String == parms.NTParentName); } @@ -77,12 +70,10 @@ internal static class GenericTypeFilters // Filter based on abstract or not if (parms.IsAbstract is true) { - Logger.Log("IsAbstract is true", ConsoleColor.Yellow); types = types.Where(t => t.IsAbstract && !t.IsInterface); } else if (parms.IsAbstract is false) { - Logger.Log("IsAbstract is false", ConsoleColor.Yellow); types = types.Where(t => !t.IsAbstract); } @@ -100,12 +91,10 @@ internal static class GenericTypeFilters // Filter based on abstract or not if (parms.IsSealed is true) { - Logger.Log("IsSealed is true", ConsoleColor.Yellow); types = types.Where(t => t.IsSealed); } else if (parms.IsSealed is false) { - Logger.Log("IsSealed is false", ConsoleColor.Yellow); types = types.Where(t => !t.IsSealed); } @@ -123,12 +112,10 @@ internal static class GenericTypeFilters // Filter based on interface or not if (parms.IsInterface is true) { - Logger.Log("IsInterface is true", ConsoleColor.Yellow); types = types.Where(t => t.IsInterface); } else if (parms.IsInterface is false) { - Logger.Log("IsInterface is false", ConsoleColor.Yellow); types = types.Where(t => !t.IsInterface); } @@ -145,12 +132,10 @@ internal static class GenericTypeFilters { if (parms.IsStruct is true) { - Logger.Log("IsStruct is true", ConsoleColor.Yellow); types = types.Where(t => t.IsValueType && !t.IsEnum); } else if (parms.IsStruct is false) { - Logger.Log("IsStruct is false", ConsoleColor.Yellow); types = types.Where(t => !t.IsValueType); } @@ -168,12 +153,10 @@ internal static class GenericTypeFilters // Filter based on enum or not if (parms.IsEnum is true) { - Logger.Log("IsEnum is true", ConsoleColor.Yellow); types = types.Where(t => t.IsEnum); } else if (parms.IsEnum is false) { - Logger.Log("IsEnum is false", ConsoleColor.Yellow); types = types.Where(t => !t.IsEnum); } @@ -191,12 +174,10 @@ internal static class GenericTypeFilters // Filter based on HasAttribute or not if (parms.HasAttribute is true) { - Logger.Log("HasAttribute is true", ConsoleColor.Yellow); types = types.Where(t => t.HasCustomAttributes); } else if (parms.HasAttribute is false) { - Logger.Log("HasAttribute is false", ConsoleColor.Yellow); types = types.Where(t => !t.HasCustomAttributes); } @@ -214,24 +195,20 @@ internal static class GenericTypeFilters // Filter based on IsDerived or not if (parms.IsDerived is true) { - Logger.Log("IsDerived is true", ConsoleColor.Yellow); types = types.Where(t => t.GetBaseType()?.Name?.String != "Object"); if (parms.MatchBaseClass is not null and not "") { - Logger.Log($"Matching base class: {parms.MatchBaseClass}", ConsoleColor.Yellow); types = types.Where(t => t.GetBaseType()?.Name?.String == parms.MatchBaseClass); } if (parms.IgnoreBaseClass is not null and not "") { - Logger.Log($"Ignoring base class: {parms.MatchBaseClass}", ConsoleColor.Yellow); types = types.Where(t => t.GetBaseType()?.Name?.String != parms.IgnoreBaseClass); } } else if (parms.IsDerived is false) { - Logger.Log("IsDerived is false", ConsoleColor.Yellow); types = types.Where(t => t.GetBaseType()?.Name?.String is "Object"); } @@ -247,8 +224,7 @@ internal static class GenericTypeFilters public static IEnumerable FilterByGenericParameters(IEnumerable types, SearchParams parms) { if (parms.HasGenericParameters is null) return types; - - Logger.Log("Matching generic parameters", ConsoleColor.Yellow); + types = types.Where(t => t.HasGenericParameters == parms.HasGenericParameters); return types; diff --git a/RecodeItLib/Remapper/Search/MethodTypeFilters.cs b/RecodeItLib/Remapper/Search/MethodTypeFilters.cs index cfd5a32..cb4720f 100644 --- a/RecodeItLib/Remapper/Search/MethodTypeFilters.cs +++ b/RecodeItLib/Remapper/Search/MethodTypeFilters.cs @@ -69,7 +69,6 @@ internal static class MethodTypeFilters if (parms.MethodCount >= 0) { - Logger.Log("Matching method count", ConsoleColor.Yellow); types = types.Where(t => GetMethodCountExcludingConstructors(t) == parms.MethodCount); } diff --git a/RecodeItLib/Remapper/Search/PropertyTypeFilters.cs b/RecodeItLib/Remapper/Search/PropertyTypeFilters.cs index 3e0ec81..c26efed 100644 --- a/RecodeItLib/Remapper/Search/PropertyTypeFilters.cs +++ b/RecodeItLib/Remapper/Search/PropertyTypeFilters.cs @@ -69,7 +69,6 @@ internal static class PropertyTypeFilters if (parms.PropertyCount >= 0) { - Logger.Log("Matching property count", ConsoleColor.Yellow); types = types.Where(t => t.Properties.Count == parms.PropertyCount); }