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

C# to F# go to definition navigates to metadata, and not the source code #13882

Closed
oleksandr-bilyk opened this issue Sep 12, 2022 · 14 comments · Fixed by #14377
Closed

C# to F# go to definition navigates to metadata, and not the source code #13882

oleksandr-bilyk opened this issue Sep 12, 2022 · 14 comments · Fixed by #14377
Assignees
Labels
Area-LangService-Navigation go to definition, F1 help + the FCS APIs related to it Feature Request release/17.5
Milestone

Comments

@oleksandr-bilyk
Copy link

Every year we have to buy Rider because Rider allows to navigate from C# code to F# method definition.
We had big expectations that VS2022 will support such a basic feature but not.
Our team decided to use F# in solution where we have many C# and F# projects calling each other.
This small feature is very important for future use of F# in our solutions.

@vzarytovskii
Copy link
Member

vzarytovskii commented Sep 12, 2022

@tmat do you have any insights on how should we approach it?

My guess is that we theoretically can provide either IGoToDefinitionSymbolService , IFindDefinitionService or ISymbolMappingService, which can provide needed info to Roslyn, however it is tied to ISymbol, not sure what is the correct approach here.

@smoothdeveloper
Copy link
Contributor

@oleksandr-bilyk please consider appending your experience in this discussion: dotnet/csharplang#6412 (comment)

it is about "C#-adjacent tooling experience" from C# Language Design Meeting notes discussions.

The reverse navigation works (Go To Definition on C# member from F# code reaches), which I think came at some point in VS 2019.

@vzarytovskii vzarytovskii changed the title C# code go to definition navigate to F# code C# to F# go to definition navigates to metadata, and not the source code Sep 13, 2022
@vzarytovskii vzarytovskii self-assigned this Sep 13, 2022
@vzarytovskii vzarytovskii added Area-LangService-Navigation go to definition, F1 help + the FCS APIs related to it Area-VS VS support for F# not covered elsewhere labels Sep 13, 2022
@vzarytovskii vzarytovskii moved this to Not Planned in F# Compiler and Tooling Sep 13, 2022
@vzarytovskii vzarytovskii added this to the Backlog milestone Sep 13, 2022
@tmat
Copy link
Member

tmat commented Sep 13, 2022

@CyrusNajmabadi IIRC LSP should be able to handle this, correct?

@vzarytovskii
Copy link
Member

dotnet/roslyn#64010 is in, will experiment with it next week

@vzarytovskii vzarytovskii modified the milestones: Backlog, September-2022 Sep 15, 2022
@vzarytovskii vzarytovskii moved this from Not Planned to Planned in F# Compiler and Tooling Sep 15, 2022
@kerams
Copy link
Contributor

kerams commented Sep 15, 2022

The reverse navigation works (Go To Definition on C# member from F# code reaches),

You say that, but it stopped working for me with yesterday's VS preview update :).

@vzarytovskii
Copy link
Member

vzarytovskii commented Sep 15, 2022

The reverse navigation works (Go To Definition on C# member from F# code reaches),

You say that, but it stopped working for me with yesterday's VS preview update :).

Works for me:
image
image

Do you have any specific example?

@kerams
Copy link
Contributor

kerams commented Sep 15, 2022

image

BCL/external dependency metadata navigation. I'm pressing F12 on this to no avail (it used to work). Perhaps it's a different use case.

@vzarytovskii
Copy link
Member

image

BCL/external dependency metadata navigation. I'm pressing F12 on this to no avail (it used to work). Perhaps it's a different use case.

Yep, doesn't work for me for Newtonsoft.Json.

@vzarytovskii
Copy link
Member

I hopefully can fix it in one batch with C#->F# navigation.

@smoothdeveloper
Copy link
Contributor

@kerams / @vzarytovskii I noticed in some F# editor "go to definition" use cases, it will generate F# signature (of C# code).

IMO, generating F# signatures is relevant, only if those cases don't resolve:

  • project reference, with the source file
  • assembly reference with pdb pointing to source file
  • sourcelink

AND if, the assembly referenced is compiled with F#.

If it is not the case, it is probably better to do what the C# editor would do.

@vzarytovskii and @CyrusNajmabadi, thanks for giving a shot at the C# -> F# code navigation, this is going to help a lot.

@vzarytovskii
Copy link
Member

IMO, generating F# signatures is relevant, only if those cases don't resolve:

  • project reference, with the source file

I think, if we know that we have source, we will navigate to it.

  • assembly reference with pdb pointing to source file
  • sourcelink

Not sure about these. Will try to remember and look at it. When I navigate to "WriteLine" source code now, it brings me to the source (not sure whether via sourcelink ok pdbs).

@dsyme dsyme removed the Area-VS VS support for F# not covered elsewhere label Sep 23, 2022
@dsyme
Copy link
Contributor

dsyme commented Sep 23, 2022

@vzarytovskii I removed the VS label - trying to keep to one most-specific Area label per issue, unless it really is across multiple areas

@dsyme
Copy link
Contributor

dsyme commented Sep 26, 2022

Closing #3497 as a duplicate of this more recent one. There is interesting information there on prototype attempts to address this

@vzarytovskii
Copy link
Member

vzarytovskii commented Oct 10, 2022

Note: new API with assembly name included: dotnet/roslyn#64475
Will make changes in the WIP branch, once back next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-LangService-Navigation go to definition, F1 help + the FCS APIs related to it Feature Request release/17.5
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

6 participants