BindingSource.SortDescriptions doesn't return null
BindingSource.SortDescriptions has been updated to return an empty ListSortDescriptionCollection instead of null
if the data source is not an IBindingListView.
Version introduced
.NET 9 Preview 1
Previous behavior
Previously, BindingSource.SortDescriptions returned null
if the data source wasn't an IBindingListView.
New behavior
Starting in .NET 9, BindingSource.SortDescriptions returns an empty ListSortDescriptionCollection if the data source is not an IBindingListView.
Change category
This change is a behavioral change.
Reason for change
The previous behavior was incorrect.
BindingSource.SortDescriptions has historically returned null
if the data source was not an IBindingListView
. However BindingSource.SortDescriptions
implements IBindingListView.SortDescriptions, whose return type is non-nullable. To align with the interface it implements, BindingSource.SortDescriptions
was changed to return an empty ListSortDescriptionCollection
instead.
Recommended action
If your code expects null
from BindingSource.SortDescriptions for any reason, update your code to expect an empty ListSortDescriptionCollection instead.
Affected APIs
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for