tags:

views:

33

answers:

1

I have some base class ControlBase and many derived classes which also have derived classes... ControlBase and derived classes have parameterless constructor. How can I easily find all derived classes constructor invocation points? ReSharper find usages on ControlBase constructor shows only usages of this base class constructor but not derived classes constructors.

Thanks.

+2  A: 

You can achieve this by using the structural search feature in Resharper 5.

Go to Resharper/Find/Search with Pattern in the menu. Then enter the following pattern in the textbox on the left:

new $type$($args$)

The words enclosed by the Dollar signs are placeholders which have to be specified. You can do this by clicking on "Add Placeholder".

In your example you need a Type placeholder (name=type, Type=ControlBase, check "Or derived type") and an Argument placeholder (name=args).

Markus Dulghier
Thanks, this is better solution that one I used before: VS Regular Expressions. I do not understand why, but when I am searching pattern `new $ControlBase$` it successfully finds `new Derived2()` but not `new Derived2{}` or even `new Derived2(){}` (constructor call with properties initializer). Mystery...
Roman

related questions