Create project / classes without newest C# features

So without going into details about the project itself, I need to be able to create projects without the default file scoped namespaces and global usings.

Also when I create a new class it gets a file scoped namespace by default... I've not found any setting that could change this behaviour.

0
3 comments

Hello Glen,

Thank you for contacting Rider support.
Regrettably, it depends on project templates and can not be modified. However, there are the following options to solve this problem:

  • Target .NET 5.0 in your projects;
  • Creating a project that targets .NET 5. Then just change the `TargetFramework` in .csproj file to net6.0;
  • Use non-standart templates. You can create your own or use those that are shared by dotnet community. For example, here you can find this template for .NET 6 console project without the mentioned top-level statement and global using features. It is just like .net 5 default template but targets .NET 6.

Also, to create new classes with block-scoped namespaces, please set the `File | Settings | Editor | Code Style | C# | Syntax Style | Code Body | Namespaces` option to `Block-scoped`.

Hope it helps. Have a nice day!

0

That was actually very helpful, thanks.

0

Hello Glenn,

I am happy to hear that I was able to help.
Should you have any other questions or difficulties in the future, do not hesitate to contact support.

Have a nice day!

0

Please sign in to leave a comment.