OmniSharp / omnisharp-roslyn

OmniSharp server (HTTP, STDIO) based on Roslyn workspaces
MIT License
1.79k stars 420 forks source link

VSCode: CodeLens references numbers cannot be loaded if re-open the project #2210

Open Serena01 opened 3 years ago

Serena01 commented 3 years ago

Azure DevOps work item: https://devdiv.visualstudio.com/web/wi.aspx?pcguid=011b8bdf-6d56-4f87-be0d-0092136884d9&id=1363493

INSTALL STEPS:

  1. Clean machine: Win10 x64 ENU 20H1

  2. Install the latest version of VS Code

  3. Install .NET 6.0 preview 7

  4. Apply feed

Install C# Extensions version: v1.23.14

Testcases Affected SimpleBlazorRazorEditingWithVSCode SimpleWebAppRazorEditingWithVSCode SimpleBlazorRazorEditingWithVSCode

Platform

Repro Steps

  1. Open a normal Terminal Emulator

  2. Create mvc project and open it using VS code

  3. Open the VS Code, then the PROBLEMS window will appear error.

  4. Install csharp-1.23.14.vsix with vs

  5. Create a test.cs file in the project and add following code namespace razor // project name { public interface ICheese {} }

  6. Open Index.cshtml and add code as bellow: @{ var x = typeof(ICheese); } @functions { public class Cheddar : ICheese {} }

  7. Build the project with command "dotnet build"

  8. There are refences in the test.cs as bellow image

  9. Close the vscode instance and re-open the project

  10. Build the project

Actual Result No references in the test.cs as bellow: image

Expected Result There are references in the test.cs as bellow: image

Note

  1. The references cannot be loaded on the linux even through I did not close the project
  2. Error message in the output as bellow: Starting OmniSharp server at 7/30/2021, 9:09:26 AM Target: /home/aapt/test/razor

OmniSharp server started. Path: /home/aapt/.vscode/extensions/ms-dotnettools.csharp-1.23.14/.omnisharp/1.37.14/run PID: 110391

    Starting OmniSharp on rhel 8.4 (x64)
    DotNetPath set to dotnet
    Located 1 MSBuild instance(s)
        1: StandAlone 17.0.0 - "/home/aapt/.vscode/extensions/ms-dotnettools.csharp-1.23.14/.omnisharp/1.37.14/omnisharp/.msbuild/Current/Bin"
    MSBUILD_EXE_PATH environment variable set to '/home/aapt/.vscode/extensions/ms-dotnettools.csharp-1.23.14/.omnisharp/1.37.14/omnisharp/.msbuild/Current/Bin/MSBuild.exe'
    Registered MSBuild instance: StandAlone 17.0.0 - "/home/aapt/.vscode/extensions/ms-dotnettools.csharp-1.23.14/.omnisharp/1.37.14/omnisharp/.msbuild/Current/Bin"
        CscToolExe = csc.exe
        MSBuildToolsPath = /home/aapt/.vscode/extensions/ms-dotnettools.csharp-1.23.14/.omnisharp/1.37.14/omnisharp/.msbuild/Current/Bin
        CscToolPath = /home/aapt/.vscode/extensions/ms-dotnettools.csharp-1.23.14/.omnisharp/1.37.14/omnisharp/.msbuild/Current/Bin/Roslyn
        BypassFrameworkInstallChecks = true
        MSBuildExtensionsPath = /home/aapt/.vscode/extensions/ms-dotnettools.csharp-1.23.14/.omnisharp/1.37.14/omnisharp/.msbuild
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
    Detecting Cake files in '/home/aapt/test/razor'.
    Could not find any Cake files
    No solution files found in '/home/aapt/test/razor'
    Queue project update for '/home/aapt/test/razor/razor.csproj'
    Detecting CSX files in '/home/aapt/test/razor'.
    Could not find any CSX files
    Configuration finished.
    Omnisharp server running using Stdio at location '/home/aapt/test/razor' on host 109927.
    Loading project: /home/aapt/test/razor/razor.csproj
    Successfully loaded project file '/home/aapt/test/razor/razor.csproj'.
    Adding project '/home/aapt/test/razor/razor.csproj'
    Update project: razor

Received response for /v2/codestructure but could not find request. Received response for /v2/getcodeactions but could not find request. Received response for /v2/getcodeactions but could not find request. Received response for /completion but could not find request. Received response for /v2/getcodeactions but could not find request. Received response for /v2/codestructure but could not find request. Received response for /findusages but could not find request. Received response for /v2/getcodeactions but could not find request. Received response for /v2/getcodeactions but could not find request. Received response for /quickinfo but could not find request. Received response for /v2/getcodeactions but could not find request.

    No symbol found. File: /home/aapt/test/razor/CustomTagHelper.cs, Line: 7, Column: 41.

