Skip to content

Fix issue 14071: ComboBox.ObjectCollection.CopyTo(Array destination, int index) copies Entry object, not inner item - #14075

Merged
SimonZhao888 merged 1 commit into
dotnet:mainfrom
SimonZhao888:Fix_issue_14071
Mar 18, 2026
Merged

SimonZhao888 merged 1 commit into
dotnet:mainfrom
SimonZhao888:Fix_issue_14071

Conversation

@SimonZhao888

@SimonZhao888 SimonZhao888 commented Nov 24, 2025 •

Copy link
Copy Markdown
Member

Fixes #14071

Proposed changes

  • Refactored the CopyTo methods to ensure correct item copying and type safety.

Customer Impact

  • Copying ComboBox items to an array or using a collection wrapper will not throw an InvalidCastException exception.

Regression?

  • Yes

Risk

  • Minimal

Screenshots

Before

Before.mp4

After

After.mp4

Test methodology

  • Manually

Test environment(s)

  • 10.0.100-rc.2.25502.107
Microsoft Reviewers: Open in CodeFlow

…int index) copies Entry object, not inner item

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes issue #14071 where ComboBox.ObjectCollection.CopyTo(Array destination, int index) was incorrectly copying internal Entry wrapper objects instead of the actual items contained within them. This caused InvalidCastException when using collection wrappers or explicit ICollection interface calls.

Key changes:

  • Modified the explicit ICollection.CopyTo implementation to unwrap Entry objects by accessing .Item property
  • Ensures consistency between the typed CopyTo(object[], int) and explicit ICollection.CopyTo(Array, int) implementations

@codecov

codecov Bot commented Nov 24, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 77.15185%. Comparing base (09c759b) to head (80df32d).
⚠️ Report is 107 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #14075         +/-   ##
===================================================
- Coverage   77.16719%   77.15185%   -0.01535%     
===================================================
  Files           3279        3279                 
  Lines         645317      645317                 
  Branches       47718       47718                 
===================================================
- Hits          497973      497874         -99     
- Misses        143657      143757        +100     
+ Partials        3687        3686          -1     
Flag Coverage Δ
Debug 77.15185% <0.00000%> (-0.01535%) ⬇️
integration 18.98337% <0.00000%> (-0.03587%) ⬇️
production 52.01170% <0.00000%> (-0.03439%) ⬇️
test 97.40749% <ø> (ø)
unit 49.44068% <0.00000%> (-0.03196%) ⬇️

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.

@ricardobossan ricardobossan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

All LGTM!

@KlausLoeffelmann KlausLoeffelmann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good.

@SimonZhao888
SimonZhao888 merged commit 6f9c433 into dotnet:main Mar 18, 2026
14 of 15 checks passed
@SimonZhao888
SimonZhao888 deleted the Fix_issue_14071 branch March 18, 2026 02:02
@Olina-Zhang Olina-Zhang added this to the 11.0 Preview3 milestone Mar 18, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ComboBox.ObjectCollection.CopyTo(Array destination, int index) copies Entry object, not inner item

6 participants