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

Missing predefined types and namespaces #2295

Closed
coldacid opened this issue May 12, 2018 · 16 comments
Closed

Missing predefined types and namespaces #2295

coldacid opened this issue May 12, 2018 · 16 comments

Comments

@coldacid
Copy link

Environment data

dotnet --info output:

.NET Command Line Tools (2.1.200)

Product Information:
 Version:            2.1.200
 Commit SHA-1 hash:  2edba8d7f1

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

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.7
  Build    : 2d61d0b043915bc948ebf98836fefe9ba942be11

VS Code version: 1.23.1
C# Extension version: 1.15.1 (OmniSharp 1.30.0)

Steps to reproduce

After opening an existing project, all source files in the project are flagged with these errors (types and namespaces can be treated as wildcards as all predefined types, top-level namespaces, and types imported from referenced packages or the framework itself are error-flagged):

  • Predefined type 'System.Object' is not defined or imported
  • The type of namespace name 'System' could not be found in the global namespace (are you missing an assembly reference?)

Per issue #1855 I do have a valid and up to date install of Visual Studio 2017 Community as selected by OmniSharp:

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Visual Studio Community 2017 15.7.27703.2000 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin"
            2: StandAlone 15.0 - "C:\Users\Chris\.vscode\extensions\ms-vscode.csharp-1.15.1\.omnisharp\1.30.0\msbuild\15.0\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Visual Studio Community 2017 15.7.27703.2000 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin"

I've confirmed that the path to MSBuild for VS 2017 exists and contains a functional install of MSBuild.

Expected behavior

Predefined types, and both namespaces and types from referenced packages would not be marked as errors.

Actual behavior

Red squigglies. Red squigglies everywhere. And every source file in the project shown in red in the workspace explorer pane.

@rchande
Copy link

rchande commented May 14, 2018

@coldacid Does your project do any multitargeting (per #2095 ) ?

@coldacid
Copy link
Author

@rchande No, it's solely targeted to net462.

@DustinCampbell
Copy link
Member

Are there any errors or warnings in your OmniSharp Log?

@coldacid
Copy link
Author

Nothing but info messages. Path names changed to protect the innocent.

Starting OmniSharp server at 2018-5-14 16:27:10
    Target: c:\Users\Chris\Work\PROJECT-NAME\PROJECT-NAME.sln

OmniSharp server started
    Path: C:\Users\Chris\.vscode\extensions\ms-vscode.csharp-1.15.1\.omnisharp\1.30.0\OmniSharp.exe
    PID: 29564

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Visual Studio Community 2017 15.7.27703.2000 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin"
            2: StandAlone 15.0 - "C:\Users\Chris\.vscode\extensions\ms-vscode.csharp-1.15.1\.omnisharp\1.30.0\msbuild\15.0\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Visual Studio Community 2017 15.7.27703.2000 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin"
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in 'c:\Users\Chris\Work\PROJECT-NAME'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Initializing in c:\Users\Chris\Work\PROJECT-NAME
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Auto package restore: False
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Update workspace context
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Resolving projects references
[info]: OmniSharp.MSBuild.ProjectSystem
        Detecting projects in 'c:\Users\Chris\Work\PROJECT-NAME\PROJECT-NAME.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Users\Chris\Work\PROJECT-NAME\PROJECT-NAME.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\Users\Chris\Work\PROJECT-NAME\PROJECT-NAME.csproj
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'c:\Users\Chris\Work\PROJECT-NAME'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.Stdio.Host
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.Stdio.Host
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location 'c:\Users\Chris\Work\PROJECT-NAME' on host 28548.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'c:\Users\Chris\Work\PROJECT-NAME\PROJECT-NAME.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: PROJECT-NAME
[info]: OmniSharp.MSBuild.ProjectManager
        Found referenced project outside root directory: c:\Users\Chris\Repos\structurizr-dotnet\Structurizr.Annotations\Structurizr.Annotations.csproj

@rchande
Copy link

rchande commented May 14, 2018

@coldacid And just to confirm, you are able to dotnet restore and dotnet build without errors?

@coldacid
Copy link
Author

@rchande That is correct.

@roycefanproxy
Copy link

I encounter the same bug when using vscode version 1.23.1 to open coreapp2.0 project. However, opening a netstandard2.0 project doesn't trigger this bug.

@coldacid
Copy link
Author

I just remembered that one of the referenced projects is multi-targeted, but not my main project, in case that makes a difference.

@DustinCampbell
Copy link
Member

That may make a difference. I suspect this is the same issue as #2095. Is there any chance that you'd be willing to share your project with us to reproduce the issue?

@coldacid
Copy link
Author

It's not my place to make the decision to share, but I'll try and put together a repro case project when I get home tonight.

@DustinCampbell
Copy link
Member

That would be fantastic. Thanks!

@coldacid
Copy link
Author

Here's the repro. It looks like it might very well be the reference to the multi-targeted external project; commenting out the <ProjectReference/> tag for it and reloading OmniSharp makes the problem go away in this repro, while leaving it as-is causes the error.

When trying the repro please make sure to clone the external projects as described in the readme file inside the zip.

@DustinCampbell
Copy link
Member

Thanks very much for the repro. I can definitely reproduce the issue. This will be very helpful.

@DustinCampbell
Copy link
Member

Again, thanks very much for the repro. I have a fix prototyped.

@DustinCampbell
Copy link
Member

The fix for this has been pushed into OmniSharp. You should be able to get the fix by setting the "omnisharp.path" option in VS Code to "latest". That will cause C# for VS Code to download the latest build OmniSharp at start up.

@coldacid
Copy link
Author

Thanks!

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

4 participants