WeihanLi.Common bundles a set of production-ready helpers, extensions, and middleware to simplify .NET application development. It covers dependency injection, AOP, eventing, logging, data access helpers, OTP utilities, templating, and more—built from real-world usage and battle-tested across services.
| Package | Description |
|---|---|
WeihanLi.Common |
Core helpers and extensions: dependency resolver, configuration helpers, pipelines, TOTP utilities, command executors, etc. |
WeihanLi.Common.Logging.Serilog |
Integration layer so core logging abstractions seamlessly forward to Serilog or Microsoft.Extensions.Logging. |
WeihanLi.Extensions.Hosting |
Hosting helpers for quickly wiring background services, console apps, and DI bootstrapping. |
Each package is available on NuGet and can be referenced independently.
Install the package you need using the .NET CLI or NuGet Package Manager:
dotnet add package WeihanLi.Common
# or install the Serilog integration
dotnet add package WeihanLi.Common.Logging.SerilogPreview builds are also published; append --version <preview> to opt in.
using WeihanLi.Common.Helpers;
// Generate a TOTP code with the built-in helper.
var secret = $"{ApplicationHelper.ApplicationName}_demo_secret";
var code = TotpHelper.GenerateCode(secret);
Console.WriteLine($"Generated code: {code}");
var isValid = TotpHelper.ValidateCode(secret, code);
Console.WriteLine($"Valid code: {isValid}");See samples/DotNetCoreSample and samples/AspNetCoreSample for richer scenarios that exercise DI decorators, event buses, logging pipelines, and more.
- Dependency Injection: Lightweight container abstractions, decorator helpers, metadata-based registrations, proxy support, and integration with
Microsoft.Extensions.DependencyInjection. - Fluent Aspects (AOP): Dynamic proxy-based interception with fluent configuration for method-level behaviors (logging, validation, caching, etc.).
- Event Infrastructure: In-memory and queue-backed
EventBus,EventStore, and handler helpers to wire publish/subscribe workflows. - Logging: Abstractions with adapters for built-in logging and Serilog plus formatting helpers to ship structured events.
- Data Access Helpers: Dapper-style extensions over ADO.NET, entity mapping utilities, and SQL expression parsers to streamline data access layers.
- OTP & Security: TOTP implementation, helpers, and service abstractions to secure user flows with minimal setup.
- Templating & Text: Lightweight template engine and string utility helpers for dynamic content rendering.
- Utilities: Process executor, pipeline builder, command helpers, configuration helpers, async invokers, and more.
- Browse the docs in
docs/index.mdand articles underdocs/articlesfor deep dives. - API references can be generated with DocFX (
docs/docfx.json). - Samples live under
samples/and demonstrate step-by-step usage patterns you can adapt.
dotnet build
dotnet testCI builds run with both Azure Pipelines (azure-pipelines.yml) and GitHub Actions (.github/workflows/default.yml), so you can rely on the same commands locally.
Head to the merged pull requests list or the docfx ReleaseNotes for a chronological view of changes.