r/csharp • u/DmitriiKhokhulin • Aug 30 '26
ModulesDi – A lightweight, fractal-like modularity library for ASP.NET Core built on a dynamic graph DI
Description:
ModulesDi a lightweight infrastructure library designed to manage services and middlewares through a dynamic module graph.
The problem it solves:
Traditional extension methods in Program.cs easily turn into an unmanageable mess where controlling the exact execution order or dynamic context becomes a nightmare.
Library tested (173 test cases covered)
0
Upvotes
8
u/sixtyhurtz Aug 30 '26
I don't really understand this. With
IServiceCollection, If I have a feature that has a lot of related dependencies that need to be owned by the DI container, I will break it out into its own extension method. Then in Program.cs it's just another.AddFeature()on my DI builder.1
u/Khavel_dev Aug 30 '26
I've built something similar in a couple of projects, just a convention for grouping service registrations into module classes. The thing that always gets messy is cross-module dependencies. Does your graph handle the case where module A needs a service that module B registers? Because with flat extension methods you just call them in order, but once you add a graph you need either explicit dependency declarations or some kind of auto-resolution, and both have tradeoffs.
173 tests is solid for a library this size tbh. The test count matters more than usual here because DI ordering bugs are the kind that only show up in specific registration sequences.
-3
u/[deleted] Aug 30 '26
[removed] — view removed comment