When refactoring a good piece of code I ran into the problem: I have to find and check all places where new instances of a particular type of object are created. Whether it is: methods, constructors, 'new' keyword. I can't do it without checking all references to the class with CodeLens, but there are too many references!
Asked
Active
Viewed 122 times
1
-
2Rename it without refactoring it. Then hit compile. The compiler will give you a list of all places that are broken then. From that list you can pick instantiations ... But I don't think that's any better than using CodeLens. Can you elaborate a little bit what it is in particular that you need to "check"? – Fildor Nov 09 '18 at 07:23
-
1It s the job of tools like CodeLens and Resharper to make it easy for us to find references and usages of type just by single click. How easier than this you can get? It would be better if you can provide bit more details of the problem you are facing. – Chetan Nov 09 '18 at 07:23
-
1If you just need to find all usages of a particular Constructor: make it private and hit compile. The error list will give you all places of those usages. If you need to check multiple ctors go one by one to keep the hits lower than when checking all at once. But again: I guess you can do that, too with CodeLens just as good, if not even better. – Fildor Nov 09 '18 at 07:27
-
I'm trying to figure out where my poor fellow programmers decided not to imlement some constructors of the class and set default values manually. There's a big hodgepodge of creting new object in services, singletons, static properties, DI containers, manual creating new object, retrieving templates from the DB. Everybody is doing whatever he wants. And when I was asked to change single default value I was very confused with this mess. Of course, I easily solved the problem, but I couldn't stop here doing nothing with this code heap – JohnIdlewood Nov 09 '18 at 08:01
1 Answers
1
Ok, thanks for the guys who commented this section the solution was found and it was trivial: create parameterless contstuctor - than you can navigate to all object creations using any constructor with CodeLens.

JohnIdlewood
- 356
- 3
- 12