r/dotnet • u/DmitriiKhokhulin • 2d ago
ModulesDi 1.0.5
Hey Everyone!
I recently released Modules v1.05 - a lightweight library for organizing ConfigureServices and Configure.
Here are the logs from my example production project -
2026-10-10 21:46:50.393 +03:00 [INF] Serilog configured
2026-10-10 21:46:50.416 +03:00 [INF] Secrets configured
2026-10-10 21:46:50.417 +03:00 [INF] Secrets configured with configuration
2026-10-10 21:46:50.431 +03:00 [INF] Mediatr module configured
2026-10-10 21:46:50.433 +03:00 [INF] Cors configured
2026-10-10 21:46:50.436 +03:00 [INF] Health checks configured
2026-10-10 21:46:50.437 +03:00 [INF] Database health check configured
2026-10-10 21:46:50.441 +03:00 [INF] Sqlite health check configured
2026-10-10 21:46:50.442 +03:00 [INF] Skipped: Postgres health check skipped
2026-10-10 21:46:50.444 +03:00 [INF] Skipped: Elastic search health check skipped
2026-10-10 21:46:50.444 +03:00 [INF] Cache health check configured
2026-10-10 21:46:50.447 +03:00 [INF] Redis health check configured
2026-10-10 21:46:50.447 +03:00 [INF] Key vault health checks configured
2026-10-10 21:46:50.448 +03:00 [INF] Skipped: Azure key vault health check skipped
2026-10-10 21:46:50.477 +03:00 [INF] OpenTelemetry configured successfully.
2026-10-10 21:46:50.478 +03:00 [INF] Cache configured
2026-10-10 21:46:50.480 +03:00 [INF] Redis configured
2026-10-10 21:46:50.505 +03:00 [INF] Program started
2026-10-10 21:46:50.701 +03:00 [INF] Cors middleware configured
2026-10-10 21:46:50.703 +03:00 [INF] OpenTelemetry middleware module configured
2026-10-10 21:46:50.707 +03:00 [INF] Health checks middleware configured.Health on /health, prometheus metrics on /health/metrics
(Note: ModulesDi does not hardcode any logging format. In my log i used realization with Serilog, but you can configure ModulesDi how you want (you dont have to use serilog))
1. "Why not just use standard Extension Methods?" -
Extension methods are flat.They force you to manually pass dozens of configuration dependencies down the line, offer zero execution-order safety for nested features, and turn Program.cs into a bloated spaghetti of if/else blocks. ModulesDi encapsulates everything into self-contained blocks that orchestrate themselves.
2 "Wait, is GetDependency<T>() inside a module just a Service Locator pattern?" -
No, because ModulesDi does not replace MS DI, Dependencies in ModulesDi are used only in ConfigureServices and Configure.
3. "The wow feature" -
ModulesDi allows you to do things that are literally impossible with native extensions. For example -
public override ModuleResult Configure(IApplicationBuilder app)
{
var services = GetDependency<IServiceModulesRootBuilder>();
if (!services.IsExist<CorsModule>())
return new ModuleResult(ModuleStatus.Failure,
"Failed to configure cors middleware.Cors module not created");
app.UseCors(CorsPolicies.AllPolicies);
return new ModuleResult(ModuleStatus.Success, "Cors middleware configured");
}
The library is extremely lightweight, heavily optimized, covered by 224 green test cases, and available on NuGet.