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

[C# 10] Semantic highlighting doesn't work with file scoped namespaces #2228

Closed
vchirikov opened this issue Sep 4, 2021 · 1 comment · Fixed by #2232
Closed

[C# 10] Semantic highlighting doesn't work with file scoped namespaces #2228

vchirikov opened this issue Sep 4, 2021 · 1 comment · Fixed by #2232

Comments

@vchirikov
Copy link

Hi, first of all thanks for the omnisharp :)

Highlighting with csharplang/file-scoped-namespaces + record struct is broken.

Version: ms-dotnettools.csharp-1.23.15 + omnisharp 1.37.16-beta.2

image

image

Where Error and OperationResult are readonly record struct types.

Omnisharp log:

[fail]: OmniSharp.Stdio.Host
        ************  Response (0.8227ms) ************ 
{
  "Request_seq": 3170,
  "Command": "/v2/highlight",
  "Running": true,
  "Success": false,
  "Message": "\"System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.\\r\\n   at System.ThrowHelper.ThrowKeyNotFoundException()\\r\\n   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)\\r\\n   at OmniSharp.Roslyn.CSharp.Services.SemanticHighlight.SemanticHighlightService.CreateSemanticSpan(IEnumerable`1 results, TextLineCollection lines) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\SemanticHighlight\\\\SemanticHighlightService.cs:line 85\\r\\n   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()\\r\\n   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)\\r\\n   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)\\r\\n   at OmniSharp.Roslyn.CSharp.Services.SemanticHighlight.SemanticHighlightService.<Handle>d__3.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\SemanticHighlight\\\\SemanticHighlightService.cs:line 66\\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__14.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Stdio\\\\Host.cs:line 218\"",
  "Body": null,
  "Seq": 703,
  "Type": "response"
}
Received response for /v2/codestructure but could not find request.
Received response for /v2/getcodeactions but could not find request.
[warn]: OmniSharp.Stdio.Host
        ************ Request ************
{
  "Type": "request",
  "Seq": 3179,
  "Command": "/v2/highlight",
  "Arguments": {
    "FileName": "c:\\****.cs",
    "Line": 0,
    "Column": 0,
    "Range": null
  }
}
[fail]: OmniSharp.Stdio.Host
        ************  Response (2.9182ms) ************ 
{
  "Request_seq": 3179,
  "Command": "/v2/highlight",
  "Running": true,
  "Success": false,
  "Message": "\"System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.\\r\\n   at System.ThrowHelper.ThrowKeyNotFoundException()\\r\\n   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)\\r\\n   at OmniSharp.Roslyn.CSharp.Services.SemanticHighlight.SemanticHighlightService.CreateSemanticSpan(IEnumerable`1 results, TextLineCollection lines) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\SemanticHighlight\\\\SemanticHighlightService.cs:line 85\\r\\n   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()\\r\\n   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)\\r\\n   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)\\r\\n   at OmniSharp.Roslyn.CSharp.Services.SemanticHighlight.SemanticHighlightService.<Handle>d__3.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\SemanticHighlight\\\\SemanticHighlightService.cs:line 66\\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__14.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Stdio\\\\Host.cs:line 218\"",
  "Body": null,
  "Seq": 715,
  "Type": "response"
}
[warn]: OmniSharp.Stdio.Host
        ************ Request ************
{
  "Type": "request",
  "Seq": 3180,
  "Command": "/v2/highlight",
  "Arguments": {
    "FileName": "c:\\****.cs",
    "Line": 0,
    "Column": 0,
    "Range": {
      "Start": {
        "Line": 0,
        "Column": 0
      },
      "End": {
        "Line": 13,
        "Column": 0
      }
    }
  }
}
[fail]: OmniSharp.Stdio.Host
        ************  Response (1.0043ms) ************ 
{
  "Request_seq": 3180,
  "Command": "/v2/highlight",
  "Running": true,
  "Success": false,
  "Message": "\"System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.\\r\\n   at System.ThrowHelper.ThrowKeyNotFoundException()\\r\\n   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)\\r\\n   at OmniSharp.Roslyn.CSharp.Services.SemanticHighlight.SemanticHighlightService.CreateSemanticSpan(IEnumerable`1 results, TextLineCollection lines) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\SemanticHighlight\\\\SemanticHighlightService.cs:line 85\\r\\n   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()\\r\\n   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)\\r\\n   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)\\r\\n   at OmniSharp.Roslyn.CSharp.Services.SemanticHighlight.SemanticHighlightService.<Handle>d__3.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\SemanticHighlight\\\\SemanticHighlightService.cs:line 66\\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__14.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Stdio\\\\Host.cs:line 218\"",
  "Body": null,
  "Seq": 718,
  "Type": "response"
}

cc: @filipw

@filipw
Copy link
Member

filipw commented Sep 7, 2021

thanks for reporting - in fact it was broken when using regular namespaces too 🙂

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

Successfully merging a pull request may close this issue.

2 participants