Basic method support

This commit is contained in:
Cj 2024-06-16 16:21:42 -04:00
parent f903e1c73e
commit f847ab424d
6 changed files with 318 additions and 108 deletions

View File

@ -101,6 +101,19 @@ partial class ReCodeItForm
IsSealedUpDown = new DomainUpDown();
TabControlMain = new TabControl();
AutoMapperTab = new TabPage();
AutoMapperMethodTextBox = new TextBox();
AutoMapperMethodRemoveButton = new Button();
AutoMapperMethodAddButton = new Button();
AutoMapperMethodBox = new ListBox();
AutoMapperSearchMethodsCheckBox = new CheckBox();
AutoMapperFPTextField = new TextBox();
AutoMapperFPRemoveButton = new Button();
AutoMapperFPAddButton = new Button();
AutoMapperFPBox = new ListBox();
AutoMapperTokensTextField = new TextBox();
AutoMapperTokensRemoveButton = new Button();
AutoMapperTokensAddButton = new Button();
AutoMapperTokensBox = new ListBox();
label3 = new Label();
AutoMapperMinLengthUpDown = new NumericUpDown();
RunAutoRemapButton = new Button();
@ -128,14 +141,6 @@ partial class ReCodeItForm
AssemblyPathTextBox = new TextBox();
SilentModeCheckbox = new CheckBox();
DebugLoggingCheckbox = new CheckBox();
AutoMapperTokensTextField = new TextBox();
AutoMapperTokensRemoveButton = new Button();
AutoMapperTokensAddButton = new Button();
AutoMapperTokensBox = new ListBox();
AutoMapperFPTextField = new TextBox();
AutoMapperFPRemoveButton = new Button();
AutoMapperFPAddButton = new Button();
AutoMapperFPBox = new ListBox();
TabPageRemapper.SuspendLayout();
groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)ConstuctorCountUpDown).BeginInit();
@ -943,6 +948,11 @@ partial class ReCodeItForm
// AutoMapperTab
//
AutoMapperTab.BackColor = SystemColors.ControlDarkDark;
AutoMapperTab.Controls.Add(AutoMapperMethodTextBox);
AutoMapperTab.Controls.Add(AutoMapperMethodRemoveButton);
AutoMapperTab.Controls.Add(AutoMapperMethodAddButton);
AutoMapperTab.Controls.Add(AutoMapperMethodBox);
AutoMapperTab.Controls.Add(AutoMapperSearchMethodsCheckBox);
AutoMapperTab.Controls.Add(AutoMapperFPTextField);
AutoMapperTab.Controls.Add(AutoMapperFPRemoveButton);
AutoMapperTab.Controls.Add(AutoMapperFPAddButton);
@ -967,6 +977,134 @@ partial class ReCodeItForm
AutoMapperTab.TabIndex = 3;
AutoMapperTab.Text = "Auto Mapper";
//
// AutoMapperMethodTextBox
//
AutoMapperMethodTextBox.BackColor = SystemColors.ScrollBar;
AutoMapperMethodTextBox.Location = new Point(365, 496);
AutoMapperMethodTextBox.Name = "AutoMapperMethodTextBox";
AutoMapperMethodTextBox.PlaceholderText = "method parameter names to blacklist";
AutoMapperMethodTextBox.Size = new Size(353, 31);
AutoMapperMethodTextBox.TabIndex = 43;
//
// AutoMapperMethodRemoveButton
//
AutoMapperMethodRemoveButton.Location = new Point(606, 768);
AutoMapperMethodRemoveButton.Name = "AutoMapperMethodRemoveButton";
AutoMapperMethodRemoveButton.Size = new Size(112, 34);
AutoMapperMethodRemoveButton.TabIndex = 42;
AutoMapperMethodRemoveButton.Text = "Remove";
AutoMapperMethodRemoveButton.UseVisualStyleBackColor = true;
AutoMapperMethodRemoveButton.Click += AutoMapperMethodRemoveButton_Click;
//
// AutoMapperMethodAddButton
//
AutoMapperMethodAddButton.Location = new Point(365, 768);
AutoMapperMethodAddButton.Name = "AutoMapperMethodAddButton";
AutoMapperMethodAddButton.Size = new Size(112, 34);
AutoMapperMethodAddButton.TabIndex = 41;
AutoMapperMethodAddButton.Text = "Add";
AutoMapperMethodAddButton.UseVisualStyleBackColor = true;
AutoMapperMethodAddButton.Click += AutoMapperMethodAddButton_Click;
//
// AutoMapperMethodBox
//
AutoMapperMethodBox.BackColor = Color.Gray;
AutoMapperMethodBox.FormattingEnabled = true;
AutoMapperMethodBox.ItemHeight = 25;
AutoMapperMethodBox.Location = new Point(365, 533);
AutoMapperMethodBox.Name = "AutoMapperMethodBox";
AutoMapperMethodBox.Size = new Size(353, 229);
AutoMapperMethodBox.TabIndex = 40;
//
// AutoMapperSearchMethodsCheckBox
//
AutoMapperSearchMethodsCheckBox.AutoSize = true;
AutoMapperSearchMethodsCheckBox.Location = new Point(13, 132);
AutoMapperSearchMethodsCheckBox.Name = "AutoMapperSearchMethodsCheckBox";
AutoMapperSearchMethodsCheckBox.Size = new Size(291, 29);
AutoMapperSearchMethodsCheckBox.TabIndex = 39;
AutoMapperSearchMethodsCheckBox.Text = "Search Methods (Experiemental)";
AutoMapperSearchMethodsCheckBox.UseVisualStyleBackColor = true;
AutoMapperSearchMethodsCheckBox.CheckedChanged += SearchMethodsCheckBox_CheckedChanged;
//
// AutoMapperFPTextField
//
AutoMapperFPTextField.BackColor = SystemColors.ScrollBar;
AutoMapperFPTextField.Location = new Point(6, 496);
AutoMapperFPTextField.Name = "AutoMapperFPTextField";
AutoMapperFPTextField.PlaceholderText = "Field or property names to blacklist";
AutoMapperFPTextField.Size = new Size(353, 31);
AutoMapperFPTextField.TabIndex = 38;
//
// AutoMapperFPRemoveButton
//
AutoMapperFPRemoveButton.Location = new Point(247, 768);
AutoMapperFPRemoveButton.Name = "AutoMapperFPRemoveButton";
AutoMapperFPRemoveButton.Size = new Size(112, 34);
AutoMapperFPRemoveButton.TabIndex = 37;
AutoMapperFPRemoveButton.Text = "Remove";
AutoMapperFPRemoveButton.UseVisualStyleBackColor = true;
AutoMapperFPRemoveButton.Click += AutoMapperFPRemoveButton_Click;
//
// AutoMapperFPAddButton
//
AutoMapperFPAddButton.Location = new Point(6, 768);
AutoMapperFPAddButton.Name = "AutoMapperFPAddButton";
AutoMapperFPAddButton.Size = new Size(112, 34);
AutoMapperFPAddButton.TabIndex = 36;
AutoMapperFPAddButton.Text = "Add";
AutoMapperFPAddButton.UseVisualStyleBackColor = true;
AutoMapperFPAddButton.Click += AutoMapperFPAddButton_Click;
//
// AutoMapperFPBox
//
AutoMapperFPBox.BackColor = Color.Gray;
AutoMapperFPBox.FormattingEnabled = true;
AutoMapperFPBox.ItemHeight = 25;
AutoMapperFPBox.Location = new Point(6, 533);
AutoMapperFPBox.Name = "AutoMapperFPBox";
AutoMapperFPBox.Size = new Size(353, 229);
AutoMapperFPBox.TabIndex = 35;
//
// AutoMapperTokensTextField
//
AutoMapperTokensTextField.BackColor = SystemColors.ScrollBar;
AutoMapperTokensTextField.Location = new Point(365, 173);
AutoMapperTokensTextField.Name = "AutoMapperTokensTextField";
AutoMapperTokensTextField.PlaceholderText = "Class Tokens To Match During Renaming";
AutoMapperTokensTextField.Size = new Size(353, 31);
AutoMapperTokensTextField.TabIndex = 34;
//
// AutoMapperTokensRemoveButton
//
AutoMapperTokensRemoveButton.Location = new Point(606, 445);
AutoMapperTokensRemoveButton.Name = "AutoMapperTokensRemoveButton";
AutoMapperTokensRemoveButton.Size = new Size(112, 34);
AutoMapperTokensRemoveButton.TabIndex = 33;
AutoMapperTokensRemoveButton.Text = "Remove";
AutoMapperTokensRemoveButton.UseVisualStyleBackColor = true;
AutoMapperTokensRemoveButton.Click += AutoMapperTokensRemoveButton_Click;
//
// AutoMapperTokensAddButton
//
AutoMapperTokensAddButton.Location = new Point(365, 445);
AutoMapperTokensAddButton.Name = "AutoMapperTokensAddButton";
AutoMapperTokensAddButton.Size = new Size(112, 34);
AutoMapperTokensAddButton.TabIndex = 32;
AutoMapperTokensAddButton.Text = "Add";
AutoMapperTokensAddButton.UseVisualStyleBackColor = true;
AutoMapperTokensAddButton.Click += AutoMapperTokensAddButton_Click;
//
// AutoMapperTokensBox
//
AutoMapperTokensBox.BackColor = Color.Gray;
AutoMapperTokensBox.FormattingEnabled = true;
AutoMapperTokensBox.ItemHeight = 25;
AutoMapperTokensBox.Location = new Point(365, 210);
AutoMapperTokensBox.Name = "AutoMapperTokensBox";
AutoMapperTokensBox.Size = new Size(353, 229);
AutoMapperTokensBox.TabIndex = 31;
//
// label3
//
label3.AutoSize = true;
@ -1254,84 +1392,6 @@ partial class ReCodeItForm
DebugLoggingCheckbox.UseVisualStyleBackColor = true;
DebugLoggingCheckbox.CheckedChanged += DebugLoggingCheckbox_CheckedChanged;
//
// AutoMapperTokensTextField
//
AutoMapperTokensTextField.BackColor = SystemColors.ScrollBar;
AutoMapperTokensTextField.Location = new Point(365, 173);
AutoMapperTokensTextField.Name = "AutoMapperTokensTextField";
AutoMapperTokensTextField.PlaceholderText = "Class Tokens To Match During Renaming";
AutoMapperTokensTextField.Size = new Size(353, 31);
AutoMapperTokensTextField.TabIndex = 34;
//
// AutoMapperTokensRemoveButton
//
AutoMapperTokensRemoveButton.Location = new Point(606, 445);
AutoMapperTokensRemoveButton.Name = "AutoMapperTokensRemoveButton";
AutoMapperTokensRemoveButton.Size = new Size(112, 34);
AutoMapperTokensRemoveButton.TabIndex = 33;
AutoMapperTokensRemoveButton.Text = "Remove";
AutoMapperTokensRemoveButton.UseVisualStyleBackColor = true;
AutoMapperTokensRemoveButton.Click += AutoMapperTokensRemoveButton_Click;
//
// AutoMapperTokensAddButton
//
AutoMapperTokensAddButton.Location = new Point(365, 445);
AutoMapperTokensAddButton.Name = "AutoMapperTokensAddButton";
AutoMapperTokensAddButton.Size = new Size(112, 34);
AutoMapperTokensAddButton.TabIndex = 32;
AutoMapperTokensAddButton.Text = "Add";
AutoMapperTokensAddButton.UseVisualStyleBackColor = true;
AutoMapperTokensAddButton.Click += AutoMapperTokensAddButton_Click;
//
// AutoMapperTokensBox
//
AutoMapperTokensBox.BackColor = Color.Gray;
AutoMapperTokensBox.FormattingEnabled = true;
AutoMapperTokensBox.ItemHeight = 25;
AutoMapperTokensBox.Location = new Point(365, 210);
AutoMapperTokensBox.Name = "AutoMapperTokensBox";
AutoMapperTokensBox.Size = new Size(353, 229);
AutoMapperTokensBox.TabIndex = 31;
//
// AutoMapperFPTextField
//
AutoMapperFPTextField.BackColor = SystemColors.ScrollBar;
AutoMapperFPTextField.Location = new Point(6, 496);
AutoMapperFPTextField.Name = "AutoMapperFPTextField";
AutoMapperFPTextField.PlaceholderText = "Field or property names to blacklist";
AutoMapperFPTextField.Size = new Size(353, 31);
AutoMapperFPTextField.TabIndex = 38;
//
// AutoMapperFPRemoveButton
//
AutoMapperFPRemoveButton.Location = new Point(247, 768);
AutoMapperFPRemoveButton.Name = "AutoMapperFPRemoveButton";
AutoMapperFPRemoveButton.Size = new Size(112, 34);
AutoMapperFPRemoveButton.TabIndex = 37;
AutoMapperFPRemoveButton.Text = "Remove";
AutoMapperFPRemoveButton.UseVisualStyleBackColor = true;
AutoMapperFPRemoveButton.Click += AutoMapperFPRemoveButton_Click;
//
// AutoMapperFPAddButton
//
AutoMapperFPAddButton.Location = new Point(6, 768);
AutoMapperFPAddButton.Name = "AutoMapperFPAddButton";
AutoMapperFPAddButton.Size = new Size(112, 34);
AutoMapperFPAddButton.TabIndex = 36;
AutoMapperFPAddButton.Text = "Add";
AutoMapperFPAddButton.UseVisualStyleBackColor = true;
AutoMapperFPAddButton.Click += AutoMapperFPAddButton_Click;
//
// AutoMapperFPBox
//
AutoMapperFPBox.BackColor = Color.Gray;
AutoMapperFPBox.FormattingEnabled = true;
AutoMapperFPBox.ItemHeight = 25;
AutoMapperFPBox.Location = new Point(6, 533);
AutoMapperFPBox.Name = "AutoMapperFPBox";
AutoMapperFPBox.Size = new Size(353, 229);
AutoMapperFPBox.TabIndex = 35;
//
// ReCodeItForm
//
AutoScaleDimensions = new SizeF(10F, 25F);
@ -1483,4 +1543,9 @@ partial class ReCodeItForm
private Button AutoMapperFPRemoveButton;
private Button AutoMapperFPAddButton;
private ListBox AutoMapperFPBox;
private CheckBox AutoMapperSearchMethodsCheckBox;
private TextBox AutoMapperMethodTextBox;
private Button AutoMapperMethodRemoveButton;
private Button AutoMapperMethodAddButton;
private ListBox AutoMapperMethodBox;
}

