Alex Rivera | Logout

Tell Resharper to use spring.net DI configuration for the inspection of unused classes?

Asked 2010-11-25T12:05:30.923
10

Resharper warns me when parts of my code are never used; this is very helpful.

However, I have quite a few classes that are not referenced by other code directly. These classes are used in the dependency injection (DI) configuration only.

I use spring.net for DI. The DI configuration is in xml format.

Is there any way I can tell Resharper to use the DI files for the inspection of unused classes?

I know I can suppress the Resharper warning using something like:

// ReSharper disable UnusedMember.Global
public class TheClass : IInterfaceWiredUsingSpringDI
// ReSharper restore UnusedMember.Global

But I don't like this very much - it's difficult to read and I don't really want to suppress the warning.

Note:

There is a less obtrusive and more readable way to suppress the warning, which I found on the jetbrains forum. When you define this custom attribute:

[MeansImplicitUse]
public class IoCAttribute : Attribute { }

Then you can suppress the warning:

[IoC]
public class TheClass : IInterfaceWiredUsingSpringDI 
Edit
Report

1 Answer

7

I'm 3 years too late to answer this, but I just saw this question via ReSharper's twitter stream. I created a plugin for ReSharper called Agent Mulder, and it does exactly this -- analyzes IoC container registrations, and allows navigating and finding usages of types that are registered via the container!

For the list of supported containers, please visit the project's wiki on github.

(Unfortunately, it doesn't work with Spring.NET, since there was no demand for it, sorry :))

answered 2013-05-29T06:49:22.823

Your Answer