C
C#5mo ago
chx777

Using the C# dev kit(not the dotnet cli) how to disable top level statements within vscode?

Is there a setting to disable top level statements in vscode please?. I only know the "dotnet new console --use-program-main" command
19 Replies
Jimmacle
Jimmacle5mo ago
what do you mean disable them? just don't use them
leowest
leowest5mo ago
think he wants the opposite the older template with namespace and class which vscode doesnt really have an option for other than doing the cli command manually like in visual studio u have a checkbox to disable/enable it
chx777
chx777OP5mo ago
exactly....i was hoping there is a way in vscode too
leowest
leowest5mo ago
only way I can think of would be for u to edit the default template
chx777
chx777OP5mo ago
How can i do that please?
leowest
leowest5mo ago
mmm I dont know where .net 8 stores the template I know where visual studio does and I dont know if its shared or the same folder https://learn.microsoft.com/en-us/visualstudio/ide/how-to-locate-and-organize-project-and-item-templates?view=vs-2022 that is for visual studio dont know if its shared with dotnet or not so I dont know what would be the location to find the ones used by the cli and how easy they can be editted
chx777
chx777OP5mo ago
i see...thank you anyway my friend...i appreciate your help
Angius
Angius5mo ago
The alternative is to just use top-level statements ¯\_(ツ)_/¯
leowest
leowest5mo ago
ah looks like the templates on dotnet 8 are nuget packages now interesting
No description
leowest
leowest5mo ago
so u would have to package it properly to replace it so I would not recommend u to touch those anyway gl with whatever u decide to do C:\Program Files\dotnet\templates\x.x.x is the folder
Angius
Angius5mo ago
Templates in general are distributed as nuggies
leowest
leowest5mo ago
before it was not(been a few years since I done it, I remember just modifying a file and that was it but with .net core which is now just .net seems like a lot has changed in that regards) u could easily modify it on older version of visual studio
chx777
chx777OP5mo ago
I am a beginner to c# and i thought that it is better to start with the old style first.Most tutorials follow the old style. I guess i have to stick withe the new template
leowest
leowest5mo ago
if you're a beginner I strongly recommend u use visual studio if u are not on linux c# is not like python and other alike languages and visual studio will give u a better frame while i learn it
chx777
chx777OP5mo ago
i am on linux
Angius
Angius5mo ago
Do you qualify for $freerider license?
MODiX
MODiX5mo ago
There are two ways to get Rider for free: Being a student: https://www.jetbrains.com/community/education/#students Using it for an OSS project: https://www.jetbrains.com/community/opensource/#support
reflectronic
reflectronic5mo ago
you can just press Ctrl + . in your Program.cs and then select the option "Convert to Main style program" it is not the same as changing the template yes but it is one press to go back to the old style
chx777
chx777OP5mo ago
Thank you really...I did not know that
Want results from more Discord servers?
Add your server