CQRSharp.Generators
2.2.6
dotnet add package CQRSharp.Generators --version 2.2.6
NuGet\Install-Package CQRSharp.Generators -Version 2.2.6
<PackageReference Include="CQRSharp.Generators" Version="2.2.6" />
<PackageVersion Include="CQRSharp.Generators" Version="2.2.6" />
<PackageReference Include="CQRSharp.Generators" />
paket add CQRSharp.Generators --version 2.2.6
#r "nuget: CQRSharp.Generators, 2.2.6"
#:package CQRSharp.Generators@2.2.6
#addin nuget:?package=CQRSharp.Generators&version=2.2.6
#tool nuget:?package=CQRSharp.Generators&version=2.2.6
A set of Roslyn source code generators that allow Native AoT compatibility for the CQRSharp Library.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- CQRSharp.Shared (>= 2.2.6)
- Microsoft.CodeAnalysis.CSharp (>= 4.13.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version 2.2.6 (2025‑04‑20)
Breaking Changes
- `QueueBackgroundWorkItemAsync` now returns `Task<QueueWriteResult>` instead of a fire‑and‑forget `Task`.
- `IBackgroundTaskQueue` no longer exposes `OnTaskEnqueued`/`OnTaskRejected` events; use the notification channel.
- `BackgroundTaskQueue.DequeueAsync` signature changed to `ValueTask<QueuedTask>`.
- `BackgroundTaskQueueOptions.DequeueBatchSize` deprecated in favor of `CallbackChannelCapacity` and `ShutdownTimeout`.
- All `.ContinueWith` usage in the Dispatcher was replaced by `async`/`await`, preserving stack traces and the `SynchronizationContext`.
Added
- **Dispatcher**: `EnqueueAndWatchAsync` helper; simplified `finalHandlerWrapper` logic.
- **DI Extensions**: `CqrsStartupLogger` (`IHostedService`) & `CqrsRegistrationInfo` for deferred CQRS‑registration logging.
- **RateLimiter**: `ShardedLruCache` with per‑shard LRU eviction; implements `IDisposable` to tear down the cleanup timer.
- **BackgroundTaskQueue**:
- `QueuedTask` struct (with `QueueId`, `SequenceNumber`, `EnqueueTime`) and `QueueWriteResult` struct.
- Built‑in metrics: `TotalItemsEnqueued`, `TotalDroppedNewest`, `TotalDroppedOldest`.
- Dedicated notification channel via `INotificationDispatcher`.
- `CountingChannelReader` for atomic queue‑depth tracking.
- **BackgroundTaskQueueConsumer**: single loop gated by a `SemaphoreSlim` (`ConsumerCount`); lifecycle logging; `ShutdownTimeout` support.
Changed
- **Dispatcher**: `ExecuteCommand` now returns a `Task` immediately in async mode.
- **RateLimiter**:
- Corrected refill formula to apply `replenishRatePerSecond` directly.
- High‑precision timing via `Stopwatch.GetTimestamp()`.
- Sliding‑expiration cleanup via explicit snapshot and background timer.
- **BackgroundTaskQueue**:
- Consolidated multi‑shard design into a single bounded `Channel<QueuedTask>`.
- Explicit implementation of all `BoundedChannelFullMode` policies (`Wait`, `DropNewest`, `DropOldest`, `Throw`).
- Replaced manual `WaitToReadAsync` and`TryRead` loops with `ReadAllAsync()`.
- Refactored notification dispatch into `ProcessNotificationsAsync` with retry parameters.
Removed
- All `.ContinueWith` calls; static CQRS‑registrar logging at DI setup.
- Third‑party/`MemoryCache` dependencies in `RateLimiter`.
- Busy‑wait loops and redundant `Task.Run` calls in the background queue.
- Public `OnTaskEnqueued`/`OnTaskRejected` events on `IBackgroundTaskQueue`.
Fixed
- Race conditions in `DropOldest`/`DropNewest` policies under contention.
- Cancellation and exception propagation in `Dispatcher.EnqueueAndWatchAsync`.
- Timer leak in `RateLimiter` by implementing `Dispose`.
- Refill‑rate drift in token‑bucket logic; restored full exception stacks by removing `.ContinueWith`.
Performance
- **Dispatcher**: end‑to‑end `await` for context‑safe execution.
- **RateLimiter**: sharded cache + stopwatch timing for minimal contention.
- **BackgroundTaskQueue**: single channel + `CountingChannelReader` for lock‑free depth tracking.
- **Consumer**: `SemaphoreSlim`‑gated loop avoids thread‑pool storms.
Testing
- **DispatcherTests**: sync/async execution, cancellation, exception‑propagation coverage.
- **RateLimiterTests**: refill accuracy, shard eviction, timer disposal.
- **BackgroundTaskQueueTests**: backpressure modes, FIFO ordering, metrics, high‑concurrency and graceful shutdown.
- **RequestDispatcherTests**: host‑lifetime cancellation via `TestHostApplicationLifetime`.
- **BackgroundTaskQueueConsumerTests**: concurrency gating and lifecycle logging.
Documentation
- Updated XML docs for new options (`EnableMetrics`, `NotificationMaxRetries`, `ShutdownTimeout`, `MetricLogInterval`).
- Clarified defaults and valid ranges in `BackgroundTaskQueueOptions` and `RateLimiterOptions`.