roslyn: Request: Find All References broken down by use

This is a feature supported in Red Gate Reflector that I think would be very useful within Visual Studio.

I’d like to see Find References be able to differentiate between the use of the reference and allow either breaking down the references by their use or isolating a specific use type:

  1. Properties by accessor method (get vs. set) image

  2. Fields, locals and parameters by whether they are used or assigned image

  3. Types by where they are instantiated (via instance constructor invocation), exposed (via non-private field, property or method parameter) or used image

I am currently working on a project where many fields are exposed as protected or as internal and are frequently referenced directly by other types. I am trying to discern where those fields are being mutated and in quite a few cases Find All References is identifying over a 100 direct references of each of those fields, but scanning through the results I might identify only a couple assignments. Doing this manually is both tedious and very likely error prone.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 8
  • Comments: 29 (25 by maintainers)

Most upvoted comments

I believe the primary request here has been addressed by https://github.com/dotnet/roslyn/pull/30155.

image

New FAR column allows classification, sorting, filtering, etc. by reference kind (this will show up in Dev16 Preview2)

@HaloFour Does this meet your request?

@jnm2 is right. this should be one of:

  1. ‘Name’
  2. ‘Name only’
  3. ‘Name Only’

it def should not be NameOnly 😃

@mavasani

That looks really nice and solves most of my use cases!

Fyi– I made it this far on 15.6 without ReSharper, but there’s no way I can finish the task I have at hand without going back to ReSharper. I have to look through 223 hits, the overwhelming majority of which are usages of the getter, while the tool window title is 'set_ThisProperty' references.

Edit: as it turns out, 222 of the hits were usages of the getter 😁

Even more useful to me would be the same thing for fields: find all reads of a field or all writes of a field, but don’t show me both at the same time and make me wade through a ton of false positives to get to what I need to see. (nameof wouldn’t count and ref would trigger either. out would count as a write.)

We have the data for this internally. It could be expose as a new column in the VS FAR window. You could hten use that column to ‘group by’, as you can with the other columns.