Received response for /v2/getcodeactions but could not find request. Received response for /v2/getcodeactions but could not find request.

    Applying code action: using Microsoft.AspNetCore.Razor.TagHelpers;

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

    No symbol found. File: /home/aapt/test/razor/test.cs, Line: 8, Column: 5.

Received response for /v2/getcodeactions but could not find request. Received response for /v2/codestructure but could not find request. Received response for /v2/codestructure but could not find request. Received response for /v2/blockstructure but could not find request. Received response for /v2/codestructure but could not find request.

    Queue project update for '/home/aapt/test/razor/razor.csproj'
    Loading project: /home/aapt/test/razor/razor.csproj
    Queue project update for '/home/aapt/test/razor/razor.csproj'
    Successfully loaded project file '/home/aapt/test/razor/razor.csproj'.

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object at OmniSharp.Helpers.LocationExtensions+<>c.b0_2 (Microsoft.CodeAnalysis.Document document) [0x00000] in :0 at System.Linq.Utilities+<>c__DisplayClass2_0`3[TSource,TMiddle,TResult].b0 (TSource x) [0x00012] in <9ba54d07696a449db4a4279fc05aa435>:0 at System.Linq.Enumerable+SelectArrayIterator2[TSource,TResult].ToArray () [0x00012] in <9ba54d07696a449db4a4279fc05aa435>:0 at System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable1[T] source) [0x0001f] in <9ba54d07696a449db4a4279fc05aa435>:0 at OmniSharp.Helpers.LocationExtensions.GetQuickFix (Microsoft.CodeAnalysis.Location location, OmniSharp.OmniSharpWorkspace workspace) [0x00128] in :0 at OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService+<>cDisplayClass3_0.b2 (Microsoft.CodeAnalysis.Location l) [0x00000] in :0 at System.Linq.Enumerable+SelectEnumerableIterator2[TSource,TResult].MoveNext () [0x00048] in <9ba54d07696a449db4a4279fc05aa435>:0 at System.Linq.Set1[TElement].UnionWith (System.Collections.Generic.IEnumerable1[T] other) [0x00018] in <9ba54d07696a449db4a4279fc05aa435>:0 at System.Linq.Enumerable+DistinctIterator1[TSource].FillSet () [0x0000b] in <9ba54d07696a449db4a4279fc05aa435>:0 at System.Linq.Enumerable+DistinctIterator1[TSource].ToArray () [0x00000] in <9ba54d07696a449db4a4279fc05aa435>:0 at System.Linq.Buffer1[TElement]..ctor (System.Collections.Generic.IEnumerable1[T] source) [0x0000a] in <9ba54d07696a449db4a4279fc05aa435>:0 at System.Linq.OrderedEnumerable1+d3[TElement].MoveNext () [0x0001e] in <9ba54d07696a449db4a4279fc05aa435>:0 at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList (Newtonsoft.Json.JsonWriter writer, System.Collections.IEnumerable values, Newtonsoft.Json.Serialization.JsonArrayContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract collectionContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x000e1] in <2676a2da6edc420e890ed28aa4572ee5>:0 at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonContract valueContract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x000d6] in <2676a2da6edc420e890ed28aa4572ee5>:0 at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract collectionContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x0008d] in <2676a2da6edc420e890ed28aa4572ee5>:0 at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonContract valueContract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x000b2] in <2676a2da6edc420e890ed28aa4572ee5>:0 at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract collectionContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x0008d] in <2676a2da6edc420e890ed28aa4572ee5>:0 at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonContract valueContract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x000b2] in <2676a2da6edc420e890ed28aa4572ee5>:0 at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00079] in <2676a2da6edc420e890ed28aa4572ee5>:0 at Newtonsoft.Json.JsonSerializer.SerializeInternal (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x0023a] in <2676a2da6edc420e890ed28aa4572ee5>:0 at Newtonsoft.Json.JsonSerializer.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00000] in <2676a2da6edc420e890ed28aa4572ee5>:0 at Newtonsoft.Json.JsonConvert.SerializeObjectInternal (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializer jsonSerializer) [0x00028] in <2676a2da6edc420e890ed28aa4572ee5>:0 at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x00007] in <2676a2da6edc420e890ed28aa4572ee5>:0 at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value) [0x00000] in <2676a2da6edc420e890ed28aa4572ee5>:0 at OmniSharp.Protocol.Packet.ToString () [0x00000] in <1d1f3e0019d94b108eae99dea9ec434f>:0 at System.IO.TextWriter.WriteLine (System.Object value) [0x00028] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 at System.IO.TextWriter+SyncTextWriter.WriteLine (System.Object value) [0x00000] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 at (wrapper synchronized) System.IO.TextWriter+SyncTextWriter.WriteLine(object) at OmniSharp.Services.SharedTextWriter.ProcessWriteQueue () [0x0001d] in <1d1f3e0019d94b108eae99dea9ec434f>:0 at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) [0x00014] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x0002b] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 at System.Threading.ThreadHelper.ThreadStart () [0x00008] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object at OmniSharp.Helpers.LocationExtensions+<>c.b0_2 (Microsoft.CodeAnalysis.Document document) [0x00000] in :0 at System.Linq.Utilities+<>cDisplayClass2_03[TSource,TMiddle,TResult].<CombineSelectors>b__0 (TSource x) [0x00012] in <9ba54d07696a449db4a4279fc05aa435>:0 at System.Linq.Enumerable+SelectArrayIterator2[TSource,TResult].ToArray () [0x00012] in <9ba54d07696a449db4a4279fc05aa435>:0 at System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x0001f] in <9ba54d07696a449db4a4279fc05aa435>:0 at OmniSharp.Helpers.LocationExtensions.GetQuickFix (Microsoft.CodeAnalysis.Location location, OmniSharp.OmniSharpWorkspace workspace) [0x00128] in :0 at OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService+<>c__DisplayClass3_0.b2 (Microsoft.CodeAnalysis.Location l) [0x00000] in :0 at System.Linq.Enumerable+SelectEnumerableIterator2[TSource,TResult].MoveNext () [0x00048] in <9ba54d07696a449db4a4279fc05aa435>:0 at System.Linq.Set1[TElement].UnionWith (System.Collections.Generic.IEnumerable1[T] other) [0x00018] in <9ba54d07696a449db4a4279fc05aa435>:0 at System.Linq.Enumerable+DistinctIterator1[TSource].FillSet () [0x0000b] in <9ba54d07696a449db4a4279fc05aa435>:0 at System.Linq.Enumerable+DistinctIterator1[TSource].ToArray () [0x00000] in <9ba54d07696a449db4a4279fc05aa435>:0 at System.Linq.Buffer1[TElement]..ctor (System.Collections.Generic.IEnumerable1[T] source) [0x0000a] in <9ba54d07696a449db4a4279fc05aa435>:0 at System.Linq.OrderedEnumerable1+d__3[TElement].MoveNext () [0x0001e] in <9ba54d07696a449db4a4279fc05aa435>:0 at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList (Newtonsoft.Json.JsonWriter writer, System.Collections.IEnumerable values, Newtonsoft.Json.Serialization.JsonArrayContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract collectionContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x000e1] in <2676a2da6edc420e890ed28aa4572ee5>:0 at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonContract valueContract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x000d6] in <2676a2da6edc420e890ed28aa4572ee5>:0 at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract collectionContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x0008d] in <2676a2da6edc420e890ed28aa4572ee5>:0 at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonContract valueContract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x000b2] in <2676a2da6edc420e890ed28aa4572ee5>:0 at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract collectionContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x0008d] in <2676a2da6edc420e890ed28aa4572ee5>:0 at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonContract valueContract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x000b2] in <2676a2da6edc420e890ed28aa4572ee5>:0 at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00079] in <2676a2da6edc420e890ed28aa4572ee5>:0 at Newtonsoft.Json.JsonSerializer.SerializeInternal (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x0023a] in <2676a2da6edc420e890ed28aa4572ee5>:0 at Newtonsoft.Json.JsonSerializer.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00000] in <2676a2da6edc420e890ed28aa4572ee5>:0 at Newtonsoft.Json.JsonConvert.SerializeObjectInternal (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializer jsonSerializer) [0x00028] in <2676a2da6edc420e890ed28aa4572ee5>:0 at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x00007] in <2676a2da6edc420e890ed28aa4572ee5>:0 at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value) [0x00000] in <2676a2da6edc420e890ed28aa4572ee5>:0 at OmniSharp.Protocol.Packet.ToString () [0x00000] in <1d1f3e0019d94b108eae99dea9ec434f>:0 at System.IO.TextWriter.WriteLine (System.Object value) [0x00028] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 at System.IO.TextWriter+SyncTextWriter.WriteLine (System.Object value) [0x00000] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 at (wrapper synchronized) System.IO.TextWriter+SyncTextWriter.WriteLine(object) at OmniSharp.Services.SharedTextWriter.ProcessWriteQueue () [0x0001d] in <1d1f3e0019d94b108eae99dea9ec434f>:0 at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) [0x00014] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x0002b] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 at System.Threading.ThreadHelper.ThreadStart () [0x00008] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0

Serena01 commented 3 years ago

The issue could reproduce on windows and linux with .NET 6.0 RC2(6.0.100-rc..21473.26)