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

Omnisharp not reloading references #4174

Closed
gionapaolini opened this issue Nov 3, 2020 · 18 comments · Fixed by #4178
Closed

Omnisharp not reloading references #4174

gionapaolini opened this issue Nov 3, 2020 · 18 comments · Fixed by #4178

Comments

@gionapaolini
Copy link

gionapaolini commented Nov 3, 2020

Issue Description

Every time I reference a new class and get the quick fixes I don't get the option to add a "using namespace" statement to the file.
Also when I reference a new class contained in a namespace that is already referenced I still get the error:
The type or namespace name 'ClassName' could not be found (are you missing a using directive or an assembly reference?)

To fix it I have to manually restart Omnisharp

Some more context: I'm running VSCode on Docker containers

Steps to Reproduce

  1. Create a simple dotnet core application
  2. Create 2 class files in separate namespaces and reference one in the other

Expected Behavior

You should be able to get the option to add a Using statement when using the Quick Fix feature

Actual Behavior

Quick Fix feature not shown, unless Omnisharp is restarted

Logs

OmniSharp log

Starting OmniSharp server at 11/3/2020, 2:10:59 PM
    Target: /workspace

OmniSharp server started.
    Path: /root/.vscode-server/extensions/ms-dotnettools.csharp-1.23.4/.omnisharp/1.37.3/run
    PID: 1532

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on debian 10.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 1 MSBuild instance(s)
            1: StandAlone 16.8.0 - "/root/.vscode-server/extensions/ms-dotnettools.csharp-1.23.4/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        MSBUILD_EXE_PATH environment variable set to '/root/.vscode-server/extensions/ms-dotnettools.csharp-1.23.4/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin/MSBuild.exe'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: StandAlone 16.8.0 - "/root/.vscode-server/extensions/ms-dotnettools.csharp-1.23.4/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin"
            CscToolExe = csc.exe
            MSBuildToolsPath = /root/.vscode-server/extensions/ms-dotnettools.csharp-1.23.4/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin
            CscToolPath = /root/.vscode-server/extensions/ms-dotnettools.csharp-1.23.4/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin/Roslyn
            BypassFrameworkInstallChecks = true
            MSBuildExtensionsPath = /root/.vscode-server/extensions/ms-dotnettools.csharp-1.23.4/.omnisharp/1.37.3/omnisharp/.msbuild
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in '/workspace'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
        No solution files found in '/workspace'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/workspace/ContentEditor.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in '/workspace'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /workspace/ContentEditor.csproj
