You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Clone the following project designed to demonstrate the problem:
Let OmniSharp load and initialize itself. Note there are no errors shown.
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
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
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.
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
Clone the following project designed to demonstrate the problem:
https://github.com/toptensoftware/crossplat-test
Open the project folder in VS Code
Let OmniSharp load and initialize itself. Note there are no errors shown.
Note how the
omnisharp.json
file says to exclude the projectcrossplat-test.osx.csproj
and how the project filecrossplat-test.win.csproj
says to exclude the PlatformOsx sub-folderMake 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: 6ea70c8dcaRuntime 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
The text was updated successfully, but these errors were encountered: