https://github.com/feature23/kernel
https://github.com/feature23/kernel
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/feature23/kernel
- Owner: feature23
- License: mit
- Created: 2024-12-18T22:24:34.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-12-01T22:52:18.000Z (7 months ago)
- Last Synced: 2026-01-09T10:00:50.112Z (5 months ago)
- Language: C#
- Size: 75.2 KB
- Stars: 1
- Watchers: 4
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# feature[23] Shared Kernel
[](https://github.com/feature23/kernel/actions/workflows/ci_build.yml)
A library of reusable types for implementing Clean Architecture in .NET and ASP.NET Core applications, based heavily on the work of [Steve Smith](https://github.com/ardalis) in the following open-source projects:
- [ASP.NET Core Template](https://github.com/ardalis/CleanArchitecture)
- [Shared Kernel](https://github.com/ardalis/Ardalis.SharedKernel)
For the core functionality, only the `F23.Kernel` library is needed. This library provides types for events, results, query and command handlers, validation, and messaging. For smoother integration with ASP.NET Core, the `F23.Kernel.AspNetCore` library can be used for easily mapping between core result types and ASP.NET Core `IActionResult` and model state.
> **WARNING:** This library is currently in a pre-release state, and breaking changes may occur before reaching version 1.0.
>
---
**What if your day job was contributing to open-source projects and custom AI solutions — and you got paid for it?**
We're hiring remote engineers to contribute to cutting-edge AI and custom software projects. 100% remote, 100% real impact. https://www.feature23.com/careers
## NuGet Installation
### Core Package
```powershell
dotnet add package F23.Kernel
```
### ASP.NET Core Helper Package
```powershell
dotnet add package F23.Kernel.AspNetCore
```
## Examples
### Query Handler
```csharp
class GetWeatherForecastQueryResult
{
public required IReadOnlyList Forecast { get; init; }
}
class GetWeatherForecastQuery : IQuery
{
public int DaysIntoTheFuture { get; init; } = 5;
}
record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
{
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}
class GetWeatherForecastQueryHandler(IValidator validator, IWeatherForecastRepository repository)
: IQueryHandler
{
public async Task> Handle(GetWeatherForecastQuery query, CancellationToken cancellationToken = default)
{
if (await validator.Validate(query, cancellationToken) is ValidationFailedResult failed)
{
return Result.ValidationFailed(failed.Errors);
}
var forecast = await repository.GetForecast(query.DaysIntoTheFuture, cancellationToken);
var result = new GetWeatherForecastQueryResult
{
Forecast = forecast
};
return Result.Success(result);
}
}
```
#### Program.cs
```csharp
builder.Services.RegisterQueryHandler();
// Other code omitted for brevity
app.MapGet("/weatherforecast", async (IQueryHandler queryHandler) =>
{
var result = await queryHandler.Handle(new GetWeatherForecastQuery());
return result.ToMinimalApiResult();
})
.WithName("GetWeatherForecast")
.WithOpenApi();
```
### Command Handler
> TODO
### Event Sourcing
> TODO