dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.86k stars 670 forks source link

Problems only being detected after the file that contains the problem is edited. #3602

Open Shapis opened 4 years ago

Shapis commented 4 years ago

Issue Description

Problems are only detected in the file I'm currently editing, if you don't change the file it won't detect problems.

https://gfycat.com/snappyhideouseland here's a video of what I mean.

https://gfycat.com/oblongmagnificentbarb here's a video of the expected behavior, it's the same code running on a different machine where the bug does not happen.

I've tried the same thing in a different computer with the same projects, and it worked as expected in the other computers.

It also happens with no extensions other than the C# one, and it also happens in every project.

Edit: Fixed by formatting windows/the whole computer and starting over from scratch. /shrug

Steps to Reproduce

Create/Import a project. Do something that breaks the code (rename a variable that's used somewhere else, remove a semi colon, anything like that).

Expected Behavior

It'd be reported as a problem, and the other classes that whatever change you made broke, would also be reported as a problem.

https://gfycat.com/oblongmagnificentbarb here's a video of the expected behavior, it's the same code running on a different machine where the bug does not happen.

Actual Behavior

It only detects, underlines and shows up on the problems tab after you change something in the file that is now broken.

Logs

OmniSharp log

Starting OmniSharp server at 2/23/2020, 8:14:34 PM Target: c:\Users\shapi\Documents\CodingProjects\TestConsole OmniSharp server started. Path: C:\Users\shapi\.vscode\extensions\ms-vscode.csharp-1.21.12\.omnisharp\1.34.13\OmniSharp.exe PID: 10852 [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.4 - "c:\Users\shapi\.vscode\extensions\ms-vscode.csharp-1.21.12\.omnisharp\1.34.13\.msbuild\Current\Bin" [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator MSBUILD_EXE_PATH environment variable set to 'c:\Users\shapi\.vscode\extensions\ms-vscode.csharp-1.21.12\.omnisharp\1.34.13\.msbuild\Current\Bin\MSBuild.exe' [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator Registered MSBuild instance: StandAlone 16.4 - "c:\Users\shapi\.vscode\extensions\ms-vscode.csharp-1.21.12\.omnisharp\1.34.13\.msbuild\Current\Bin" CscToolExe = csc.exe CscToolPath = c:\Users\shapi\.vscode\extensions\ms-vscode.csharp-1.21.12\.omnisharp\1.34.13\.msbuild\Current\Bin\Roslyn MSBuildExtensionsPath = c:\Users\shapi\.vscode\extensions\ms-vscode.csharp-1.21.12\.omnisharp\1.34.13\.msbuild MSBuildToolsPath = c:\Users\shapi\.vscode\extensions\ms-vscode.csharp-1.21.12\.omnisharp\1.34.13\.msbuild\Current\Bin [info]: OmniSharp.Cake.CakeProjectSystem Detecting Cake files in 'c:\Users\shapi\Documents\CodingProjects\TestConsole'. [info]: OmniSharp.Cake.CakeProjectSystem Could not find any Cake files [info]: OmniSharp.MSBuild.ProjectSystem No solution files found in 'c:\Users\shapi\Documents\CodingProjects\TestConsole' [info]: OmniSharp.MSBuild.ProjectManager Queue project update for 'c:\Users\shapi\Documents\CodingProjects\TestConsole\TestConsole.csproj' [info]: OmniSharp.Script.ScriptProjectSystem Detecting CSX files in 'c:\Users\shapi\Documents\CodingProjects\TestConsole'. [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\shapi\Documents\CodingProjects\TestConsole\TestConsole.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.EditorConfigWorkspaceOptionsProvider, Order: 200 [info]: OmniSharp.WorkspaceInitializer Configuration finished. [info]: OmniSharp.Stdio.Host Omnisharp server running using Stdio at location 'c:\Users\shapi\Documents\CodingProjects\TestConsole' on host 7676. [info]: OmniSharp.MSBuild.ProjectManager Successfully loaded project file 'c:\Users\shapi\Documents\CodingProjects\TestConsole\TestConsole.csproj'. [info]: OmniSharp.MSBuild.ProjectManager Adding project 'c:\Users\shapi\Documents\CodingProjects\TestConsole\TestConsole.csproj' [info]: OmniSharp.MSBuild.ProjectManager Update project: TestConsole [info]: OmniSharp.Roslyn.CSharp.Services.Diagnostics.CSharpDiagnosticWorkerWithAnalyzers Solution initialized -> queue all documents for code analysis. Initial document count: 4.

C# log

Post the output from Output-->C# here

Environment information

VSCode version: 1.42.1 C# Extension: 1.21.12

Dotnet Information .NET Core SDK (reflecting any global.json): Version: 3.1.102 Commit: 573d158fea 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.102\ Host (useful for support): Version: 3.1.2 Commit: 916b5cba26 .NET Core SDKs installed: 3.1.102 [C:\Program Files\dotnet\sdk] .NET Core runtimes installed: Microsoft.AspNetCore.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.2 [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| |---|---|---| |bracket-pair-colorizer-2|CoenraadS|0.0.29| |code-settings-sync|Shan|3.4.3| |csharp|ms-vscode|1.21.12| |csharpextensions|jchannon|1.3.1| |prettier-vscode|SimonSiefke|1.1.18| |TabOut|albert|0.1.6| |unity-code-snippets|kleber-swf|1.3.0| |unity-tools|Tobiah|1.2.3| |vscode-icons|vscode-icons-team|10.0.0| |vscodeintellicode|VisualStudioExptTeam|1.2.5|;
savpek commented 4 years ago

Its likely that in another computer you don't have analyzers enabled, in that mode it re-analyzes every document at every change. With analyzers enabled it don't do that. Currently you can manually trigger project or solution level analysis from vscode with "Analyze current project" or "Analyze current solution" commands.

It's not perfect situation 😢 But i don't attleast know any api from roslyn that can directly to solve that issue. Visual studio etc. does it but i don't think that part is public (?). Developing engine that can traverse all affected documents based on change is pretty huge task to say atleast. That rename case is pretty trivial (calculate changed nodes from previous to current -> find references to them). But theres basically endles combination of possible modifications which must be combined with truth that that routine must also be very very fast because it must be calculated basically after any change on documents.

cc @filipw @david-driscoll any insights for visual studio that how it calculates those changes over documents in workspace?

an-dr-eas-k commented 4 years ago

any updates on this issue? I have the same problem. Roslyn Analyzers enabled.

Version: 1.49.2 (system setup) Commit: e5e9e69aed6e1984f7499b7af85b3d05f9a6883a Date: 2020-09-24T16:29:41.983Z Electron: 9.2.1 Chrome: 83.0.4103.122 Node.js: 12.14.1 V8: 8.3.110.13-electron.0 OS: Windows_NT x64 10.0.17763

Name: C# Id: ms-dotnettools.csharp Description: C# for Visual Studio Code (powered by OmniSharp). Version: 1.23.2 Publisher: Microsoft VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp

gaoshan0621 commented 4 years ago

Bumping up. The same issue #4086 .