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();
|
||||
TabControlMain = new TabControl();
|
||||
AutoMapperTab = new TabPage();
|
||||
label3 = new Label();
|
||||
AutoMapperMinLengthUpDown = new NumericUpDown();
|
||||
RunAutoRemapButton = new Button();
|
||||
label2 = new Label();
|
||||
AutoMapperRequiredMatchesUpDown = new NumericUpDown();
|
||||
treeView1 = new TreeView();
|
||||
@ -126,7 +129,6 @@ partial class ReCodeItForm
|
||||
AssemblyPathTextBox = new TextBox();
|
||||
SilentModeCheckbox = new CheckBox();
|
||||
DebugLoggingCheckbox = new CheckBox();
|
||||
RunAutoRemapButton = new Button();
|
||||
TabPageRemapper.SuspendLayout();
|
||||
groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)ConstuctorCountUpDown).BeginInit();
|
||||
@ -141,6 +143,7 @@ partial class ReCodeItForm
|
||||
((System.ComponentModel.ISupportInitialize)NestedTypeCountUpDown).BeginInit();
|
||||
TabControlMain.SuspendLayout();
|
||||
AutoMapperTab.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)AutoMapperMinLengthUpDown).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)AutoMapperRequiredMatchesUpDown).BeginInit();
|
||||
SettingsTab.SuspendLayout();
|
||||
groupBox3.SuspendLayout();
|
||||
@ -724,7 +727,7 @@ partial class ReCodeItForm
|
||||
NestedTypeCountEnabled.AutoSize = true;
|
||||
NestedTypeCountEnabled.Location = new Point(287, 326);
|
||||
NestedTypeCountEnabled.Name = "NestedTypeCountEnabled";
|
||||
NestedTypeCountEnabled.Size = new Size(189, 29);
|
||||
NestedTypeCountEnabled.Size = new Size(276, 29);
|
||||
NestedTypeCountEnabled.TabIndex = 12;
|
||||
NestedTypeCountEnabled.Text = "Nested OriginalTypeRef Count";
|
||||
NestedTypeCountEnabled.UseVisualStyleBackColor = true;
|
||||
@ -933,6 +936,8 @@ partial class ReCodeItForm
|
||||
// AutoMapperTab
|
||||
//
|
||||
AutoMapperTab.BackColor = SystemColors.ControlDarkDark;
|
||||
AutoMapperTab.Controls.Add(label3);
|
||||
AutoMapperTab.Controls.Add(AutoMapperMinLengthUpDown);
|
||||
AutoMapperTab.Controls.Add(RunAutoRemapButton);
|
||||
AutoMapperTab.Controls.Add(label2);
|
||||
AutoMapperTab.Controls.Add(AutoMapperRequiredMatchesUpDown);
|
||||
@ -948,6 +953,33 @@ partial class ReCodeItForm
|
||||
AutoMapperTab.TabIndex = 3;
|
||||
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.AutoSize = true;
|
||||
@ -963,6 +995,7 @@ partial class ReCodeItForm
|
||||
AutoMapperRequiredMatchesUpDown.Name = "AutoMapperRequiredMatchesUpDown";
|
||||
AutoMapperRequiredMatchesUpDown.Size = new Size(57, 31);
|
||||
AutoMapperRequiredMatchesUpDown.TabIndex = 26;
|
||||
AutoMapperRequiredMatchesUpDown.ValueChanged += AutoMapperRequiredMatchesUpDown_ValueChanged_1;
|
||||
//
|
||||
// treeView1
|
||||
//
|
||||
@ -1214,16 +1247,6 @@ partial class ReCodeItForm
|
||||
DebugLoggingCheckbox.UseVisualStyleBackColor = true;
|
||||
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
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
@ -1254,6 +1277,7 @@ partial class ReCodeItForm
|
||||
TabControlMain.ResumeLayout(false);
|
||||
AutoMapperTab.ResumeLayout(false);
|
||||
AutoMapperTab.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)AutoMapperMinLengthUpDown).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)AutoMapperRequiredMatchesUpDown).EndInit();
|
||||
SettingsTab.ResumeLayout(false);
|
||||
groupBox3.ResumeLayout(false);
|
||||
@ -1365,4 +1389,6 @@ partial class ReCodeItForm
|
||||
private Label label2;
|
||||
private NumericUpDown AutoMapperRequiredMatchesUpDown;
|
||||
private Button RunAutoRemapButton;
|
||||
private Label label3;
|
||||
private NumericUpDown AutoMapperMinLengthUpDown;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ public partial class ReCodeItForm : Form
|
||||
InitializeComponent();
|
||||
PopulateDomainUpDowns();
|
||||
RefreshSettingsPage();
|
||||
RefreshAutoMapperPage();
|
||||
RemapTreeView.NodeMouseDoubleClick += EditSelectedRemap;
|
||||
|
||||
Remapper.OnComplete += ReloadTreeView;
|
||||
@ -475,6 +476,35 @@ public partial class ReCodeItForm : Form
|
||||
|
||||
#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
|
||||
private void ResetAll()
|
||||
{
|
||||
|
@ -50,7 +50,9 @@ public class ReCodeItAutoMapper
|
||||
MappingPairs.AddRange(FilterPropertyNames(type));
|
||||
}
|
||||
|
||||
FilterTypeNames();
|
||||
Logger.Log(MappingPairs.Count());
|
||||
|
||||
PrimaryTypeNameFilter();
|
||||
SanitizeProposedNames();
|
||||
StartRenameProcess();
|
||||
|
||||
@ -145,7 +147,7 @@ public class ReCodeItAutoMapper
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
private List<MappingPair> FilterPropertyNames(TypeDefinition type)
|
||||
private IEnumerable<MappingPair> FilterPropertyNames(TypeDefinition type)
|
||||
{
|
||||
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
|
||||
/// and properties is complete
|
||||
/// </summary>
|
||||
private void FilterTypeNames()
|
||||
private void PrimaryTypeNameFilter()
|
||||
{
|
||||
// Filter types to the ones we're looking for
|
||||
var mappingPairs = MappingPairs
|
||||
@ -223,16 +225,35 @@ public class ReCodeItAutoMapper
|
||||
|
||||
// Filter out backing fields
|
||||
/// 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
|
||||
.GroupBy(pair => pair.OriginalTypeDefinition.FullName)
|
||||
.Select(group => group.First())
|
||||
.GroupBy(pair => pair.Name)
|
||||
.Select(group => group.First())
|
||||
.ToList();
|
||||
|
||||
MappingPairs = [.. mappingPairs];
|
||||
.Select(group => group.First()).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -291,7 +312,7 @@ public class ReCodeItAutoMapper
|
||||
Logger.Log($"------------------------------------------------------------------------");
|
||||
}
|
||||
|
||||
Logger.Log($"Automatically remapped {MappingPairs.Count} objects");
|
||||
Logger.Log($"Automatically remapped {MappingPairs.Count()} objects");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -354,8 +375,6 @@ public class ReCodeItAutoMapper
|
||||
Error = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
x
Reference in New Issue
Block a user