Disable .NET 6 top-level statements on ConsoleApp

How to return old console style, like in .NET 5.0? Visual Studio has disable-button.I love old style.

8 comments
Comment actions Permalink

Hello, there is no such option in Rider. There is a corresponding issue on our tracker: RIDER-79136. As a workaround, I can suggest creating a solution that targets .NET 5 and then changing target.

0
Comment actions Permalink

HI, the given advice to use SDK5 then change to SDK6 no longer works!

I have just hit this exact thing, I want to NOT TURN ON top level statements in a .NET 6 console app and there is no option.

If I create my app as an SDK5 app, I get what's expected:

BUT, if I then go into my properties, there is NO .NET 6 option

.NET 6 is definitely installed on my machine, because I'm allowed to choose it when creating a new project:

When can we get this option added?

 

0
Comment actions Permalink

Hello Shawty,

This feature is not yet implemented. We have a corresponding issue on our bug tracker. It has not been planned yet. We would appreciate it if you would upvote the issue in order to demonstrate additional interest and bring increased awareness to the issue.

If you have any other questions, do not hesitate to ask. Have a great day!

0
Comment actions Permalink

Already upvoted :-)  5 mins after I originally posted this.

I just also wanted to make a point that the old way of creating an SDK5 then switching to 6 advice you've been using as a workround no longer works.

0
Comment actions Permalink

Can you edit the csproj and remove the

<ImplicitUsings>enable</ImplicitUsings>

setting - does that work?

0
Comment actions Permalink

Tim Barrass, yes and no.

All that setting does is disable the feature in your project, so that if anyone then tries to create a top level file without the required boiler plate, the compiler will complain.

What we are talking about here in this thread is having the option in the IDE to enable/disable this at project creation time (IE: before csproj is even created)

 

0
Comment actions Permalink

Yes, it's a workaround, not a fix, but it helps anyone waiting for the fix.

0
Comment actions Permalink

I agree Tim, but it still means that when you create a new project, you have no choice but to create a project that has only the one top line statement in your program.cs file, and thus have to sit and write all the old boiler plate back in by hand.

 

0

Please sign in to leave a comment.