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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Dhanman.Shared.Contracts" Version="1.8.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Dhanman.Shared.Contracts" Version="1.8.5" />
                    
Directory.Packages.props
<PackageReference Include="Dhanman.Shared.Contracts" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Dhanman.Shared.Contracts --version 1.8.5
                    
#r "nuget: Dhanman.Shared.Contracts, 1.8.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Dhanman.Shared.Contracts@1.8.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Dhanman.Shared.Contracts&version=1.8.5
                    
Install as a Cake Addin
#tool nuget:?package=Dhanman.Shared.Contracts&version=1.8.5
                    
Install as a Cake Tool

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

  1. Reference this package from any microservice that needs to publish or consume these contracts.

  2. Use the DTOs, event classes, and commands here for MassTransit message serialization and deserialization.

  3. 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
Loading failed