Skip to content

Top-level statements for EFGetStarted #3865

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
May 17, 2022
Merged

Top-level statements for EFGetStarted #3865

merged 1 commit into from
May 17, 2022

Conversation

danielniccoli
Copy link
Contributor

Migrate EFGetStarted sample to using top-level statements feature. (https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/program-structure/top-level-statements)

@dnfadmin
Copy link

dnfadmin commented May 13, 2022

CLA assistant check
All CLA requirements met.

@roji
Copy link
Member

roji commented May 15, 2022

Briefly discussed in #2697. Not sure if we decided something specifically for the getting started sample, top-level statements may have been too new (and therefore unfamiliar to new users).

@danielniccoli
Copy link
Contributor Author

danielniccoli commented May 15, 2022

Top-level statements may have been too new (and therefore unfamiliar to new users).

  • Top-level statements are enabled for new projects by default, since November 2020.
  • People new to C# will probably start with the official Hello World tutorial, which also uses top-level statements.

So if anyone is unfamiliar with top-level statements, it's old users, not new users. 🙂

Top-level statements are going to stay. They have been the recommended way to start new C# projects since November 2020 and will be in the future.

Creating a new .NET console project will create a top-level statement based sample code. Consequently, when following the "Getting Started" tutorial for EF, running dotnet new console -o EFGetStarted, you already start with top-level statements.

When you create a ASP.NET Core 6 Web App, a Razor App, or a Blazor App, you start with a top-level statement sample. The official tutorial for ASP.NET Core 6 uses top-level statements e.g., the one for Razor Pages

It makes no sense that the EF Get Started tutorial keeps using void Main(), while top-level statements are used everywhere else, in the official docs and tutorials and all .NET templates (dotnet net console/webapp/razor/blazor/…).

Not sure where to discuss this, as the ticket you mention is closed. Maybe you have a suggestion where to put this opinion.

@roji
Copy link
Member

roji commented May 15, 2022

@danielniccoli I don't disagree with you, but the team had other thoughts. It's a while later, so we'll revisit this when triaging this issue.

@roji
Copy link
Member

roji commented May 17, 2022

Actually I forgot we've already received #3828 for this, and decided it was OK to do it. I'll look at both PRs soon and merge one.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants