Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Go to Implementation" across projects with an Analyzer? #8144

Closed
steffenloesch opened this issue Jan 24, 2016 · 5 comments
Closed

"Go to Implementation" across projects with an Analyzer? #8144

steffenloesch opened this issue Jan 24, 2016 · 5 comments
Labels
Area-IDE Question Resolution-Answered The question has been answered

Comments

@steffenloesch
Copy link

From within an Analyzer, is there a way to do a "go to implementation" (as in Visual Studio) across projects of the same solution? For example, I have a type symbol, and I want to go to the source code of that type, in order to analyze it. If that worked across projects, many solution-wide analyses would be simple to do.

Performance might be an issue, but how much that is an issue will likely vary from use-case to use-case.

@srivatsn
Copy link
Contributor

As mentioned in #7766, since analyzers are a compiler concept finding implementations across projects is not feasible in an analyzer. I think @jmarolf's suggestion was about providing such an API at the workspace layer so that if we have analyzers that can work at the workspaces level (#3797) then such an API could be used.

@Pilchie
Copy link
Member

Pilchie commented Jan 26, 2016

We do NOT currently have this API to make public at the workspace layer.

In our design discussions, the way we would approach implementing something like this is by reversing it and having your analyzer look at all method invocations, instead of looking at method declarations.

@Pilchie Pilchie added the Resolution-Answered The question has been answered label Jan 26, 2016
@Pilchie Pilchie closed this as completed Jan 26, 2016
@steffenloesch
Copy link
Author

Thanks for the feedback!

Are there any plans to expose an API like that, possibly with some notion of VS-Analyzer? It seems counter-intuitive that something that is very easy to do interactively with VS, is very hard to do with an Analyzer.

@Pilchie , can you please elaborate some more about the 'reverse' approach. I don't quite understand yet what you mean exactly. How would that apply to my 'go to type implementation' example?

@Pilchie
Copy link
Member

Pilchie commented Jan 26, 2016

I'm fine with the notion of adding a Workspaces-layer data API for Go To Implementation (cc @jasonmalinowski about that). However, I'm loathe to introduce the concept of workspace analyzers that know about multiple projects, since I think a big part of the value of analyzers is their ability to travel with compilation to CI servers, etc.

From you description above here though, it doesn't really sound like you're looking for Go To Implementation as we think about it. Instead you just want ISymbol.Locations to return source locations for types in other projects (what we use SymbolFinder.FindSourceDefinitionAsync for in the IDE code). One approach to this sort of problem (though not great I admit) in analyzers would be to analyze the types as you find them and write the results out to a file beside the output assembly of the compilation, and then when you come across the usage, you load the file that has the already summarized results for the type.

@steffenloesch
Copy link
Author

Thanks for the additional explanation, @Pilchie . Your're right with that's the kind of thing I'm looking for. I thought too that your approach described is what I have to resort to. I was hoping that the result of #6324 would help me with the file access. The advantage of that approach is hopefully that it's performant.

I also agree that being able to run analyzers from the command line, for example on a CI server, is a big advantage of Analyzers. Optimally you could keep that, but still allow some solution level analysis, but I guess that's wishful thinking ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Question Resolution-Answered The question has been answered
Projects
None yet
Development

No branches or pull requests

4 participants