diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.cs index 1668bb98437..29e4704594b 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.cs @@ -799,7 +799,7 @@ private void TestHook_GetAllSnapLines(ref Message m) if (host.GetDesigner(comp) is ControlDesigner designer) { - foreach (SnapLine line in designer.SnapLinesInternal) + foreach (SnapLine line in designer.SnapLines) { snapLineInfo.Append($"{line}\tAssociated Control = {designer.Control.Name}:::"); } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DragAssistanceManager.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DragAssistanceManager.cs index b7bdde94089..84e1230118c 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DragAssistanceManager.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DragAssistanceManager.cs @@ -165,7 +165,7 @@ internal DragAssistanceManager( /// private void AddSnapLines(ControlDesigner controlDesigner, List horizontalList, List verticalList, bool isTarget, bool validTarget) { - IList snapLines = controlDesigner.SnapLinesInternal; + IList snapLines = controlDesigner.SnapLines; // Used for padding snaplines Rectangle controlRect = controlDesigner.Control.ClientRectangle; // Used for all others diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/Behavior/SnapLineTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/Behavior/SnapLineTests.cs index 77c7c622090..36970f66217 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/Behavior/SnapLineTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/Behavior/SnapLineTests.cs @@ -236,4 +236,59 @@ public void SnapLine_ToString(string filter, string expected) Assert.Equal(expected, snapLine.ToString()); } + + // Unit test for https://github.com/dotnet/winforms/issues/13305 + [Fact] + public void SnapLine_ReturnOverrided() + { + using ControlDesigner baseDesigner = new(); + using Control control = new(); + baseDesigner.Initialize(control); + baseDesigner.SnapLines.Count.Should().Be(8); + + ControlDesigner derivedDesigner = new ButtonBaseDesigner(); + using Button button = new(); + derivedDesigner.Initialize(button); + derivedDesigner.SnapLines.Count.Should().Be(9); + + derivedDesigner = new ComboBoxDesigner(); + using ComboBox comboBox = new(); + derivedDesigner.Initialize(comboBox); + derivedDesigner.SnapLines.Count.Should().Be(9); + + derivedDesigner = new DateTimePickerDesigner(); + using DateTimePicker dateTimePicker = new(); + derivedDesigner.Initialize(dateTimePicker); + derivedDesigner.SnapLines.Count.Should().Be(9); + + derivedDesigner = new LabelDesigner(); + using Label label = new(); + derivedDesigner.Initialize(label); + derivedDesigner.SnapLines.Count.Should().Be(9); + + derivedDesigner = new ParentControlDesigner(); + derivedDesigner.Initialize(control); + derivedDesigner.SnapLines.Count.Should().Be(12); + + derivedDesigner = new SplitterPanelDesigner(); + using SplitContainer splitContainer = new(); + using SplitterPanel splitterPanel = new(splitContainer); + derivedDesigner.Initialize(splitterPanel); + derivedDesigner.SnapLines.Count.Should().Be(4); + + derivedDesigner = new TextBoxBaseDesigner(); + using TextBox textBox = new(); + derivedDesigner.Initialize(textBox); + derivedDesigner.SnapLines.Count.Should().Be(9); + + derivedDesigner = new ToolStripContentPanelDesigner(); + using ToolStripContentPanel toolStripContentPanel = new(); + derivedDesigner.Initialize(toolStripContentPanel); + derivedDesigner.SnapLines.Count.Should().Be(4); + + derivedDesigner = new UpDownBaseDesigner(); + using DomainUpDown domainUpDown = new(); + derivedDesigner.Initialize(domainUpDown); + derivedDesigner.SnapLines.Count.Should().Be(9); + } }