View File

@ -365,6 +365,7 @@ public partial class ReCodeItForm : Form
MaxMatchCountUpDown.Value = DataProvider.Settings.Remapper.MaxMatchCount;
AutoMapperRequiredMatchesUpDown.Value = DataProvider.Settings.AutoMapper.RequiredMatches;
AutoMapperMinLengthUpDown.Value = DataProvider.Settings.AutoMapper.MinLengthToMatch;
}
#region SETTINGS_BUTTONS
@ -486,6 +487,7 @@ public partial class ReCodeItForm : Form
MaxMatchCountUpDown.Value = DataProvider.Settings.Remapper.MaxMatchCount;
AutoMapperRequiredMatchesUpDown.Value = DataProvider.Settings.AutoMapper.RequiredMatches;
AutoMapperSearchMethodsCheckBox.Checked = DataProvider.Settings.AutoMapper.SearchMethods;
foreach (var type in DataProvider.Settings.AutoMapper.TypesToIgnore)
{
@ -501,6 +503,11 @@ public partial class ReCodeItForm : Form
{
AutoMapperFPBox.Items.Add(fp);
}
foreach (var mp in DataProvider.Settings.AutoMapper.MethodParamaterBlackList)
{
AutoMapperMethodBox.Items.Add(mp);
}
}
private void AutoMapperRequiredMatchesUpDown_ValueChanged_1(object sender, EventArgs e)
@ -520,9 +527,9 @@ public partial class ReCodeItForm : Form
if (!AutoMapperTokensBox.Items.Contains(AutoMapperTokensTextField.Text))
{
AutoMapperTokensBox.Items.Add(AutoMapperTokensTextField.Text);
DataProvider.Settings.AutoMapper.TokensToMatch.Add(AutoMapperTokensTextField.Text);
AutoMapperTokensTextField.Clear();
DataProvider.Settings.AutoMapper.TokensToMatch.Add(AutoMapperTokensTextField.Text);
DataProvider.SaveAppSettings();
}
}
@ -532,7 +539,7 @@ public partial class ReCodeItForm : Form
if (AutoMapperTokensBox.SelectedItem != null)
{
AutoMapperTokensBox.Items.Remove(AutoMapperTokensBox.SelectedItem);
DataProvider.Settings.AutoMapper.TokensToMatch.RemoveAt(AutoMapperTokensBox.SelectedIndex);
DataProvider.Settings.AutoMapper.TokensToMatch.RemoveAt(AutoMapperTokensBox.SelectedIndex + 1);
DataProvider.SaveAppSettings();
}
}
@ -542,9 +549,9 @@ public partial class ReCodeItForm : Form
if (!AutoMapperFPBox.Items.Contains(AutoMapperFPTextField.Text))
{
AutoMapperFPBox.Items.Add(AutoMapperFPTextField.Text);
DataProvider.Settings.AutoMapper.PropertyFieldBlackList.Add(AutoMapperFPTextField.Text);
AutoMapperFPTextField.Clear();
DataProvider.Settings.AutoMapper.PropertyFieldBlackList.Add(AutoMapperFPTextField.Text);
DataProvider.SaveAppSettings();
}
}
@ -559,6 +566,34 @@ public partial class ReCodeItForm : Form
}
}
private void AutoMapperMethodAddButton_Click(object sender, EventArgs e)
{
if (!AutoMapperMethodBox.Items.Contains(AutoMapperMethodTextBox.Text))
{
AutoMapperMethodBox.Items.Add(AutoMapperMethodTextBox.Text);
DataProvider.Settings.AutoMapper.MethodParamaterBlackList.Add(AutoMapperMethodTextBox.Text);
AutoMapperMethodTextBox.Clear();
DataProvider.SaveAppSettings();
}
}
private void AutoMapperMethodRemoveButton_Click(object sender, EventArgs e)
{
if (AutoMapperMethodBox.SelectedItem != null)
{
AutoMapperMethodBox.Items.Remove(AutoMapperMethodBox.SelectedItem);
DataProvider.Settings.AutoMapper.MethodParamaterBlackList.RemoveAt(AutoMapperMethodBox.SelectedIndex > 0 ? AutoMapperMethodBox.SelectedIndex : 0);
DataProvider.SaveAppSettings();
}
}
private void SearchMethodsCheckBox_CheckedChanged(object sender, EventArgs e)
{
DataProvider.Settings.AutoMapper.SearchMethods = AutoMapperSearchMethodsCheckBox.Checked;
DataProvider.SaveAppSettings();
}
#endregion AUTOMAPPER
// Reset All UI elements to default

