Incorrectly reporting errors in unity project
See original GitHub issueEnvironment data
dotnet --info
output:
.NET Command Line Tools (1.0.4)
Product Information: Version: 1.0.4 Commit SHA-1 hash: af1e6684fd
Runtime Environment: OS Name: Mac OS X OS Version: 10.13 OS Platform: Darwin RID: osx.10.11-x64 Base Path: /usr/local/share/dotnet/sdk/1.0.4
VS Code version:
1.27.2
C# Extension version:
1.16.1
Steps to reproduce
I don’t have a simple repro. In my project, if I open the “Shooter.cs” file then it’s fine. If I open the “Rifle.cs” file it’s still fine. If I then click back on the open Shooter.cs file I get about 400 spurious errors.
Expected behavior
Only real errors should be reported.
Actual behavior
Almost every line of the file is reported as an error. This is the error on the rifle class itself:
The type 'Rifle' in '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assets/Scripts/Rifle.cs' conflicts with the imported type 'Rifle' in 'Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assets/Scripts/Rifle.cs'. [Assembly-CSharp]
The type 'Rifle' in '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assets/Scripts/Rifle.cs' conflicts with the imported type 'Rifle' in 'Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assets/Scripts/Rifle.cs'. [Assembly-CSharp-Editor]
This is from a reference to the rifle in the Shooter class:
The type or namespace name 'Rifle' could not be found (are you missing a using directive or an assembly reference?) [Assembly-CSharp, Assembly-CSharp-firstpass, Assembly-CSharp-Editor]
(This is most of the errors)
This is a reference in Shooter to an external enum:
Cannot implicitly convert type 'Shooter.LaserType [Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]' to 'Shooter.LaserType [Assembly-CSharp-Editor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]'. An explicit conversion exists (are you missing a cast?) [Assembly-CSharp-Editor]
This is the output from omnisharp when loading up:
Starting OmniSharp server at 9/17/2018, 4:57:48 PM
Target: /Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/swatson_OSX_SVT2.sln
OmniSharp server started with Mono 5.14.0.
Path: /Users/simonwatson/.vscode/extensions/ms-vscode.csharp-1.16.1/.omnisharp/1.32.5/omnisharp/OmniSharp.exe
PID: 12532
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on MacOS 10.13.6 (x64)
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 2 MSBuild instance(s)
1: Mono 15.0 - "/usr/local/Cellar/mono/5.14.0.177/lib/mono/msbuild/15.0/bin"
2: StandAlone 15.0 - "/Users/simonwatson/.vscode/extensions/ms-vscode.csharp-1.16.1/.omnisharp/1.32.5/omnisharp/msbuild/15.0/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: Mono 15.0 - "/usr/local/Cellar/mono/5.14.0.177/lib/mono/msbuild/15.0/bin"
CscToolPath = /Users/simonwatson/.vscode/extensions/ms-vscode.csharp-1.16.1/.omnisharp/1.32.5/omnisharp/msbuild/15.0/Bin/Roslyn
CscToolExe = csc.exe
[info]: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2'.
[info]: OmniSharp.Cake.CakeProjectSystem
Could not find any Cake files
[info]: OmniSharp.WorkspaceInitializer
Project system 'OmniSharp.DotNet.DotNetProjectSystem' is disabled in the configuration.
[info]: OmniSharp.MSBuild.ProjectSystem
Detecting projects in '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/swatson_OSX_SVT2.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assembly-CSharp.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assembly-CSharp-firstpass.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assembly-CSharp-Editor.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2'.
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assembly-CSharp.csproj
[info]: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assembly-CSharp.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
Adding project '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assembly-CSharp.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assembly-CSharp-firstpass.csproj
[info]: OmniSharp.Script.ScriptProjectSystem
Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.WorkspaceInitializer
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2' on host 12486.
[info]: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assembly-CSharp-firstpass.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
Adding project '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assembly-CSharp-firstpass.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assembly-CSharp-Editor.csproj
[info]: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assembly-CSharp-Editor.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
Adding project '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assembly-CSharp-Editor.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Update project: Assembly-CSharp
[warn]: OmniSharp.MSBuild.ProjectManager
Unable to resolve assembly '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Temp/bin/Debug/Assembly-CSharp-firstpass.dll'
[info]: OmniSharp.MSBuild.ProjectManager
Update project: Assembly-CSharp-firstpass
[info]: OmniSharp.MSBuild.ProjectManager
Update project: Assembly-CSharp-Editor
[warn]: OmniSharp.MSBuild.ProjectManager
Unable to resolve assembly '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Temp/bin/Debug/Assembly-CSharp-firstpass.dll'
[warn]: OmniSharp.MSBuild.ProjectManager
Unable to resolve assembly '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Temp/bin/Debug/Assembly-CSharp.dll'
Issue Analytics
- State:
- Created 5 years ago
- Reactions:9
- Comments:25 (1 by maintainers)
Top GitHub Comments
Quick Update: Unity 2019.2 officially added support for VS Code via package manager. To ensure projects are generated correctly, remove all csproj files that are related to the unity project and reopen the the project from Unity in order to properly generated the proj files. You might also want to remove any old .vscode directory just to be sure that a clean vs-code compatible is generated from unity.
Will come with updates after I test this for a few days
@Aciho I think I might know what is the problem here. Do you have symbolic links in your project? Can you try setting omnisharp.path: “1.32.2” in your settings and then Ctrl+Shift+P --> Restart OmniSharp and see if the error still reproduces ?