dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.87k stars 675 forks source link

Debugging Unit Test loses codelens Run Test / Debug Test - DebugSessionManager does not stop #2398

Open xcellsoft opened 6 years ago

xcellsoft commented 6 years ago

Related to #1743

Environment data

dotnet --info output:

.NET Core SDK (reflecting any global.json): Version: 2.1.301 Commit: 59524873d6

Runtime Environment: OS Name: Windows OS Version: 10.0.17134 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\2.1.301\

Host (useful for support): Version: 2.1.1 Commit: 6985b9f684

.NET Core SDKs installed: 1.0.4 [C:\Program Files\dotnet\sdk] 2.0.2 [C:\Program Files\dotnet\sdk] 2.0.3 [C:\Program Files\dotnet\sdk] 2.1.2 [C:\Program Files\dotnet\sdk] 2.1.3 [C:\Program Files\dotnet\sdk] 2.1.4 [C:\Program Files\dotnet\sdk] 2.1.100 [C:\Program Files\dotnet\sdk] 2.1.101 [C:\Program Files\dotnet\sdk] 2.1.102 [C:\Program Files\dotnet\sdk] 2.1.103 [C:\Program Files\dotnet\sdk] 2.1.104 [C:\Program Files\dotnet\sdk] 2.1.105 [C:\Program Files\dotnet\sdk] 2.1.200 [C:\Program Files\dotnet\sdk] 2.1.201 [C:\Program Files\dotnet\sdk] 2.1.300 [C:\Program Files\dotnet\sdk] 2.1.301 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download PS D:\CBRock\XCellorator>

VS Code version: 1.24.1 C# Extension version: ms-vscode.csharp-1.15.2.omnisharp\1.30.1\OmniSharp.exe

Steps to reproduce

Create a TestServer that has a IHostedService with dependencies and do not perform a graceful close on the TestServer using the following code: this.testServerIam.Host.StopAsync().GetAwaiter().GetResult();. The OmniSharp.DotNetTest.DebugSessionManager will never report "Debug session ended", it will be stuck with "Debug session started.", even though the .NET Test Log says Debugging complete. The extra host process not being cleaned up / shutdown must be confusing omnisharp. In some cases the codelens may appear on a fresh restart but clicking the debug again will just hang with the debug starting in the output window (it will never start).

Expected behavior

Omnisharp debug session stops, codelens run/debug appears and a subsequent debug can be performed.

trackingallday commented 4 years ago

Also experiencing this error:

macOS Mojave 10.14.6

dotnetcore 3.1 opening project in a dev container using vs code

Debug tests once then omnisharp is killed. Tests are in a referenced project Tests are testing controllers

    Successfully loaded project file '/app/service/WebAPIApplication.csproj'.
    Adding project '/app/service/WebAPIApplication.csproj'
    Update project: Tests
    Update project: WebAPIApplication
    read: {"MessageType":"TestSession.Connected","Payload":null}
    read: {"MessageType":"ProtocolVersion","Payload":1}
    Debug session started.

/root/.vscode-server/extensions/ms-dotnettools.csharp-1.22.0/.omnisharp/1.35.2/run: line 28: 235 Killed "${mono_cmd}" "${omnisharp_cmd}" "$@"

wbuck commented 4 years ago

Yeah I'm having the same issue on Windows developing in WSL1.

.vscode-server-insiders/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.35.3/run: line 28: 12519 Killed "${mono_cmd}" "${omnisharp_cmd}" "$@"

Only restarting VS fixes it.

Windows Info

OS : Windows 10 Pro Version : 1909 Build : 18363.900

WSL Info

OS : Ubuntu 20.04 LTS Release : 20.04

VS Code Info

Version: 1.48.0-insider (user setup) Commit: e7920dce7bfd0b707ebfc0a5379c6edd2233e475 Date: 2020-07-10T11:58:37.847Z Electron: 8.3.3 Chrome: 80.0.3987.165 Node.js: 12.13.0 V8: 8.0.426.27-electron.0 OS: Windows_NT x64 10.0.18363

turowicz commented 3 years ago

Same issue here on Ubuntu 20.04

[info]: OmniSharp.DotNetTest.VSTestManager
        read: {"MessageType":"TestSession.Connected","Payload":null}
[info]: OmniSharp.DotNetTest.VSTestManager
        read: {"MessageType":"ProtocolVersion","Payload":1}
[info]: OmniSharp.DotNetTest.DebugSessionManager
        Debug session started.
Received response for /v2/getcodeactions but could not find request.
Received response for /v2/getcodeactions but could not find request.
/root/.vscode-server/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/run: line 28: 65649 Killed                  "${mono_cmd}" "${omnisharp_cmd}" "$@"
lonix1 commented 3 years ago

ubuntu 20, vscode 1.60, dotnet 5.

As I posted on a related issue:

I can often (but not always) prevent a crash by disabling the "All Exceptions" and "User-Unhandled Exceptions" breakpoints. When those are disabled, it crashes less often.

When those are enabled - and I hit a breakpoint, or step through code - and step over a throw new FooException(), it'll proceed to the end of the test, then crash (a Mono crash like described above.)

msigut commented 3 years ago

ubuntu 20, vscode 1.60, dotnet 5.

As I posted on a related issue:

I can often (but not always) prevent a crash by disabling the "All Exceptions" and "User-Unhandled Exceptions" breakpoints. When those are disabled, it crashes less often.

When those are enabled - and I hit a breakpoint, or step through code - and step over a throw new FooException(), it'll proceed to the end of the test, then crash (a Mono crash like described above.)

Unfortunatelly, I've test it right now it doesn't works for me.

Please OmniSharp team help to us this issue that means restart VS Code after every fail in UNIT testig ...

lonix1 commented 2 years ago

Some feedback: since upgrading to the net6-based o#, I no longer have debugging crashes. :smile:

smargoli2 commented 2 years ago

I'm still experiencing this issue, VS Code 1.73.1. I have to restart my computer to get the run test/debug test options to show!