View File

@ -38,6 +38,11 @@ public sealed class MappingPair(
/// </summary>
public bool HasBeenRenamed { get; set; } = false;
/// <summary>
/// Did this match come from a method?
/// </summary>
public EMapPairSource IsMatchFrom { get; set; } = EMapPairSource.None;
/// <summary>
/// This is the name we want to change the assembly class to
/// </summary>
@ -47,4 +52,12 @@ public sealed class MappingPair(
/// Original name of the property or field type
/// </summary>
public string OriginalPropOrFieldName { get; } = name;
}
public enum EMapPairSource
{
None,
Field,
Property,
Method
}

View File

@ -48,11 +48,20 @@ public class ReCodeItAutoMapper
foreach (var type in types)
{
// We dont want to do anything with compiler generated objects
if (CompilerGeneratedClasses.Contains(type.Name))
{
continue;
}
MappingPairs.AddRange(FilterFieldNames(type));
MappingPairs.AddRange(FilterPropertyNames(type));
}
Logger.Log(MappingPairs.Count());
if (Settings.SearchMethods)
{
MappingPairs.AddRange(GatherFromMethods(type));
}
}
PrimaryTypeNameFilter();
SanitizeProposedNames();
@ -89,6 +98,68 @@ public class ReCodeItAutoMapper
}
}
#region METHODS
private List<MappingPair> GatherFromMethods(TypeDefinition type)
{
var methodsWithTypes = new List<MappingPair>();
// Handle nested types recursively
foreach (var nestedType in type.NestedTypes)
{
methodsWithTypes.AddRange(GatherFromMethods(nestedType));
}
var methods = type.Methods
// We only want methods with parameters
.Where(m => m.HasParameters)
// Only want parameter names of a certain length
.Where(m => m.Parameters.Any(p => p.Name.Length > Settings.MinLengthToMatch));
// Now go over over all filterd methods manually, because fuck this with linq
foreach (var method in methods)
{
var parmNames = method.Parameters.Select(p => p.Name);
var parmTypes = method.Parameters.Select(p => p.ParameterType.Name);
// Now over all parameters in the method
foreach (var parm in method.Parameters)
{
// We dont want blacklisted items
if (Settings.MethodParamaterBlackList.Contains(parm.ParameterType.Name.TrimAfterSpecialChar())
|| Settings.TypesToIgnore.Contains(parm.ParameterType.Name.TrimAfterSpecialChar()))
{
continue;
}
if (parm.ParameterType.Resolve() == null) { continue; }
//Logger.Log($"Method Data Found");
//Logger.Log($"Parameter count: {method.Parameters.Count}");
//Logger.Log($"Paremeter Names: {string.Join(", ", parmNames)}");
//Logger.Log($"Paremeter Types: {string.Join(", ", parmTypes)}\n");
var mapPair = new MappingPair(
parm.ParameterType.Resolve(),
parm.Name,
parm.ParameterType.Resolve().IsInterface,
parm.ParameterType.Name.Contains("Struct"),
true);
mapPair.IsMatchFrom = EMapPairSource.Method;
methodsWithTypes.Add(mapPair);
}
}
return methodsWithTypes;
}
#endregion METHODS
#region FIELDS_PROPERTIES
/// <summary>
/// Pair field declaring types with their names
/// </summary>
@ -98,12 +169,6 @@ public class ReCodeItAutoMapper
{
var fieldsWithTypes = new List<MappingPair>();
if (CompilerGeneratedClasses.Contains(type.Name))
{
//Logger.Log($"Skipping over compiler generated object: {type.Name}");
return fieldsWithTypes;
}
// Handle nested types recursively
foreach (var nestedType in type.NestedTypes)
{
@ -133,12 +198,16 @@ public class ReCodeItAutoMapper
// Dont rename things we cant resolve
if (typeDef is null) { continue; }
fieldsWithTypes.Add(new MappingPair(
var pair = new MappingPair(
typeDef,
field.Name,
field.FieldType.Name.Contains("Interface"),
field.FieldType.Name.Contains("Struct"),
field.IsPublic));
field.IsPublic);
pair.IsMatchFrom = EMapPairSource.Field;
fieldsWithTypes.Add(pair);
}
return fieldsWithTypes;
@ -153,12 +222,6 @@ public class ReCodeItAutoMapper
{
var propertiesWithTypes = new List<MappingPair>();
if (CompilerGeneratedClasses.Contains(type.Name))
{
//Logger.Log($"Skipping over compiler generated object: {type.Name}");
return propertiesWithTypes;
}
// Handle nested types recursively
foreach (var nestedType in type.NestedTypes)
{
@ -188,17 +251,25 @@ public class ReCodeItAutoMapper
// Dont rename things we cant resolve
if (typeDef is null) { continue; }
propertiesWithTypes.Add(new MappingPair(
var mapPair = new MappingPair(
typeDef,
property.Name,
property.PropertyType.Name.Contains("Interface"),
property.PropertyType.Name.Contains("Struct"),
true));
true);
mapPair.IsMatchFrom = EMapPairSource.Property;
propertiesWithTypes.Add(mapPair);
}
return propertiesWithTypes;
}
#endregion FIELDS_PROPERTIES
#region FILTER
/// <summary>
/// This giant linq statement handles all of the filtering once the initial gathering of fields
/// and properties is complete
@ -248,6 +319,9 @@ public class ReCodeItAutoMapper
FinalGroupAndSelect();
}
/// <summary>
/// This is where we make sure everything is original
/// </summary>
private void FinalGroupAndSelect()
{
MappingPairs = MappingPairs
@ -258,6 +332,10 @@ public class ReCodeItAutoMapper
.Select(group => group.First()).ToList();
}
#endregion FILTER
#region OUTPUT
/// <summary>
/// Sanitizes and prepares mapping pairs for remapping once filtering is complete.
/// </summary>
@ -311,6 +389,7 @@ public class ReCodeItAutoMapper
Logger.Log($"Matched From Name: {pair.OriginalPropOrFieldName}");
Logger.Log($"IsInterface: {pair.IsInterface}");
Logger.Log($"IsStruct: {pair.IsStruct}");
Logger.Log($"Is match from: {pair.IsMatchFrom}");
Logger.Log($"------------------------------------------------------------------------");
}
@ -338,6 +417,7 @@ public class ReCodeItAutoMapper
{
Logger.Log($"------------------------------------------------------------------------", ConsoleColor.Green);
Logger.Log($"Renaming: {pair.OriginalTypeDefinition.Name} to {pair.Name}", ConsoleColor.Green);
Logger.Log($"Is match from method: {pair.IsMatchFrom}", ConsoleColor.Green);
var fieldCount = RenameHelper.RenameAllFields(
pair.OriginalTypeDefinition.Name,
@ -371,6 +451,7 @@ public class ReCodeItAutoMapper
Logger.Log($"Trying to match: {pair.IsInterface}", ConsoleColor.Red);
Logger.Log($"IsInterface: {pair.IsInterface}", ConsoleColor.Red);
Logger.Log($"IsStruct: {pair.IsStruct}", ConsoleColor.Red);
Logger.Log($"Is match from: {pair.IsMatchFrom}", ConsoleColor.Red);
Logger.Log($"------------------------------------------------------------------------", ConsoleColor.Red);
FailureCount++;
@ -402,12 +483,21 @@ public class ReCodeItAutoMapper
{
var path = DataProvider.WriteAssemblyDefinition();
var fieldCountMatchResult = MappingPairs.Where(x => x.IsMatchFrom == EMapPairSource.Field).Count();
var propertyCountMatchResult = MappingPairs.Where(x => x.IsMatchFrom == EMapPairSource.Property).Count();
var methodCountMatchResult = MappingPairs.Where(x => x.IsMatchFrom == EMapPairSource.Method).Count();
Logger.Log($"-------------------------------RESULT-----------------------------------", ConsoleColor.Green);
Logger.Log($"Complete: Assembly written to `{path}`", ConsoleColor.Green);
Logger.Log($"Found {MappingPairs.Count()} automatic remaps", ConsoleColor.Green);
Logger.Log($"Found {fieldCountMatchResult} automatic remaps from fields", ConsoleColor.Green);
Logger.Log($"Found {propertyCountMatchResult} automatic remaps from properties", ConsoleColor.Green);
Logger.Log($"Found {methodCountMatchResult} automatic remaps from methods", ConsoleColor.Green);
Logger.Log($"Renamed {TotalFieldRenameCount} fields", ConsoleColor.Green);
Logger.Log($"Renamed {TotalPropertyRenameCount} properties", ConsoleColor.Green);
Logger.Log($"Failed to rename: {FailureCount} mapping pairs", ConsoleColor.Green);
Logger.Log($"Failed to rename: {FailureCount} mapping pairs", (FailureCount == 0 ? ConsoleColor.Green : ConsoleColor.Red));
Logger.Log($"------------------------------------------------------------------------", ConsoleColor.Green);
}
#endregion OUTPUT
}

View File

@ -35,9 +35,13 @@ public class AutoMapperSettings
public int MinLengthToMatch { get; set; }
public bool SearchMethods { get; set; }
public List<string> TypesToIgnore { get; set; }
public List<string> TokensToMatch { get; set; }
public List<string> PropertyFieldBlackList { get; set; }
public List<string> MethodParamaterBlackList { get; set; }
}

View File

@ -16,6 +16,7 @@
"AutoMapper": {
"RequiredMatches": 5, // Minimum number of times a member must have this name in the assembly before considering it for remapping
"MinLengthToMatch": 7, // Minimum length of the field/property name in code before it will be considered for a rename
"SearchMethods": true, // Will attempt to map types from method meta data and parameters
"TypesToIgnore": [ // Any member name you want to ignore while iterating through the assembly
"Boolean",
"List",
@ -51,6 +52,8 @@
"Instance",
"Command",
"_template"
],
"MethodParamaterBlackList": [ // method parameter names to ignore in the automap, these are case sanitized so case does not matter
]
}
}