CollectionViewSource does not include group items with AOT
Describe the bug
When using CollectionViewSource with native AOT enabled; items that the CollectionViewSource bound to are only creating groups, items are missing.
Debug build
Release build (AOT/Trim enabled)
- ListView's prepare-clear container overrides are not triggered.
- CVS.View has DependencyObjects for CollectionGroups, but groups are empty.
- Setting HideIfEmpty on GroupStyle of ListView hides the groups as well, making the CVS completely invisible.
I am not sure if it is something with CommunityToolkit.MVVM's ReadOnlyObservableGroupedCollection. I will try CollectionViewSource with IGrouping<IEnumerable>> as well to see. If so I will close the bug and move the report to the proper repository.
Minimal repro project: https://github.com/bkaankose/CVSBinding
Why is this important?
CollectionViewSource is highly used for Windows apps. It's the only way to group items properly this not working with AOT is a major blocker for developers who'd like to gain all the performance benefits of it.
Steps to reproduce the bug
It's described in the minimal repro project. Basically;
1- Run in Debug, click add item, see items are added as grouped. 2- Run in Release (compiles AOT), click add item, observe only group headers are added to the list but the items are missing.
Actual behavior
Group items are not visible. They are not added to group collections under the hood.
Expected behavior
Items must be visible under group headers.
Screenshots
No response
NuGet package version
WinUI 3 - Windows App SDK 1.8.3: 1.8.251106002
Windows version
Windows 11 (24H2): Build 26100
Additional context
No response
The same problem is visible with UWP and .NET 10: sample project: https://github.com/jp-weber/UWPGroupedCollection
Without AOT:
With AOT:
Using IEnumerable<IGrouping<TKey,TValue>> literally crashes the app with ArgumentException.