Skip to content

Go to C# symbols - #3357

Merged
KevinRansom merged 28 commits into
dotnet:masterfrom
vasily-kirichenko:go-to-csharp-declaration
Aug 21, 2017
Merged

Go to C# symbols#3357
KevinRansom merged 28 commits into
dotnet:masterfrom
vasily-kirichenko:go-to-csharp-declaration

Conversation

@vasily-kirichenko

Copy link
Copy Markdown
Contributor

This is saul@dad4934

1

@majocha any ideas how to make the tooltip links work as well for C# symbols?

@dsyme

dsyme commented Jul 21, 2017

Copy link
Copy Markdown
Contributor

Oh wow. A while back I promised a bounty (ok, a beer, a book, whatever) to whoever did this :) But do you get it or @saul!? :)

@forki

forki commented Jul 21, 2017

Copy link
Copy Markdown
Contributor

this is seriously nice, but the other direction is even more important since many projects want to write domain logic in F# and UI in C#. AFAIK this would require mapping the F# TAST to roslyn TAST. Is this something the F# team or the roslyn team is working on?

@dsyme

dsyme commented Jul 21, 2017

Copy link
Copy Markdown
Contributor

Is this something [anyone] is working on?

I don't think I've seen anyone on any team prototype this

@forki

forki commented Jul 21, 2017

Copy link
Copy Markdown
Contributor

sad since this was one of the promised things when the roslyn topic came up in VF# ;-) "we could benefit from the infrastructure and the roslyn team would help ..." ;-)

Anyway nice to see one direction is at least possible! Kudos!

@saul

saul commented Jul 21, 2017

Copy link
Copy Markdown
Contributor

I don't think this is much different to what I committed months ago - you can see by the number of 'todos' this isn't nearly complete! Thanks to @vasily-kirichenko for bringing it up to date

@saul

saul commented Jul 21, 2017

Copy link
Copy Markdown
Contributor

It's actually not too difficult to implement it "the other way" without us having to move everything over to the Roslyn symbol API. There's a legacy interface that is used as a fallback if Roslyn can't find a symbol - I can't find the exact name but it should be simple for us to implement.

@vasily-kirichenko

Copy link
Copy Markdown
Contributor Author

@saul any chance you remember that interface name?

@vasily-kirichenko

vasily-kirichenko commented Jul 21, 2017

Copy link
Copy Markdown
Contributor Author

@Pilchie can you help?

@saul

saul commented Jul 21, 2017

Copy link
Copy Markdown
Contributor

I can't - it was @CyrusNajmabadi who told me.

@saul

saul commented Jul 22, 2017

Copy link
Copy Markdown
Contributor

@vasily-kirichenko I've found Cyrus's comment detailing how to go the other way: dotnet/roslyn#16511 (comment)

@vasily-kirichenko

Copy link
Copy Markdown
Contributor Author

@saul I added a IVsSymbolicNavigationNotify impl, but it's not called on F12.

@CyrusNajmabadi any ideas? I've failed to find an example of how to expose this interface anywhere.

@vasily-kirichenko

Copy link
Copy Markdown
Contributor Author

Ah, looks like Roslyn query IVsSymbolicNavigationNotify casting IVsHierarchy to it, so it seems we should implement the interface in one of node classes in ProjectSystem...

@vasily-kirichenko

Copy link
Copy Markdown
Contributor Author

I tried to implement it in our ProjectNode class, the methods are not called either.

@saul

saul commented Jul 22, 2017

Copy link
Copy Markdown
Contributor

@vasily-kirichenko

vasily-kirichenko commented Jul 22, 2017

Copy link
Copy Markdown
Contributor Author

serviceProvider.GetService<VsSymbolicNavigationManagerClass, IVsSymbolicNavigationManager>() returns null being called in FSharpGoToDefinitionService ctor :(

@saul

saul commented Jul 22, 2017

Copy link
Copy Markdown
Contributor

According to docs.microsoft.com, "This interface is available via QueryService(Type, Object)." It looks like there's a difference between GetService and QueryService - try QueryService instead.

@vasily-kirichenko

Copy link
Copy Markdown
Contributor Author

@saul I've tried QueryService, it returns non-zero code.

@vasily-kirichenko

Copy link
Copy Markdown
Contributor Author

image

@saul

saul commented Jul 22, 2017

Copy link
Copy Markdown
Contributor

Looks like the manager isn't used in Roslyn - it's pulled off the IVsHierarchy of the open document? Or something similar:

https://github.com/dotnet/roslyn/blob/6847f1e5a909395aae9456e8f366cbf4deb86b69/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioSymbolNavigationService.cs#L172

@vasily-kirichenko

Copy link
Copy Markdown
Contributor Author

@vasily-kirichenko

Copy link
Copy Markdown
Contributor Author

:) Yes. See my comment #3357 (comment)

