@maxitb I find that MSDI is good enough for 80% of my work but the more complex setups are painful.
Modular setups is the biggest reason I've defaulted to Autofac. MSDI doesn't have a baked in method for "and include DI from this project". There are extension libraries that do it but not in the core. Nor ones that give me options to extend registrations (like adding CLI commands from an assembly) or replace (having default services, then replacing them with mock or test ones).
Mostly I use that to have a single point of setup. In Nitride (my ecs ssg), I have extension methods to pull in features like Gemini, feeds, or front matter processing.
The second reason is because I do a lot of registration by interfaces. In Nitride, all of the operations are pulled in by reflection so I don't have to list each one. Autofac makes that easy, MSDI requires another library to do that.
Third is partial DI. I like Autofac's delegate handling that let's me provide some parameters for a service but then use DI for the others constructor parameters. I'm not aware of a MSDI library that does that but I know verbose techniques to do it. That let's me create a service that takes a UserId and have it passed into the constructor along with ILogger and other DI injected components.
Fourth is ascetics (much like my frustration with MS logging). MSDI's method calls are verbose on the consumption side but terse on the registration. I prefer the reverse.
Ultimately, I don't enjoy using MSDI as much as Autofac. I'm trying to convince myself to accept MSDI but I find I keep hitting its limitations or have to jump though excessive hoops compared to Autofac (such as setting up unit testing, nested scopes). And if I have to use a library to get the features I want, it seems logical to use one library that does everything cohesively across all my projects instead of making that choice per project.
That all said, I'm still trying to write my CLI library to only use MSDI and MSL (because I prefer Serilog also for the same reasons). It is painful but also a chance to see if the DX has improved since last time.
#CSharp