vscode-csharp icon indicating copy to clipboard operation
vscode-csharp copied to clipboard

Creating class produces errors

Open Igorgro opened this issue 3 years ago • 3 comments

Environment data

dotnet --info output:

.NET SDK (reflecting any global.json):
 Version:   6.0.201
 Commit:    ef40e6aa06

Runtime Environment:
 OS Name:     arch
 OS Version:  
 OS Platform: Linux
 RID:         arch-x64
 Base Path:   /usr/share/dotnet/sdk/6.0.201/

Host (useful for support):
  Version: 6.0.3
  Commit:  c24d9a9c91

.NET SDKs installed:
  6.0.201 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.3 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

VS Code version: 1.67.2 C# Extension version: 1.25.0

OmniSharp log

Log is full of the following messages:

[fail]: OmniSharp.Stdio.Host
        ************  Response (5.1360ms) ************ 
{
  "Request_seq": 5935,
  "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 78\\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": 11950,
  "Type": "response"
}

Steps to reproduce

  1. Create empty project
  2. Create new class in namespace

Expected behavior

No errors are shown

Actual behavior

Every new class is marked as already existing (error CS0101) and the log is flooded with the error message. The same thing happens when renaming existing classes. The only solution is to restart omnisharp after avery class creation which is very annoying.

Additional context

I've already posted similar issues here https://github.com/OmniSharp/omnisharp-vscode/issues/5216 and here https://github.com/OmniSharp/omnisharp-roslyn/issues/2391

Igorgro avatar Jun 08 '22 10:06 Igorgro

Reporting same exact problem and as @Igorgro. Have been experiencing it for a while but it's just getting beyond a joke having to restart Omnisharp after creating a new file.

Winter avatar Aug 22 '22 15:08 Winter

Same problem here.

Environment

$ dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.400
 Commit:    7771abd614

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  20.04
 OS Platform: Linux
 RID:         ubuntu.20.04-x64
 Base Path:   /usr/share/dotnet/sdk/6.0.400/

global.json file:
  Not found

Host:
  Version:      6.0.8
  Architecture: x64
  Commit:       55fb7ef977

.NET SDKs installed:
  6.0.400 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.8 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.8 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Download .NET:
  https://aka.ms/dotnet-download

Learn about .NET Runtimes and SDKs:
  https://aka.ms/dotnet/runtimes-sdk-info

OmniSharp log

{
  "Type": "request",
  "Seq": 603,
  "Command": "/v2/highlight",
  "Arguments": {
    "FileName": "/home/tom/test/test/test.cs",
    "Line": 0,
    "Column": 0,
    "Range": null
  }
}
[fail]: OmniSharp.Stdio.Host
        ************  Response (1.7154ms) ************ 
{
  "Request_seq": 603,
  "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 78\\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": 4222,
  "Type": "response"
}

tmeadon avatar Sep 13 '22 08:09 tmeadon

Same problem, running on fully patched Ubuntu 22.04.

vscode version 1.71.2 C# Extension version 1.25.0

dotnet --info

.NET SDK (reflecting any global.json):
 Version:   6.0.109
 Commit:    58a93139d8

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  22.04
 OS Platform: Linux
 RID:         ubuntu.22.04-x64
 Base Path:   /usr/lib/dotnet/dotnet6-6.0.109/sdk/6.0.109/

global.json file:
  Not found

Host:
  Version:      6.0.9
  Architecture: x64
  Commit:       163a63591c

.NET SDKs installed:
  6.0.109 [/usr/lib/dotnet/dotnet6-6.0.109/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.9 [/usr/lib/dotnet/dotnet6-6.0.109/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.9 [/usr/lib/dotnet/dotnet6-6.0.109/shared/Microsoft.NETCore.App]

Download .NET:
  https://aka.ms/dotnet-download

Learn about .NET Runtimes and SDKs:
  https://aka.ms/dotnet/runtimes-sdk-info

ChopperRob avatar Sep 17 '22 15:09 ChopperRob

Have been experiencing this until now any fixes?

jsiuaganatmyalii avatar May 14 '23 22:05 jsiuaganatmyalii