SyntaxCircus.Common 0.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package SyntaxCircus.Common --version 0.1.1
                    
NuGet\Install-Package SyntaxCircus.Common -Version 0.1.1
                    
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="SyntaxCircus.Common" Version="0.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SyntaxCircus.Common" Version="0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="SyntaxCircus.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 SyntaxCircus.Common --version 0.1.1
                    
#r "nuget: SyntaxCircus.Common, 0.1.1"
                    
#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 SyntaxCircus.Common@0.1.1
                    
#: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=SyntaxCircus.Common&version=0.1.1
                    
Install as a Cake Addin
#tool nuget:?package=SyntaxCircus.Common&version=0.1.1
                    
Install as a Cake Tool

SyntaxCircus.Common

Build NuGet License: MIT

The handful of contract types and dependency-free helpers that keep getting reinvented per product: a pagination result, ClaimsPrincipal claim resolution, a minimal current-user abstraction, a periodic background service base, and a standalone sliding-window rate limiter for hosts that aren't a normal ASP.NET Core pipeline.

No support guaranteed. Published as-is and maintained on a best-effort basis. Issues and PRs are welcome, but there's no SLA — fork it or vendor what you need if that's not enough.

PagedResult<T>

new PagedResult<Widget>(items, page: 1, pageSize: 25, totalCount: 142);
// .TotalPages, .HasPreviousPage, .HasNextPage are computed

ClaimsPrincipalExtensions

user.GetSubject();     // "sub" claim, falling back to ClaimTypes.NameIdentifier
user.GetEmail();       // "email" claim, falling back to ClaimTypes.Email
user.GetDisplayName(); // "name" claim, falling back to "preferred_username"

ICurrentUserService

builder.Services.AddCurrentUserService();
public sealed class MyService(ICurrentUserService currentUser)
{
    public void DoSomething()
    {
        if (!currentUser.IsAuthenticated) return;
        var userId = currentUser.UserId;
    }
}

A thin scoped wrapper over IHttpContextAccessor exposing IsAuthenticated, UserId, Email, DisplayName, and the raw Principal, built on ClaimsPrincipalExtensions.

PeriodicBackgroundService

public sealed class CleanupWorker(ILogger<CleanupWorker> logger)
    : PeriodicBackgroundService(TimeSpan.FromMinutes(5), logger)
{
    protected override async Task ExecuteTickAsync(CancellationToken cancellationToken)
    {
        // do the periodic work
    }
}

A BackgroundService base that runs ExecuteTickAsync on a fixed interval — one failing tick is caught and logged rather than crashing the whole service, and the delay is between ticks (not tick starts), so a slow tick can't overlap the next one.

SlidingWindowRateLimiter

var limiter = new SlidingWindowRateLimiter(permitLimit: 5, window: TimeSpan.FromMinutes(1));

if (!limiter.TryAcquire(key: remoteIpAddress))
{
    // reject
}

A plain, key-based sliding-window limiter with no HttpContext or middleware dependency — for hosts that aren't a normal ASP.NET Core request pipeline (an embedded server, a SignalR hub, a background worker) where System.Threading.RateLimiting's middleware integration doesn't apply.

Contributing

Issues and pull requests are welcome:

  • Keep changes focused, with a clear description of the behavior change.
  • Match the existing code style (see .editorconfig).
  • Call out any breaking changes to the public API in your PR description.

License

MIT — see LICENSE.txt.

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.
  • net10.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on SyntaxCircus.Common:

Package Downloads
SyntaxCircus.AspNetCore.Common

Small, near-universal ASP.NET Core host boilerplate: result-to-ProblemDetails mapping, correlation-ID middleware, security headers, and exception handling.

SyntaxCircus.AspNetCore.Common.MassTransit

Optional companion to SyntaxCircus.AspNetCore.Common: MassTransit consume/publish/send filters that propagate the configured correlation ID across message-bus boundaries, keeping log enrichment consistent with the HTTP middleware.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.3 262 8/29/2026
0.1.2 130 8/28/2026
0.1.1 106 8/16/2026