-
Notifications
You must be signed in to change notification settings - Fork 666
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 ignores code in newly added source files #4223
Comments
Another observation: Moving the new file to a different folder within the project doesn't even cause the message It appears as if certain file events are not picked up in all cases, e.g. when a new file is created or when a file is moved to a new location (which might trigger the same or a different event). I'm just guessing here as I am not familiar with the inner workings of VS Code or how extensions interact with it. |
Can you give a more detailed set of repro steps? For example, I see no issues with this:
|
@333fred I'll create a minimal repro repo and provide detailed steps to reproduce. |
@333fred A minimal repo with detailed steps to reproduce is available at https://github.com/ManfredLange/issue-201121 Steps to reproduce are in file README.md of that repo. It appears as if OmniSharp doesn't pick up any change when a file is created, moved or deleted. Please do let me know if you need further details. If you still cannot reproduce this issue, please let me know as well. I'm happy to arrange a zoom call if that helps. |
Looking at those steps, it seems likely it's docker-specific. I'll try to take a look sometime this weekend, but I have never used the container development model so it may take me a bit. |
@333fred I agree. With futher experiments I tried to eliminate elements from the picture. I tried this:
Therefore I now tend to believe that this is related to the missing notification issue of WSL2, aka "inotify". WSL2 doesn't have a solution right now for creating inotify events for Windows file systems to the Linux file system running in the container. This issue has tripped up other people as well. It has been submitted in a few places:
It has also been discussed on StackOverflow, e.g. here https://stackoverflow.com/q/64689585/411428 Microsoft themselves suggest to store the files in the same file system on the host as is used in the container. So this would mean to store in the Linux file system on Windows. For example see the note half-way down this article: https://docs.microsoft.com/en-us/windows/wsl/tutorials/wsl-containers Howeve, this article does not specify in more detail how to work with a git clone, WSL2, a distro, and a Docker Container and how all of that works together. I believe I now have learned how to make this work and intend to write an article over the next few weeks that hopefully allows others avoid this problem in the first place. The fact that WSL2 does not send inotify events to Linux file systems and that Microsoft did not provide a solution at this stage has probably caused a large number of wasted hours. Not only mine, but those of other people as well. What a shame! :-) I think we can close this issue for now. Once I have an article with the details I intend to post a link here as well. |
As promised I wrote an article that describes the details of the root cause of this problem and how to avoid it: Article on Medium.com: "Docker Desktop on WSL2: The Problem with Mixing File Systems" |
I am getting this error for 1.23.8. I reverted to 1.23.3 and the issue is no longer experienced. |
I also downgraded to 1.23.3 as a workaround. Any version above that does not work in Windows or in WSL. |
You do not have to downgrade to 1.23.3 if you are using Windows.
It should get solved. |
Issue Description
Omnisharp ignores code in new files, e.g. when a file with C# code is added, no suggestions are made. This includes not making suggestions for adding appropriate using statements for class identifiers in referenced assemblies, e.g. TestFixture in package NUnit.
Steps to Reproduce
Set
"omnisharp.path"
to"latest"
. At the time of writing this will install version1.37.4-beta.61
Open a folder with a C# project, e.g. a test project that references NUnit.Framework
Create a new file for a class inside of a namespace, e.g. namespace
Foo
and classBar
. Have the implementation use a class exists in a referenced assembly, e.g. NUnit.FrameworkOmnisharp will not make any suggestions to add the using statement for NUnit.Framework. OmniSharp Log will have entries as follows:
However, the file does exist at that location.
Other things I tried:
Expected Behavior
Omnisharp should pick up the content of the new file. A restart of OmniSharp should not be required.
Actual Behavior
Requires frequent restart of Omnisharp server
Please let me know in case you cannot reproduce this. I'll then attempt to provide a minimal repro git repo.
Logs
OmniSharp 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
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 - "/home/piranha/.vscode-server/extensions/ms-dotnettools.csharp-1.23.6/.omnisharp/1.37.4-beta.61/omnisharp/.msbuild/Current/Bin"
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
MSBUILD_EXE_PATH environment variable set to '/home/piranha/.vscode-server/extensions/ms-dotnettools.csharp-1.23.6/.omnisharp/1.37.4-beta.61/omnisharp/.msbuild/Current/Bin/MSBuild.exe'
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: StandAlone 16.8.0 - "/home/piranha/.vscode-server/extensions/ms-dotnettools.csharp-1.23.6/.omnisharp/1.37.4-beta.61/omnisharp/.msbuild/Current/Bin"
CscToolExe = csc.exe
MSBuildToolsPath = /home/piranha/.vscode-server/extensions/ms-dotnettools.csharp-1.23.6/.omnisharp/1.37.4-beta.61/omnisharp/.msbuild/Current/Bin
CscToolPath = /home/piranha/.vscode-server/extensions/ms-dotnettools.csharp-1.23.6/.omnisharp/1.37.4-beta.61/omnisharp/.msbuild/Current/Bin/Roslyn
BypassFrameworkInstallChecks = true
MSBuildExtensionsPath = /home/piranha/.vscode-server/extensions/ms-dotnettools.csharp-1.23.6/.omnisharp/1.37.4-beta.61/omnisharp/.msbuild
info: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in '/app'.
info: OmniSharp.Cake.CakeProjectSystem
Could not find any Cake files
info: OmniSharp.MSBuild.ProjectSystem
Detecting projects in '/app/RimuTec.Piranha.sln'.
info: OmniSharp.MSBuild.ProjectManager
Queue project update for '/app/src/PiranhaNH/PiranhaNH.csproj'
info: OmniSharp.MSBuild.ProjectManager
Queue project update for '/app/src/PiranhaNH.Tests/PiranhaNH.Tests.csproj'
info: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in '/app'.
info: OmniSharp.MSBuild.ProjectManager
Loading project: /app/src/PiranhaNH/PiranhaNH.csproj
info: OmniSharp.Script.ScriptProjectSystem
Could not find any CSX files
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 '/app' on host 177.
info: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file '/app/src/PiranhaNH/PiranhaNH.csproj'.
info: OmniSharp.MSBuild.ProjectManager
Adding project '/app/src/PiranhaNH/PiranhaNH.csproj'
info: OmniSharp.MSBuild.ProjectManager
Loading project: /app/src/PiranhaNH.Tests/PiranhaNH.Tests.csproj
info: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file '/app/src/PiranhaNH.Tests/PiranhaNH.Tests.csproj'.
info: OmniSharp.MSBuild.ProjectManager
Adding project '/app/src/PiranhaNH.Tests/PiranhaNH.Tests.csproj'
info: OmniSharp.MSBuild.ProjectManager
Update project: PiranhaNH
info: OmniSharp.MSBuild.ProjectManager
Update project: PiranhaNH.Tests
info: OmniSharp.Roslyn.CSharp.Services.Diagnostics.CSharpDiagnosticWorkerWithAnalyzers
Solution initialized -> queue all documents for code analysis. Initial document count: 28.
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file /app/src/Foo22Tests.cs
C# log
Downloading package 'OmniSharp for Linux (x64), Version = 1.37.4-beta.61' (47240 KB).................... Done!
Installing package 'OmniSharp for Linux (x64), Version = 1.37.4-beta.61'
Finished
Environment information
VSCode version: 1.51.1
C# Extension: 1.23.6
OmniSharp: 1.37.4-beta.61
Host: Windows 10
Docker Desktop for Windows: 2.5.0.1
Base image: mcr.microsoft.com/dotnet/sdk:5.0
Note that this base image does not come with
ps
installed, Withoutps
restarting omnisharp-vscode is not possible. Other omnisharp-vscode commands depend onps
as well and won't work withoutps
.The first few lines of the Dockerfile need to look similar to this:
Mono Information
OmniSharp using built-in monoDotnet Information
.NET SDK (reflecting any global.json): Version: 5.0.100 Commit: 5044b93829Runtime Environment:
OS Name: debian
OS Version: 10
OS Platform: Linux
RID: debian.10-x64
Base Path: /usr/share/dotnet/sdk/5.0.100/
Host (useful for support):
Version: 5.0.0
Commit: cf258a14b7
.NET SDKs installed:
5.0.100 [/usr/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 5.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 5.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
Visual Studio Code Extensions
The text was updated successfully, but these errors were encountered: