Introduction

Agent Mulder is a plugin for resharper, so you will need that.

Agent Mulder plugin for ReSharper analyzes DI containers (Dependency Injection, sometimes called Inversion of Control, or IoC containers) in your solution, and provides navigation to and finding usages of types registered or resolved by those containers.

You will clearly also need a DI container 😉

I will test it with Autofac and VB.Net (of course) and I used Agent mulder 1.0.4 for this.

Installation

But first you install it. Download the msi first or the source and compile it yourself.

When installed, you should see this in the Resharper -> Options -> plugins window thing.

The code

Let me first show you this with some C#.

Here is my test code.

using Autofac;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            ContainerBuilder builder;
            builder = new ContainerBuilder();
            builder.RegisterType<Service1>().As<IService1>();
            var container = builder.Build();
        }
    }

    internal class Class1
    {
        private IService1 _service1;
        
        public Class1(Service1 service1)
        {
            _service1 =service1;
        }

    }

    interface IService1
    {}

    class Service1: IService1
    {
    }

}

If you have the resharper solution wide analysis turned on you will see this on the Service1 class.

This is because we inject our service in to our class and never instantiate it anywhere. We let our DI-container deal with that. So resharper will always give this error.

Now if we use the Agent mulder plugin this warningwill go away.

But now we will see an icon appear.

Which tells us agent mulder has detected it’s existence and knows it has been configured in our DI-container.

IF you now comment out the line

csharp builder.RegisterType<Service1>().As<IService1>(); It will give the warning again.

What is even more amazing is that you can click on the icon and navigate to where service has been registered.

Sadly Agent mulder doesn’t seem to work in VB.Net.

Conclusion

Agent mulder is a great plugin if you work with DI containers an resharper.