ArgTelecom.SharedKernel 1.0.0

dotnet add package ArgTelecom.SharedKernel --version 1.0.0
                    
NuGet\Install-Package ArgTelecom.SharedKernel -Version 1.0.0
                    
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="ArgTelecom.SharedKernel" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ArgTelecom.SharedKernel" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="ArgTelecom.SharedKernel" />
                    
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 ArgTelecom.SharedKernel --version 1.0.0
                    
#r "nuget: ArgTelecom.SharedKernel, 1.0.0"
                    
#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 ArgTelecom.SharedKernel@1.0.0
                    
#: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=ArgTelecom.SharedKernel&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=ArgTelecom.SharedKernel&version=1.0.0
                    
Install as a Cake Tool

ArgTelecom.SharedKernel

Reusable shared kernel for ArgTelecom .NET 10 microservices, published as a NuGet package.

The package follows Clean Architecture principles and is intentionally small: it contains abstractions, one sample domain, the Result pattern and DI registration only. There is no infrastructure, persistence or EF Core code, so every microservice can reference it without inheriting a technology choice.

Contents

Area Type Purpose
Abstractions ICurrentUser Identity of the caller in the current execution context.
Abstractions IDateTimeProvider Testable clock (UtcNow, UtcNowOffset, UtcToday).
Providers SystemDateTimeProvider Default clock backed by TimeProvider.
Domain BaseEntity, BaseEntity<TId> Identity, audit timestamps, identity based equality, domain events.
Domain IDomainEvent, DomainEvent Domain event contract and base record.
Domain Error, ErrorType Machine readable failure description.
Domain Result, Result<T> Result pattern with Map / Bind / Ensure / Match / Tap.
DependencyInjection AddSharedKernel() Single registration entry point, safe to call more than once.

Installation

From the GitLab Package Registry:

dotnet nuget add source "https://git.arg-eng.ir/api/v4/projects/<PROJECT_ID>/packages/nuget/index.json" \
  --name argtelecom \
  --username <USERNAME> \
  --password <PERSONAL_ACCESS_TOKEN> \
  --store-password-in-clear-text

dotnet add package ArgTelecom.SharedKernel

Or pin a version explicitly:

dotnet add package ArgTelecom.SharedKernel --version 1.0.0

Usage

Registration

builder.Services.AddSharedKernel();

// The consuming service supplies its own ICurrentUser implementation:
builder.Services.AddScoped<ICurrentUser, HttpContextCurrentUser>();

Every registration uses TryAdd semantics, so your own implementations always win. Options are available for advanced scenarios:

builder.Services.AddSharedKernel(options =>
{
    options.RegisterDefaultDateTimeProvider = true; // default
    options.TimeProvider = TimeProvider.System;     // swap for FakeTimeProvider in tests
});

Result pattern

public async Task<Result<Order>> GetAsync(Guid id, CancellationToken ct)
{
    Order? order = await _repository.FindAsync(id, ct);

    return order is null
        ? Error.NotFound($"Order '{id}' was not found.", "Order.NotFound")
        : Result.Ok(order);
}

// Composition
Result<string> reference = await GetAsync(id, ct)
    .MapAsync(order => order.Reference);

// Mapping to a transport response
IResult response = result.Match(
    order => Results.Ok(order),
    error => error.Type switch
    {
        ErrorType.NotFound => Results.NotFound(error),
        ErrorType.Validation => Results.BadRequest(error),
        ErrorType.Conflict => Results.Conflict(error),
        ErrorType.Unauthorized => Results.Unauthorized(),
        ErrorType.Forbidden => Results.Forbid(),
        _ => Results.Problem(error.Message),
    });

Entities and domain events

public sealed record OrderPlaced(Guid OrderId) : DomainEvent;

public sealed class Order : BaseEntity
{
    public Order(string reference) => Reference = reference;

    public string Reference { get; private set; } = string.Empty;

    public void Place() => RaiseDomainEvent(new OrderPlaced(Id));

    public void Rename(string reference, IDateTimeProvider clock)
    {
        Reference = reference;
        SetUpdated(clock);
    }
}

BaseEntity generates a sortable UUID v7 identity, compares entities by identity and type, and collects domain events that the consuming service dispatches after its unit of work is committed (entity.DomainEvents / entity.ClearDomainEvents()).

Local development

dotnet restore
dotnet build
dotnet test
dotnet pack -c Release -o artifacts

The build treats warnings as errors, generates XML documentation and enforces the rules in .editorconfig. Package versions are managed centrally in Directory.Packages.props.

Versioning and release

The version is never hard coded in the project file — it comes from the Git tag:

Git tag Package version
v1.0.0 1.0.0
v1.2.3 1.2.3

Untagged pipelines still pack a throwaway 0.0.0-ci.<pipeline> package so packaging is always validated, but they never publish.

git checkout master
git pull
git add .
git commit -m "Initial release"
git push

git tag v1.0.0
git push origin v1.0.0

The tag pipeline runs restore → build → test → pack → publish and pushes the package to the GitLab Package Registry using CI_JOB_TOKEN (no secrets required). Publishing to nuget.org is a manual job that only appears when a protected and masked NUGET_API_KEY variable is defined.

Publishing manually

dotnet pack -c Release -o artifacts -p:Version=1.0.0

dotnet nuget push "artifacts/*.nupkg" \
  --source "https://git.arg-eng.ir/api/v4/projects/<PROJECT_ID>/packages/nuget/index.json" \
  --api-key <PERSONAL_ACCESS_TOKEN> \
  --skip-duplicate

Repository layout

├── ArgTelecom.SharedKernel.slnx          # solution
├── src/ArgTelecom.SharedKernel/          # the published library
├── tests/ArgTelecom.SharedKernel.Tests/  # xUnit test suite
├── docs/init-SDD.md                      # original software design document
├── docs/design-decisions.md              # improvements made on top of the SDD
├── Directory.Build.props                 # shared build settings and versioning defaults
├── Directory.Packages.props              # central package version management
├── .editorconfig                         # formatting and analyzer configuration
└── .gitlab-ci.yml                        # restore / build / test / pack / publish pipeline
Product 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. 
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.0.0 111 8/10/2026
0.1.0 110 7/27/2026
0.0.2.1 110 7/27/2026