dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.86k stars 671 forks source link

Creating project in Vscode, not automatically generating namespace etc #7470

Closed KazuyaZW closed 1 month ago

KazuyaZW commented 2 months ago

Hi! Basically a student who just started using vscode after learning c# in visual studio community. When creating a .net console app project it doesn't auto generate this stuff:

image

Is there any way to get it to do this? (c# and c# developer extension are the only things I have installed)

dibarbet commented 2 months ago

@KazuyaZW if you're using the C# Dev Kit extension, you should be able to invoke the following command to create a new project: image

That should then put you in a quick pick menu where you can select the project template (for example Console App would be one similar to the one in your screenshot).

If you're doing that, and you're not seeing what you expect, can you please share a screenshot of what actually gets generated?

JoeRobich commented 2 months ago

@KazuyaZW The latest .NET console templates use Top-Level Statements (See https://learn.microsoft.com/en-us/dotnet/csharp/tutorials/top-level-statements). The C# extension includes a refactoring to convert a Top-Level Statements program to the more conventional Program.Main style. It should be in the light bulb when editing a top-level statements program.

Image

dibarbet commented 1 month ago

Closing, no action to take here. If you're still encountering issues please feel free to reopen.