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

Debugging unit tests always uses coreclr launch, even for non-coreclr project #1586

Closed
AHelper opened this issue Jun 23, 2017 · 12 comments · Fixed by #1663
Closed

Debugging unit tests always uses coreclr launch, even for non-coreclr project #1586

AHelper opened this issue Jun 23, 2017 · 12 comments · Fixed by #1663

Comments

@AHelper
Copy link

AHelper commented Jun 23, 2017

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-preview2-003131)

Product Information:
Version: 1.0.0-preview2-003131
Commit SHA-1 hash: 635cf40e58

Runtime Environment:
OS Name: Windows
OS Version: 6.1.7601
OS Platform: Windows
RID: win7-x64

VS Code version: 1.13.1
C# Extension version: 1.10.0

Steps to reproduce

Using example.zip as base net46 xunit workspace:
Set a breakpoint on Console.WriteLine line in Test method
Click debug test on Test method

Expected behavior

Breakpoint should be hit

Actual behavior

Breakpoint is missed, the debug launch uses a coreclr configuration and vsdbg outputs

The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core. This may be expected if the target process did not run on .NET Core.

Looking at https://github.com/OmniSharp/omnisharp-vscode/blob/master/src/features/dotnetTest.ts#L116 the launch configuration generated has the type hard-coded to "coreclr" while this assumption may be (and in this case is) invalid. It appears that the csharp.unitTestDebuggingOptions setting is used as a basis for the launch configuration, but the type is set after the fact.

Manually setting the type to "clr" in the extension allows the debugger to properly attach to the process and debugging works as expected.

I'm not sure about the effort required to auto-detect the launch type, however a suitable workaround would be to allow type to be specified in unitTestDebuggingOptions.

@gregg-miskelly
Copy link
Contributor

@AHelper Do you know if the unit test worker process will run as a 32-bit or 64-bit process when using desktop CLR?

@AHelper
Copy link
Author

AHelper commented Jun 26, 2017

@gregg-miskelly 64-bit process.

@gregg-miskelly
Copy link
Contributor

@AHelper in that case, this sounds pretty easy to do via unitTestDebuggingOptions if needed. @DustinCampbell would OmniSharp know what framework a test is supposed to run in?

@gregg-miskelly
Copy link
Contributor

@DustinCampbell would OmniSharp know what framework a test is supposed to run in? Or should I just allow 'type' to be set like AHelper suggested.

@DustinCampbell
Copy link
Member

Today, there's no input that tells us what the TargetFramework is unless it's specified in the project.

@gregg-miskelly gregg-miskelly self-assigned this Jul 24, 2017
@gregg-miskelly
Copy link
Contributor

Okay, I will make a tweak to let 'type' be settable.

@DustinCampbell
Copy link
Member

To be clear, if there's a single TargetFramework, we can do the right thing in OmniSharp. However, there's a further experience that needs built around having a switcher for TargetFramework, similar to Debug|Release, x86|x64, etc.

gregg-miskelly added a commit to gregg-miskelly/vscode-csharp that referenced this issue Jul 25, 2017
This checkin allows the unit test debugging options to set 'type'. This resolves dotnet#1586.
@gregg-miskelly
Copy link
Contributor

gregg-miskelly commented Jul 25, 2017

@AHelper I created a fix for you. Can you give it a try and verify it actually works end-to-end for your scenario?

  1. Download csharp-1.12.0-beta3.zip
  2. Change the extension from .zip to .vsix
  3. Follow beta release instructions to install

@gregg-miskelly
Copy link
Contributor

Actually, hold up one sec. I accidentally included more changes than I wanted to in that .vsix.

gregg-miskelly added a commit to gregg-miskelly/vscode-csharp that referenced this issue Jul 25, 2017
This checkin allows the unit test debugging options to set 'type'. This resolves dotnet#1586.
@gregg-miskelly
Copy link
Contributor

Okay, .zip updated. This should now work.

@AHelper
Copy link
Author

AHelper commented Jul 27, 2017

Just got to testing this on my end, the fix works perfectly, thanks!

@gregg-miskelly gregg-miskelly added this to the 1.12 milestone Jul 27, 2017
@gregg-miskelly
Copy link
Contributor

Great! This fix will ship in 1.12.

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

Successfully merging a pull request may close this issue.

3 participants