Skip to content

Runtime: Command Router stream send primitives - #284

Merged
Skymly merged 1 commit into
mainfrom
feature/282-command-router-stream-runtime
Jul 29, 2026
Merged

Runtime: Command Router stream send primitives#284
Skymly merged 1 commit into
mainfrom
feature/282-command-router-stream-runtime

Conversation

@Skymly

@Skymly Skymly commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add Command Router stream send runtime primitives: IStreamCommandHandler<TCommand, TItem>, SendStreamAsync / TrySendStreamAsync, and builder Register for stream handlers on the shared 1:1 command map.
  • Keep existing non-stream SendAsync / TrySendAsync paths unchanged; reference Microsoft.Bcl.AsyncInterfaces on netstandard2.0 for IAsyncEnumerable.
  • Cover progressive yield, missing-handler, contract mismatch, and duplicate registration in unit tests.

Related Issue

Closes #282

Solution module

  • Runtime (DesignPatterns/)
  • Diagnostics (DesignPatterns.Diagnostics/)
  • SourceGenerators (DesignPatterns.SourceGenerators/)
  • Analyzers (DesignPatterns.Analyzers/ + DesignPatterns.CodeFixes/)
  • DependencyInjection (DesignPatterns.Extensions.DependencyInjection/)
  • Package (DesignPatterns.Package/)
  • Docs / Repository (README, docs/, .github/, AGENTS.md, build/)

Note: Directory.Packages.props only adds the central Microsoft.Bcl.AsyncInterfaces version required by the Runtime PackageReference.

Type of change

  • Bug fix
  • Feature
  • Source generator / diagnostic / CodeFix change
  • Refactor (no behavior change)
  • Docs / repo metadata only

Test plan

  • ./build.ps1 --target Ci --configuration Release (or CiPack if packaging changed)
  • Sibling samples (if API/generator behavior changed): clone DesignPatterns.Samples beside this repo and run ./build.ps1 --target Ci

Breaking changes

  • None
  • Yes — describe migration steps (APIs may still be pre-stable):

Checklist

  • This PR touches only one solution module (see AGENTS.md)
  • Commit messages are in English (no AI/agent tooling mentions in commits)
  • PR description is English only — no AI/agent/Cursor tool attribution, no auto-generated summary blocks (e.g. CURSOR_SUMMARY, "Made with …")
  • No version bumps, tags, releases, or NuGet publish steps included unless explicitly requested
  • Public API / diagnostic / generated code changes are documented if user-visible

Documentation checklist

  • Design Doc updated if API / diagnostic / implementation changed
  • User-facing docs synced (separate PRs if multi-repo)
  • No documentation changes needed

Docs for stream capability tracked in #283; generator binding in #265.


Note

Medium Risk
Additive public API on core command routing; behavior mirrors existing send paths, but any custom ICommandRouter implementors must add the new members.

Overview
Adds streaming command dispatch alongside existing void/result routing: new IStreamCommandHandler<TCommand, TItem>, SendStreamAsync / TrySendStreamAsync on ICommandRouter (implemented in CommandRouter), and CommandRouterBuilder.Register for stream handlers on the same 1:1 command-type map.

Stream routing follows the same rules as SendAsync / TrySendAsync—missing handlers throw or return failure via CommandSendAttempt, and calling the wrong overload for a registered contract throws InvalidOperationException. Only one handler kind per command type (void, result, or stream); docs clarify that pipeline behaviors apply to void/result handlers only.

netstandard2.0 gains Microsoft.Bcl.AsyncInterfaces for IAsyncEnumerable. Unit tests cover progressive yield, cancellation, contract mismatch, duplicate registration, and coexistence with non-stream commands.

Reviewed by Cursor Bugbot for commit 0a45b75. Configure here.

Enable progressive IAsyncEnumerable dispatch on the same 1:1 router map without changing non-stream Send/TrySend paths (#282).
@Skymly
Skymly merged commit a96dfbb into main Jul 29, 2026
4 checks passed
@Skymly
Skymly deleted the feature/282-command-router-stream-runtime branch July 29, 2026 13:41
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.

Runtime: Command Router stream send primitives

1 participant