Skip to content

Should the console project template use top-level statements #27420

Closed

Description

@tdykstra

For .NET 6, the console project template was changed to use top-level statements. The code that is created in Program.cs is:

// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");

In earlier versions of .NET and .NET Core, the code that is created in Program.cs is:

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!");
        }
    }
}

Discussion about whether this was a good change began in #26313 but there was some confusion about what exactly the various up or down votes applied to. This issue provides comments to vote on that clearly describe the options.

Activity

  1. tdykstra commented on Dec 6, 2021

    @tdykstra
    ContributorAuthor

    Up-vote this comment if you support the use of top-level statements in project templates.

  2. tdykstra commented on Dec 6, 2021

    @tdykstra
    ContributorAuthor

    Up-vote this comment if you prefer project templates to use the code created in previous .NET versions.

  3. tdykstra commented on Dec 6, 2021

    @tdykstra
    ContributorAuthor

    Up-vote this comment if you would like to be given a choice between top-level statements code and the code created in previous .NET versions.

  4. added
    discussion
    and removed
    ⌚ Not Triaged
    on Dec 6, 2021
  5. added and removed on Dec 6, 2021
  6. q00Dree commented on Dec 7, 2021

    @q00Dree

    I'm sorry in advance, but what about ASP.NET Core templates like -webapi ?
    I'd like to have choice between normal Startup.cs and Program.cs vs new Program.cs

  7. tdykstra commented on Dec 7, 2021

    @tdykstra
    ContributorAuthor

    what about ASP.NET Core templates like -webapi ? I'd like to have choice between normal Startup.cs and Program.cs vs new Program.cs

    @Rick-Anderson do you want to create a discussion issue like this one in the ASP.NET Core repo?

  8. Rick-Anderson commented on Dec 7, 2021

    @Rick-Anderson
    Contributor

    I'm sorry in advance, but what about ASP.NET Core templates like -webapi ?
    I'd like to have choice between normal Startup.cs and Program.cs vs new Program.cs

    Use the ASP.NET Core 5 templates. Startup is fully supported.

  9. bravecobra commented on Dec 7, 2021

    @bravecobra

    Use the ASP.NET Core 5 templates. Startup is fully supported.

    That is only temporary as those templates will be removed once .net core 5 is out of support. So, no, that is not a valid permanent solution to the problem.

  10. 823 remaining items

  11. ccarlo88 commented on Nov 28, 2022

    @ccarlo88

    @milanjaros Positive feedback from which group? The Python programmers who create 1 micro-microservice for each task? The group who likes the feature but in the end go back and do it in Python? The feedback you need to listen is from C# programmers, not Python programmers. If Python was good no one would use C#.

  12. derempoukas commented on Nov 28, 2022

    @derempoukas

    Fake simplicity for the sake of looking busy.
    This whole idea is the new Clippy
    image

  13. milanjaros commented on Nov 28, 2022

    @milanjaros

    We can joke about it, and we can disagree about it, but that's all we can do against it.

  14. MrChenLearnSpace commented on Dec 15, 2022

    @MrChenLearnSpace

    Do not support, gild the lily, quickly change back, it is recommended to add this setting in the options, for later generated projects can automatically close this function, thank you

  15. Joebeazelman commented on Dec 19, 2022

    @Joebeazelman
  16. ccarlo88 commented on Dec 19, 2022

    @ccarlo88
  17. derempoukasm commented on Dec 19, 2022

    @derempoukasm
  18. mwwhited commented on Dec 19, 2022

    @mwwhited
  19. mwwhited commented on Dec 19, 2022

    @mwwhited
  20. CyrusNajmabadi commented on Dec 19, 2022

    @CyrusNajmabadi
    Contributor

    The topic is about project templates. Discussing things like hiring practices or the zune (which was in 2006) is just about as off topic as one could get on this subject. This also includes grievances on other unrelated technologies (like azure functions). If you have feedback on those tools and technologies, there are other suitable locations to bring that up.

    Wrt other languages, I can say that that wasn't what we were thinking about when doing these features. As the main designer of one of them (file scoped namespaces), and a codesigner on many others, I can say that it goals were to bring the benefits we found with our REPL experience in c# interactive to the majority of programs.

    Clearly the ideas are polarizing for some. So we've provided knobs and options to disable all the things that are not desired. If you're having issues with those, or want to bring up some case that hasn't been considered , please let use know what those cases are. However, please keep those new issues on topic and constructive. We're all devs here, and we can keep things grounded on the project templates. Thanks!

  21. locked as too heated and limited conversation to collaborators on Dec 19, 2022
  22. BillWagner commented on Sep 30, 2025

    @BillWagner
    Member

    Closing as this discussion has run its course.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions