Search code examples
c#unity-game-enginerider

Prevent Rider from generating namespaces around new scripts


I'm trying out Rider for Unity development. When I create a new script in the Scripts folder, it always wraps the class in

namespace DefaultNamespace {

    class MyClass //...

}

This is super annoying. I don't want a namespace assigned to every script, forcing them to be indented and for my other scripts having to have more using imports.

I can't figure out how to disable this.


Solution

  • On the top of rider click

    File -> Settings -> Editor -> Code style -> C# -> After file-scoped namespace directive enter image description here

    Set file-scoped namespace to 1

    Set inside namespace to 0

    UPDATE:

    Answer above resolve another issue, it`s about formatting existing code. To resolve this question you need to change template inside Rider settings, which you can do next way:

    Settings -> Editor -> File Templates -> C# -> class enter image description here There you can setup everything you need and remove what you don`t need