Skip to content

Fix issue 14049:The title of the collection editor for custom controls in .NET Core is incorrect.#14375

Open
SimonZhao888 wants to merge 1 commit intodotnet:mainfrom
SimonZhao888:Fix_issue_14049
Open

Fix issue 14049:The title of the collection editor for custom controls in .NET Core is incorrect.#14375
SimonZhao888 wants to merge 1 commit intodotnet:mainfrom
SimonZhao888:Fix_issue_14049

Conversation

@SimonZhao888
Copy link
Member

@SimonZhao888 SimonZhao888 commented Mar 10, 2026

Fixes #14049

Proposed changes

  • Add a helper (GetCollectionItemTypeNameForCaption) that detects a generic ControlProxy-like wrapper and unwraps the inner T when T derives from System.Windows.Forms.Control.
  • Add a test case to verify the created collection editor form caption contains the underlying control type name and does not contain ControlProxy\1`.

Customer Impact

  • The title of the collection editor for custom controls in .NET Core show correctly.

Regression?

  • Yes

Risk

  • Min

Screenshots

Before

image

After

image

Test methodology

  • Manually

Test environment(s)

  • 11.0.0-preview.2.26122.107
Microsoft Reviewers: Open in CodeFlow

Copy link
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.

Pull request overview

Fixes the WinForms designer CollectionEditor dialog caption so that, when the collection item type is a generic ControlProxy<T>-style wrapper around a Control, the caption displays the underlying control type name instead of ControlProxy\1`.

Changes:

  • Update CollectionEditorCollectionForm caption generation to unwrap ControlProxy<T> when T : Control.
  • Add a unit test to validate the caption includes the underlying control type name and excludes ControlProxy\1`.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.CollectionEditorCollectionForm.cs Uses a helper to derive a more user-friendly caption type name by unwrapping ControlProxy<T> for control types.
src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/CollectionEditorTests.cs Adds coverage to ensure the collection editor form caption unwraps ControlProxy<TControl> and shows the underlying control type.

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

Comment on lines 98 to 103
public void CollectionEditor_CreateCollectionForm_Invoke_Success()
{
SubCollectionEditor editor = new(typeof(List<int>));
Form form = editor.CreateCollectionForm();
Assert.NotSame(form, editor.CreateCollectionForm());
}
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

CollectionEditor_CreateCollectionForm_Invoke_Success creates two Form instances without disposing them (the first assigned to form, and the second created inside Assert.NotSame). This can leak window handles/resources across the test run and may cause flaky failures. Please dispose both forms (e.g., wrap each in using or store the second form in a variable and dispose it as well).

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.31693%. Comparing base (3d190f7) to head (c978e71).
⚠️ Report is 15 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #14375         +/-   ##
===================================================
+ Coverage   77.25545%   77.31693%   +0.06148%     
===================================================
  Files           3280        3265         -15     
  Lines         645315      644463        -852     
  Branches       47780       47632        -148     
===================================================
- Hits          498541      498279        -262     
+ Misses        143088      142497        -591     
- Partials        3686        3687          +1     
Flag Coverage Δ
Debug 77.31693% <100.00000%> (+0.06148%) ⬆️
integration 19.12673% <63.63636%> (+0.04272%) ⬆️
production 52.28772% <100.00000%> (+0.06935%) ⬆️
test 97.41920% <100.00000%> (+0.00293%) ⬆️
unit 49.64153% <100.00000%> (+0.03948%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
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.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How to fix the title of the Collection Editor for the custom control in NET Core?

4 participants