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

Incorrect syntax, errors, references, etc. #5216

Closed
markdibarry opened this issue May 16, 2022 · 4 comments · Fixed by #5218
Closed

Incorrect syntax, errors, references, etc. #5216

markdibarry opened this issue May 16, 2022 · 4 comments · Fixed by #5218

Comments

@markdibarry
Copy link

Issue Description

Omnisharp regularly crashes. This results in references displaying in incorrect positions, hides errors and shows errors where there are none, incorrect syntax, etc. See below:
image

Steps to Reproduce

Inconsistent. Will sometimes occur on save. Sometimes when moving between tabs of an unsaved file. Making a change to the document corrects the display. Noticed this behavior about a month ago.

Expected Behavior

N/A

Actual Behavior

See description.

Logs

OmniSharp log

Starting OmniSharp server at 5/16/2022, 2:43:26 PM Target: d:\Coding\godot\Arenbee\Arenbee.sln

OmniSharp server started.
Path: c:\Users\Dael.vscode\extensions\ms-dotnettools.csharp-1.24.4-win32-x64.omnisharp\1.38.2\OmniSharp.exe
PID: 23300

Starting OmniSharp on Windows 6.2.9200.0 (x64)
info: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
info: OmniSharp.Services.DotNetCliService
DotNetPath set to C:\Program Files\dotnet\dotnet
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 2 MSBuild instance(s)
1: Visual Studio Community 2022 17.2.32505.173 17.2.1 - "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin"
2: StandAlone 17.1.1 - "c:\Users\Dael.vscode\extensions\ms-dotnettools.csharp-1.24.4-win32-x64.omnisharp\1.38.2.msbuild\Current\Bin"
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: Visual Studio Community 2022 17.2.32505.173 17.2.1 - "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin"
info: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
info: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in 'd:\Coding\godot\Arenbee'.
info: OmniSharp.Cake.CakeProjectSystem
Did not find any Cake files
info: OmniSharp.MSBuild.ProjectSystem
Detecting projects in 'd:\Coding\godot\Arenbee\Arenbee.sln'.
info: OmniSharp.MSBuild.ProjectManager
Queue project update for 'd:\Coding\godot\Arenbee\Arenbee.csproj'
info: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in 'd:\Coding\godot\Arenbee'.
info: OmniSharp.Script.ScriptProjectSystem
Did not find any CSX files
info: OmniSharp.WorkspaceInitializer
Configuration finished.
info: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location 'd:\Coding\godot\Arenbee' on host 24556.
info: OmniSharp.MSBuild.ProjectManager
Loading project: d:\Coding\godot\Arenbee\Arenbee.csproj
info: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file 'd:\Coding\godot\Arenbee\Arenbee.csproj'.
info: OmniSharp.MSBuild.ProjectManager
Adding project 'd:\Coding\godot\Arenbee\Arenbee.csproj'
info: OmniSharp.MSBuild.ProjectManager
Update project: Arenbee
info: OmniSharp.Roslyn.CSharp.Services.Diagnostics.CSharpDiagnosticWorkerWithAnalyzers
Solution initialized -> queue all documents for code analysis. Initial document count: 206.
[warn]: OmniSharp.Stdio.Host
************ Request ************
{
"Type": "request",
"Seq": 7,
"Command": "/inlayHint",
"Arguments": {
"Location": {
"FileName": "d:\Coding\godot\Arenbee\Framework\Actors\State\StateController.cs",
"Range": {
"Start": {
"Line": 32,
"Column": 0
},
"End": {
"Line": 168,
"Column": 1
}
}
}
}
}
[fail]: OmniSharp.Stdio.Host
************ Response (21.5511ms) ************
{
"Request_seq": 7,
"Command": "/inlayHint",
"Running": true,
"Success": false,
"Message": ""System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.\r\nParameter name: index\r\n at Microsoft.CodeAnalysis.Text.SourceText.LineInfo.get_Item(Int32 index)\r\n at OmniSharp.Extensions.TextExtensions.GetPositionFromLineAndOffset(SourceText text, Int32 lineNumber, Int32 offset) in D:\\a\\1\\s\\src\\OmniSharp.Roslyn\\Extensions\\TextExtensions.cs:line 28\r\n at OmniSharp.Extensions.TextExtensions.GetSpanFromRange(SourceText text, Range range) in D:\\a\\1\\s\\src\\OmniSharp.Roslyn\\Extensions\\TextExtensions.cs:line 55\r\n at OmniSharp.Roslyn.CSharp.Services.InlayHints.InlayHintService.d__6.MoveNext() in D:\\a\\1\\s\\src\\OmniSharp.Roslyn.CSharp\\Services\\InlayHints\\InlayHintService.cs:line 56\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.EndpointHandler2.<GetFirstNotEmptyResponseFromHandlers>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 OmniSharp.Endpoint.EndpointHandler2.d__20.MoveNext() in D:\\a\\1\\s\\src\\OmniSharp.Host\\Endpoint\\EndpointHandler.cs:line 230\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.EndpointHandler2.<Process>d__16.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 138\\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.<HandleRequest>d__14.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Stdio\\\\Host.cs:line 218\"", "Body": null, "Seq": 129, "Type": "response" } [warn]: OmniSharp.Stdio.Host ************ Request ************ { "Type": "request", "Seq": 17, "Command": "/inlayHint", "Arguments": { "Location": { "FileName": "d:\\Coding\\godot\\Arenbee\\Framework\\Actors\\State\\StateController.cs", "Range": { "Start": { "Line": 32, "Column": 0 }, "End": { "Line": 168, "Column": 1 } } } } } [fail]: OmniSharp.Stdio.Host ************ Response (0.5629ms) ************ { "Request_seq": 17, "Command": "/inlayHint", "Running": true, "Success": false, "Message": "\"System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.\\r\\nParameter name: index\\r\\n at Microsoft.CodeAnalysis.Text.SourceText.LineInfo.get_Item(Int32 index)\\r\\n at OmniSharp.Extensions.TextExtensions.GetPositionFromLineAndOffset(SourceText text, Int32 lineNumber, Int32 offset) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn\\\\Extensions\\\\TextExtensions.cs:line 28\\r\\n at OmniSharp.Extensions.TextExtensions.GetSpanFromRange(SourceText text, Range range) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn\\\\Extensions\\\\TextExtensions.cs:line 55\\r\\n at OmniSharp.Roslyn.CSharp.Services.InlayHints.InlayHintService.<Handle>d__6.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\InlayHints\\\\InlayHintService.cs:line 56\\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.EndpointHandler2.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 OmniSharp.Endpoint.EndpointHandler2.<HandleRequestForLanguage>d__20.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 230\\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.EndpointHandler2.d__16.MoveNext() in D:\\a\\1\\s\\src\\OmniSharp.Host\\Endpoint\\EndpointHandler.cs:line 138\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__14.MoveNext() in D:\\a\\1\\s\\src\\OmniSharp.Stdio\\Host.cs:line 218"",
"Body": null,
"Seq": 141,
"Type": "response"
}

