VsixCommunity / Community.VisualStudio.Toolkit.DependencyInjection

Adds Dependency Injection tooling for the Community.VisualStudio.Toolkit
Other
14 stars 7 forks source link

Guidelines for dependency injection in VS extensions #3

Closed dybzon closed 2 years ago

dybzon commented 2 years ago

Hi

I've recently started writing my first VS extension, and I've been struggling to find a good way to handle dependency injection. I come from the "web world" with .NET Core/ASP.NET Core where it's pretty much built in, and I can just declare my dependencies in the constructor of a controller class or similar. Assuming I've built a service container, of course. I was hoping I could do something similar in my VS extension.

Do you know of any guidelines/documentation/good examples of how dependency injection can be set up and used in a VS extension?

Any pointers to helpful resources are greatly appreciated!

StevenRasmussen commented 2 years ago

Hi @dybzon - I have updated the ReadMe to include information on how to use this package.

dybzon commented 2 years ago

Hi @StevenRasmussen , thanks for the update. That is exactly what I did after reading through the code, and it works great!

Are there any plans of adding support for other DI containers? Otherwise I'll probably look into writing a package for Autofac (similar to your MicrosoftDIToolkitPackage)

StevenRasmussen commented 2 years ago

There aren't any immediate plans for adding more DI containers, but it has definitely been architected with this in mind. Feel free to submit a PR if you come up with something for Autofac.