From 38a636b8ea168685ae45371165f6e7cc0084c97f Mon Sep 17 00:00:00 2001 From: "Ricardo Bossan (BEYONDSOFT CONSULTING INC) (from Dev Box)" Date: Thu, 28 May 2026 15:28:39 -0300 Subject: [PATCH] Fixes #14571 Related #12055 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `PropertyGrid.ResetHelpForeColor` (PropertyGrid.cs:3631) delegated to `_helpPane.ResetBackColor()` instead of `_helpPane.ResetForeColor()` — copy-paste typo from `ResetHelpBackColor`, present since the initial WinForms source import in 2018. The method is private with zero call sites, so the defect was never observable through any public API and went undetected. - PropertyGrid.cs:3631: `_helpPane.ResetBackColor()` → `_helpPane.ResetForeColor()`. - PropertyGridTests.cs: add `PropertyGrid_ResetHelpForeColor_Invoke_ResetsForeColorOnly` and `PropertyGrid_ResetHelpBackColor_Invoke_ResetsBackColorOnly`, invoking the private methods directly via `TestAccessor.Dynamic` so coverage and regression protection are independent of the `PropertyDescriptor.ResetValue` path. Contributes to #12055. None. The buggy method has no call sites; no shipped behavior changes. No. Minimal Unit tests. Two new tests in `PropertyGridTests.cs` directly invoke `ResetHelpForeColor` and `ResetHelpBackColor` via `TestAccessor.Dynamic` and assert that only the targeted color is reset while the sibling color is left untouched. 11.0.100-preview.5.26227.104 --- .../Controls/PropertyGrid/PropertyGrid.cs | 2 +- .../System/Windows/Forms/PropertyGridTests.cs | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/System.Windows.Forms/System/Windows/Forms/Controls/PropertyGrid/PropertyGrid.cs b/src/System.Windows.Forms/System/Windows/Forms/Controls/PropertyGrid/PropertyGrid.cs index 9f19a33d013..f1fb81b9071 100644 --- a/src/System.Windows.Forms/System/Windows/Forms/Controls/PropertyGrid/PropertyGrid.cs +++ b/src/System.Windows.Forms/System/Windows/Forms/Controls/PropertyGrid/PropertyGrid.cs @@ -3628,7 +3628,7 @@ internal void RemoveTab(Type tabType) private void ResetHelpBackColor() => _helpPane.ResetBackColor(); - private void ResetHelpForeColor() => _helpPane.ResetBackColor(); + private void ResetHelpForeColor() => _helpPane.ResetForeColor(); /// /// This method is intended for use in replacing a specific selected root object with another object of the diff --git a/src/test/unit/System.Windows.Forms/System/Windows/Forms/PropertyGridTests.cs b/src/test/unit/System.Windows.Forms/System/Windows/Forms/PropertyGridTests.cs index 72f66da482b..5540c780840 100644 --- a/src/test/unit/System.Windows.Forms/System/Windows/Forms/PropertyGridTests.cs +++ b/src/test/unit/System.Windows.Forms/System/Windows/Forms/PropertyGridTests.cs @@ -1972,6 +1972,36 @@ public void PropertyGrid_HelpForeColor_ShouldSerializeValue_Success() Assert.False(property.ShouldSerializeValue(control)); } + [WinFormsFact] + public void PropertyGrid_ResetHelpForeColor_Invoke_ResetsForeColorOnly() + { + using PropertyGrid control = new() + { + HelpForeColor = Color.Red, + HelpBackColor = Color.Yellow + }; + + control.TestAccessor.Dynamic.ResetHelpForeColor(); + + Assert.Equal(SystemColors.ControlText, control.HelpForeColor); + Assert.Equal(Color.Yellow, control.HelpBackColor); + } + + [WinFormsFact] + public void PropertyGrid_ResetHelpBackColor_Invoke_ResetsBackColorOnly() + { + using PropertyGrid control = new() + { + HelpForeColor = Color.Red, + HelpBackColor = Color.Yellow + }; + + control.TestAccessor.Dynamic.ResetHelpBackColor(); + + Assert.Equal(SystemColors.Control, control.HelpBackColor); + Assert.Equal(Color.Red, control.HelpForeColor); + } + [WinFormsTheory] [InlineData(true, true, 0, 0, 1)] [InlineData(true, false, 1, 1, 2)]