Is there a ReSharper shortcut to find all instantiations of a certain type?
For example:
..开发者_高级运维. new MyClass();
... new MyClass { ... };
If I'm lucky:
... Activator.CreateInstance<MyClass>();
etc.
Any thoughts?
Right click the constructor, "Find Usages". I often create a constructor for classes even if I don't need it because of this feature.
Another way, right click on class and click "Find usages". Then click "Filter usages" (in the icon bar), "Show invocation usages". If it's grayed out, there are no invocation usages, which will probably be the case if you use
Activator.CreateInstance<MyClass>();
I found this question because I'm currently looking for a better way of doing this. No luck so far.
Select the constructor and press Shift+Alt+F12. This will show you all explicit calls to the constructor, which should include any factory methods. You can then use the same shortcut to see where they are called from.
Find Usages menu available on any member and type shows all usages, including instantiation.
I'm not aware of any way to filter the results to instantiation only.
Your first two are both calls to the same constructor. Simply doing a Find Usages will locate them (ALT+F7).
The Find Usages Feature is able to find all occurrences of any symbol. ReSharper is able to find all explicit references and the references created by using Reflection. See http://www.jetbrains.com/resharper/features/navigation_search.html#Find_Usages
精彩评论