-
Notifications
You must be signed in to change notification settings - Fork 368
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
Add simpler way to get the "old style" console templates #3985
Comments
How often to you "dotnet new console"? As features go this one has minimal utility. |
@glennsills VERY often in VS (not so much from the console). The suggestion has zero effect on everyone who wants the new template, as it's still default. But it does give an easy opt-out for those who doesn't want it. |
Adding to the initial @dotMorten 's request, it would be great whether we could set the default value too (in order to avoid having to type the same options all the time). Answering to @glennsills, in the team, we use console applications quite often for different types of tests, simulators, etc (mainly in IoT projects, which I understand are quite specific, but not exclusively). We are even working on our own templates for this. |
In a C# training I do this maybe 10 times a day. So I do this 50 times a month. |
An update on this: Unfortunately the directions in docs are not complete and that approach relies on .NET 5 being installed. We will update the page, but it is more difficult to get old style projects than suggested in the page as posted. Honestly, it will probably be easiest to just copy the old version from docs (which we included in the page for your convenience). We do not plan to change this for .NET 6 GA. We are still assessing the best path and do not want to make a knee jerk reaction - there's a key question in whether folks hate all four of the changes in the new templates, or just this one:
There are also questions around naming of a switch. I know one is suggested in this issue, but it's long and most of you have not enabled tab completion, and we'd want more feedback and consideration of the other issues. Even if we were ready to make this change, we do not have time to get feedback to get it right for .NET 6 GA. We want your feedback and to help with the decision on providing a way to opt in to the old style templates. If haven't voted on the issue, please do. @dotMorten Could you edit the initial issue to say that we are updating the docs page and that it also requires .NET 5 to be installed. If you rather I do it, let me know. @sonnemaf Could you give feedback on whether switching training to the new style is something you are considering. |
@KathleenDollard I did point out that not having .NET 5 installed creates issues. Don't really get your comment about doc and how that affects this issue. The doc I referred to was just to say "this is how you're telling us to work around it", and wanted to point out that you have use work arounds rather than having a built-in feature. I don't see how updating the doc would change that?
I'd say just the one. Wrt all the other features, those are IMHO completely different and unrelated to this issue - they are also all project settings that can more easily be changed after-the-fact. Enabling new language features seems reasonable when targeting .NET 6 - the issue here and my gut feeling most people don't like is the magic hidden code that gets generated. No other class in your project will look like this, you can't see the namespace, class name, name of parameters or the return type.
Just a conceptual thing. I don't care about the final name - In most cases I just want a checkbox generated inside the VS template wizard. |
I took the existing console template and tweaked it slightly. I was surprised how little I needed to do, because switching it on and off was already there. So here's the experience I got in VS with that (notice the extra checkbox): If you want to try this for yourself, here's the template package: To install it: You can uninstall with |
@KathleenDollard I don't use the TopLevelStatements because some of the refactorings are not available in it. Take for example the Explaining what a class Program and a static method Main is doing isn't that hard. It also gives me the opportunity to explain readonly fields and access modifiers. Maybe it is just me. But I like the old way just better. So no I'm not considering switching to the new style. |
Also consider #3654 (and its original https://GitHub.com/dotnet/templates/issues/520 ) proposing a second template |
I don't use top level statement because the pattern is so disjoin from the rest of the source that it doesn't even seem like the same programming language. |
Norville Barnes to his co-dev: "Top-level statements, I developed it my self, yessiree this is my ticket upstairs." Actually,- Norville Barnes idea was genius, a 'Hula hoop', unlike this one, 'Top-level statements'. static int Main(string[] args) { return 0; } Yeah, I know, |
I'm happy to report that in .NET SDK 6.0, the |
You don't get to decide how people use features. Please don't give non answers like this... |
I am on VS2022 and none of these solutions work, btw. I am sure my SDK is up to date. and there is no "Top Level Statements" Checkbox when starting a new console app. Unless I need to download a new template? Shouldn't this just be a part of the SDK by now? I think this new console template is kinda bad. It's just confusing to new users. |
Can you please show what version of the SDK you're using? |
Verify this...
If I then run
Program.cs should then look like:
You might also want to verify that there is no global.json forcing the use of an older SDK. You can verify it like this
To get the latest .NET 6 SDK you can
Then you can easily update to the latest version when updates come out like this
|
I've the exact same problem... |
@federico-r-figueredo Try upgrading you .net sdk to 6.0.300 or greater. |
If I don't want to use the new console style projects with generated top-level statements , since I might feel it becomes the odd-one-out file in a project otherwise consisting of "full" classes, I have to do so in a very round about way, as documented here:
https://docs.microsoft.com/en-us/dotnet/core/tutorials/top-level-templates#use-the-old-program-style
The problem with this approach (apart from being very unintuitive) is that it doesn't work from within VS2022 (sure I could pick 5 then manually change it after, but if I don't have the 5 SDK installed that leads to more confusing errors on project creation).
Instead I think it would have been cleaner if there was a boolean I could set that the VS IDE also allows me to uncheck to disable the use of top level statements .
It would have been cleaner to have something like
and in VS this would translate to a checkbox I can uncheck.
The text was updated successfully, but these errors were encountered: