vscode-csharp: OmniSharp ArgumentOutOfRangeException in Semantic Highlighting

Issue Type: Bug

I get the below error in the OmniSharp log after opening a Unity 2019.4.17f1 project. Tested with 1.23.8 and 1.23.7, both the same. Restarting OmniSharp and VSCode doesn’t change the behavior.

[fail]: OmniSharp.Stdio.Host
        ************  Response ************ 
{
  "Request_seq": 59,
  "Command": "/v2/highlight",
  "Running": true,
  "Success": false,
  "Message": "\"System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.\\r\\nParameter name: line\\r\\n   at Microsoft.CodeAnalysis.Text.LinePosition..ctor(Int32 line, Int32 character)\\r\\n   at OmniSharp.Roslyn.CSharp.Services.SemanticHighlight.SemanticHighlightService.<Handle>d__1.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\SemanticHighlight\\\\SemanticHighlightService.cs:line 36\\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.<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.EndpointHandler`2.<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.EndpointHandler`2.<Process>d__16.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.<HandleRequest>d__13.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Stdio\\\\Host.cs:line 215\"",
  "Body": null,
  "Seq": 137,
  "Type": "response"
}

Extension version: 1.23.8 VS Code version: Code 1.52.1 (ea3859d4ba2f3e577a159bc91e3074c5d85c0523, 2020-12-16T16:34:46.910Z) OS version: Windows_NT x64 10.0.18362

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 14
  • Comments: 20 (4 by maintainers)

Most upvoted comments

are you able to share a project that consistently reproduces this? I would like to be able to pin it down There were no OmniSharp server changes to semantic highlighting since 1.34.15 😄 but perhaps something else is causing this

@filipw repro: https://github.com/vchirikov/limiter file LimiterTests.cs

ms-dotnettools.csharp-1.23.8 omnisharp 1.37.6-beta.16

[fail]: OmniSharp.Stdio.Host
        ************  Response ************ 
{
  "Request_seq": 60,
  "Command": "/v2/highlight",
  "Running": true,
  "Success": false,
  "Message": "\"System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.\\r\\nParameter name: line\\r\\n   at Microsoft.CodeAnalysis.Text.LinePosition..ctor(Int32 line, Int32 character)\\r\\n   at OmniSharp.Roslyn.CSharp.Services.SemanticHighlight.SemanticHighlightService.<Handle>d__1.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\SemanticHighlight\\\\SemanticHighlightService.cs:line 36\\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.<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.EndpointHandler`2.<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.EndpointHandler`2.<Process>d__16.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.<HandleRequest>d__13.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Stdio\\\\Host.cs:line 215\"",
  "Body": null,
  "Seq": 59,
  "Type": "response"
}

anyone knows about a omnisharp version that’s not broken I can switch to? edit: "omnisharp.path": "1.37.2-beta.105" seems to work.

the error is transient, caused by a corrupt state between the editor and server, a restart should fix it.

there were no changes to semantic highlighting in OmniSharp in several months. As I linked, possible cause is #4088 but that’s just my guess

I’ve restarted multple times + switching back to the newest re-breakes it (and it requires a restart to switch), so either a corrupt file is cached somewhere on my pc or it’s something else.

I’m receiving a very similar error too!!! [fail]: OmniSharp.Stdio.Host ************ Response ************ { "Request_seq": 9, "Command": "/v2/highlight", "Running": true, "Success": false, "Message": "\"System.ArgumentOutOfRangeException: 指定的参数已超出有效值的范围。\\r\\n参数名: line\\r\\n 在 Microsoft.CodeAnalysis.Text.LinePosition..ctor(Int32 line, Int32 character)\\r\\n 在 OmniSharp.Roslyn.CSharp.Services.SemanticHighlight.SemanticHighlightService.<Handle>d__1.MoveNext() 位置 D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\SemanticHighlight\\\\SemanticHighlightService.cs:行号 36\\r\\n--- 引发异常的上一位置中堆栈跟踪的末尾 ---\\r\\n 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n 在 OmniSharp.Endpoint.EndpointHandler2.<GetFirstNotEmptyResponseFromHandlers>d__19.MoveNext()\r\n— 引发异常的上一位置中堆栈跟踪的末尾 —\r\n 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n 在 OmniSharp.Endpoint.EndpointHandler2.<HandleRequestForLanguage>d__20.MoveNext() 位置 D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:行号 230\\r\\n--- 引发异常的上一位置中堆栈跟踪的末尾 ---\\r\\n 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n 在 OmniSharp.Endpoint.EndpointHandler2.<Process>d__16.MoveNext() 位置 D:\\a\\1\\s\\src\\OmniSharp.Host\\Endpoint\\EndpointHandler.cs:行号 131\r\n— 引发异常的上一位置中堆栈跟踪的末尾 —\r\n 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n 在 OmniSharp.Stdio.Host.<HandleRequest>d__13.MoveNext() 位置 D:\\a\\1\\s\\src\\OmniSharp.Stdio\\Host.cs:行号 215"", “Body”: null, “Seq”: 36, “Type”: “response” } [fail]: OmniSharp.Stdio.Host ************ Response ************ { “Request_seq”: 15, “Command”: “/v2/highlight”, “Running”: true, “Success”: false, “Message”: ""System.ArgumentOutOfRangeException: 指定的参数已超出有效值的范围。\r\n参数名: line\r\n 在 Microsoft.CodeAnalysis.Text.LinePosition…ctor(Int32 line, Int32 character)\r\n 在 OmniSharp.Roslyn.CSharp.Services.SemanticHighlight.SemanticHighlightService.<Handle>d__1.MoveNext() 位置 D:\\a\\1\\s\\src\\OmniSharp.Roslyn.CSharp\\Services\\SemanticHighlight\\SemanticHighlightService.cs:行号 36\r\n— 引发异常的上一位置中堆栈跟踪的末尾 —\r\n 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n 在 OmniSharp.Endpoint.EndpointHandler2.<GetFirstNotEmptyResponseFromHandlers>d__19.MoveNext()\\r\\n--- 引发异常的上一位置中堆栈跟踪的末尾 ---\\r\\n 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n 在 OmniSharp.Endpoint.EndpointHandler2.<HandleRequestForLanguage>d__20.MoveNext() 位置 D:\\a\\1\\s\\src\\OmniSharp.Host\\Endpoint\\EndpointHandler.cs:行号 230\r\n— 引发异常的上一位置中堆栈跟踪的末尾 —\r\n 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n 在 OmniSharp.Endpoint.EndpointHandler2.<Process>d__16.MoveNext() 位置 D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:行号 131\\r\\n--- 引发异常的上一位置中堆栈跟踪的末尾 ---\\r\\n 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n 在 OmniSharp.Stdio.Host.<HandleRequest>d__13.MoveNext() 位置 D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Stdio\\\\Host.cs:行号 215\"", "Body": null, "Seq": 43, "Type": "response" } [info]: OmniSharp.Roslyn.CSharp.Services.Diagnostics.CSharpDiagnosticWorkerWithAnalyzers Solution initialized -> queue all documents for code analysis. Initial document count: 5.