I implemented IVsSymbolicNavigationNotify in ProjectNode, but it was not called.

@saul

saul commented Aug 20, 2017

Copy link
Copy Markdown
Contributor

To whoever reviews this (@dsyme/@KevinRansom), it's worth pointing out that I want to add a test suite to this. I want to use the code that I've been demoing in the gifs, as it's a complete real-world use of this functionality. How best can I integrate it into our test suite?

@vasily-kirichenko

Copy link
Copy Markdown
Contributor Author

Go to props works great 👍

@realvictorprm

realvictorprm commented Aug 20, 2017 via email

Copy link
Copy Markdown
Contributor

@vasily-kirichenko

Copy link
Copy Markdown
Contributor Author

@dotnet-bot test Release_ci_part3 please

@vasily-kirichenko

Copy link
Copy Markdown
Contributor Author

@dotnet-bot test this please

saul and others added 2 commits August 21, 2017 09:18
Comment thread src/fsharp/vs/ExternalSymbol.fs Outdated
| Array of inner: ExternalType
| Pointer of inner: ExternalType
| TypeVar of typeName: string
with

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove with please

None

[<RequireQualifiedAccess>]
type ExternalType =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a /// comment please, also to each union case

Comment thread src/fsharp/vs/ExternalSymbol.fs Outdated
type ParamTypeSymbol =
| Param of ExternalType
| Byref of ExternalType
with

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove with please

Comment thread src/fsharp/vs/ExternalSymbol.fs Outdated
| Field of typeName: string * name: string
| Event of typeName: string * name: string
| Property of typeName: string * name: string
with

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove with please

Comment thread src/fsharp/vs/ExternalSymbol.fsi Outdated
| Array of inner: ExternalType
| Pointer of inner: ExternalType
| TypeVar of typeName: string
with

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove withs please

Comment thread src/fsharp/vs/service.fs

let fail defaultReason =
match item with
| Item.CtorGroup (_, (ILMeth (_,ilinfo,_)) :: _) ->

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically, we should use property accessors on ILMeth rather than pattern matching on its contents. It's not curcial though - we can clean up the code later

let task = tcs.Task
let disposeReg() = barrier.Stop(); if not task.IsCanceled then reg.Dispose()
Async.StartWithContinuations(
async { do! Async.SwitchToThreadPool()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a cosmetic whitespace change?

@dsyme dsyme left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've left minor review comments - it looks great!

More unit testing would be appreciated but I'm OK with merging as @cartermp has tested many cases manually

@cartermp

Copy link
Copy Markdown
Contributor

@dsyme Do you have a recommended place where unit tests could go here? It feels like a good opportunity to create a new test project specifically for the language service, rather than adding on to the older tests which happen to test the language service alongside other changes.

@vasily-kirichenko

Copy link
Copy Markdown
Contributor Author

@dsyme done.

@dsyme

dsyme commented Aug 21, 2017

Copy link
Copy Markdown
Contributor

@dsyme Do you have a recommended place where unit tests could go here?

I believe adding tests to tests\service\... would make sense

Alternatively vsintegration\tests\unittests\GoToDefinitionServiceTests.fs

@KevinRansom
KevinRansom merged commit 9606209 into dotnet:master Aug 21, 2017
@vasily-kirichenko

Copy link
Copy Markdown
Contributor Author

:)

@realvictorprm

realvictorprm commented Aug 21, 2017 via email

Copy link
Copy Markdown
Contributor

| :? OperationCanceledException ->
tcs.TrySetCanceled(cancellationToken) |> ignore
| exn ->
System.Diagnostics.Trace.WriteLine("Visual F# Tools: exception swallowed and not passed to Roslyn: {0}", exn.Message)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nooooo 😱 This wasn't a whitespace change - the old code (that you've reverted to) didn't assert on failure, and Trace.WriteLine doesn't take a format string! This bit me for a while. I'll open another PR fixing this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry, man :(

nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Jan 26, 2022
* go to C# symbols

* fix tests

* cleanup

* fix tests

* support field, events and constructors

* fix tests

* implement IVsSymbolicNavigationNotify

* cleanup

* fix

* cleanup

* Improve package definition specs fro F# VS Package

* Fixed some bugs with nested types with fields/events

* fix compilation

* use AppTy AP

* Add support for overloaded methods, generic methods, generic (nested) classes, constructors

* Jump to property definition instead of getter/setter

* Add ExternalSymbol to FSharp.Compiler.Service.fsproj

* Fix FSharp.Compiler.Private.BuildFromSource.fsproj

* address code review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants