dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.88k stars 678 forks source link

Versions 1.23.3 or Higher breaking assembly references #4144

Closed devgibsonsp closed 4 years ago

devgibsonsp commented 4 years ago

Issue Description

I recently came back to a project in Unity 3D that I had been working on around 4 months ago. At the time, I was using VS Code as my editor/debugger. There were no assembly reference issues. Coming back to the project. Literally thousands of assembly reference issues. I tracked it down to v1.23.3 of this extension causing the issue.

I also followed the directions in the changelog here:

For Mono-based development (e.g. Unity) that requires full .NET framework, you need to set "omnisharp.useGlobalMono": "always". This is needed until Mono upgrades their bundled MSBuild version

And it hasn't seemed to have had an effect.

Steps to Reproduce

I can't say for sure if this is very specific to Unity 3D or more widespread so my steps will reflect my own circumstance.

  1. Create a Unity 3D project
  2. Create a C# Script
  3. Open VS Code (with C# extension v1.23.3 or Higher)
  4. Use any reference to any project added to your solution
  5. It will get flagged with: The type or namespace name 'Pun' does not exist in the namespace 'Photon' (are you missing an assembly reference?) [Assembly-CSharp, Assembly-CSharp, Assembly-CSharp, Assembly-CSharp, Assembly-CSharp, Assembly-CSharp, Assembly-CSharp, Assembly-CSharp]csharp(CS0234)

Expected Behavior

Assembly references to work properly if the project itself has no underlying issues with it

Actual Behavior

1000s of "missing" assembly references despite no actual issue with the code

Logs

OmniSharp log

Starting OmniSharp server at 10/23/2020, 11:22:23 PM Target: d:\Unity Projects\Acteaus2\Acteaus2.sln OmniSharp server started. Path: c:\Users\radic\.vscode\extensions\ms-dotnettools.csharp-1.23.4\.omnisharp\1.37.3\OmniSharp.exe PID: 18484 [info]: OmniSharp.Stdio.Host Starting OmniSharp on Windows 6.2.9200.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 - "c:\Users\radic\.vscode\extensions\ms-dotnettools.csharp-1.23.4\.omnisharp\1.37.3\.msbuild\Current\Bin" [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator MSBUILD_EXE_PATH environment variable set to 'c:\Users\radic\.vscode\extensions\ms-dotnettools.csharp-1.23.4\.omnisharp\1.37.3\.msbuild\Current\Bin\MSBuild.exe' [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator Registered MSBuild instance: StandAlone 16.8.0 - "c:\Users\radic\.vscode\extensions\ms-dotnettools.csharp-1.23.4\.omnisharp\1.37.3\.msbuild\Current\Bin" CscToolExe = csc.exe CscToolPath = c:\Users\radic\.vscode\extensions\ms-dotnettools.csharp-1.23.4\.omnisharp\1.37.3\.msbuild\Current\Bin\Roslyn MSBuildExtensionsPath = c:\Users\radic\.vscode\extensions\ms-dotnettools.csharp-1.23.4\.omnisharp\1.37.3\.msbuild MSBuildToolsPath = c:\Users\radic\.vscode\extensions\ms-dotnettools.csharp-1.23.4\.omnisharp\1.37.3\.msbuild\Current\Bin [info]: OmniSharp.Cake.CakeProjectSystem Detecting Cake files in 'd:\Unity Projects\Acteaus2'. [info]: OmniSharp.Cake.CakeProjectSystem Could not find any Cake files [info]: OmniSharp.MSBuild.ProjectSystem Detecting projects in 'd:\Unity Projects\Acteaus2\Acteaus2.sln'. [info]: OmniSharp.MSBuild.ProjectManager Queue project update for 'd:\Unity Projects\Acteaus2\Assembly-CSharp.csproj' [info]: OmniSharp.MSBuild.ProjectManager Queue project update for 'd:\Unity Projects\Acteaus2\PhotonUnityNetworking.Demos.csproj' [info]: OmniSharp.MSBuild.ProjectManager Queue project update for 'd:\Unity Projects\Acteaus2\PhotonUnityNetworking.Utilities.csproj' [info]: OmniSharp.MSBuild.ProjectManager Queue project update for 'd:\Unity Projects\Acteaus2\PhotonChat.csproj' [info]: OmniSharp.MSBuild.ProjectManager Queue project update for 'd:\Unity Projects\Acteaus2\PhotonUnityNetworking.csproj' [info]: OmniSharp.MSBuild.ProjectManager Queue project update for 'd:\Unity Projects\Acteaus2\PhotonRealtime.csproj' [info]: OmniSharp.MSBuild.ProjectManager Queue project update for 'd:\Unity Projects\Acteaus2\NavMeshComponents.csproj' [info]: OmniSharp.MSBuild.ProjectManager Queue project update for 'd:\Unity Projects\Acteaus2\PhotonWebSocket.csproj' [info]: OmniSharp.MSBuild.ProjectManager Queue project update for 'd:\Unity Projects\Acteaus2\Assembly-CSharp-Editor.csproj' [info]: OmniSharp.MSBuild.ProjectManager Queue project update for 'd:\Unity Projects\Acteaus2\NavMeshComponentsEditor.csproj' [info]: OmniSharp.MSBuild.ProjectManager Queue project update for 'd:\Unity Projects\Acteaus2\PhotonUnityNetworking.Editor.csproj' [info]: OmniSharp.MSBuild.ProjectManager Queue project update for 'd:\Unity Projects\Acteaus2\PunDemos.DemoHubEditor.csproj' [info]: OmniSharp.MSBuild.ProjectManager Queue project update for 'd:\Unity Projects\Acteaus2\PhotonUnityNetworking.Utilities.PhotonPlayer.Editor.csproj' [info]: OmniSharp.MSBuild.ProjectManager Queue project update for 'd:\Unity Projects\Acteaus2\PhotonUnityNetworking.Utilities.Culling.Editor.csproj' [info]: OmniSharp.MSBuild.ProjectManager Queue project update for 'd:\Unity Projects\Acteaus2\PunDemos.DemoSlotcarEditor.csproj' [info]: OmniSharp.Script.ScriptProjectSystem Detecting CSX files in 'd:\Unity Projects\Acteaus2'. [info]: OmniSharp.MSBuild.ProjectManager Loading project: d:\Unity Projects\Acteaus2\Assembly-CSharp.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 'd:\Unity Projects\Acteaus2' on host 6352. [info]: OmniSharp.MSBuild.ProjectManager Successfully loaded project file 'd:\Unity Projects\Acteaus2\Assembly-CSharp.csproj'. [info]: OmniSharp.MSBuild.ProjectManager Adding project 'd:\Unity Projects\Acteaus2\Assembly-CSharp.csproj' [info]: OmniSharp.MSBuild.ProjectManager Loading project: d:\Unity Projects\Acteaus2\PhotonUnityNetworking.Demos.csproj [info]: OmniSharp.MSBuild.ProjectManager Successfully loaded project file 'd:\Unity Projects\Acteaus2\PhotonUnityNetworking.Demos.csproj'. [info]: OmniSharp.MSBuild.ProjectManager Adding project 'd:\Unity Projects\Acteaus2\PhotonUnityNetworking.Demos.csproj' [info]: OmniSharp.MSBuild.ProjectManager Loading project: d:\Unity Projects\Acteaus2\PhotonUnityNetworking.Utilities.csproj [info]: OmniSharp.MSBuild.ProjectManager Successfully loaded project file 'd:\Unity Projects\Acteaus2\PhotonUnityNetworking.Utilities.csproj'. [info]: OmniSharp.MSBuild.ProjectManager Adding project 'd:\Unity Projects\Acteaus2\PhotonUnityNetworking.Utilities.csproj' [info]: OmniSharp.MSBuild.ProjectManager Loading project: d:\Unity Projects\Acteaus2\PhotonChat.csproj [info]: OmniSharp.MSBuild.ProjectManager Successfully loaded project file 'd:\Unity Projects\Acteaus2\PhotonChat.csproj'. [info]: OmniSharp.MSBuild.ProjectManager Adding project 'd:\Unity Projects\Acteaus2\PhotonChat.csproj' [info]: OmniSharp.MSBuild.ProjectManager Loading project: d:\Unity Projects\Acteaus2\PhotonUnityNetworking.csproj [info]: OmniSharp.MSBuild.ProjectManager Successfully loaded project file 'd:\Unity Projects\Acteaus2\PhotonUnityNetworking.csproj'. [info]: OmniSharp.MSBuild.ProjectManager Adding project 'd:\Unity Projects\Acteaus2\PhotonUnityNetworking.csproj' [info]: OmniSharp.MSBuild.ProjectManager Loading project: d:\Unity Projects\Acteaus2\PhotonRealtime.csproj [info]: OmniSharp.MSBuild.ProjectManager Successfully loaded project file 'd:\Unity Projects\Acteaus2\PhotonRealtime.csproj'. [info]: OmniSharp.MSBuild.ProjectManager Adding project 'd:\Unity Projects\Acteaus2\PhotonRealtime.csproj' [info]: OmniSharp.MSBuild.ProjectManager Loading project: d:\Unity Projects\Acteaus2\NavMeshComponents.csproj [info]: OmniSharp.MSBuild.ProjectManager Successfully loaded project file 'd:\Unity Projects\Acteaus2\NavMeshComponents.csproj'. [info]: OmniSharp.MSBuild.ProjectManager Adding project 'd:\Unity Projects\Acteaus2\NavMeshComponents.csproj' [info]: OmniSharp.MSBuild.ProjectManager Loading project: d:\Unity Projects\Acteaus2\PhotonWebSocket.csproj [info]: OmniSharp.MSBuild.ProjectManager Successfully loaded project file 'd:\Unity Projects\Acteaus2\PhotonWebSocket.csproj'. [info]: OmniSharp.MSBuild.ProjectManager Adding project 'd:\Unity Projects\Acteaus2\PhotonWebSocket.csproj' [info]: OmniSharp.MSBuild.ProjectManager Loading project: d:\Unity Projects\Acteaus2\Assembly-CSharp-Editor.csproj [info]: OmniSharp.MSBuild.ProjectManager Successfully loaded project file 'd:\Unity Projects\Acteaus2\Assembly-CSharp-Editor.csproj'. [info]: OmniSharp.MSBuild.ProjectManager Adding project 'd:\Unity Projects\Acteaus2\Assembly-CSharp-Editor.csproj' [info]: OmniSharp.MSBuild.ProjectManager Loading project: d:\Unity Projects\Acteaus2\NavMeshComponentsEditor.csproj [info]: OmniSharp.MSBuild.ProjectManager Successfully loaded project file 'd:\Unity Projects\Acteaus2\NavMeshComponentsEditor.csproj'. [info]: OmniSharp.MSBuild.ProjectManager Adding project 'd:\Unity Projects\Acteaus2\NavMeshComponentsEditor.csproj' [info]: OmniSharp.MSBuild.ProjectManager Loading project: d:\Unity Projects\Acteaus2\PhotonUnityNetworking.Editor.csproj [info]: OmniSharp.MSBuild.ProjectManager Successfully loaded project file 'd:\Unity Projects\Acteaus2\PhotonUnityNetworking.Editor.csproj'. [info]: OmniSharp.MSBuild.ProjectManager Adding project 'd:\Unity Projects\Acteaus2\PhotonUnityNetworking.Editor.csproj' [info]: OmniSharp.MSBuild.ProjectManager Loading project: d:\Unity Projects\Acteaus2\PunDemos.DemoHubEditor.csproj [info]: OmniSharp.MSBuild.ProjectManager Successfully loaded project file 'd:\Unity Projects\Acteaus2\PunDemos.DemoHubEditor.csproj'. [info]: OmniSharp.MSBuild.ProjectManager Adding project 'd:\Unity Projects\Acteaus2\PunDemos.DemoHubEditor.csproj' [info]: OmniSharp.MSBuild.ProjectManager Loading project: d:\Unity Projects\Acteaus2\PhotonUnityNetworking.Utilities.PhotonPlayer.Editor.csproj [info]: OmniSharp.MSBuild.ProjectManager Successfully loaded project file 'd:\Unity Projects\Acteaus2\PhotonUnityNetworking.Utilities.PhotonPlayer.Editor.csproj'. [info]: OmniSharp.MSBuild.ProjectManager Adding project 'd:\Unity Projects\Acteaus2\PhotonUnityNetworking.Utilities.PhotonPlayer.Editor.csproj' [info]: OmniSharp.MSBuild.ProjectManager Loading project: d:\Unity Projects\Acteaus2\PhotonUnityNetworking.Utilities.Culling.Editor.csproj [info]: OmniSharp.MSBuild.ProjectManager Successfully loaded project file 'd:\Unity Projects\Acteaus2\PhotonUnityNetworking.Utilities.Culling.Editor.csproj'. [info]: OmniSharp.MSBuild.ProjectManager Adding project 'd:\Unity Projects\Acteaus2\PhotonUnityNetworking.Utilities.Culling.Editor.csproj' [info]: OmniSharp.MSBuild.ProjectManager Loading project: d:\Unity Projects\Acteaus2\PunDemos.DemoSlotcarEditor.csproj [info]: OmniSharp.MSBuild.ProjectManager Successfully loaded project file 'd:\Unity Projects\Acteaus2\PunDemos.DemoSlotcarEditor.csproj'. [info]: OmniSharp.MSBuild.ProjectManager Adding project 'd:\Unity Projects\Acteaus2\PunDemos.DemoSlotcarEditor.csproj' [info]: OmniSharp.MSBuild.ProjectManager Update project: Assembly-CSharp [info]: OmniSharp.MSBuild.ProjectManager Update project: PhotonUnityNetworking.Demos [info]: OmniSharp.MSBuild.ProjectManager Update project: PhotonUnityNetworking.Utilities [info]: OmniSharp.MSBuild.ProjectManager Update project: PhotonChat [info]: OmniSharp.MSBuild.ProjectManager Update project: PhotonUnityNetworking [info]: OmniSharp.MSBuild.ProjectManager Update project: PhotonRealtime [info]: OmniSharp.MSBuild.ProjectManager Update project: NavMeshComponents [info]: OmniSharp.MSBuild.ProjectManager Update project: PhotonWebSocket [info]: OmniSharp.MSBuild.ProjectManager Update project: Assembly-CSharp-Editor [info]: OmniSharp.MSBuild.ProjectManager Update project: NavMeshComponentsEditor [info]: OmniSharp.MSBuild.ProjectManager Update project: PhotonUnityNetworking.Editor [info]: OmniSharp.MSBuild.ProjectManager Update project: PunDemos.DemoHubEditor [info]: OmniSharp.MSBuild.ProjectManager Update project: PhotonUnityNetworking.Utilities.PhotonPlayer.Editor [info]: OmniSharp.MSBuild.ProjectManager Update project: PhotonUnityNetworking.Utilities.Culling.Editor [info]: OmniSharp.MSBuild.ProjectManager Update project: PunDemos.DemoSlotcarEditor

C# log

N/A as I build my code in Unity rather than VSCode

Environment information

VSCode version: 1.50.1 C# Extension: 1.23.3

Dotnet Information .NET Core SDK (reflecting any global.json): Version: 2.1.602 Commit: 04475eb7cf Runtime Environment: OS Name: Windows OS Version: 10.0.18362 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\2.1.602\ Host (useful for support): Version: 2.1.9 Commit: dcedc87d22 .NET Core SDKs installed: 2.1.602 [C:\Program Files\dotnet\sdk] .NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download
Visual Studio Code Extensions |Extension|Author|Version| |---|---|---| |aurora-x|marqu3s|2.0.2| |csharp|ms-dotnettools|1.23.3| |deepdark-material|Nimda|3.2.1| |firefly|ankitcode|3.0.1| |nicer-high-contrast|rafmsou|1.0.5| |night-coder|a5hk|0.20.2| |particle-vscode-theme|particle|1.12.5| |printcode|nobuhito|3.0.0| |python|ms-python|2020.9.114305| |signed-dark-pro|alex-munene|1.5.0| |unity-debug|Unity|2.7.5| |unity-tools|Tobiah|1.2.12| |vscode-pitch-black-theme|viktorqvarfordt|1.2.3| |vsliveshare|ms-vsliveshare|1.0.3046| |zeonica|andrewvallette|1.3.1|;
amlinux commented 4 years ago

Same here. Can confirm that downgrade to 1.32.2 fixes the issue.

filipw commented 4 years ago

This is a duplicate. A recent change in OmniSharp to make project loading more correct, exposed a Unity bug. See https://github.com/OmniSharp/omnisharp-vscode/issues/4113#issuecomment-714748347