dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.85k stars 667 forks source link

Tooltips, peeking and ctrl+clicking don't work when project source in inside src folder #5011

Open Asghwor opened 2 years ago

Asghwor commented 2 years ago

Issue Description

When the source code is inside the src/ folder, and not directly in the root path, hovering class and interface names doesn't show any tooltips, and the peeking and ctrl+clicking functionality is missing. When opening the src folder directly it works, however.

Steps to Reproduce

  1. Create dotnet project.
  2. Create src/ folder.
  3. Put C# source code inside the src/ folder
  4. Try to use peek, hovering class and interface names and ctrl+clicking elements.

Expected Behavior

Tooltips, peek and ctrl+clicking elements should work even if the source code is inside the src/ folder.

Actual Behavior

Tooltips, peek and ctrl+clicking elements don't work when the source code is inside the src/ folder.

Logs

OmniSharp log

Starting OmniSharp server at 19/01/2022, 09:14:04 Target: /home/my-name/path-to-project/docs/samples/CosmosGettingStarted.sln OmniSharp server started. Path: /home/my-name/.vscode/extensions/ms-dotnettools.csharp-1.23.17/.omnisharp/1.37.17/run PID: 22822 [info]: OmniSharp.Stdio.Host Starting OmniSharp on ubuntu 18.4 (x64) [info]: OmniSharp.Services.DotNetCliService Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK [info]: OmniSharp.Services.DotNetCliService Using the 'dotnet' on the PATH. [info]: OmniSharp.Services.DotNetCliService DotNetPath set to dotnet [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator Located 1 MSBuild instance(s) 1: StandAlone 17.0.0 - "/home/my-name/.vscode/extensirions/ms-dotnettools.csharp-1.23.17/.omnisharp/1.37.17/omnisharp/.msbuild/Current/Bin" [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator MSBUILD_EXE_PATH environment variable set to '/home/my-name/.vscode/extensions/ms-dotnettools.csharp-1.23.17/.omnisharp/1.37.17/omnisharp/.msbuild/Current/Bin/MSBuild.exe' [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator Registered MSBuild instance: StandAlone 17.0.0 - "/home/my-name/.vscode/extensions/ms-dotnettools.csharp-1.23.17/.omnisharp/1.37.17/omnisharp/.msbuild/Current/Bin" CscToolExe = csc.exe MSBuildToolsPath = /home/my-name/.vscode/extensions/ms-dotnettools.csharp-1.23.17/.omnisharp/1.37.17/omnisharp/.msbuild/Current/Bin CscToolPath = /home/my-name/.vscode/extensions/ms-dotnettools.csharp-1.23.17/.omnisharp/1.37.17/omnisharp/.msbuild/Current/Bin/Roslyn BypassFrameworkInstallChecks = true MSBuildExtensionsPath = /home/my-name/.vscode/extensions/ms-dotnettools.csharp-1.23.17/.omnisharp/1.37.17/omnisharp/.msbuild [info]: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0 [info]: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0 [info]: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100 [info]: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110 [info]: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140 [info]: OmniSharp.Cake.CakeProjectSystem Detecting Cake files in '/home/my-name/path-to-project/docs/samples'. [info]: OmniSharp.Cake.CakeProjectSystem Could not find any Cake files [info]: OmniSharp.MSBuild.ProjectSystem Detecting projects in '/home/my-name/path-to-project/docs/samples/CosmosGettingStarted.sln'. [info]: OmniSharp.MSBuild.ProjectManager Queue project update for '/home/my-name/path-to-project/docs/samples/CosmosGettingStartedTutorial/CosmosGettingStarted.csproj' [info]: OmniSharp.Script.ScriptProjectSystem Detecting CSX files in '/home/my-name/path-to-project/docs/samples'. [info]: OmniSharp.Script.ScriptProjectSystem Could not find any CSX files [info]: OmniSharp.WorkspaceInitializer Configuration finished. [info]: OmniSharp.Stdio.Host Omnisharp server running using Stdio at location '/home/my-name/path-to-project/docs/samples' on host 22758. [info]: OmniSharp.MSBuild.ProjectManager Loading project: /home/my-name/path-to-project/docs/samples/CosmosGettingStartedTutorial/CosmosGettingStarted.csproj [info]: OmniSharp.MSBuild.ProjectManager Successfully loaded project file '/home/my-name/path-to-project/docs/samples/CosmosGettingStartedTutorial/CosmosGettingStarted.csproj'. [info]: OmniSharp.MSBuild.ProjectManager Adding project '/home/my-name/path-to-project/docs/samples/CosmosGettingStartedTutorial/CosmosGettingStarted.csproj' [info]: OmniSharp.MSBuild.ProjectManager Update project: CosmosGettingStarted

C# log

Post the output from Output-->C# here

Environment information

VSCode version: 1.63.2 C# Extension: 1.23.17

Mono Information OmniSharp using built-in mono
Dotnet Information .NET Core SDK (reflecting any global.json): Version: 3.1.416 Commit: 8d3765c609 Runtime Environment: OS Name: ubuntu OS Version: 18.04 OS Platform: Linux RID: ubuntu.18.04-x64 Base Path: /usr/share/dotnet/sdk/3.1.416/ Host (useful for support): Version: 3.1.22 Commit: 35fa579a30 .NET Core SDKs installed: 3.1.416 [/usr/share/dotnet/sdk] .NET Core runtimes installed: Microsoft.AspNetCore.App 3.1.22 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.22 [/usr/share/dotnet/shared/Microsoft.NETCore.App] To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download
Visual Studio Code Extensions |Extension|Author|Version| |---|---|---| |csharp|ms-dotnettools|1.23.17|;
filipw commented 2 years ago

This is not a bug, but normal MSBuild behavior. According to your logs you have your current solution file under:

/home/my-name/path-to-project/docs/samples/CosmosGettingStarted.sln

with one project file

 /home/my-name/path-to-project/docs/samples/CosmosGettingStartedTutorial/CosmosGettingStarted.csproj

if you now create files under

 /home/my-name/path-to-project/src

they do not belong to any project. Also, even if they did, your currently loaded solution CosmosGettingStarted.sln only contains a single project CosmosGettingStarted.csproj so only code from that project would be active.

Make sure your new code belongs to a project and that that particular project is correctly added to your open solution. You can use the OmniSharp: Select project... from the command palette to switch between projects.

Asghwor commented 2 years ago

Apparently there is a project inside src, which it uses when I open src directly.

However, when I try to run OmniSharp: Select project..., it shows me the following message:

Extension 'ms-dotnettools.csharp' CANNOT use API proposal: quickPickSeparators. Its package.json#enabledApiProposals-property declares: [] but NOT quickPickSeparators. The missing proposal MUST be added and you must start in extension development mode or use the following command line switch: --enable-proposed-api ms-dotnettools.csharp

So I cannot change it.