Skip to content

Conversation

@imurashka
Copy link
Contributor

Problem

During Dispose() method, the composite enumerates its internal list. If a client adds a disposable at that time, the list is mutated and we get:
InvalidOperationException: Collection was modified; enumeration operation may not execute.

Root cause

Add/AddRange methods continued to push into the internal list after disposal had begun.

Fix

If the composite is disposed, Add/AddRange dispose the incoming item(s) immediately.

Notes

  • API unchanged; callers that add after disposal simply have their disposables disposed.
  • Exception aggregation slightly improved: single exception is rethrown as-is.

@imurashka imurashka closed this Nov 4, 2025
@imurashka imurashka reopened this Nov 4, 2025
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.

1 participant