[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.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location '/workspace' on host 371.
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file '/workspace/ContentEditor.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project '/workspace/ContentEditor.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: ContentEditor

C# log

Installing C# dependencies...
Platform: linux, x86_64, name=debian, version=10

Downloading package 'OmniSharp for Linux (x64)' (47313 KB).................... Done!
Validating download...
Integrity Check succeeded.
Installing package 'OmniSharp for Linux (x64)'

Downloading package '.NET Core Debugger (linux / x64)' (55714 KB).................... Done!
Validating download...
Integrity Check succeeded.
Installing package '.NET Core Debugger (linux / x64)'

Downloading package 'Razor Language Server (Linux / x64)' (54208 KB).................... Done!
Installing package 'Razor Language Server (Linux / x64)'

Finished

Environment information

VSCode version: 1.50.1
C# Extension: 1.23.4

Mono Information OmniSharp using built-in mono
Dotnet Information .NET Core SDK (reflecting any global.json): Version: 3.1.403 Commit: 9e895200cd

Runtime Environment:
OS Name: debian
OS Version: 10
OS Platform: Linux
RID: debian.10-x64
Base Path: /usr/share/dotnet/sdk/3.1.403/

Host (useful for support):
Version: 3.1.9
Commit: 774fc3d6a9

.NET Core SDKs installed:
3.1.403 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.1.9 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.9 [/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.4
@tverboon
Copy link

tverboon commented Nov 4, 2020

You are using version 1.23.4. 1.23.5 is even worse for me. It looks like new files are never added to the in memory workspace, while in previous releases new files were found most of the time after a little delay.

@333fred could #4141 or #4143 have something to do with this?

I am not running in a Docker context.

@333fred
Copy link
Member

333fred commented Nov 4, 2020

Likely, I can reproduce it locally. I'll take a look. Thanks for the tag @tverboon.

@333fred
Copy link
Member

333fred commented Nov 4, 2020

1.23.5 is even worse for me.

FWIW, I would very much expect .5 to be better than .4 here. I made a couple of bug fixes for .5, .4 will have very bad behavior if an external editor changes the file on disk.

@tverboon
Copy link

tverboon commented Nov 5, 2020

Yeah, sorry, I couldn't find the right words. It wasn't meant to say this complete version is worse, but I just started a new library project, so I am adding a lof of new files at the moment 😄 .

I am following your work on Omnisharp and it's obvious you are really pushing this forward to give us a better experience. Thanks for that!

@JoeRobich
Copy link
Member

A fix is available in this pre-release build - https://github.com/OmniSharp/omnisharp-vscode/releases/tag/v1.23.6-beta1. Instructions for installing our beta releases https://github.com/OmniSharp/omnisharp-vscode/wiki/Installing-Beta-Releases

@Katekko
Copy link

Katekko commented Nov 10, 2020

A fix is available in this pre-release build - https://github.com/OmniSharp/omnisharp-vscode/releases/tag/v1.23.6-beta1. Instructions for installing our beta releases https://github.com/OmniSharp/omnisharp-vscode/wiki/Installing-Beta-Releases

Here its not working yet... :(

#4192 (comment)

@333fred
Copy link
Member

333fred commented Nov 10, 2020

It sounds like the issue you're experience is unrelated Katekko.

@gionapaolini
Copy link
Author

gionapaolini commented Nov 17, 2020

@333fred I'm still experiencing the same issue. Not sure if it's related to vscode-server (i'm working inside a docker container).
I can reproduce simply by copying a .cs file. Omnisharp won't work on that new copied file.

Also I noticed that restarting omnisharp does not always fix the issue, but it seems that when that fails I can just reload the window and that will succeed in fixing the issue.

@333fred
Copy link
Member

333fred commented Nov 17, 2020

We haven't released 1.23.6 yet.

@gionapaolini
Copy link
Author

gionapaolini commented Nov 17, 2020

@333fred I can see it here https://github.com/OmniSharp/omnisharp-vscode/releases/tag/v.1.23.6
And the C# version on vscode is 1.23.6

Am I missing something?

@333fred
Copy link
Member

333fred commented Nov 17, 2020

@JoeRobich did we release this yet? I didn't think we did.

@JoeRobich
Copy link
Member

@333fred We have.

@333fred
Copy link
Member

333fred commented Nov 17, 2020

@gionapaolini then can you please open a new bug with repro instructions?

@gionapaolini
Copy link
Author

Sure, I tried reproducing with a simple case using docker containers, but I wasn't able to reproduce.
I think it might have something to do either with Volumes or Kubernetes, since in my case I'm using both (development inside K8S).
I'll create a new ticket when I have more time to find the steps to reproduce.
In any case thanks for your work.

@ManfredLange
Copy link

This issue has not been resolved with release 1.23.6 unfortunately. Here is an output from "Omnisharp Log" after creating a new file then typing in a namespace plus a new class plus a new method.

Could not find document for file /app/src/PiranhaNH.Tests/FooTests.cs

It's easy to reproduce:

  1. Create a console project targeting either netcoreappp3.1 or net5.0
  2. Create a new file in the same folder as the project file
  3. Add reference to NUnit framework
  4. Add the code below. No suggestion to adding the NUnit.Framework reference will be made

Code in a new file:

namespace Bar
{
    [TestFixture]
    public class FooTests
    {
        [Test]
        public void Foobar()
        {

        }
    }
}

The screenshot shows that no actions are available either to add the using statement / reference:
2020-11-21_11-11-10

Saving the file makes no difference.
(Re-)building the project makes no difference.
Restarting omnisharp-vscode with "OmniSharp: Restart OmniSharp" solve the problem

Note, though, that on average I probably have to restart OmniSharp every 5 to 10 minutes. It's quite a significant impediment to working faster.

I'll probably file this as a separate issue, since this affects version 1.23.6

@333fred
Copy link
Member

333fred commented Nov 20, 2020

@ManfredLange can you try setting omnisharp.path to latest as well? We have another bug fix on the server-side that might fix it for you. If not, then please do open a new issue.

@ManfredLange
Copy link

@333fred Thank you! I set omnisharp.path to latest as well. It then installed version 1.37.4-beta.61. However, that didn't change the behavior. Same error message.

From the OmniShar log:

OmniSharp server started.
Path: /home/piranha/.vscode-server/extensions/ms-dotnettools.csharp-1.23.6/.omnisharp/1.37.4-beta.61/run
PID: 959

As suggested I'll open a new issue.

@ManfredLange
Copy link

New issue filed: see #4223

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 a pull request may close this issue.

6 participants