ReSharper 5 Structural Search can do this. Assume the following code:
class Program { static void Main(string[] args) { var hm = new HurtMe(); var dhm = new DontHurtMe(); DoBadThings(hm); DoBadThings(dhm); } static void DoBadThings(IBusinessObject ibo) { } } interface IBusinessObject { } class DontHurtMe : IBusinessObject { } class HurtMe : IBusinessObject { }
Now, as noted, R # Find Usages on DoBadThings , no matter what parameters we specify, will find both calls in Main .
But if we
- Go to
ReSharper | Find | Search with Pattern.... ReSharper | Find | Search with Pattern.... Add Placeholder | Expression , name it dhm and specify DontHurtMe as type- In the
Search pattern enter DoBadThings($dbm$) - Click Find
we get in our results only a call to DoBadThings object with a type statically identified as a DontHurtMe , and not a call to a HurtMe .
I like the accuracy of the procedure suggested by @Carl Manaster, but this method makes it possible when you cannot overload this method.
source share