Search code examples
namespacesindentationriderc#-10.0

Jetbrains Rider: Prevent Indentation in file-scoped namespace


I am trying to make Rider not indent my c# code that is within a file-scoped namespace, because currently what Rider does, both when creating a new class and when reformatting existing code is the following:

namespace PreviewNamespace ;

    public class C
    {
    }

and i would want (also notice the whitespace between the namespace and the semicolon)

namespace PreviewNamespace;

public class C
{
}

What i tried so far:

  • Well i wished, i was able to edit the before/after preview that rider shows under Editor>Code Style> C#> Syntax Style>Code Body>Namespaces but unfortunately it's readonly.

  • It wouldn't really make sense, that this toggles it, but i also tried unchecking "Indent inside namespace declaration" under ...>C#>braces layout

Maybe it's just me and i need a clean installation of Rider or i'm just blind and completely missed a setting for this.

Either way, any help is greatly appreciated!

Cheers


Solution

  • I managed to figure out what caused this issue for me with a side-by-side setting comparison thanks to mu88's comments:

    Under Editor>Code Style> C#> Other I had the box Revert to old formatting engine (Resharper Other-section) ticked, unticking it resolved the issue.

    I hope this helps anyone that also has the same issue.

    EDIT: I also just noticed, that when Revert to old formatting engine is ticked, the checkbox Braces Layout > Indent inside namespace declaration (for me at least) changes nothing in the preview below.