Skip to content

fix: prevent recursive IList.Add in ObservableVector - #25314

Merged
MartinZikmund merged 1 commit into
unoplatform:masterfrom
Doomguy-BFG9000:fix/observable-vector-ilist-add
Nov 5, 2026
Merged

MartinZikmund merged 1 commit into
unoplatform:masterfrom
Doomguy-BFG9000:fix/observable-vector-ilist-add

Conversation

@Doomguy-BFG9000

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #25215

PR Type:

🐞 Bugfix

What changed? 🚀

Route non-generic IList.Add through the typed collection path without recursively calling itself.

Testing

  • Focused tests passed: 5/5.

PR Checklist ✅

  • 🧪 Added Runtime tests, UI tests, or a manual test sample (for bug fixes / features, if applicable)
  • 📚 Docs have been added or updated (not applicable to this focused code change)
  • 🖼️ Validated PR Screenshots Compare Test Run results
  • ❗ Contains NO breaking changes
  • 👀 Reviewed 2 other open pull requests (optional but appreciated)

@CLAassistant

CLAassistant commented Oct 12, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions Bot added the area/automation Categorizes an issue or PR as relevant to project automation label Oct 12, 2026

@morning4coffe-dev morning4coffe-dev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified by code review at head 68a849a: the explicit IList.Add(object) path, the public Add(T) it now calls, the event count, the new tests, and the linked issue #25215.

APPROVE

Findings:

  1. (Correct root-cause fix, no finding.) The old ((IList)this).Add(typedValue) re-entered IList.Add(object) forever, which is the stack overflow in #25215. The new code calls the typed Add(T) directly (src/Uno.Foundation/Collections/Internal/ObservableVector.cs:105), so the event is raised once, from the same place as IObservableVector.Add(object), and the returned index is _list.Count - 1 (line 106). Subclass overrides of the virtual Add(T) are now honored on the non-generic path too, which matches the typed path.
  2. (Test coverage, adequate.) When_Item_Added_Through_IList checks the returned index, count, value, single event, event type, and event index. Before the fix it crashes the test host with a stack overflow, so it fails before and passes after by inspection. When_Incompatible_Item_Added_Through_IList is a guard test that already passed before; it is fine as a regression guard.
  3. (Nit, non-blocking.) None.

Not validated: I did not build or run the tests. The author reports 5/5 focused tests passing. The PR's CI shows only triage, docs, Codacy, WIP and summary checks; no build or unit-test job ran for this PR.

@MartinZikmund

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@MartinZikmund
MartinZikmund merged commit 6bea4b8 into unoplatform:master Nov 5, 2026
48 of 54 checks passed
@welcome

welcome Bot commented Nov 5, 2026

Copy link
Copy Markdown

🎉 Congratulations on getting your very first pull request merged into Uno Platform! This is a huge milestone — you are now officially part of the community of contributors helping shape the future of cross-platform .NET development, and your code will reach developers and apps all over the world. 🌍

We are genuinely grateful for the time and care you put into this contribution. Every PR — big or small — makes Uno Platform better for everyone, and we hope this is the first of many. We cannot wait to see what you build next! 🚀

As a small thank-you, we would love to send you some swag so you can wear your contributor status with pride. And if you have any feedback or ideas on how we can make contributing to Uno Platform even better, please open a feedback issue — we truly value your perspective.

giphy
Welcome to the family, and merci beaucoup! 👋❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ObservableVector<T>'s explicit IList.Add(object) calls itself and overflows the stack

5 participants