Dependency Injection Toolset upgrade

Akos Nagy
Oct 26, 2021

I have a little tool in the VS Marketplace called Dependency Injection Toolset. The idea behind the tool was to help developers who apply dependency injection regularly by making it easier to code constructor injection.

The original version of the tool basically did two things:

  • Could generate a constructor for any type with parameters corresponding to the private, readonly fields that were of an interface or abstract class type and initialize the fields from the parameters.
  • Could also go the other way and generate a private readonly field for a constructor parameter.

Over time, people took to the tool and some also submitted pull requests and issues. The first major upgrade contained mostly bugfixes, the second was a VS 2017 update. Both came from the community, which makes me very proud. The third major upgrade came for an issue also submitted by the community that I implemented myself.

And now, I got another pull request to support getter only properties. The original version of the tool was created before C# 6, so this feature was not considered.
Now, if the property is an interface or abstract class and it's getter-only, you can also generate injection for that. And it goes the other way around: you can now generate getter-only properties for parameters as well. Awesome!

Be sure to check out the source code on Github or install the tool from the marketplace.

Akos Nagy
Software engineer, software architect, software craftsman. .NET-enthusiast, Azure-fan, Javascript-hater. Amateur athlete.