Closed Pilchie closed 5 days ago
Just for informational purposes, here's my use case that triggered the send-a-smile.
I was implementing a custom protocol in code in which each request in the protocol has a class associated with it. I tag the request classes with a attribute in order to be able to reflect over them and construct the appropriate request/response object for the request/response code. IE: a factory pattern working over custom attributes to identify the appropriate type to create and instantiate it via reflection.
When I did a "find reference" in the IDE to where the custom attribute was being tagged on the class, I couldn't find where the reflection code was finding the attribute even though I was using a generically typed method Type.GetCustomAttribute
After the response in the send-a-smile, the IDE interaction does make sense now as the semantic model/analysis for find references for usage of the attribute resolves to the Ctor for the attribute and not the type itself. So, the IDE searches just for references to the Ctor of the attribute. It finds those, but wouldn't return places where the attribute is reflected over as that is a reference to the type and not the Ctor.
I don't use this pattern a lot. However, it would be helpful to find places where an attribute is being reflected over based on finding references in the usage/ctor of the attribute. Implementing this would allow me to do that.
Very nice to see the send a smile result in a github issue :)
Another place affected by this is MediatR
and Send
interface, when you want to navigate to implementation you need first go to type definition then click FAR to find handler implementation:
await _mediator.Send(new Foo(1, 2)); //only constructor accessible for FAR but I want search for type only
var foo = new Foo(42); //here you can target `var` and access type, but this
await _mediator.Send(foo);
Overall I see conflict there as sometimes I would like see included type usage but other times I would be interested in only specific constructor usage. Question is would be better to split FAR in two modes, one only for specific type or constructor and other where you find all type usage and all constructors? This could be extended in some way to normal functions too, but this would be "only specific function" and "all overloads of given function".
Closing out du to lack of broader feedback.
FAR gives both the types and constructors in the results window. Users can just look at the reuslts of the particular symbol tehy care abuot.
(Inspired by VS Send-a-smile feedback).
Early in Roslyn, we stopped cascading from constructors to types in FAR to reduce noise if all you were looking for was the constructor.
However, now that we have hierarchical FAR with the references to the type and constructor grouped differently, we should re-add the cascading