Momentum.Extensions.Abstractions
0.0.9
dotnet add package Momentum.Extensions.Abstractions --version 0.0.9
NuGet\Install-Package Momentum.Extensions.Abstractions -Version 0.0.9
<PackageReference Include="Momentum.Extensions.Abstractions" Version="0.0.9" />
<PackageVersion Include="Momentum.Extensions.Abstractions" Version="0.0.9" />
<PackageReference Include="Momentum.Extensions.Abstractions" />
paket add Momentum.Extensions.Abstractions --version 0.0.9
#r "nuget: Momentum.Extensions.Abstractions, 0.0.9"
#:package Momentum.Extensions.Abstractions@0.0.9
#addin nuget:?package=Momentum.Extensions.Abstractions&version=0.0.9
#tool nuget:?package=Momentum.Extensions.Abstractions&version=0.0.9
Momentum.Extensions.Abstractions
Core abstractions and interfaces for the Momentum platform. This foundational package defines contracts, attributes, and marker interfaces used across all Momentum libraries for CQRS messaging, database command generation, and distributed event handling.
Overview
The Momentum.Extensions.Abstractions package provides the foundational contracts that enable the Momentum platform's CQRS architecture, source-generated database commands, and distributed event streaming. As a dependency-free abstraction layer targeting .NET Standard 2.1, it defines the interfaces and attributes that other Momentum libraries (source generators, Kafka integration, service defaults) build upon.
Installation
dotnet add package Momentum.Extensions.Abstractions
Key Features
- CQRS Messaging Contracts:
ICommand<T>andIQuery<T>marker interfaces for Wolverine-based message handling - Database Command Generation:
[DbCommand]attribute for source-generated Dapper handlers (stored procedures, SQL queries, functions) - Distributed Event Abstractions:
IDistributedEvent,[EventTopic], and[PartitionKey]for Kafka event streaming with CloudEvents - String Utilities: Snake case, kebab case conversion, and English pluralization
- Dependency-Free: No external dependencies; targets .NET Standard 2.1
CQRS Messaging
Commands
Define commands that modify state. Handlers are discovered by convention via Wolverine.
// A command that returns a result
public record CreateCashierCommand(Guid TenantId, string Name, string Email)
: ICommand<Result<Cashier>>;
// A command with no meaningful return value
public record DeleteCashierCommand(Guid TenantId, Guid CashierId)
: ICommand<Result<bool>>;
Queries
Define read-only data retrieval operations.
// A query returning a single entity
public record GetCashierQuery(Guid TenantId, Guid CashierId)
: IQuery<Result<Cashier>>;
// A query returning a collection
public record GetCashiersQuery(Guid TenantId, int Page, int Size)
: IQuery<Result<IEnumerable<Cashier>>>;
Database Command Generation
The [DbCommand] attribute marks records for source-generated Dapper database handlers via Momentum.Extensions.SourceGenerators.
Stored Procedures
[DbCommand(sp: "main.usp_get_cashier")]
public record GetCashierDbQuery(Guid TenantId, Guid CashierId)
: IQuery<Cashier>;
SQL Queries
[DbCommand(sql: "SELECT * FROM main.cashiers WHERE tenant_id = @p_tenant_id")]
public record FindCashiersDbQuery(Guid TenantId)
: IQuery<IEnumerable<Cashier>>;
Database Functions
[DbCommand(fn: "main.fn_get_invoice_total")]
public record GetInvoiceTotalDbQuery(Guid TenantId, Guid InvoiceId)
: IQuery<decimal>;
Parameter Control
Parameters are automatically converted to snake_case with p_ prefix by default. Use DbParamsCase to control this:
// Default: TenantId -> p_tenant_id
[DbCommand(sp: "main.usp_create_cashier")]
public record CreateCashierDbCommand(Guid TenantId, string Name) : ICommand<Cashier>;
// No conversion: parameters used as-is
[DbCommand(sp: "main.usp_create_cashier", paramsCase: DbParamsCase.None)]
public record CreateCashierDbCommand(Guid TenantId, string Name) : ICommand<Cashier>;
// Exclude a property from parameter generation
public record UpdateCashierDbCommand(
Guid TenantId,
string Name,
[property: DbCommandIgnore] DateTime LocalTimestamp
) : ICommand<Cashier>;
Custom Parameter Providers
For complex parameter mapping, implement IDbParamsProvider:
public record BulkInsertCommand(List<CashierData> Items) : ICommand<int>, IDbParamsProvider
{
public object ToDbParams() => new { items = JsonSerializer.Serialize(Items) };
}
Distributed Events
Event Topics
Mark records as distributed events with topic routing:
// Explicit topic name
[EventTopic("app-domain.cashiers.cashier-created")]
public record CashierCreated(Guid TenantId, Guid CashierId, string Name);
// Auto-generated topic from entity type (e.g., "app-domain.cashiers.cashier-updated")
[EventTopic<Cashier>(suffix: "updated")]
public record CashierUpdated(Guid TenantId, Guid CashierId, string Name);
Partition Keys
Control message ordering and routing in Kafka:
[EventTopic("app-domain.invoices.invoice-created")]
public record InvoiceCreated(
Guid TenantId,
[property: PartitionKey] Guid InvoiceId,
decimal Amount
);
// Composite partition keys with ordering
[EventTopic("app-domain.invoices.line-item-added")]
public record LineItemAdded(
[property: PartitionKey(Order = 0)] Guid TenantId,
[property: PartitionKey(Order = 1)] Guid InvoiceId,
Guid LineItemId
);
IDistributedEvent
Implement IDistributedEvent for custom partition key logic:
[EventTopic("app-domain.cashiers.cashier-created")]
public record CashierCreated(Guid TenantId, Guid CashierId) : IDistributedEvent
{
public string GetPartitionKey() => $"{TenantId}:{CashierId}";
}
Default Domain
Set the default domain prefix for all events in an assembly:
[assembly: DefaultDomain("app-domain")]
String Extensions
Utility extensions for case conversion and pluralization:
using Momentum.Extensions.Abstractions.Extensions;
"TenantId".ToSnakeCase(); // "tenant_id"
"CashierId".ToKebabCase(); // "cashier-id"
"cashier".Pluralize(); // "cashiers"
"person".Pluralize(); // "people"
"status".Pluralize(); // "statuses"
Architecture
This package sits at the foundation of the Momentum library ecosystem:
Application Code
├── Momentum.Extensions (Result types, validation, data access)
├── Momentum.Extensions.SourceGenerators (DbCommand code generation)
├── Momentum.Extensions.Messaging.Kafka (CloudEvents, Kafka integration)
├── Momentum.ServiceDefaults (Aspire, observability)
├── Momentum.ServiceDefaults.Api (OpenAPI, gRPC)
└── Momentum.Extensions.Abstractions ← Foundation (this package)
Target Frameworks
- .NET Standard 2.1: Compatible with .NET Core 3.0+, .NET 5.0+
Related Packages
- Momentum.Extensions - Result types, validation, and data access
- Momentum.Extensions.SourceGenerators - Compile-time DbCommand handler generation
- Momentum.Extensions.Messaging.Kafka - Kafka integration with CloudEvents
- Momentum.ServiceDefaults - Service configuration and observability
License
This project is licensed under the MIT License. See the LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- No dependencies.
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Momentum.Extensions.Abstractions:
| Package | Downloads |
|---|---|
|
Momentum.Extensions.XmlDocs
XML documentation utilities for Momentum platform providing parsing, processing, and generation capabilities for XML documentation files. Essential for code analysis and documentation tooling. |
|
|
Momentum.Extensions
Core extensions library for Momentum .NET providing common utilities, result types, messaging abstractions, and data access helpers. Includes integrations with Dapper, FluentValidation, OneOf, and WolverineFx. |
|
|
Momentum.Extensions.Messaging.Kafka
Kafka messaging integration for Momentum platform providing event-driven communication through Apache Kafka with CloudEvents and WolverineFx support. |
|
|
Momentum.ServiceDefaults.Api
API-specific service defaults for Momentum platform extending the base ServiceDefaults with gRPC, OpenAPI documentation (Scalar), and API-focused configurations. Essential for Momentum API projects. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.0.9 | 211 | 3/5/2026 |
| 0.0.9-preview.3 | 38 | 3/4/2026 |
| 0.0.9-preview.2 | 54 | 2/25/2026 |
| 0.0.9-preview.1 | 48 | 2/25/2026 |
| 0.0.8 | 161 | 2/23/2026 |
| 0.0.8-preview.12 | 54 | 2/22/2026 |
| 0.0.8-preview.11 | 43 | 2/22/2026 |
| 0.0.8-preview.10 | 47 | 2/22/2026 |
| 0.0.8-preview.9 | 53 | 2/22/2026 |
| 0.0.8-preview.8 | 51 | 2/22/2026 |
| 0.0.8-preview.7 | 46 | 2/22/2026 |
| 0.0.8-preview.6 | 48 | 2/22/2026 |
| 0.0.8-preview.5 | 49 | 2/22/2026 |
| 0.0.8-preview.4 | 54 | 2/21/2026 |
| 0.0.8-preview.3 | 50 | 2/20/2026 |
| 0.0.8-preview.2 | 50 | 2/20/2026 |
| 0.0.8-preview.1 | 49 | 2/20/2026 |
| 0.0.7 | 161 | 2/16/2026 |
| 0.0.7-preview.3 | 48 | 2/16/2026 |
| 0.0.7-preview.2 | 52 | 2/16/2026 |