Skip to content

.NET 6 template changes for dotnet new console #25085

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

Closed
BillWagner opened this issue Jul 12, 2021 · 2 comments · Fixed by #25092
Closed

.NET 6 template changes for dotnet new console #25085

BillWagner opened this issue Jul 12, 2021 · 2 comments · Fixed by #25092
Assignees

Comments

@BillWagner
Copy link
Member

BillWagner commented Jul 12, 2021

For .NET 6, in preview 7, the “dotnet new console” app and Visual Studio’s “File:New Project” template for console apps will use top level statements.

We expect new developers to find this confusing if they are following an existing tutorial that shows the earlier Program.cs generated by those templates.

We need a new doc that helps these customers map from the tutorial text (using static void Main() in a Program class in a namespace) to the new output using top-level statements.

This new article will be linked from an aka.ms link that describes the changes.

@KathleenDollard
Copy link
Contributor

This looks good and matches the goal. I'd add that multiple people will encounter this link. We might want a landing page that has a bit about what top level programs are and has a few links:

  • Creating your first program using top level programs
  • Understanding top level programs
    • Compiler feature, no runtime changes
    • The class name is unspeakable (can't access from tests) although we are open to feedback on that
    • Multiple lines can be used (this has not been obvious to a couple people I have talked to, so making this easy)
    • If you add methods, they are local methods
    • Adding classes looks legal. I'm pretty sure they are nested in the unspeakable class for use by Main. Adding a namespace may change that.
    • They (of course) have access to implicit usings and any global usings set for the project

This last set of things would be super confusing for a new user, but pretty essential for any current programmer. Some of this is demonstrated in the current tutorial https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/tutorials/top-level-statements, but not laid out directly. That tutorial needs will not be best practice for C# 10 (implicit usings)

@BillWagner
Copy link
Member Author

Thanks @KathleenDollard

I think this article covers a lot of your additional points.

I'd like to keep this new link destination a short article that explains how to build the mental map from top-level programs to traditional tutorial content. That will point to these two articles, and let people explore more when they are ready. But the first touch is to remove the confusion by having different code than you were expecting.

BillWagner added a commit to BillWagner/docs that referenced this issue Jul 12, 2021
Fixes dotnet#25085

Describe the updated console app template changes, and point to more details on those language features.
@BillWagner BillWagner added doc-idea and removed Pri3 ⌚ Not Triaged Not triaged labels Jul 13, 2021
BillWagner added a commit that referenced this issue Jul 13, 2021
* Add article on new template output

Fixes #25085

Describe the updated console app template changes, and point to more details on those language features.

* fix broken link

* proofread and edit

* respond to feedback

* respond to feedback.

* Apply suggestions from code review

Co-authored-by: Kathleen Dollard <[email protected]>

* grammar

* Apply suggestions from code review

Co-authored-by: Andy (Steve) De George <[email protected]>

Co-authored-by: Kathleen Dollard <[email protected]>
Co-authored-by: Andy (Steve) De George <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants