Open danroth27 opened 3 years ago
I don't think this is related to Preview 3. There is an (unfortunately) known issue with the client and server getting out of sync which manifests itself this way (basically line numbers in the editor don't match the server state). see e.g. the discussion here https://github.com/OmniSharp/omnisharp-vscode/issues/4307#issuecomment-766874460 it often happens when you start editing without the project being fully loades yet
this has been introduced in recent versions of the extension and we think moving to LSP will improve stability and consistency.
a restart normally fixes this.
a restart normally fixes this.
Just restart VS Code? Or do you mean the whole machine?
OmniSharp restart (there is a command for this) which can also be achieved simply by a VS Code restart
Restarting VS Code and Omnisharp doesn't seem to help in this case. I've also tried waiting until it looks like things have loaded in the Omnisharp logs before starting to edit. This repros reliably for me.
Yeah but the exception you shared is not related to code actions - it comes from find references and is triggered via code lense, so it sounds like we are mixing up two things here. What I understand you are opening this because you don't get the expected code action, and this exception is likely only clouding the picture and perhaps your root cause is different.
Does other stuff work correctly e.g. intellisense or navigation?
Perhaps you can capture all the logs by setting "omnisharp.loggingLevel":"debug"
FWIW this is what I see, albeit on a Mac
Other stuff does seem to work:
Issue Description
Steps to Reproduce
dotnet new console -o ConsoleApp1
code ConsoleApp1
Expected Behavior
Code action offered to add
using System;
No exceptions in the Omnisharp logs.Actual Behavior
No code action offered to add missing using directive. Exception in Omnisharp log: InvalidOperationException: Unexpected null
Logs
OmniSharp log
Starting OmniSharp server at 3/26/2021, 8:20:57 AM Target: c:\Users\daroth\Desktop\ConsoleApp1
OmniSharp server started. Path: c:\Users\daroth.vscode\extensions\ms-dotnettools.csharp-1.23.9.omnisharp\1.37.6\OmniSharp.exe PID: 4720
{ "Type": "request", "Seq": 21, "Command": "/findusages", "Arguments": { "FileName": "c:\Users\daroth\Desktop\ConsoleApp1\Program.cs", "Line": 0, "Column": 0, "OnlyThisFile": true, "ExcludeDefinition": false } }
{ "Request_seq": 21, "Command": "/findusages", "Running": true, "Success": false, "Message": "\"System.InvalidOperationException: Unexpected null\r\n at Roslyn.Utilities.Contract.Fail(String message)\r\n at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.MapToAppropriateSymbol(ISymbol symbol)\r\n at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.d20.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.d 19.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.d8.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.d 8.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.d8.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.CodeAnalysis.FindSymbols.SymbolFinder.d 34.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.CodeAnalysis.FindSymbols.SymbolFinder.d40.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.CodeAnalysis.FindSymbols.SymbolFinder.d 39.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService.d2.MoveNext() in D:\\a\\1\\s\\src\\OmniSharp.Roslyn.CSharp\\Services\\Navigation\\FindUsagesService.cs:line 41\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at OmniSharp.Endpoint.EndpointHandler`2.d 18.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at OmniSharp.Endpoint.EndpointHandlerd16.MoveNext() in D:\\a\\1\\s\\src\\OmniSharp.Host\\Endpoint\\EndpointHandler.cs:line 131\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at OmniSharp.Stdio.Host.d 13.MoveNext() in D:\\a\\1\\s\\src\\OmniSharp.Stdio\\Host.cs:line 215\"",
"Body": null,
"Seq": 128,
"Type": "response"
}
2.<HandleRequestForLanguage>d__20.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 227\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n at OmniSharp.Endpoint.EndpointHandler
2.C# log
[No output]
Environment information
VSCode version: 1.54.3 C# Extension: 1.23.9
Dotnet Information
.NET SDK (reflecting any global.json): Version: 6.0.100-preview.3.21176.3 Commit: 89f2987f74 Runtime Environment: OS Name: Windows OS Version: 10.0.19042 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\6.0.100-preview.3.21176.3\ Host (useful for support): Version: 6.0.0-preview.3.21167.1 Commit: 0f64b267ac .NET SDKs installed: 3.1.407 [C:\Program Files\dotnet\sdk] 5.0.104 [C:\Program Files\dotnet\sdk] 5.0.200-preview.21077.7 [C:\Program Files\dotnet\sdk] 5.0.200 [C:\Program Files\dotnet\sdk] 5.0.201 [C:\Program Files\dotnet\sdk] 6.0.100-preview.3.21176.3 [C:\Program Files\dotnet\sdk] .NET runtimes installed: Microsoft.AspNetCore.All 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.25 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.25 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.0-preview.3.21172.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.25 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.0-preview.3.21167.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.0-preview.3.21172.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-downloadVisual Studio Code Extensions
|Extension|Author|Version| |---|---|---| |azure-account|ms-vscode|0.9.7| |code-spell-checker|streetsidesoftware|1.10.2| |csharp|ms-dotnettools|1.23.9| |dart-code|Dart-Code|3.20.1| |flutter|Dart-Code|3.20.0| |javascript-ejs-support|DigitalBrainstem|1.3.1| |LiveServer|ritwickdey|5.6.1| |remote-wsl|ms-vscode-remote|0.54.6| |vscode-azureappservice|ms-azuretools|0.21.2| |vscode-azureresourcegroups|ms-azuretools|0.3.0| |WebTemplateStudio-dev-nightly|WASTeamAccount|0.5.2104801|;