httpflow icon indicating copy to clipboard operation
httpflow copied to clipboard

Suggestion for replacement of "StructureMap".

Open luizs81 opened this issue 8 years ago • 8 comments

As the development of "StructureMap" has been discontinued, is there any good replacement for it?

Their website suggest using Lamar, but their current build seems to be failing, so I'm not very confident in adding it in my project.

Thanks!

luizs81 avatar Aug 06 '18 01:08 luizs81

AutoFac or SimpleInjector are two that I have gone with.

https://autofac.org/

https://simpleinjector.org/index.html

camainc avatar Aug 06 '18 14:08 camainc

I'm planning on swapping in AutoFac. PR welcome if someone gets to it first.

ardalis avatar Sep 27 '18 13:09 ardalis

Please excuse my ignorance but what makes the default .NET Core DI unfit for the job?

Van-Dame avatar Sep 29 '18 13:09 Van-Dame

I guess that @ardalis wants to completely detach the infrastructure project from the web, binding the interfaces and implementations on runtime, but the built in DI doesn't allow that.

But I can be wrong.. ;)

luizs81 avatar Oct 02 '18 08:10 luizs81

@luizs81 that's one reason, yes, although you probably could achieve that, too. The main reason is that I like some of the features that other DI containers offer, such as default conventions/policies for wiring up types to interfaces. You can easily wire up all types that match this pattern: IFoo <-> Foo for instance, so that as long as you use that naming convention you don't need to remember to touch Startup every time you add another interface and service implementation. Many small projects don't need anything more than the built-in DI container but larger ones may benefit from the features offered by Autofac, et al.

ardalis avatar Oct 02 '18 12:10 ardalis

@ardalis I didn't know that it was possible!

ratanparai avatar Oct 03 '18 02:10 ratanparai

@ardalis Any reason you chose Autofac over Lamar, the replacement to Structuremap?

cal5barton avatar Oct 16 '18 01:10 cal5barton

That's a good question. Mostly because I hadn't kept up with its progress and because Autofac I knew from when I wrote the ASP.NET Core Docs was a fully supported container from the 1.0 days. I should look into Lamar, though, especially since my first glance at it seems to indicate it's a) very much like StructureMap and b) designed to work closely with ASP.NET Core's DI system.

Thanks!

ardalis avatar Oct 16 '18 01:10 ardalis