dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.86k stars 673 forks source link

Code actions not working #5109

Closed css13c closed 2 years ago

css13c commented 2 years ago

Issue Description

Steps to Reproduce

Expected Behavior

Actual Behavior

Logs

OmniSharp log

Post the output from Output-->OmniSharp log here

C# log

Post the output from Output-->C# here

Environment information

VSCode version: 1.65.2 C# Extension: 1.24.1

Mono Information OmniSharp using built-in mono
Dotnet Information .NET SDK (reflecting any global.json): Version: 6.0.103 Commit: 2d7bc7059f Runtime Environment: OS Name: Mac OS X OS Version: 11.6 OS Platform: Darwin RID: osx.11.0-x64 Base Path: /usr/local/share/dotnet/sdk/6.0.103/ Host (useful for support): Version: 6.0.3 Commit: c24d9a9c91 .NET SDKs installed: 5.0.202 [/usr/local/share/dotnet/sdk] 6.0.101 [/usr/local/share/dotnet/sdk] 6.0.103 [/usr/local/share/dotnet/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 5.0.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 5.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download
Visual Studio Code Extensions |Extension|Author|Version| |---|---|---| |cpptools|ms-vscode|1.8.4| |csharp|ms-dotnettools|1.24.1| |csharpextensions|jchannon|1.3.1| |csharpsortusings|jongrant|0.0.3| |data-workspace-vscode|ms-mssql|0.1.1| |docomment|k--kato|0.1.30| |dotenv|mikestead|1.0.1| |dotnet-test-explorer|formulahendry|0.7.7| |EditorConfig|EditorConfig|0.16.4| |elixir-ls|JakeBecker|0.9.0| |elixir-symbols|pkujundzic|0.0.4| |fakesharper|fakesharper|1.0.0| |githubinator|chdsbd|2.0.0| |guides|spywhere|0.9.3| |html-slim-scss-css-class-completion|gencer|1.7.8| |jupyter|ms-toolsai|2022.2.1030672458| |jupyter-keymap|ms-toolsai|1.0.0| |jupyter-renderers|ms-toolsai|1.0.6| |markdown-preview-github-styles|bierner|1.0.1| |mssql|ms-mssql|1.13.0| |npm-intellisense|christian-kohler|1.4.1| |powershell|ms-vscode|2021.12.0| |prettier-vscode|esbenp|9.3.0| |python|ms-python|2022.2.1924087327| |roslynator|josefpihrt-vscode|4.0.3| |se-csproj-extensions|selcukermaya|0.0.7| |sql-database-projects-vscode|ms-mssql|0.14.1| |todo-tree|Gruntfuggly|0.0.215| |todos-vscode-extension|sherwyn11|0.0.1| |unicode-math-vscode|GuidoTapia2|0.3.3| |vetur|octref|0.35.0| |vim|vscodevim|1.22.2| |vscode-autohotkey|slevesque|0.2.2| |vscode-docker|ms-azuretools|1.20.0| |vscode-eslint|dbaeumer|2.2.2| |vscode-graphql|GraphQL|0.3.52| |vscode-icons|vscode-icons-team|11.10.0| |vscode-npm-script|eg2|0.3.24| |vscode-nuget-package-manager|jmrog|1.1.6| |vscode-pylance|ms-python|2022.3.1| |vscode-react-native|msjsdiag|1.9.2| |vscode-scss|mrmlnc|0.10.0| |vscode-scss-formatter|sibiraj-s|2.3.3|;

Code actions have not been working for quite a while. Updating versions, browsing issues and trying fixes suggested have not worked. Error for context:


 "Request_seq": 835,
  "Command": "/v2/getcodeactions",
  "Running": true,
  "Success": false,
  "Message": "\"System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.\\nMethod 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationArrayTypeSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nMethod 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationConstructedMethodSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nMethod 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationConstructedNamedTypeSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nMethod 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationMethodSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nMethod 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationMethodSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nMethod 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationMethodSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nMethod 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationEventSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nMethod 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationFieldSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nMethod 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationMethodSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nMethod 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationNamedTypeSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nMethod 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationNamespaceSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nMethod 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationMethodSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nMethod 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationParameterSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nMethod 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationPointerTypeSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nMethod 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationPropertySymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nMethod 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationTypeParameterSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\n   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)\\n   at System.Reflection.RuntimeAssembly.get_DefinedTypes()\\n   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()\\n   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()\\n   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()\\n   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)\\n   at System.Collections.Generic.SparseArrayBuilder`1.ReserveOrAdd(IEnumerable`1 items)\\n   at System.Linq.Enumerable.Concat2Iterator`1.ToArray()\\n   at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)\\n   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.LoadFrom(Project project) in /Users/runner/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs:line 95\\n   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.GetAllCodeFixesForProject(ProjectId projectId) in /Users/runner/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs:line 57\\n   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.GetSortedCodeFixProviders(Document document) in /Users/runner/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 156\\n   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.AppendFixesAsync(Document document, TextSpan span, IEnumerable`1 diagnostics, List`1 codeActions)\\n   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.CollectCodeFixesActions(Document document, TextSpan span, List`1 codeActions) in /Users/runner/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 130\\n   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.GetAvailableCodeActions(ICodeActionRequest request) in /Users/runner/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 88\\n   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.GetCodeActionsService.Handle(GetCodeActionsRequest request) in /Users/runner/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/GetCodeActionsService.cs:line 38\\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\\nSystem.TypeLoadException: Method 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationArrayTypeSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nSystem.TypeLoadException: Method 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationConstructedMethodSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nSystem.TypeLoadException: Method 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationConstructedNamedTypeSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nSystem.TypeLoadException: Method 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationMethodSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nSystem.TypeLoadException: Method 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationMethodSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nSystem.TypeLoadException: Method 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationMethodSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nSystem.TypeLoadException: Method 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationEventSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nSystem.TypeLoadException: Method 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationFieldSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nSystem.TypeLoadException: Method 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationMethodSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nSystem.TypeLoadException: Method 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationNamedTypeSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nSystem.TypeLoadException: Method 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationNamespaceSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nSystem.TypeLoadException: Method 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationMethodSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nSystem.TypeLoadException: Method 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationParameterSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nSystem.TypeLoadException: Method 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationPointerTypeSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nSystem.TypeLoadException: Method 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationPropertySymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\\nSystem.TypeLoadException: Method 'get_MetadataToken' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationTypeParameterSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.\"",
  "Body": null,
  "Seq": 24152,
  "Type": "response"
JoeRobich commented 2 years ago

Possible duplicate of https://github.com/OmniSharp/omnisharp-vscode/issues/5098.

@css13c If you are using the StrawberryShake library, see this issue https://github.com/ChilliCream/hotchocolate/issues/4823. If you are not using these libraries, please share the full OmniSharp Log from the VS Code Output pane.

css13c commented 2 years ago

Fixed, thanks.