BindingSource.SortDescriptions 不返回 null

BindingSource.SortDescriptions 已更新为在数据源不是 IBindingListView 时返回空的 ListSortDescriptionCollection,而不是返回 null

引入的版本

.NET 9 预览版 1

旧行为

以前,如果数据源不是 IBindingListView,则 BindingSource.SortDescriptions 返回 null

新行为

从 .NET 9 开始,如果数据源不是 IBindingListView,则 BindingSource.SortDescriptions 会返回空的 ListSortDescriptionCollection

更改类别

此更改为行为变更

更改原因

之前的行为不正确。

如果数据源不是 IBindingListViewBindingSource.SortDescriptions 在过去会返回 null。 但是,BindingSource.SortDescriptions 实现了 IBindingListView.SortDescriptions,其返回类型不可为 null。 为了与其实现的接口保持一致,BindingSource.SortDescriptions 已改为返回空的 ListSortDescriptionCollection

如果代码出于某种原因需要 BindingSource.SortDescriptions 中的 null,请更新代码,改为期待空的 ListSortDescriptionCollection

受影响的 API