Implement filtering by required matches
This commit is contained in:
parent
c24a5683cd
commit
1c5e8d5db8
50
RecodeItGUI/GUI/Main.Designer.cs
generated
50
RecodeItGUI/GUI/Main.Designer.cs
generated
@ -101,6 +101,9 @@ partial class ReCodeItForm
|
|||||||
IsSealedUpDown = new DomainUpDown();
|
IsSealedUpDown = new DomainUpDown();
|
||||||
TabControlMain = new TabControl();
|
TabControlMain = new TabControl();
|
||||||
AutoMapperTab = new TabPage();
|
AutoMapperTab = new TabPage();
|
||||||
|
label3 = new Label();
|
||||||
|
AutoMapperMinLengthUpDown = new NumericUpDown();
|
||||||
|
RunAutoRemapButton = new Button();
|
||||||
label2 = new Label();
|
label2 = new Label();
|
||||||
AutoMapperRequiredMatchesUpDown = new NumericUpDown();
|
AutoMapperRequiredMatchesUpDown = new NumericUpDown();
|
||||||
treeView1 = new TreeView();
|
treeView1 = new TreeView();
|
||||||
@ -126,7 +129,6 @@ partial class ReCodeItForm
|
|||||||
AssemblyPathTextBox = new TextBox();
|
AssemblyPathTextBox = new TextBox();
|
||||||
SilentModeCheckbox = new CheckBox();
|
SilentModeCheckbox = new CheckBox();
|
||||||
DebugLoggingCheckbox = new CheckBox();
|
DebugLoggingCheckbox = new CheckBox();
|
||||||
RunAutoRemapButton = new Button();
|
|
||||||
TabPageRemapper.SuspendLayout();
|
TabPageRemapper.SuspendLayout();
|
||||||
groupBox1.SuspendLayout();
|
groupBox1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)ConstuctorCountUpDown).BeginInit();
|
((System.ComponentModel.ISupportInitialize)ConstuctorCountUpDown).BeginInit();
|
||||||
@ -141,6 +143,7 @@ partial class ReCodeItForm
|
|||||||
((System.ComponentModel.ISupportInitialize)NestedTypeCountUpDown).BeginInit();
|
((System.ComponentModel.ISupportInitialize)NestedTypeCountUpDown).BeginInit();
|
||||||
TabControlMain.SuspendLayout();
|
TabControlMain.SuspendLayout();
|
||||||
AutoMapperTab.SuspendLayout();
|
AutoMapperTab.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)AutoMapperMinLengthUpDown).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)AutoMapperRequiredMatchesUpDown).BeginInit();
|
((System.ComponentModel.ISupportInitialize)AutoMapperRequiredMatchesUpDown).BeginInit();
|
||||||
SettingsTab.SuspendLayout();
|
SettingsTab.SuspendLayout();
|
||||||
groupBox3.SuspendLayout();
|
groupBox3.SuspendLayout();
|
||||||
@ -724,7 +727,7 @@ partial class ReCodeItForm
|
|||||||
NestedTypeCountEnabled.AutoSize = true;
|
NestedTypeCountEnabled.AutoSize = true;
|
||||||
NestedTypeCountEnabled.Location = new Point(287, 326);
|
NestedTypeCountEnabled.Location = new Point(287, 326);
|
||||||
NestedTypeCountEnabled.Name = "NestedTypeCountEnabled";
|
NestedTypeCountEnabled.Name = "NestedTypeCountEnabled";
|
||||||
NestedTypeCountEnabled.Size = new Size(189, 29);
|
NestedTypeCountEnabled.Size = new Size(276, 29);
|
||||||
NestedTypeCountEnabled.TabIndex = 12;
|
NestedTypeCountEnabled.TabIndex = 12;
|
||||||
NestedTypeCountEnabled.Text = "Nested OriginalTypeRef Count";
|
NestedTypeCountEnabled.Text = "Nested OriginalTypeRef Count";
|
||||||
NestedTypeCountEnabled.UseVisualStyleBackColor = true;
|
NestedTypeCountEnabled.UseVisualStyleBackColor = true;
|
||||||
@ -933,6 +936,8 @@ partial class ReCodeItForm
|
|||||||
// AutoMapperTab
|
// AutoMapperTab
|
||||||
//
|
//
|
||||||
AutoMapperTab.BackColor = SystemColors.ControlDarkDark;
|
AutoMapperTab.BackColor = SystemColors.ControlDarkDark;
|
||||||
|
AutoMapperTab.Controls.Add(label3);
|
||||||
|
AutoMapperTab.Controls.Add(AutoMapperMinLengthUpDown);
|
||||||
AutoMapperTab.Controls.Add(RunAutoRemapButton);
|
AutoMapperTab.Controls.Add(RunAutoRemapButton);
|
||||||
AutoMapperTab.Controls.Add(label2);
|
AutoMapperTab.Controls.Add(label2);
|
||||||
AutoMapperTab.Controls.Add(AutoMapperRequiredMatchesUpDown);
|
AutoMapperTab.Controls.Add(AutoMapperRequiredMatchesUpDown);
|
||||||
@ -948,6 +953,33 @@ partial class ReCodeItForm
|
|||||||
AutoMapperTab.TabIndex = 3;
|
AutoMapperTab.TabIndex = 3;
|
||||||
AutoMapperTab.Text = "Auto Mapper";
|
AutoMapperTab.Text = "Auto Mapper";
|
||||||
//
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
label3.AutoSize = true;
|
||||||
|
label3.Location = new Point(76, 97);
|
||||||
|
label3.Name = "label3";
|
||||||
|
label3.Size = new Size(277, 25);
|
||||||
|
label3.TabIndex = 30;
|
||||||
|
label3.Text = "Min Length of field or prop name";
|
||||||
|
//
|
||||||
|
// AutoMapperMinLengthUpDown
|
||||||
|
//
|
||||||
|
AutoMapperMinLengthUpDown.Location = new Point(13, 95);
|
||||||
|
AutoMapperMinLengthUpDown.Name = "AutoMapperMinLengthUpDown";
|
||||||
|
AutoMapperMinLengthUpDown.Size = new Size(57, 31);
|
||||||
|
AutoMapperMinLengthUpDown.TabIndex = 29;
|
||||||
|
AutoMapperMinLengthUpDown.ValueChanged += AutoMapperMinLengthUpDown_ValueChanged;
|
||||||
|
//
|
||||||
|
// RunAutoRemapButton
|
||||||
|
//
|
||||||
|
RunAutoRemapButton.Location = new Point(6, 3);
|
||||||
|
RunAutoRemapButton.Name = "RunAutoRemapButton";
|
||||||
|
RunAutoRemapButton.Size = new Size(168, 34);
|
||||||
|
RunAutoRemapButton.TabIndex = 28;
|
||||||
|
RunAutoRemapButton.Text = "Run Auto Remap";
|
||||||
|
RunAutoRemapButton.UseVisualStyleBackColor = true;
|
||||||
|
RunAutoRemapButton.Click += RunAutoRemapButton_Click;
|
||||||
|
//
|
||||||
// label2
|
// label2
|
||||||
//
|
//
|
||||||
label2.AutoSize = true;
|
label2.AutoSize = true;
|
||||||
@ -963,6 +995,7 @@ partial class ReCodeItForm
|
|||||||
AutoMapperRequiredMatchesUpDown.Name = "AutoMapperRequiredMatchesUpDown";
|
AutoMapperRequiredMatchesUpDown.Name = "AutoMapperRequiredMatchesUpDown";
|
||||||
AutoMapperRequiredMatchesUpDown.Size = new Size(57, 31);
|
AutoMapperRequiredMatchesUpDown.Size = new Size(57, 31);
|
||||||
AutoMapperRequiredMatchesUpDown.TabIndex = 26;
|
AutoMapperRequiredMatchesUpDown.TabIndex = 26;
|
||||||
|
AutoMapperRequiredMatchesUpDown.ValueChanged += AutoMapperRequiredMatchesUpDown_ValueChanged_1;
|
||||||
//
|
//
|
||||||
// treeView1
|
// treeView1
|
||||||
//
|
//
|
||||||
@ -1214,16 +1247,6 @@ partial class ReCodeItForm
|
|||||||
DebugLoggingCheckbox.UseVisualStyleBackColor = true;
|
DebugLoggingCheckbox.UseVisualStyleBackColor = true;
|
||||||
DebugLoggingCheckbox.CheckedChanged += DebugLoggingCheckbox_CheckedChanged;
|
DebugLoggingCheckbox.CheckedChanged += DebugLoggingCheckbox_CheckedChanged;
|
||||||
//
|
//
|
||||||
// RunAutoRemapButton
|
|
||||||
//
|
|
||||||
RunAutoRemapButton.Location = new Point(6, 3);
|
|
||||||
RunAutoRemapButton.Name = "RunAutoRemapButton";
|
|
||||||
RunAutoRemapButton.Size = new Size(168, 34);
|
|
||||||
RunAutoRemapButton.TabIndex = 28;
|
|
||||||
RunAutoRemapButton.Text = "Run Auto Remap";
|
|
||||||
RunAutoRemapButton.UseVisualStyleBackColor = true;
|
|
||||||
RunAutoRemapButton.Click += RunAutoRemapButton_Click;
|
|
||||||
//
|
|
||||||
// ReCodeItForm
|
// ReCodeItForm
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||||
@ -1254,6 +1277,7 @@ partial class ReCodeItForm
|
|||||||
TabControlMain.ResumeLayout(false);
|
TabControlMain.ResumeLayout(false);
|
||||||
AutoMapperTab.ResumeLayout(false);
|
AutoMapperTab.ResumeLayout(false);
|
||||||
AutoMapperTab.PerformLayout();
|
AutoMapperTab.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)AutoMapperMinLengthUpDown).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)AutoMapperRequiredMatchesUpDown).EndInit();
|
((System.ComponentModel.ISupportInitialize)AutoMapperRequiredMatchesUpDown).EndInit();
|
||||||
SettingsTab.ResumeLayout(false);
|
SettingsTab.ResumeLayout(false);
|
||||||
groupBox3.ResumeLayout(false);
|
groupBox3.ResumeLayout(false);
|
||||||
@ -1365,4 +1389,6 @@ partial class ReCodeItForm
|
|||||||
private Label label2;
|
private Label label2;
|
||||||
private NumericUpDown AutoMapperRequiredMatchesUpDown;
|
private NumericUpDown AutoMapperRequiredMatchesUpDown;
|
||||||
private Button RunAutoRemapButton;
|
private Button RunAutoRemapButton;
|
||||||
|
private Label label3;
|
||||||
|
private NumericUpDown AutoMapperMinLengthUpDown;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ public partial class ReCodeItForm : Form
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
PopulateDomainUpDowns();
|
PopulateDomainUpDowns();
|
||||||
RefreshSettingsPage();
|
RefreshSettingsPage();
|
||||||
|
RefreshAutoMapperPage();
|
||||||
RemapTreeView.NodeMouseDoubleClick += EditSelectedRemap;
|
RemapTreeView.NodeMouseDoubleClick += EditSelectedRemap;
|
||||||
|
|
||||||
Remapper.OnComplete += ReloadTreeView;
|
Remapper.OnComplete += ReloadTreeView;
|
||||||
@ -475,6 +476,35 @@ public partial class ReCodeItForm : Form
|
|||||||
|
|
||||||
#endregion SETTINGS_TAB
|
#endregion SETTINGS_TAB
|
||||||
|
|
||||||
|
#region AUTOMAPPER
|
||||||
|
|
||||||
|
public void RefreshAutoMapperPage()
|
||||||
|
{
|
||||||
|
AutoMapperExcludeBox.Items.Clear();
|
||||||
|
|
||||||
|
foreach (var method in DataProvider.Settings.AutoMapper.TypesToIgnore)
|
||||||
|
{
|
||||||
|
AutoMapperExcludeBox.Items.Add(method);
|
||||||
|
}
|
||||||
|
|
||||||
|
MaxMatchCountUpDown.Value = DataProvider.Settings.Remapper.MaxMatchCount;
|
||||||
|
AutoMapperRequiredMatchesUpDown.Value = DataProvider.Settings.AutoMapper.RequiredMatches;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AutoMapperRequiredMatchesUpDown_ValueChanged_1(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DataProvider.Settings.AutoMapper.RequiredMatches = (int)AutoMapperRequiredMatchesUpDown.Value;
|
||||||
|
DataProvider.SaveAppSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AutoMapperMinLengthUpDown_ValueChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DataProvider.Settings.AutoMapper.MinLengthToMatch = (int)AutoMapperMinLengthUpDown.Value;
|
||||||
|
DataProvider.SaveAppSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion AUTOMAPPER
|
||||||
|
|
||||||
// Reset All UI elements to default
|
// Reset All UI elements to default
|
||||||
private void ResetAll()
|
private void ResetAll()
|
||||||
{
|
{
|
||||||
|
@ -50,7 +50,9 @@ public class ReCodeItAutoMapper
|
|||||||
MappingPairs.AddRange(FilterPropertyNames(type));
|
MappingPairs.AddRange(FilterPropertyNames(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
FilterTypeNames();
|
Logger.Log(MappingPairs.Count());
|
||||||
|
|
||||||
|
PrimaryTypeNameFilter();
|
||||||
SanitizeProposedNames();
|
SanitizeProposedNames();
|
||||||
StartRenameProcess();
|
StartRenameProcess();
|
||||||
|
|
||||||
@ -145,7 +147,7 @@ public class ReCodeItAutoMapper
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private List<MappingPair> FilterPropertyNames(TypeDefinition type)
|
private IEnumerable<MappingPair> FilterPropertyNames(TypeDefinition type)
|
||||||
{
|
{
|
||||||
var propertiesWithTypes = new List<MappingPair>();
|
var propertiesWithTypes = new List<MappingPair>();
|
||||||
|
|
||||||
@ -199,7 +201,7 @@ public class ReCodeItAutoMapper
|
|||||||
/// This giant linq statement handles all of the filtering once the initial gathering of fields
|
/// This giant linq statement handles all of the filtering once the initial gathering of fields
|
||||||
/// and properties is complete
|
/// and properties is complete
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void FilterTypeNames()
|
private void PrimaryTypeNameFilter()
|
||||||
{
|
{
|
||||||
// Filter types to the ones we're looking for
|
// Filter types to the ones we're looking for
|
||||||
var mappingPairs = MappingPairs
|
var mappingPairs = MappingPairs
|
||||||
@ -223,16 +225,35 @@ public class ReCodeItAutoMapper
|
|||||||
|
|
||||||
// Filter out backing fields
|
// Filter out backing fields
|
||||||
/// This is slow, but oh well
|
/// This is slow, but oh well
|
||||||
.Where(pair => !pair.Name.ToCharArray().Contains('<'))
|
.Where(pair => !pair.Name.ToCharArray().Contains('<')).ToList();
|
||||||
|
|
||||||
|
MappingPairs = mappingPairs;
|
||||||
|
SecondaryTypeNameFilter();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This is where we filter down based on more specific parameters
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mappingPairs"></param>
|
||||||
|
private void SecondaryTypeNameFilter()
|
||||||
|
{
|
||||||
|
// Filter property/field names by required number of matches
|
||||||
|
MappingPairs = MappingPairs
|
||||||
|
.GroupBy(pair => pair.OriginalPropOrFieldName.TrimAfterSpecialChar())
|
||||||
|
.Where(group => group.Count() > Settings.RequiredMatches)
|
||||||
|
.SelectMany(group => group).ToList();
|
||||||
|
|
||||||
|
FinalGroupAndSelect();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FinalGroupAndSelect()
|
||||||
|
{
|
||||||
|
MappingPairs = MappingPairs
|
||||||
// We only want types once, so make it unique
|
// We only want types once, so make it unique
|
||||||
.GroupBy(pair => pair.OriginalTypeDefinition.FullName)
|
.GroupBy(pair => pair.OriginalTypeDefinition.FullName)
|
||||||
.Select(group => group.First())
|
.Select(group => group.First())
|
||||||
.GroupBy(pair => pair.Name)
|
.GroupBy(pair => pair.Name)
|
||||||
.Select(group => group.First())
|
.Select(group => group.First()).ToList();
|
||||||
.ToList();
|
|
||||||
|
|
||||||
MappingPairs = [.. mappingPairs];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -291,7 +312,7 @@ public class ReCodeItAutoMapper
|
|||||||
Logger.Log($"------------------------------------------------------------------------");
|
Logger.Log($"------------------------------------------------------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.Log($"Automatically remapped {MappingPairs.Count} objects");
|
Logger.Log($"Automatically remapped {MappingPairs.Count()} objects");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -354,8 +375,6 @@ public class ReCodeItAutoMapper
|
|||||||
Error = true;
|
Error = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user