C# log

(None)

Environment information

VSCode version: 1.67.1
C# Extension: 1.24.4

Dotnet Information .NET SDK (reflecting any global.json): Version: 6.0.300 Commit: 8473146e7d

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

Host (useful for support):
Version: 6.0.5
Commit: 70ae3df4a6

.NET SDKs installed:
6.0.300 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download

Visual Studio Code Extensions
Extension Author Version
csharp ms-dotnettools 1.24.4
LiveServer ritwickdey 5.7.5
mono-debug ms-vscode 0.16.2
powershell ms-vscode 2022.5.1
vscode-firefox-debug firefox-devtools 2.9.6
vsliveshare ms-vsliveshare 1.0.5561
@JoeRobich
Copy link
Member

I suspect this is related to the "fileChanged" behavior that was introduced in #5088

@ApeOnFire
Copy link

ApeOnFire commented May 20, 2022

I'm seeing this all the time as well, in multiple projects. Seems to be coupled with this exception in the OmniSharp Log:

[fail]: OmniSharp.Stdio.Host
        ************  Response (0.5495ms) ************ 
{
  "Request_seq": 1249,
  "Command": "/inlayHint",
  "Running": true,
  "Success": false,
  "Message": "\"System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.\\nParameter name: index\\n  at Microsoft.CodeAnalysis.Text.SourceText+LineInfo.get_Item (System.Int32 index) [0x0000f] in <ebb143507af8464da18f46e5ed0accdf>:0 \\n  at OmniSharp.Extensions.TextExtensions.GetPositionFromLineAndOffset (Microsoft.CodeAnalysis.Text.SourceText text, System.Int32 lineNumber, System.Int32 offset) [0x00006] in <3997e19046634a39a20d03c6385fc69b>:0 \\n  at OmniSharp.Extensions.TextExtensions.GetSpanFromRange (Microsoft.CodeAnalysis.Text.SourceText text, OmniSharp.Models.V2.Range range) [0x00033] in <3997e19046634a39a20d03c6385fc69b>:0 \\n  at OmniSharp.Roslyn.CSharp.Services.InlayHints.InlayHintService.Handle (OmniSharp.Models.v1.InlayHints.InlayHintRequest request) [0x00128] in <013e1d73869645519db61be39695f2b9>:0 \\n  at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].GetFirstNotEmptyResponseFromHandlers (OmniSharp.Endpoint.Exports.ExportHandler`2[TRequest,TResponse][] handlers, TRequest request) [0x00099] in <2c738f48401c42ab8866fe9742b40aa0>:0 \\n  at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].HandleRequestForLanguage (System.String language, TRequest request, OmniSharp.Protocol.RequestPacket packet) [0x00163] in <2c738f48401c42ab8866fe9742b40aa0>:0 \\n  at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].Process (OmniSharp.Protocol.RequestPacket packet, OmniSharp.Endpoint.LanguageModel model, Newtonsoft.Json.Linq.JToken requestObject) [0x002d8] in <2c738f48401c42ab8866fe9742b40aa0>:0 \\n  at OmniSharp.Stdio.Host.HandleRequest (System.String json, Microsoft.Extensions.Logging.ILogger logger) [0x000f3] in <b65fb505403e4a9f95ed53beadc952de>:0 \"",
  "Body": null,
  "Seq": 56737,
  "Type": "response"
}

