Is there a (better) way to find all references to

2020-03-01 02:51发布

Visual Studio's "Find All References" function works nicely for finding references to a property, and as it happens the "Call Hierarchy" does this too - it's even better in fact, as it sorts them by calling method.

My problem however is that neither of these methods discriminate between the setter and getter, and so I'm reduced to using find-in-files for "PropertyName =".

That seems like a step backwards (and would obviously not find code using "PropertyName += value" or similar), so I was wondering if I'd missed a simple way of persuading the "Call Hierarchy" function of Visual Studio to work on a property setter or getter specifically?

2条回答
时光不老,我们不散
2楼-- · 2020-03-01 03:42

It is possible in Visual Studio 2019 to sort and filter by "Kind" using the "Find All References" function. The feature was requested on Microsoft's developercommunity forum

The "references" window with the "Kind" column is displayed to the very right, highlighted by a orange box. references window with the "Kind" column

查看更多
Summer. ? 凉城
3楼-- · 2020-03-01 03:51

Resharper can do that for you.

Without R#, one way would be to temporarly set the setter to private and recompile. That will give an error everywhere you're trying to set. Not pretty, but faster than any other method I can think of.

查看更多
登录 后发表回答