Dhanman.Shared.Contracts
1.8.5
dotnet add package Dhanman.Shared.Contracts --version 1.8.5
NuGet\Install-Package Dhanman.Shared.Contracts -Version 1.8.5
<PackageReference Include="Dhanman.Shared.Contracts" Version="1.8.5" />
<PackageVersion Include="Dhanman.Shared.Contracts" Version="1.8.5" />
<PackageReference Include="Dhanman.Shared.Contracts" />
paket add Dhanman.Shared.Contracts --version 1.8.5
#r "nuget: Dhanman.Shared.Contracts, 1.8.5"
#:package Dhanman.Shared.Contracts@1.8.5
#addin nuget:?package=Dhanman.Shared.Contracts&version=1.8.5
#tool nuget:?package=Dhanman.Shared.Contracts&version=1.8.5
Dhanman.Shared.Contracts
This project contains shared data transfer objects (DTOs), events, and message contracts used across multiple Dhanman microservices.
Purpose
- Define common event and command contracts for inter-service communication.
- Keep shared message schemas consistent and centralized.
- Avoid tight coupling by sharing only contract definitions, not implementations.
Usage
Reference this package from any microservice that needs to publish or consume these contracts.
Use the DTOs, event classes, and commands here for MassTransit message serialization and deserialization.
Keep contracts immutable and versioned carefully to maintain backward compatibility.
Example Contract
public class UserCreatedEvent : IEvent
{
public Guid UserId { get; set; }
public Guid CompanyId { get; set; }
public string FirstName { get; set; } = string.Empty;
public string LastName { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
public string PhoneNumber { get; set; } = string.Empty;
}
MassTransit Integration
This library is designed to work seamlessly with MassTransit. Events defined here can be published and consumed using MassTransit's type-based routing.
Publishing Events with MassTransit
public class MyService
{
private readonly IPublishEndpoint _publishEndpoint;
public MyService(IPublishEndpoint publishEndpoint)
{
_publishEndpoint = publishEndpoint;
}
public async Task CreateUser(...)
{
// Business logic...
await _publishEndpoint.Publish(new UserCreatedEvent
{
UserId = user.Id,
CompanyId = user.CompanyId,
// ... other properties
});
}
}
Consuming Events with MassTransit
public class UserCreatedEventConsumer : IConsumer<UserCreatedEvent>
{
private readonly ILogger<UserCreatedEventConsumer> _logger;
public UserCreatedEventConsumer(ILogger<UserCreatedEventConsumer> logger)
{
_logger = logger;
}
public async Task Consume(ConsumeContext<UserCreatedEvent> context)
{
var message = context.Message;
// Use structured logging (not string interpolation)
_logger.LogInformation(
"[MESSAGE] Consuming UserCreatedEvent for UserId {UserId}",
message.UserId);
// Handle the event...
}
}
Logging Best Practices
When implementing message handlers:
- Use structured logging with placeholders like
{PropertyName}, not string interpolation$"{value}" - Tag message logs with
[MESSAGE]prefix to distinguish from general application logs - Include key identifiers: UserId, CompanyId, MessageId, CorrelationId
- Use appropriate log levels: Information for normal flow, Warning for retries, Error for failures
See MIGRATION_GUIDE.md for comprehensive logging guidelines.
Legacy Routing Keys
The RoutingKeys class is marked as obsolete. MassTransit uses type-based routing automatically, so explicit routing keys are no longer needed. The class is kept for backward compatibility during the migration period.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. 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. |
-
net9.0
- B2aTech.CrossCuttingConcern (>= 1.8.0)
- MediatR (>= 12.5.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 | Downloads | Last Updated |
|---|---|---|
| 1.8.5 | 173 | 2/18/2026 |
| 1.8.4 | 201 | 1/21/2026 |
| 1.8.3 | 247 | 1/20/2026 |
| 1.8.2 | 105 | 1/15/2026 |
| 1.6.7 | 287 | 12/24/2025 |
| 1.6.6 | 175 | 12/24/2025 |
| 1.6.5 | 178 | 12/23/2025 |
| 1.6.2 | 187 | 12/23/2025 |
| 1.6.1 | 189 | 12/23/2025 |
| 1.6.0 | 197 | 12/22/2025 |
| 1.5.9 | 223 | 12/13/2025 |
| 1.5.8 | 145 | 12/13/2025 |
| 1.5.7 | 505 | 12/12/2025 |
| 1.5.6 | 125 | 12/12/2025 |
| 1.5.5 | 140 | 12/12/2025 |
| 1.5.4 | 140 | 12/12/2025 |
| 1.5.3 | 146 | 12/12/2025 |
| 1.5.2 | 440 | 12/11/2025 |
| 1.5.1 | 414 | 12/11/2025 |
| 1.5.0 | 362 | 11/17/2025 |