Hopefully this helps a bit.

@ApeOnFire
Copy link

ApeOnFire commented May 20, 2022

Getting a lot of these in the logs too:

Received response for /rename but could not find request.
Received response for /findusages but could not find request.
Received response for /quickinfo but could not find request.
Received response for /v2/getcodeactions but could not find request.
Received response for /v2/blockstructure but could not find request.

It's actually almost unusable when refactoring. Don't suppose there might be a workaround while we wait for a fix?

@Igorgro
Copy link

Igorgro commented May 21, 2022

Updated the extension to the preview version, but having the following omnisharp error:

[fail]: OmniSharp.Stdio.Host
        ************  Response (1.9614ms) ************ 
{
  "Request_seq": 94,
  "Command": "/v2/highlight",
  "Running": true,
  "Success": false,
  "Message": "\"System.InvalidOperationException: Sequence contains more than one element\\n   at System.Linq.ThrowHelper.ThrowMoreThanOneElementException()\\n   at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Boolean& found)\\n   at OmniSharp.Roslyn.CSharp.Services.SemanticHighlight.SemanticHighlightService.CreateSemanticSpan(IEnumerable`1 results, TextLineCollection lines) in /Users/runner/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/SemanticHighlight/SemanticHighlightService.cs:line 82\\n   at OmniSharp.Roslyn.CSharp.Services.SemanticHighlight.SemanticHighlightService.<>c.<Handle>b__3_2(IGrouping`2 grouping) in /Users/runner/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/SemanticHighlight/SemanticHighlightService.cs:line 75\\n   at System.Linq.Enumerable.SelectEnumerableIterator`2.ToArray()\\n   at OmniSharp.Roslyn.CSharp.Services.SemanticHighlight.SemanticHighlightService.Handle(SemanticHighlightRequest request) in /Users/runner/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/SemanticHighlight/SemanticHighlightService.cs:line 71\\n   at OmniSharp.Endpoint.EndpointHandler`2.GetFirstNotEmptyResponseFromHandlers(ExportHandler`2[] handlers, TRequest request) in /Users/runner/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 218\\n   at OmniSharp.Endpoint.EndpointHandler`2.HandleRequestForLanguage(String language, TRequest request, RequestPacket packet) in /Users/runner/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 234\\n   at OmniSharp.Endpoint.EndpointHandler`2.Process(RequestPacket packet, LanguageModel model, JToken requestObject) in /Users/runner/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 143\\n   at OmniSharp.Stdio.Host.HandleRequest(String json, ILogger logger) in /Users/runner/work/1/s/src/OmniSharp.Stdio/Host.cs:line 258\"",
  "Body": null,
  "Seq": 155,
  "Type": "response"
}

Not sure if it is connected to this issue, but I get the log of Omnisharp flooded by this message after every typed letter.
By the way, is it the same issue as following: OmniSharp/omnisharp-roslyn#2391?
@JoeRobich it looks like this issue was not fixed, or should I open separate one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants