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

No quick fixes on Windows using VS Code

Open ghost opened this issue 3 years ago • 13 comments

Issue Description

Using vs code to work with dotnet core solutions cause "no code actions available" on all error like removing a semicolon after a statment.

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.60.1 C# Extension: 1.23.15

Dotnet Information .NET SDK (che rispecchia un qualsiasi file global.json): Version: 5.0.400 Commit: d61950f9bf

Ambiente di runtime: OS Name: Windows OS Version: 10.0.19043 OS Platform: Windows RID: win10-x64 Base Path: D:\Program Files\dotnet-sdk-5.0.400-win-x64\sdk\5.0.400\

Host (useful for support): Version: 5.0.9 Commit: 208e377a53

.NET SDKs installed: 5.0.400 [D:\Program Files\dotnet-sdk-5.0.400-win-x64\sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 5.0.9 [D:\Program Files\dotnet-sdk-5.0.400-win-x64\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 5.0.9 [D:\Program Files\dotnet-sdk-5.0.400-win-x64\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 5.0.9 [D:\Program Files\dotnet-sdk-5.0.400-win-x64\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download

Visual Studio Code Extensions
Extension Author Version
cmake twxs 0.0.17
cmake-tools ms-vscode 1.8.1
cpptools ms-vscode 1.6.0
csharp ms-dotnettools 1.23.15
jupyter ms-toolsai 2021.8.1236758218
jupyter-keymap ms-toolsai 1.0.0
python ms-python 2021.9.1230869389
vscode-pylance ms-python 2021.9.2

ghost avatar Sep 19 '21 04:09 ghost

😢

ghost avatar Sep 20 '21 10:09 ghost

@KitCarson03 Sorry you are running into issues. Can you please share the OmniSharp Log from the Output Pane? Hopefully we can work out why your project isn't loading.

JoeRobich avatar Sep 20 '21 17:09 JoeRobich

Here it is.

I've pasted it on pastebin because it's very long and it will fullfill the issue page. Sorry that it's in italian.

https://pastebin.com/q7arrZcT

ghost avatar Sep 20 '21 18:09 ghost

The analyzers assembly loader is failing to load assemblies from their shadow copied location. Will need to investigate a bit more.

'file:///C:\\\\Users\\\\Leonardo\\\\AppData\\\\Local\\\\Temp\\\\CodeAnalysis\\\\AnalyzerShadowCopies\\\\ee0c4017cd504a599037d925e219b809\\\\3\\\\Microsoft.CodeAnalysis.CSharp.NetAnalyzers.dll' 
System.NotSupportedException: An attempt was made to load an assembly from a network location, which would have caused the assembly to be sandboxed in earlier versions of the.NET Framework. In this release of the.NET Framework, code access security policies are not enabled by default, so this type of loading can be dangerous. If loading is not done to create the assembly using sandbox, enable the loadFromRemoteSources option. For more information, see

JoeRobich avatar Sep 21 '21 16:09 JoeRobich

The analyzers assembly loader is failing to load assemblies from their shadow copied location. Will need to investigate a bit more.

'file:///C:\\\\Users\\\\Leonardo\\\\AppData\\\\Local\\\\Temp\\\\CodeAnalysis\\\\AnalyzerShadowCopies\\\\ee0c4017cd504a599037d925e219b809\\\\3\\\\Microsoft.CodeAnalysis.CSharp.NetAnalyzers.dll' 
System.NotSupportedException: An attempt was made to load an assembly from a network location, which would have caused the assembly to be sandboxed in earlier versions of the.NET Framework. In this release of the.NET Framework, code access security policies are not enabled by default, so this type of loading can be dangerous. If loading is not done to create the assembly using sandbox, enable the loadFromRemoteSources option. For more information, see

Are there any other information that could be usefull?

ghost avatar Sep 22 '21 05:09 ghost

any news?

The analyzers assembly loader is failing to load assemblies from their shadow copied location. Will need to investigate a bit more.

'file:///C:\\\\Users\\\\Leonardo\\\\AppData\\\\Local\\\\Temp\\\\CodeAnalysis\\\\AnalyzerShadowCopies\\\\ee0c4017cd504a599037d925e219b809\\\\3\\\\Microsoft.CodeAnalysis.CSharp.NetAnalyzers.dll' 
System.NotSupportedException: An attempt was made to load an assembly from a network location, which would have caused the assembly to be sandboxed in earlier versions of the.NET Framework. In this release of the.NET Framework, code access security policies are not enabled by default, so this type of loading can be dangerous. If loading is not done to create the assembly using sandbox, enable the loadFromRemoteSources option. For more information, see

ghost avatar Oct 07 '21 17:10 ghost

I'm also seeing this. Just installed the C# vscode extension yesterday, but not seeing the quick fix lightbulb and Ctrl+. shows "No code actions available". Here's a screenshot:

image

@JoeRobich Since this issue looks like it's gone fairly stale (no updates in 4 months), is there any additional information I can provide that can help?

derekantrican avatar Jan 21 '22 02:01 derekantrican

Looks like I'm seeing the lightbulb & quick fixes on Ctrl+. now that I have added the using but they go away if I remove it. Weird - guess it is just to that specific error that it's not working?

image

derekantrican avatar Jan 21 '22 04:01 derekantrican

I've found the OmniSharp exception info in the logs and cleaned it up a bit:

System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeAssembly.get_DefinedTypes()
   at System.Linq.Enumerable.<SelectManyIterator>d__17`2.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Linq.Enumerable.<ConcatIterator>d__59`1.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.LoadFrom(Project project) in D:\a\1\s\src\OmniSharp.Roslyn.CSharp\Services\Refactoring\V2\CachingCodeFixProviderForProjects.cs:line 93
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.GetAllCodeFixesForProject(ProjectId projectId) in D:\a\1\s\src\OmniSharp.Roslyn.CSharp\Services\Refactoring\V2\CachingCodeFixProviderForProjects.cs:line 57
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.GetSortedCodeFixProviders(Document document) in D:\a\1\s\src\OmniSharp.Roslyn.CSharp\Services\Refactoring\V2\BaseCodeActionService.cs:line 156
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.<AppendFixesAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.<CollectCodeFixesActions>d__12.MoveNext() in D:\a\1\s\src\OmniSharp.Roslyn.CSharp\Services\Refactoring\V2\BaseCodeActionService.cs:line 123
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.<GetAvailableCodeActions>d__9.MoveNext() in D:\a\1\s\src\OmniSharp.Roslyn.CSharp\Services\Refactoring\V2\BaseCodeActionService.cs:line 80
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.GetCodeActionsService.<Handle>d__1.MoveNext() in D:\a\1\s\src\OmniSharp.Roslyn.CSharp\Services\Refactoring\V2\GetCodeActionsService.cs:line 32
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at OmniSharp.Endpoint.EndpointHandler`2.<GetFirstNotEmptyResponseFromHandlers>d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at OmniSharp.Endpoint.EndpointHandler`2.<HandleRequestForLanguage>d__20.MoveNext() in D:\a\1\s\src\OmniSharp.Host\Endpoint\EndpointHandler.cs:line 230
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at OmniSharp.Endpoint.EndpointHandler`2.<Process>d__16.MoveNext() in D:\a\1\s\src\OmniSharp.Host\Endpoint\EndpointHandler.cs:line 131
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at OmniSharp.Stdio.Host.<HandleRequest>d__14.MoveNext() in D:\a\1\s\src\OmniSharp.Stdio\Host.cs:line 218

This is part of the following log entry - in case the other items are important (where SEE_ABOVE is the exception stack trace I've pasted above):

[fail]: OmniSharp.Stdio.Host
        ************  Response (5.1613ms) ************ 
{
  "Request_seq": 644,
  "Command": "/v2/getcodeactions",
  "Running": true,
  "Success": false,
  "Message": SEE_ABOVE,
  "Body": null,
  "Seq": 47712,
  "Type": "response"
}

Also seeing this failure on a restart of the extension (not sure if it's related):

[fail]: OmniSharp.MSBuild.ProjectManager
        Failure while loading the analyzer reference 'Microsoft.NET.Sdk.Razor.SourceGenerators': Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

derekantrican avatar Jan 21 '22 04:01 derekantrican

What analyzers packages are you using? OmniSharp ships with Roslyn 4.0.1 at the moment so it can't load analyzers using Roslyn 4.1.0 yet

filipw avatar Jan 21 '22 08:01 filipw

What do you mean by "analyzers packages"? I just installed the OmniSharp/C# extension into VS code from the marketplace. I don't know anything about Roslyn

derekantrican avatar Jan 21 '22 15:01 derekantrican

+1

vsc version: 1.46.1 ext version: v1.23.11

[fail]: OmniSharp.Stdio.Host
        ************  Response ************ 
{
  "Request_seq": 252,
  "Command": "/v2/getcodeactions",
  "Running": true,
  "Success": false,
  "Message": "\"System.Reflection.ReflectionTypeLoadException: 无法加载一个或多个请求的类型。有关更多信息,请检索 LoaderExceptions 属性。
     在 System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
     在 System.Reflection.RuntimeAssembly.get_DefinedTypes()
     在 System.Linq.Enumerable.<SelectManyIterator>d__17`2.MoveNext()
     在 System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
     在 System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
     在 System.Linq.Enumerable.<ConcatIterator>d__59`1.MoveNext()
     在 System.Linq.Buffer`1..ctor(IEnumerable`1 source)
     在 System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
     在 System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
     在 OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.LoadFrom(Project project) 位置 D:\a\1\s\src\OmniSharp.Roslyn.CSharp\Services\Refactoring\V2\CachingCodeFixProviderForProjects.cs:行号 93
     在 OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.GetAllCodeFixesForProject(ProjectId projectId) 位置 D:\a\1\s\src\OmniSharp.Roslyn.CSharp\Services\Refactoring\V2\CachingCodeFixProviderForProjects.cs:行号 57
     在 OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.GetSortedCodeFixProviders(Document document) 位置 D:\a\1\s\src\OmniSharp.Roslyn.CSharp\Services\Refactoring\V2\BaseCodeActionService.cs:行号 170
     在 OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.<AppendFixesAsync>d__14.MoveNext()
     --- 引发异常的上一位置中堆栈跟踪的末尾 ---
     在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     在 OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.<CollectCodeFixesActions>d__13.MoveNext() 位置 D:\a\1\s\src\OmniSharp.Roslyn.CSharp\Services\Refactoring\V2\BaseCodeActionService.cs:行号 137
     --- 引发异常的上一位置中堆栈跟踪的末尾 ---
     在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     在 OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.<GetAvailableCodeActions>d__10.MoveNext() 位置 D:\a\1\s\src\OmniSharp.Roslyn.CSharp\Services\Refactoring\V2\BaseCodeActionService.cs:行号 94
     --- 引发异常的上一位置中堆栈跟踪的末尾 ---
     在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     在 OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.GetCodeActionsService.<Handle>d__1.MoveNext() 位置 D:\a\1\s\src\OmniSharp.Roslyn.CSharp\Services\Refactoring\V2\GetCodeActionsService.cs:行号 32
     --- 引发异常的上一位置中堆栈跟踪的末尾 ---
     在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     在 OmniSharp.Endpoint.EndpointHandler`2.<GetFirstNotEmptyResponseFromHandlers>d__19.MoveNext()
     --- 引发异常的上一位置中堆栈跟踪的末尾 ---
     在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     在 OmniSharp.Endpoint.EndpointHandler`2.<HandleRequestForLanguage>d__20.MoveNext() 位置 D:\a\1\s\src\OmniSharp.Host\Endpoint\EndpointHandler.cs:行号 230
     --- 引发异常的上一位置中堆栈跟踪的末尾 ---
     在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     在 OmniSharp.Endpoint.EndpointHandler`2.<Process>d__16.MoveNext() 位置 D:\a\1\s\src\OmniSharp.Host\Endpoint\EndpointHandler.cs:行号 131
     --- 引发异常的上一位置中堆栈跟踪的末尾 ---
     在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     在 OmniSharp.Stdio.Host.<HandleRequest>d__13.MoveNext() 位置 D:\a\1\s\src\OmniSharp.Stdio\Host.cs:行号 215\"",
  "Body": null,
  "Seq": 4724,
  "Type": "response"
}

liesauer avatar Aug 09 '22 03:08 liesauer

Trying to implement interface. Earlier implementing would only work if I did Ctrl+, Clicking on the light bulb would show the options but would not implement the interface. Now no options are showing, but if you look carefully, there is an empty dropdown

image

Version: 1.71.0-insider (user setup) Commit: eebdf8174b087979ae6af103f6f2e2f6f9062056 Date: 2022-08-12T05:17:00.323Z Electron: 19.0.11 Chromium: 102.0.5005.167 Node.js: 16.14.2 V8: 10.2.154.15-electron.0 OS: Windows_NT x64 10.0.22000 Sandboxed: Yes extension: v1.25.0

Starting OmniSharp on Windows 10.0.22000.0 (x64) info: OmniSharp.Services.DotNetCliService Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK info: OmniSharp.Services.DotNetCliService Using the 'dotnet' on the PATH. info: OmniSharp.Services.DotNetCliService DotNetPath set to dotnet info: OmniSharp.MSBuild.Discovery.MSBuildLocator Located 4 MSBuild instance(s) 1: .NET Core SDK 6.0.400 17.3.0 - "C:\Program Files\dotnet\sdk\6.0.400" 2: .NET Core SDK 6.0.302 17.2.0 - "C:\Program Files\dotnet\sdk\6.0.302" 3: .NET Core SDK 6.0.300 17.2.0 - "C:\Program Files\dotnet\sdk\6.0.300" 4: .NET Core SDK 6.0.101 17.0.0 - "C:\Program Files\dotnet\sdk\6.0.101" info: OmniSharp.MSBuild.Discovery.MSBuildLocator Registered MSBuild instance: .NET Core SDK 6.0.400 17.3.0 - "C:\Program Files\dotnet\sdk\6.0.400"

Received response for /quickinfo but could not find request.

I have noticed hints in Angular have changed.

the stable version of vscode does not have the problem

this appears to be fixed w/ this morning's vscode update

Dovernh avatar Aug 12 '22 13:08 Dovernh