Skip to content

Make weak event dispatch type-safe and deterministic - #29

Merged
Seramis merged 1 commit into
mainfrom
fix/weak-event-invocation
Nov 22, 2026
Merged

Seramis merged 1 commit into
mainfrom
fix/weak-event-invocation

Conversation

@Seramis

@Seramis Seramis commented Nov 22, 2026

Copy link
Copy Markdown
Member

Description

Reworks weak event handler invocation to use typed delegate factories instead of reflection-based argument assembly.

Publishing now:

  • Snapshots subscribers before dispatch.
  • Invokes subscribers sequentially.
  • Checks cancellation before every subscriber.
  • Preserves synchronous exception types.
  • Throws InvalidOperationException for asynchronous handlers that return null.

Also updates existing handler tests and adds coverage for cancellation, multicast preparation, synchronous exceptions, and null async tasks.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Other (please specify):

Checklist

  • The PR is submitted to the correct branch (main).
  • My code follows the project's coding style. (.editorconfig)
  • I have commented my code, particularly in hard-to-understand areas and public interfaces.
  • I have added or updated tests for the changes I made.
  • All new and existing tests passed.
  • I have updated the documentation where applicable.

Testing Instructions

  1. Open WeakEvent.sln.
  2. Build the solution; the Rider solution build passes.
  3. Run dotnet test WeakEvent.sln.
  4. Confirm cancellation, exception propagation, and weak-handler tests pass.

@Seramis Seramis self-assigned this Nov 22, 2026
@Seramis Seramis added the enhancement New feature or request label Nov 22, 2026
@Seramis
Seramis merged commit 13fddd8 into main Nov 22, 2026
3 checks passed
@Seramis
Seramis deleted the fix/weak-event-invocation branch November 22, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant