Skip to content

Fixes PropertyGrid.ResetHelpForeColor resets the back color instead of the fore color#14572

Open
ricardobossan wants to merge 1 commit into
dotnet:mainfrom
ricardobossan:Issue_14571_Fixes_PropertyGrid.ResetHelpForeColor
Open

Fixes PropertyGrid.ResetHelpForeColor resets the back color instead of the fore color#14572
ricardobossan wants to merge 1 commit into
dotnet:mainfrom
ricardobossan:Issue_14571_Fixes_PropertyGrid.ResetHelpForeColor

Conversation

@ricardobossan
Copy link
Copy Markdown
Member

@ricardobossan ricardobossan commented May 28, 2026

Fixes #14571
Related #12055

Root Cause

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.

Proposed changes

  • 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 Unit test coverage for the PropertyGrid class #12055.

Customer Impact

None. The buggy method has no call sites; no shipped behavior changes.

Regression?

No.

Risk

Minimal

Test methodology

Unit tests

Test environment(s)

11.0.100-preview.5.26227.104

Microsoft Reviewers: Open in CodeFlow

Related dotnet#12055

`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 dotnet#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
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@SimonZhao888
Copy link
Copy Markdown
Member

Looks good to me.

Copy link
Copy Markdown
Member

@LeafShi1 LeafShi1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@LeafShi1 LeafShi1 added the waiting-review This item is waiting on review by one or more members of team label May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-area-label waiting-review This item is waiting on review by one or more members of team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PropertyGrid.ResetHelpForeColor resets the back color instead of the fore color

4 participants