Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit Test Debugging with Syntax Error Requires VS Code Restart #2400

Closed
xcellsoft opened this issue Jun 30, 2018 · 10 comments · Fixed by OmniSharp/omnisharp-roslyn#1239
Closed

Comments

@xcellsoft
Copy link

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:
2.1.3 [C:\Program Files\dotnet\sdk]
2.1.4 [C:\Program Files\dotnet\sdk]
2.1.101 [C:\Program Files\dotnet\sdk]
2.1.103 [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 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

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

Steps to reproduce

Create a fresh xunit application using dotnet new xunit
, then open the unit test and create a syntax error (this example missing semicolon after assert.true) and click debug:

    public class UnitTest1
    {
        [Fact]
        public void Test1()
        {
            Assert.True(true)
        }
    }

Expected behavior

Syntax error returned, fix error and debug again.

Actual behavior

Syntax error is returned but clicking debug shows two debuggers running and then an error that the debugger is already started. Clicking debug again shows 3 debuggers running and same error, then so on so forth.

.NET Test Log Output

Debugging method 'test.UnitTest1.Test1'...

Microsoft (R) Build Engine version 15.7.179.6572 for .NET Core
Microsoft (R) Build Engine version 15.7.179.6572 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Copyright (C) Microsoft Corporation. All rights reserved.


  test -> c:\Temp\test\bin\Debug\netcoreapp2.1\test.dll
  test -> c:\Temp\test\bin\Debug\netcoreapp2.1\test.dll


Build succeeded.
Build succeeded.
    0 Warning(s)
    0 Warning(s)
    0 Error(s)
    0 Error(s)


Time Elapsed 00:00:00.67
Time Elapsed 00:00:00.67

Error Message:
Failed to start debugger: "System.InvalidOperationException: Debug session already started.\r\n at OmniSharp.DotNetTest.DebugSessionManager.VerifySession(Boolean isStarted)\r\n at OmniSharp.DotNetTest.DebugSessionManager.StartSession(TestManager testManager)\r\n at OmniSharp.DotNetTest.Services.DebugTestService.Handle(DebugTestGetStartInfoRequest request)\r\n at OmniSharp.Endpoint.EndpointHandler2.d__18.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at OmniSharp.Endpoint.EndpointHandler2.<Process>d__16.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at OmniSharp.Stdio.Host.<HandleRequest>d__15.MoveNext()"

@xcellsoft xcellsoft changed the title Unit Test Debugging with Syntax Error Causes requires vs code restart Unit Test Debugging with Syntax Error Requires VS Code Restart Jul 2, 2018
@akshita31
Copy link
Contributor

@xcellsoft The double , triple times diagnostics is coming because we are not disposing the event listeners properly in the extension, and the problem with the debugger already started is coming because the exceptions are not being handled properly. I am working on it and a PR will be out soon. Thank you for taking time to file the issue.

@xcellsoft
Copy link
Author

This will save allot of time, can’t wait. Thanks

@xcellsoft
Copy link
Author

What is the appropriate way to get this fix?

I see that setting "omnisharp.path": "latest" pulls down recent builds, looks like today it's 1.31.2-beta.98, how does this correlate with commits to master and/or what is the best way to get this patch to test it out?

@akshita31
Copy link
Contributor

akshita31 commented Jul 4, 2018

@xcellsoft Just setting "omnisharp.path": "latest" and restarting the omnisharp server will make the debugger work for you. However you will see duplicate logs if the debugger failed initially. The change for that has been merged to master in omnisharp-vscode. We are in talks of doing a beta release. Until then you can follow the steps here to create a vsix and then install it.

@mubarik
Copy link

mubarik commented Nov 12, 2018

"Just setting "omnisharp.path": "latest" and restarting the omnisharp server will make the debugger work for you. However you will see duplicate logs if the debugger failed initially"

Didn't work for me.

@mubarik
Copy link

mubarik commented Nov 12, 2018

@akshita31

@mubarik
Copy link

mubarik commented Nov 12, 2018

I was having same issue with MSTEST

@gregg-miskelly
Copy link
Contributor

I would recommend opening a new issue rather than commenting on a closed issue. "omnisharp.path": "latest" would no longer be necessary or recomended, so I would restore that back to the default if you haven't already. Also, I am not sure if this is your problem, but the LiveShare extension cause a similar sounding issue. So if you have that installed, I would recommend trying without it.

@mubarik
Copy link

mubarik commented Nov 12, 2018

LiveShare is not installed. my VSCODE version is Version: 1.28.2. I restored back to default. didn't help

@gregg-miskelly
Copy link
Contributor

Please open a new issue so that folks can try and help investigate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants