The SortDescriptionCollection may throw NullReferenceException when remove the item
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
* .NET Core Version: (e.g. 3.0 Preview1, or daily build number, use `dotnet --info`)
* Windows version: (`winver`)
* Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
* Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)? If yes, please file the issue via the instructions [here](https://docs.microsoft.com/visualstudio/ide/how-to-report-a-problem-with-visual-studio?view=vs-2019).
* Security issues and bugs should be reported privately, learn more via our [responsible disclosure guidelines](https://github.com/dotnet/wpf/blob/main/README.md#reporting-security-issues-and-security-bugs).
**Problem description:**
The SortDescriptionCollection may throw NullReferenceException when remove the item or clear
```
> PresentationFramework.dll!System.Windows.Data.ListCollectionView.PrepareLocalArray()
PresentationFramework.dll!System.Windows.Data.ListCollectionView.RefreshOverride()
PresentationFramework.dll!System.Windows.Data.CollectionView.RefreshInternal()
PresentationFramework.dll!System.Windows.Data.CollectionView.RefreshOrDefer()
PresentationFramework.dll!System.Windows.Data.ListCollectionView.SortDescriptionsChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
WindowsBase.dll!System.ComponentModel.SortDescriptionCollection.RemoveItem(int index)
System.Private.CoreLib.dll!System.Collections.ObjectModel.Collection.RemoveAt(int index)
App.dll!MyClass.Foo();
```

**Actual behavior:**
Throw NullReferenceException
**Expected behavior:**
Work well.
**Minimal repro:**
https://github.com/lindexi/lindexi_gd/tree/c7556d7b92605000011425f82793f9e4063e5a00/LechelaneHenayfucee
Contributor guide
Assessment
This issue has not been assessed yet.