Skip to content

Conversation

ricardobossan
Copy link
Member

@ricardobossan ricardobossan commented Sep 11, 2025

Fixes #12570

Root Cause

The ComboBox.DataSource property was missing a TypeConverter to handle null value display in PropertyGrid. When DataSource is null, PropertyGrid shows empty/blank instead of "(none)" text, breaking consistency with .NET Framework behavior and other similar properties like DisplayMember and ValueMember.

Proposed changes

  • Created DataSourceConverter class that inherits from ReferenceConverter and converts null values to "(none)" for string display
  • Applied TypeConverter attribute to ComboBox.DataSource property to use the new converter
  • Added comprehensive unit tests to verify converter behavior across different cultures and scenarios

Customer Impact

Restores .NET Framework parity for PropertyGrid display. Developers using PropertyGrid to inspect ComboBox properties will now see consistent "(none)" text when DataSource is null, improving design-time experience.

Regression?

No. This is a missing feature/behavior that existed in .NET Framework but was lost in .NET Core migration.

Risk

Minimal.

Screenshots

Before

before

After

after

Test methodology

  • Unit tests for DataSourceConverter covering null conversion, culture handling, and edge cases
  • Manual testing with PropertyGrid and ComboBox to verify "(none)" display

Test environment(s)

  • 10.0.100-alpha.1.24573.1
Microsoft Reviewers: Open in CodeFlow

Copy link

codecov bot commented Sep 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.41261%. Comparing base (8f9c849) to head (9120a2b).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                  @@
##                main      #13860          +/-   ##
====================================================
+ Coverage   77.12127%   97.41261%   +20.29134%     
====================================================
  Files           3273        1210        -2063     
  Lines         644931      357040      -287891     
  Branches       47692        5581       -42111     
====================================================
- Hits          497379      347802      -149577     
+ Misses        143876        8455      -135421     
+ Partials        3676         783        -2893     
Flag Coverage Δ
Debug 97.41261% <100.00000%> (+20.29134%) ⬆️
integration ?
production ?
test 97.41261% <100.00000%> (+0.00005%) ⬆️
unit ?

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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.


namespace System.Windows.Forms.Design;

internal class DataSourceConverter : ReferenceConverter
Copy link
Member

Choose a reason for hiding this comment

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

If have a few questions here:

  • What was/is the behavior in NetFX here? Do we also have such a converter there?
  • Is this just for the ComboBox? How does the ListBox for example handle this?

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.

No "(none)" text display for the DataSource property in PropertyGrid control
4 participants