question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Visual Studio does not retain 'Do not use top-level statements' check.

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

First of all, thank you ASP.NET Core Team for adding an option in templates to avoid top-level statement.

However, we have noticed that Visual Studio is not retaining the Do not use top-level statement check.

First Time:

Capture1

Second Time:

Capture2

Note: All other checks are retaining their last choice.

Expected Behavior

Check should retain the last choice.

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

6.0.300 and 7.0.100-preview.4.22252.9

Anything else?

Visual Studio Version: 2022 17.3 preview 1.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
DamianEdwardscommented, May 24, 2022

Details for the change we need to make to the ide.host.json for each web project template, including the console template, in 7.0:

{
  "id": "UseProgramMain",
  "isVisible": true,
  "PersistenceScope": "Shared",
  "PersistenceScopeName": "Microsoft"
}

@phenning is going to ensure that once we make this change in 7.0, any customer with both 6.x and 7.0 installed will see this option become sticky for all versions of the template available, i.e. it will become sticky in 6.x templates too.

/Cc @vlada-shubina

1reaction
DamianEdwardscommented, Jul 13, 2022

Yeah this fix is in the 7.0 SDK and thus will only apply to 6.0 projects when 7.0.100-preview.6 is installed. VS 17.4 will default to including .NET 7 SDK at which point this will be fixed for 6.0 projects too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Visual Studio 2022 doesn't show the "Do not use top-level ...
Visual Studio 2022 doesn't show the "Do not use top-level statements" checkbox when creating new project.
Read more >
How can I disable Top-level statements when using `dotnet ...
I created a C# project with the below command in VSCode and enabled Top-level statements automatically for this project. How can I disable...
Read more >
C# console app template generates top-level statements
On this page, select the Do not use top-level statements check box. Visual Studio do not use top-level statements check box. After your...
Read more >
Question - Trouble with Top-Level Statement
Hello Im a beginner at C# coding and trying to make a simple cmd prompt that shows the status of a service running....
Read more >
Top-Level Statements in C# - Code Maze
In this article, we are going to learn about the top-level statements in C#. Whenever we start learning a new programming language, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found