Detect (and replace?) Singletons

Hi folks,

I'd like a tool in ReSharper that lets me manage uses of the Singleton pattern in code. At best, I want a refactoring to change Singleton usage - usually to an Injected Dependency - but the ability to highlight usage would also be a boon. After some brief discussion with one of the developers/product manager(s) at JetBrains, I've been invited to raise an issue, but figured I'd poll the folks here first.

Briefly, where I have a class using a Singleton instance (a hidden dependency), I want a way to make the Singleton class a normal class, and have it passed as a parameter to client classes/methods using it.

In my previous discussion, it was mentioned that this could be implemented as "an inspection or an intention action". I'm not too sure what these are (can't see any references in RS1.5, haven't yet tried RS2.0) so some guidance there would be helpful.

So my real question is - is there anyone else who has ever wanted this or something like it?

Steve Love

Please sign in to leave a comment.