kvandijk.Common 0.5.0

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

Package content

This package contains common functionality used across multiple projects, including:

BackgroundTasks

  • BackgroundTaskQueue: A thread-safe queue for managing background tasks.
  • IBackgroundTaskQueue: An interface for the background task queue.
  • QueuedWorker: A hosted service that processes tasks from the BackgroundTaskQueue.

Diagnostics

  • RequestTimingMiddleware: Middleware for measuring and logging the time taken to process HTTP requests.
  • SkipRequestTimingAttribute: An attribute to skip request timing for specific endpoints.

Entities

  • BaseEntity: A base class for entities with an Id, CreatedAt, UpdatedAt, and DeletedAt properties.
  • BlamingEntity: An extension of BaseEntity that includes CreatedBy, UpdatedBy and DeletedBy properties for tracking user actions.

Extensions

  • SerilogExtensions: Provides methods to configure Serilog for logging.

Interfaces

  • IHashingService: An interface for hashing services.
  • IRepository: A generic repository interface for CRUD operations.

Middleware

  • ExceptionLoggingMiddleware: Generic middleware for logging exceptions.
  • RequestLoggingMiddleware: Middleware for logging HTTP requests.

Services

  • HashingService: A service that implements IHashingService for hashing strings.

Utils

  • DotenvLoader: A utility for loading environment variables from a .env file.

wwwroot

  • top-loading-bar.css: A CSS file for a top loading bar UI component.
  • top-loading-bar.js: A JavaScript file for a top loading bar UI component.

How to use

Install the package using:

dotnet add package kvandijk.Common

Configure logging, exception handling and environment variables in Program.cs using

using kvandijk.Common.Logging;
using kvandijk.Common.Middleware;
...

// Load environment variables
DotenvLoader.Load();

var builder = WebApplication.CreateBuilder(args);

// Add Serilog
builder.ConfigureSerilog();

...

var app = builder.Build();

// Middleware pipeline configuration
app.UseMiddleware<ExceptionLoggingMiddleware>();
app.UseMiddleware<RequestLoggingMiddleware>();
app.UseMiddleware<RequestTimingMiddleware>();

...

Configure background tasks in Program.cs using

using kvandijk.Common.BackgroundTasks;

...

services.AddSingleton<IBackgroundTaskQueue, BackgroundTaskQueue>();
services.AddHostedService<QueuedWorker>();

Example usage of the loading bar in a Razor page:

<link rel="stylesheet" href="/_content/kvandijk.Common/top-loading-bar.css" />
<script src="/_content/kvandijk.Common/top-loading-bar.js"></script>

<style>
    :root {
        --kvandijk-loading-bar-offset-y: var(--header-height);
        --kvandijk-loading-bar-offset-x: var(--sidebar-width);
        --kvandijk-loading-bar-color: var(--verdel-blue-gradient);
        --kvandijk-loading-bar-height: 4px;
        --kvandijk-loading-bar-z: 1001;
        --kvandijk-loading-bar-transition: width 0.3s ease-out, opacity 0.2s ease-out;
    }
</style>
<div id="top-loading-bar"></div>
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 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
0.5.0 861 12/10/2025
0.4.2 314 11/22/2025
0.4.1 199 11/22/2025
0.4.0 210 11/22/2025
0.3.0 291 11/21/2025
0.2.0 262 10/29/2025
0.1.0 176 10/24/2025