Skip to content

EntityCollection fixes: IList indexer should not return null, update INotifyCollectionChanged index calculation#581

Merged
Daniel-Svensson merged 14 commits into
mainfrom
copilot/fix-nullreferenceexception-wpf-listcollectionview
May 28, 2026
Merged

EntityCollection fixes: IList indexer should not return null, update INotifyCollectionChanged index calculation#581
Daniel-Svensson merged 14 commits into
mainfrom
copilot/fix-nullreferenceexception-wpf-listcollectionview

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 24, 2026

The previous EntityCollection CollectionView regressions did not exercise the reported failure shapes. This update swaps them for targeted scenarios that hit sorted-view update paths and null-item filter behavior, and mirrors the same coverage in Avalonia.

  • WPF regression suite (EntityCollectionTests.CollectionViewTests)

    • Replaced broad sorted/filtered/grouped tests with focused cases:
      • SortedView_EntitySetClear_DoesNotThrowNRE
      • SortedView_EntityCollectionAdd_DoesNotThrowNRE
      • SortedView_SourceSetRemove_DoesNotThrowNRE
      • FilteredView_FilterPredicate_NeverInvokedWithNull
    • Uses ListCollectionView + SortDescriptions to force PrepareLocalArray/AdjustBefore-style paths that match the reported behavior.
  • Avalonia parity (EntityCollectionTests.AvaloniaTests)

    • Added equivalent regression coverage using DataGridCollectionView for the same four scenarios.
    • Keeps expected behavior aligned across WPF and Avalonia collection-view integrations.
  • Small cleanup

    • Removed redundant entitySet = null initialization in one WPF test.
ListCollectionView view = (ListCollectionView)((ICollectionViewFactory)entityCollection).CreateView();
view.SortDescriptions.Add(new SortDescription(nameof(City.Name), ListSortDirection.Ascending));
view.Refresh();

Exception caught = null;
try { entitySet.Clear(); } catch (Exception e) { caught = e; }

Assert.IsNull(caught, $"EntitySet.Clear() must not surface NRE through the bound view: {caught}");

Copilot AI changed the title [WIP] Fix NullReferenceException in WPF ListCollectionView after IList migration Fix EntityCollection IList/ListCollectionView invariants and add WPF regression coverage May 24, 2026
Copilot AI requested a review from Daniel-Svensson May 24, 2026 10:08
Copilot AI changed the title Fix EntityCollection IList/ListCollectionView invariants and add WPF regression coverage Stabilize EntityCollection CollectionView interactions and split changes into reviewable commits May 25, 2026
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Copilot AI changed the title Stabilize EntityCollection CollectionView interactions and split changes into reviewable commits Replace non-repro CollectionView tests with targeted sorted-view regressions (WPF + Avalonia) May 27, 2026
Copilot AI requested a review from Daniel-Svensson May 27, 2026 19:25
@Daniel-Svensson Daniel-Svensson marked this pull request as ready for review May 27, 2026 19:27
@Daniel-Svensson Daniel-Svensson enabled auto-merge (squash) May 28, 2026 07:04
@sonarqubecloud
Copy link
Copy Markdown

@Daniel-Svensson Daniel-Svensson merged commit c595d2d into main May 28, 2026
6 checks passed
@Daniel-Svensson Daniel-Svensson deleted the copilot/fix-nullreferenceexception-wpf-listcollectionview branch May 28, 2026 07:19
@Daniel-Svensson Daniel-Svensson changed the title Replace non-repro CollectionView tests with targeted sorted-view regressions (WPF + Avalonia) EntityCollection fixes: IList indexer should not return null, update INotifyCollectionChanged index calculation May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NullReferenceException in WPF ListCollectionView after IList migration in 5.8.0

3 participants