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

Simplify debug #4795

Open
isidorn opened this issue Oct 4, 2021 · 6 comments
Open

Simplify debug #4795

isidorn opened this issue Oct 4, 2021 · 6 comments

Comments

@isidorn
Copy link
Contributor

isidorn commented Oct 4, 2021

Hi VS Code PM here 👋

I just followed this tutorial to setup a simple C# app and to debug it. Here's my feedback on what I think we could improve:

  1. C# should consider contributing to the Editor title area menu, such that a Play button would appear in the Editor Title area. Example how to do this
  2. You ask the user via a notification that "things are missing to run and debug..." and your intention is to automatically create a launch.json. This helps the flow, but is out of the context, since user did not even trigger debugging. Instead of this I suggest that your extension simply provides a dynamic resolveDebugConfiguartion that will provide a launch configuration on the fly. Example. That way you can generate the config when it is needed, and in memory. Alternatively: if you really want to write into launch.json you should do it when the user starts debugging I think.
  3. If the user does not see the notification it is impossible to debug since you are not resolving debug configurations on the fly
  4. If I have a purple no folder VS Code it is impossible to debug a simple C# file
  5. Consider contributing to an Empty debug view to make C# debug setup easier (C++ does this for example)

I would love if we could improve this experience, since we see in user studies that users want a confirmation that VS Code can do C#, and providing an easy way to run and debug simple C# files would be great for this.

Let me know if I can help somehow. I am also open to a quick 30 min meeting where we can discuss about the new cool VS Code debug features that C# could potentially adopt and you could let us know what are your biggest ask for the VS Code debugger.

fyi @gregg-miskelly @weinand

@WardenGnaw
Copy link
Contributor

Hi @isidorn!

Thanks for the suggestions!

C# should consider contributing to the Editor title area menu, such that a Play button would appear in the Editor Title area.

We are afraid this is going to over promise our users since if they have a project that is a class library, there is no executable to run. We could work with it and just display an error dialog if they try to run the "file", but its heavily depending on the contents of the project file (csproj).

You ask the user via a notification that "things are missing to run and debug..." and your intention is to automatically create a launch.json. This helps the flow, but is out of the context, since user did not even trigger debugging. Instead of this I suggest that your extension simply provides a dynamic resolveDebugConfiguartion that will provide a launch configuration on the fly. Example. That way you can generate the config when it is needed, and in memory. Alternatively: if you really want to write into launch.json you should do it when the user starts debugging I think.

This we can do. We will want to keep the prompt since it is helpful even without debugging since this well help users with dotnet watch in the tasks.json so they can write code and see active changes while editing their source code. However, we can also add generating and writing to tasks.json and launch.json when the user requests to start debugging.

If the user does not see the notification it is impossible to debug since you are not resolving debug configurations on the fly

Solved with the comments last question.

If I have a purple no folder VS Code it is impossible to debug a simple C# file

It is not possible to debug only a single C# file. There are configurations defined in the project file (csproj) that are needed to build and run C# source file(s).

Consider contributing to an Empty debug view to make C# debug setup easier (C++ does this for example)

We can do this and add a link to https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md

See https://github.com/microsoft/vscode-cpptools/blob/32ac8ae30d7486ba003c257ac1efd714396f1844/Extension/package.nls.json#L182

@isidorn
Copy link
Contributor Author

isidorn commented Oct 5, 2021

@WardenGnaw thanks for the quick response. I agree with the action items you proposed:

  1. Populate tasks.json and launch.json also when the user starts debugging
  2. Add link to setup docs in debug getting started, or even better add a button for "Setup Debug" that would automatically create a launch.json / tasks.json based on project

And here are some additional ones:

  1. Simplify generated launch.json (why is stopOnEntry needed)? And cwd and console. Do you think users change those 3 very often?
  2. Debugging single file: looking at my csproj file the only thing that is defined is the TargetFramework. Wouldn't it be possible that I have a single file and on debug start you ask the user what framework to use? Or you need more things from the csproj that I am missing?

@WardenGnaw
Copy link
Contributor

  1. Simplify generated launch.json (why is stopOnEntry needed)? And cwd and console. Do you think users change those 3 very often?

I think we keep these to show users its available to be changed. Newer users dont seem to use intellisense to figure out what options exist in the launch.json.

  1. Debugging single file: looking at my csproj file the only thing that is defined is the TargetFramework. Wouldn't it be possible that I have a single file and on debug start you ask the user what framework to use? Or you need more things from the csproj that I am missing?

This is dependent on the SDK version they are using. In genenral, OutputType and TargetFramework are important.

With the latest .NET 6 features, there is a ImplicitUsings tag that is important if they are using C# with top level statements e.g.

Console.WriteLine("Hello, World!");

instead of

using System;
using System.Collections.Generic;
using System.Linq;

namespace MyApp // Note: actual namespace depends on the project name.
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}

So it is not that feasible to just open a file with an extension .cs and debug it. It heavily depends on the user going through the dotnet new <project-type> that will create the project directory for them and open that folder in VS Code.

@weinand
Copy link

weinand commented Oct 7, 2021

@WardenGnaw you said:

So it is not that feasible to just open a file with an extension .cs and debug it. It heavily depends on the user going through the dotnet new that will create the project directory for them and open that folder in VS Code.

But when a user has a .cs file open in an editor and presses the editor's Run/Debug button, it would be possible to detect the missing .net project setup and present a QuickPick with some dotnet new <project-type> suggestions. And after a selection is made by the user, VS Code could reopen the newly create folder and run the file, right?

@gregg-miskelly
Copy link
Contributor

gregg-miskelly commented Oct 7, 2021

But when a user has a .cs file open in an editor and presses the editor's Run/Debug button, it would be possible to detect the missing .net project setup and present a QuickPick with some dotnet new <project-type> suggestions. And after a selection is made by the user, VS Code could reopen the newly create folder and run the file, right?

From what I can tell, not today: dotnet new doesn't seem to have an option to only generate the .csproj. So you could do it, but if your scenario was:

  1. Create a new folder
  2. Add a .cs file to the folder
  3. Type in some code
  4. Try to run it

I am not aware of any way to make that make that a smooth experience today. Today, I would highly recommend instead starting with an empty folder and using dotnet new.

This is really not a debugger question, so I don't think we have the right folks involved in this conversation. @richlander is there someone on the .NET PM team that is interested in looking at new user aquisition in VS Code who would be better at trying to understand if this is a compelling scenario for C#?

@WardenGnaw
Copy link
Contributor

I am not aware of any way to make that make that a smooth experience today. Today, I would highly recommend instead starting with an empty folder and using dotnet new.

The omnisharp-vscode extension can contribute a walkthrough similar to vscode-cpptools.

This is what you see with VS Code with no folder open.
image

This way we can get users who have the C# extension installed to open VS Code in a folder and execute dotnet new with a selection dialog of the choices.

Common templates are:
Template Name         Short Name    Language    Tags
--------------------  ------------  ----------  -------------------
ASP.NET Core Web App  webapp,razor  [C#]        Web/MVC/Razor Pages
Blazor Server App     blazorserver  [C#]        Web/Blazor
Class Library         classlib      [C#],F#,VB  Common/Library
Console App           console       [C#],F#,VB  Common/Console
Windows Forms App     winforms      [C#],VB     Common/WinForms
WPF Application       wpf           [C#],VB     Common/WPF

Here is a view of the (C++) walkthrough:
image

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

No branches or pull requests

6 participants