Agent Mulder – supporting IoC in ReSharper
The almost pervasive use of IoC containers in modern-day enterprise apps presents a special challenge to ReSharper. After all, how can ReSharper possibly know that a type, which for all intents and purposes appears to be unused, is actually configured to be instantiated implicitly by using a dependency injection mechanism?
Some might say that this is impossible, since the wide variety of IoC containers coupled with various distinct initialization options make the detection of component initialization a real challenge. This challenge was met, however, by Igal Tabachnik (@hmemcpy), the creator of the Agent Mulder plugin.
At the time of writing, Agent Mulder supports the following containers:
Depending on the container in question, Agent Mulder supports two types of component registration:
Manual registration involves registering a single component type in the container. This is typically done by providing the component’s type, so for example with Unity one might invoke
RegisterType(typeof(Foo),...)to add the component to the container.
Convention-based registration allows bulk registration of components in the container via a particular method. For example, Autofac’s
InNamespaceOf<T>()method allows the user to register all types that can be found inside the namespace inhabited by type
While it is technically infeasible for Agent Mulder to support every variety of configuration in every container, it does manage to cover a very large percentage of configuration options in the aforementioned containers, as documented in its Wiki pages. But, apart from analyzing container registrations, what does the plugin actually do?
Ultimately, Agent Mulder does three things:
The main goal of Agent Mulder is to suppress unused ispections when a container-registered component does not appear to be instantiated.
In addition, Mulder also uses a gutter mark to indicate a container-registered component. One can click this gutter mark to navigate to the exact line where this component is registered:
Finally, one can also navigate to registered component right from the statement that performs the registration:
Mulder is an open-source plugin hosted on GitHub. It appears to have an active user base, so if you are interested in, say, a container it doesn’t support, feel free to open a request or implement it yourself and send a pull request. Meanwhile, have fun with IoC and stay tuned for more plugin reviews!
Subscribe to Blog updates
Thanks, we've got you!
Another Look into the Future with Rider’s Predictive Debugger
In the 2023.2 release cycle, we’ve introduced the Predictive Debugger in ReSharper, which gives you predictions about code paths and variables beyond the current execution pointer. We’ve written extensively about its advantages compared to alternative debugging strategies like thorough thinking, log…
Visualize Entity Framework Relationships and Additional Query Analysis in ReSharper 2023.3
A lot of teams are using Entity Framework or EF Core to work with their database. As an Object-Relational Mapper (ORM), it bridges objects in code to a relational database model, so that as a developer you don’t have to worry too much about the actual database. We all know: that’s not entirely tr…
Automatically Analyze ASP.NET Core Performance With Dynamic Program Analysis
Slow web pages may make your users or customers abandon your web application, even before they’ve had a proper look at it. You’ve likely also been frustrated working with a web application that is slow to load. The good news is that the latest versions of ReSharper and JetBrains Rider’s Dynamic P…
OSS Power-Ups: MassTransit – Webinar Recording
The recording of our webinar, OSS Power-Ups: MassTransit, with Chris Patterson, is available. This was the thirteenth episode of our OSS Power-Ups series, where we put a spotlight on open-source .NET projects. Subscribe to our community newsletter to receive notifications about future webinars.…