Repository navigation
Closed as not planned
Description
Currently the unit test coverage of the PropertyGrid is 49.91%
The following code lacks unit test coverage. For details, please refer to Code Coverage
The code line under Constructor:
-
if (ScaleHelper.IsThreadPerMonitorV2Aware) -
catch (Exception ex) when (!ex.IsCriticalException())
Functions:
- PropertyGrid
- AddTab Add test cases for PropertyGrid.AddTab #14574
- CollapseAllGridItems Adds tests to ExpandAllGridItems and CollapseAllGridItems #14601
- ClearTabs Add test cases for PropertyGrid.ClearTabs #14611
- CreateGridView
if (_inGridViewCreate) - CreateTab
- DisplayCommandsPane
- Dispose
if (GetFlag(Flags.GotDesignerEventService)) - DividerDraw
if (y == -1) - DividerInside
- DividerLimitHigh
- DrawXorBar
- EnablePropPageButton
- EnableTabs
- EnsureLargeButtons
- AddLargeImage
- EnsurePendingChangesCommitted
- ExpandAllGridItems Adds tests to ExpandAllGridItems and CollapseAllGridItems #14601
- GetCommonTabs
- GetElementFromPoint
- GetUnwrappedObject
- GetCurrentEntries
- DropDownDone
- HandleF4
- SaveState
- LoadState
- OnActiveDesignerChanged
- OnChanged
- OnChildMouseMove
- OnChildMouseDown
- OnComponentAdded Add tests for method "OnComponentAdded" of the PropertyGrid #14605
- OnComponentChanged
- OnComponentRemoved Add tests for PropertyGrid.OnComponentRemoved #14561
- OnFontChanged
- OnGotFocus
- ScaleCore
- OnLayoutInternal
- OnMouseMove
- OnMouseUp
- OnRequestEdit
- OnComComponentNameChanged
- OnNotifyPropertyValueUIItemsChanged
- OnPaint
if (_commandsPane.Visible) - OnPropertyValueSet
- OnTransactionClosed
- OnTransactionOpened
- OnTypeDescriptorRefreshed
- OnTypeDescriptorRefreshedInvoke
- OnViewPropertyPagesButtonClick
- ProcessDialogKey
- Refresh
if (GetFlag(Flags.RefreshingProperties)) - Refresh(bool clearCached)
if (Disposing || GetFlag(Flags.RefreshingProperties)) - RefreshTabs Add unit tests for
PropertyGrid.RefreshTabs(PropertyTabScope)inPropertyGridTests.cs. #14627 - ReleaseTab
- RemoveTabs(PropertyTabScope classification, bool setupToolbar)
- RemoveTab(int tabIndex, bool setupToolbar)
- RemoveTab(Type tabType)
if (tabIndex == -1) - ResetHelpBackColor Fixes PropertyGrid.ResetHelpForeColor resets the back color instead of the fore color #14572
- ResetHelpForeColor Fixes PropertyGrid.ResetHelpForeColor resets the back color instead of the fore color #14572
- ReplaceSelectedObject
- TryGetSavedTabIndex
if (_designerSelections is null || ActiveDesigner is null) - SelectViewTabButtonDefault
- SetSelectState
- SetupToolbar
- ShowEventsButton
- SinkPropertyNotifyEvents
- ShouldForwardChildMouseMessage
- UpdatePropertiesViewTabVisibility
- UpdateSelection
- WantsTab
- RescaleConstants
- WndProc
Properties:
- ActiveDesigner
if (_rootEntry is not null) - CanCopy
- CanCut
- CanPaste
- CanUndo
- CommandsVisibleIfAvailable
if (hotcommandsVisible != _commandsPane.Visible) - FreezePainting
get => _paintFrozen > 0; - GridViewVisible
- PropertySort
if (selectedGridItem is not null) - SelectedObjects
Setmethod - SortedByCategories
- ToolStripRenderer
Getmethod - IComPropertyBrowser.ComComponentNameChanged
- PropertyTabChanged
Removemethod - SelectedGridItemChanged
Removemethod - InPropertySet
- UseCompatibleTextRendering
Setmethod
Reacted by Tanya Solyanik

Activity
[-]The missed test of the PropertyGrid.cs[/-][+]Unit test coverage for the PropertyGrid class[/+]Related dotnet#12055
LeafShi1 commentedon Jun 11, 2026
After reviewing the current progress on increasing test coverage for PropertyGrid (issue #12055), I believe this issue can be closed or should be re-scoped.
The original goal of this issue is to improve unit test coverage. However, many of the remaining uncovered areas are private or internal methods. Adding tests directly targeting these methods introduces several concerns:
Fragility and tight coupling
Tests that directly invoke private or internal implementation details are inherently fragile and tightly coupled to the current code structure. Any refactoring (even without behavioral changes) can easily break these tests.
Limited value for product correctness
Private methods do not represent user-observable behavior. As seen in previous cases, a private method can contain defects but remain unobservable if it is not used or does not affect public behavior. In such cases, additional tests do not improve product reliability.
Existing repo guidance and reviews
Prior reviews and guidelines in this repository emphasize testing observable behavior through public APIs rather than testing implementation details directly. In several cases, tests targeting internal/private paths were considered redundant when public behavior was already covered.
Given the above, further work on this issue would likely result in low-value or brittle tests. Instead, future efforts should focus on:
Based on this, I closed this issue .
Fixes PropertyGrid.ResetHelpForeColor resets the back color instead o…