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

Edits in excluded project sub-directories causes Omnisharp to incorrectly report errors. #3838

Closed
toptensoftware opened this issue Jun 10, 2020 · 2 comments

Comments

@toptensoftware
Copy link

Issue Description

When a .csproj file excludes sub-directories from the build, Omnisharp incorrectly reports errors when files in those excluded sub-directories are edited.

Steps to Reproduce

  1. Clone the following project designed to demonstrate the problem:

    https://github.com/toptensoftware/crossplat-test

  2. Open the project folder in VS Code

  3. Let OmniSharp load and initialize itself. Note there are no errors shown.

  4. Note how the omnisharp.json file says to exclude the project crossplat-test.osx.csproj and how the project file crossplat-test.win.csproj says to exclude the PlatformOsx sub-folder

  5. Make a change to the file PlatformOsx/implProgram.cs file. Even just changing the white space is enough.

To explain this configuration, this is a simplified version of a cross platform project I'm working on where we use partial classes for the platform specific part of the implementation. Each class is split into a common part (Program.cs) and a per-platform implementation part (implProgram.cs) with the implementation part for each platform in sub-directories named according to the platform (ie: PlatformWin and PlatformOsx). A csproj for each project (*.win.csproj and *.osx.csproj) is configured to only include one of the platform sub-directories in the build.

The omnisharp.json file is configured to exclude the .win.csproj or .osx.csproj file according to whichever platform we happen to be working on so that intellisense works reasonably (ie: jump to definitely goes to the implementation we're currently working on).

Expected Behavior

Changes to the file PlatformOsx/implProgram.cs should be ignored by omnisharp according to the omnisharp.json file and the configuration of the projects it loads.

Actual Behavior

After editing the file as described above, the Omnisharp incorrectly indicates errors in both implProgram.cs and Program.cs.

Invoking Restart Omnisharp command causes the errors go away.

Logs

OmniSharp log

Starting OmniSharp server at 10/06/2020, 7:57:02 pm
Target: c:\Users\Brad\Projects\crossplat-test

OmniSharp server started.
Path: c:\Users\Brad.vscode\extensions\ms-dotnettools.csharp-1.22.0.omnisharp\1.35.2\OmniSharp.exe
PID: 26280

Starting OmniSharp on Windows 6.2.9200.0 (x64)
info: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 3 MSBuild instance(s)
1: Visual Studio Community 2019 16.4.29728.190 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin"
2: Visual Studio Community 2017 15.9.28307.812 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin"
3: StandAlone 16.4 - "c:\Users\Brad.vscode\extensions\ms-dotnettools.csharp-1.22.0.omnisharp\1.35.2.msbuild\Current\Bin"
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: Visual Studio Community 2019 16.4.29728.190 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin"
info: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in 'c:\Users\Brad\Projects\crossplat-test'.
info: OmniSharp.Cake.CakeProjectSystem
Could not find any Cake files
info: OmniSharp.MSBuild.ProjectSystem
No solution files found in 'c:\Users\Brad\Projects\crossplat-test'
info: OmniSharp.MSBuild.ProjectManager
Queue project update for 'c:\Users\Brad\Projects\crossplat-test\crossplat-test.win.csproj'
info: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in 'c:\Users\Brad\Projects\crossplat-test'.
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.MSBuild.ProjectManager
Loading project: c:\Users\Brad\Projects\crossplat-test\crossplat-test.win.csproj
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 'c:\Users\Brad\Projects\crossplat-test' on host 45312.
info: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file 'c:\Users\Brad\Projects\crossplat-test\crossplat-test.win.csproj'.
info: OmniSharp.MSBuild.ProjectManager
Adding project 'c:\Users\Brad\Projects\crossplat-test\crossplat-test.win.csproj'
info: OmniSharp.MSBuild.ProjectManager
Update project: crossplat-test.win

C# log

Nothing in log

Environment information

VSCode version: 1.45.1
C# Extension: 1.22.0

Dotnet Information .NET Core SDK (reflecting any global.json): Version: 3.1.202 Commit: 6ea70c8dca

Runtime Environment:
OS Name: Windows
OS Version: 10.0.18362
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.1.202\

Host (useful for support):
Version: 3.1.4
Commit: 0c2e69caa6

.NET Core SDKs installed:
2.0.2 [C:\Program Files\dotnet\sdk]
2.1.104 [C:\Program Files\dotnet\sdk]
2.1.200 [C:\Program Files\dotnet\sdk]
2.1.201 [C:\Program Files\dotnet\sdk]
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.402 [C:\Program Files\dotnet\sdk]
2.1.403 [C:\Program Files\dotnet\sdk]
2.1.507 [C:\Program Files\dotnet\sdk]
2.1.508 [C:\Program Files\dotnet\sdk]
2.1.801 [C:\Program Files\dotnet\sdk]
3.1.101 [C:\Program Files\dotnet\sdk]
3.1.202 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download

Visual Studio Code Extensions
Extension Author Version
Bookmarks alefragnani 11.2.0
csharp ms-dotnettools 1.22.0
docomment k--kato 0.1.11
vscode-modern-vhdl-support rjyoung 1.0.5
@SirIntruder
Copy link

SirIntruder commented Jul 1, 2020

It's possible this PR would fix this issue OmniSharp/omnisharp-roslyn#1841

MSBuild knows that PlatformOsx/implProgram.cs should belong to crossplat-test.osx.csproj, and that information is used to create "gaps" in glob patterns of other projects in the solution. But o# currently ignores this, so changes in PlatformOsx folder trigger naive search over surrounding folders, which wrongly identifies some other random project as an owner of PlatformOsx/implProgram.cs.

@toptensoftware
Copy link
Author

Hi @SirIntruder

Thanks... that sure sounds like the same thing. Look forward to seeing this in future builds.

Brad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants