Hmz.Core.SharedKernel
0.1.0
dotnet add package Hmz.Core.SharedKernel --version 0.1.0
NuGet\Install-Package Hmz.Core.SharedKernel -Version 0.1.0
<PackageReference Include="Hmz.Core.SharedKernel" Version="0.1.0" />
<PackageVersion Include="Hmz.Core.SharedKernel" Version="0.1.0" />
<PackageReference Include="Hmz.Core.SharedKernel" />
paket add Hmz.Core.SharedKernel --version 0.1.0
#r "nuget: Hmz.Core.SharedKernel, 0.1.0"
#:package Hmz.Core.SharedKernel@0.1.0
#addin nuget:?package=Hmz.Core.SharedKernel&version=0.1.0
#tool nuget:?package=Hmz.Core.SharedKernel&version=0.1.0
Hmz.Core.ShardKernel (SharedKernel)
The shared kernel library for the Hmz ecosystem providing core abstractions, utilities, and domain building blocks that serve as the foundation for all Hmz projects.
Overview
This project contains reusable patterns and utilities based on Domain-Driven Design (DDD) principles and Clean Architecture. It provides a consistent foundation for building domain-driven applications within the Hmz family of projects.
Features
๐ก๏ธ Guard Clauses & Validation
Leverage Ardalis.GuardClauses for concise and expressive input validation:
Guard.Against.Null(input);
Guard.Against.NullOrEmpty(text);
Guard.Against.OutOfRange(age, min: 0, max: 120);
๐ Result Pattern
Implement consistent error handling with Ardalis.Result:
public Result<User> CreateUser(string email)
{
Guard.Against.NullOrEmpty(email);
var user = new User(email);
return Result.Success(user);
}
๐ Specification Pattern
Build complex queries in a domain-driven way with Ardalis.Specification and Entity Framework Core integration:
public class ActiveUserSpec : Specification<User>
{
public ActiveUserSpec()
{
Query.Where(u => u.IsActive);
}
}
var users = await repository.ListAsync(new ActiveUserSpec());
๐ท๏ธ Smart Enums
Type-safe enumerations with Ardalis.SmartEnum:
public class UserStatus : SmartEnum<UserStatus>
{
public static readonly UserStatus Active = new("Active", 1);
public static readonly UserStatus Inactive = new("Inactive", 2);
private UserStatus(string name, int value) : base(name, value) { }
}
๐งช HTTP Client Testing
Utilities for testing HTTP clients with Ardalis.HttpClientTestExtensions.
๐ง Startup Services Management
Introspect and list registered services with Ardalis.ListStartupServices.
๐ ASP.NET Core Integration
Seamless integration with ASP.NET Core through Ardalis.Result.AspNetCore.
Project Setup
Configuration
- Target Framework: .NET 10
- C# Language Version: Latest (preview)
- Nullable Reference Types: Enabled
- Implicit Usings: Enabled
- Treat Warnings as Errors: Enabled
Package Information
- Package ID:
Hmz.Core.SharedKernel - Version:
0.1.0 - Target: Distributed as a NuGet package for use across Hmz projects
Usage
In a .NET Project
- Add package reference:
dotnet add package Hmz.Core.SharedKernel
- Use the utilities:
using Ardalis.GuardClauses;
using Ardalis.Result;
public class OrderService
{
public Result<Order> CreateOrder(OrderRequest request)
{
Guard.Against.Null(request);
Guard.Against.NullOrEmpty(request.CustomerId);
var order = new Order(request.CustomerId);
return Result.Success(order);
}
}
Dependencies
All dependencies are managed through Directory.Packages.props at the solution level:
Ardalis.GuardClauses- Guard clauses and validationArdalis.HttpClientTestExtensions- HTTP client testing utilitiesArdalis.ListStartupServices- Service introspectionArdalis.Result- Result patternArdalis.Result.AspNetCore- ASP.NET Core integrationArdalis.SharedKernel- Shared kernel abstractionsArdalis.SmartEnum- Smart enumerationsArdalis.Specification- Specification patternArdalis.Specification.EntityFrameworkCore- EF Core integration
Best Practices
When extending the SharedKernel:
Validation First: Always validate inputs using Guard clauses
Guard.Against.NullOrEmpty(name, nameof(name));Consistent Error Handling: Use Result pattern for operations that can fail
return Result.Failure("User not found");Domain-Driven Queries: Leverage Specification pattern for complex queries
var spec = new UsersByRoleSpec(role); var users = await repository.ListAsync(spec);Type-Safe Enums: Use SmartEnum for status and state enumerations
if (status == OrderStatus.Pending) { // Handle pending order }
Building and Testing
Build the Project
dotnet build
Run Tests
dotnet test
Create NuGet Package
dotnet pack --configuration Release
Architecture
The SharedKernel follows these architectural principles:
- Domain-Driven Design (DDD): Core domain concepts are clearly expressed
- Clean Architecture: Separation of concerns with clear boundaries
- SOLID Principles: Adherence to design principles for maintainability
- Reusability: Components are designed to be used across multiple projects
Contributing
When adding new features to the SharedKernel:
- Ensure compatibility with .NET 10
- Follow the existing patterns and conventions
- Add proper guard clauses and validation
- Use the Result pattern for error handling
- Document public APIs thoroughly
- Update this README if adding major features
Support
For questions or issues regarding the SharedKernel, please refer to the main Hmz.Core documentation or contact the Hmz development team.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Ardalis.GuardClauses (>= 5.0.0)
- Ardalis.HttpClientTestExtensions (>= 4.2.0)
- Ardalis.ListStartupServices (>= 1.1.4)
- Ardalis.Result (>= 10.1.0)
- Ardalis.Result.AspNetCore (>= 10.1.0)
- Ardalis.SharedKernel (>= 4.1.0)
- Ardalis.SmartEnum (>= 8.2.0)
- Ardalis.Specification (>= 9.3.1)
- Ardalis.Specification.EntityFrameworkCore (>= 9.3.1)
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 |
|---|---|---|
| 0.1.0 | 81 | 3/22/2026 |