csharp_new_line_before_open_brace

Which constructs put their opening brace on a new line.

Value Notes
all
none
types
methods
accessors
anonymous_types
anonymous_methods
lambdas
control_blocks
object_collection_array_initializers Moves an object initializer's brace. A collection or array initializer's brace stays where it was written, as in dotnet format.
properties
events Accepted, but moves no brace on its own: an event's braces follow properties, as in dotnet format.

Default: all

Curb's output is not always a fixed point of the tool(s) below for this key — see conformance divergences for the full registry.

  • dotnet-format-whitespace: Same fallback-mismatch shape as csharp_indent_labels: Curb falls back to the documented default (all/Allman) for an unrecognised value. Measured: dotnet format leaves the source untouched for the same unrecognised value, i.e. it silently skips applying the setting rather than falling back to its own documented default. (NewLineBeforeOpenBraceTests.An_unrecognised_value_falls_back_to_the_default)
  • ide0055: Same fallback-mismatch divergence as the dotnet-format-whitespace entry above (Curb falls back to the documented default for an unrecognised value; dotnet format's own fallback for the same invalid value disagrees), now confirmed to reproduce under a real, analyzer-driven dotnet build -p:EnforceCodeStyleInBuild=true too, not just the dotnet format whitespace CLI — expected, since IDE0055 is the same underlying Roslyn formatting engine. (NewLineBeforeOpenBraceTests.An_unrecognised_value_falls_back_to_the_default)
Ini
csharp_new_line_before_open_brace = all
C#
using System;

namespace N;

public class Widget {
    private int _x;

    public int X {
        get {
            return _x;
        }
        set {
            _x = value;
        }
    }

    public event EventHandler Changed {
        add {
        }
        remove {
        }
    }

    public void Run() {
        if (X > 0) {
            X--;
        }

        var point = new {
            X = 1,
        };
        var copy = new Widget {
            X = 1,
        };
        Action log = delegate {
            Console.WriteLine(point);
        };
        Func<int, int> twice = n => {
            return n * 2;
        };
    }
}
C#
using System;

namespace N;

public class Widget
{
    private int _x;

    public int X
    {
        get
        {
            return _x;
        }
        set
        {
            _x = value;
        }
    }

    public event EventHandler Changed
    {
        add
        {
        }
        remove
        {
        }
    }

    public void Run()
    {
        if (X > 0)
        {
            X--;
        }

        var point = new
        {
            X = 1,
        };
        var copy = new Widget
        {
            X = 1,
        };
        Action log = delegate
        {
            Console.WriteLine(point);
        };
        Func<int, int> twice = n =>
        {
            return n * 2;
        };
    }
}
Ini
csharp_new_line_before_open_brace = none
C#
using System;

namespace N;

public class Widget
{
    private int _x;

    public int X
    {
        get
        {
            return _x;
        }
        set
        {
            _x = value;
        }
    }

    public event EventHandler Changed
    {
        add
        {
        }
        remove
        {
        }
    }

    public void Run()
    {
        if (X > 0)
        {
            X--;
        }

        var point = new
        {
            X = 1,
        };
        var copy = new Widget
        {
            X = 1,
        };
        Action log = delegate
        {
            Console.WriteLine(point);
        };
        Func<int, int> twice = n =>
        {
            return n * 2;
        };
    }
}
C#
using System;

namespace N;

public class Widget {
    private int _x;

    public int X {
        get {
            return _x;
        }
        set {
            _x = value;
        }
    }

    public event EventHandler Changed {
        add {
        }
        remove {
        }
    }

    public void Run() {
        if (X > 0) {
            X--;
        }

        var point = new {
            X = 1,
        };
        var copy = new Widget {
            X = 1,
        };
        Action log = delegate {
            Console.WriteLine(point);
        };
        Func<int, int> twice = n => {
            return n * 2;
        };
    }
}
Ini
csharp_new_line_before_open_brace = types
C#
using System;

namespace N;

public class Widget
{
    private int _x;

    public int X
    {
        get
        {
            return _x;
        }
        set
        {
            _x = value;
        }
    }

    public event EventHandler Changed
    {
        add
        {
        }
        remove
        {
        }
    }

    public void Run()
    {
        if (X > 0)
        {
            X--;
        }

        var point = new
        {
            X = 1,
        };
        var copy = new Widget
        {
            X = 1,
        };
        Action log = delegate
        {
            Console.WriteLine(point);
        };
        Func<int, int> twice = n =>
        {
            return n * 2;
        };
    }
}
C#
using System;

namespace N;

public class Widget
{
    private int _x;

    public int X {
        get {
            return _x;
        }
        set {
            _x = value;
        }
    }

    public event EventHandler Changed {
        add {
        }
        remove {
        }
    }

    public void Run() {
        if (X > 0) {
            X--;
        }

        var point = new {
            X = 1,
        };
        var copy = new Widget {
            X = 1,
        };
        Action log = delegate {
            Console.WriteLine(point);
        };
        Func<int, int> twice = n => {
            return n * 2;
        };
    }
}
Ini
csharp_new_line_before_open_brace = methods
C#
using System;

namespace N;

public class Widget
{
    private int _x;

    public int X
    {
        get
        {
            return _x;
        }
        set
        {
            _x = value;
        }
    }

    public event EventHandler Changed
    {
        add
        {
        }
        remove
        {
        }
    }

    public void Run()
    {
        if (X > 0)
        {
            X--;
        }

        var point = new
        {
            X = 1,
        };
        var copy = new Widget
        {
            X = 1,
        };
        Action log = delegate
        {
            Console.WriteLine(point);
        };
        Func<int, int> twice = n =>
        {
            return n * 2;
        };
    }
}
C#
using System;

namespace N;

public class Widget {
    private int _x;

    public int X {
        get {
            return _x;
        }
        set {
            _x = value;
        }
    }

    public event EventHandler Changed {
        add {
        }
        remove {
        }
    }

    public void Run()
    {
        if (X > 0) {
            X--;
        }

        var point = new {
            X = 1,
        };
        var copy = new Widget {
            X = 1,
        };
        Action log = delegate {
            Console.WriteLine(point);
        };
        Func<int, int> twice = n => {
            return n * 2;
        };
    }
}
Ini
csharp_new_line_before_open_brace = accessors
C#
using System;

namespace N;

public class Widget
{
    private int _x;

    public int X
    {
        get
        {
            return _x;
        }
        set
        {
            _x = value;
        }
    }

    public event EventHandler Changed
    {
        add
        {
        }
        remove
        {
        }
    }

    public void Run()
    {
        if (X > 0)
        {
            X--;
        }

        var point = new
        {
            X = 1,
        };
        var copy = new Widget
        {
            X = 1,
        };
        Action log = delegate
        {
            Console.WriteLine(point);
        };
        Func<int, int> twice = n =>
        {
            return n * 2;
        };
    }
}
C#
using System;

namespace N;

public class Widget {
    private int _x;

    public int X {
        get
        {
            return _x;
        }
        set
        {
            _x = value;
        }
    }

    public event EventHandler Changed {
        add
        {
        }
        remove
        {
        }
    }

    public void Run() {
        if (X > 0) {
            X--;
        }

        var point = new {
            X = 1,
        };
        var copy = new Widget {
            X = 1,
        };
        Action log = delegate {
            Console.WriteLine(point);
        };
        Func<int, int> twice = n => {
            return n * 2;
        };
    }
}
Ini
csharp_new_line_before_open_brace = anonymous_types
C#
using System;

namespace N;

public class Widget
{
    private int _x;

    public int X
    {
        get
        {
            return _x;
        }
        set
        {
            _x = value;
        }
    }

    public event EventHandler Changed
    {
        add
        {
        }
        remove
        {
        }
    }

    public void Run()
    {
        if (X > 0)
        {
            X--;
        }

        var point = new
        {
            X = 1,
        };
        var copy = new Widget
        {
            X = 1,
        };
        Action log = delegate
        {
            Console.WriteLine(point);
        };
        Func<int, int> twice = n =>
        {
            return n * 2;
        };
    }
}
C#
using System;

namespace N;

public class Widget {
    private int _x;

    public int X {
        get {
            return _x;
        }
        set {
            _x = value;
        }
    }

    public event EventHandler Changed {
        add {
        }
        remove {
        }
    }

    public void Run() {
        if (X > 0) {
            X--;
        }

        var point = new
        {
            X = 1,
        };
        var copy = new Widget {
            X = 1,
        };
        Action log = delegate {
            Console.WriteLine(point);
        };
        Func<int, int> twice = n => {
            return n * 2;
        };
    }
}
Ini
csharp_new_line_before_open_brace = anonymous_methods
C#
using System;

namespace N;

public class Widget
{
    private int _x;

    public int X
    {
        get
        {
            return _x;
        }
        set
        {
            _x = value;
        }
    }

    public event EventHandler Changed
    {
        add
        {
        }
        remove
        {
        }
    }

    public void Run()
    {
        if (X > 0)
        {
            X--;
        }

        var point = new
        {
            X = 1,
        };
        var copy = new Widget
        {
            X = 1,
        };
        Action log = delegate
        {
            Console.WriteLine(point);
        };
        Func<int, int> twice = n =>
        {
            return n * 2;
        };
    }
}
C#
using System;

namespace N;

public class Widget {
    private int _x;

    public int X {
        get {
            return _x;
        }
        set {
            _x = value;
        }
    }

    public event EventHandler Changed {
        add {
        }
        remove {
        }
    }

    public void Run() {
        if (X > 0) {
            X--;
        }

        var point = new {
            X = 1,
        };
        var copy = new Widget {
            X = 1,
        };
        Action log = delegate
        {
            Console.WriteLine(point);
        };
        Func<int, int> twice = n => {
            return n * 2;
        };
    }
}
Ini
csharp_new_line_before_open_brace = lambdas
C#
using System;

namespace N;

public class Widget
{
    private int _x;

    public int X
    {
        get
        {
            return _x;
        }
        set
        {
            _x = value;
        }
    }

    public event EventHandler Changed
    {
        add
        {
        }
        remove
        {
        }
    }

    public void Run()
    {
        if (X > 0)
        {
            X--;
        }

        var point = new
        {
            X = 1,
        };
        var copy = new Widget
        {
            X = 1,
        };
        Action log = delegate
        {
            Console.WriteLine(point);
        };
        Func<int, int> twice = n =>
        {
            return n * 2;
        };
    }
}
C#
using System;

namespace N;

public class Widget {
    private int _x;

    public int X {
        get {
            return _x;
        }
        set {
            _x = value;
        }
    }

    public event EventHandler Changed {
        add {
        }
        remove {
        }
    }

    public void Run() {
        if (X > 0) {
            X--;
        }

        var point = new {
            X = 1,
        };
        var copy = new Widget {
            X = 1,
        };
        Action log = delegate {
            Console.WriteLine(point);
        };
        Func<int, int> twice = n =>
        {
            return n * 2;
        };
    }
}
Ini
csharp_new_line_before_open_brace = control_blocks
C#
using System;

namespace N;

public class Widget
{
    private int _x;

    public int X
    {
        get
        {
            return _x;
        }
        set
        {
            _x = value;
        }
    }

    public event EventHandler Changed
    {
        add
        {
        }
        remove
        {
        }
    }

    public void Run()
    {
        if (X > 0)
        {
            X--;
        }

        var point = new
        {
            X = 1,
        };
        var copy = new Widget
        {
            X = 1,
        };
        Action log = delegate
        {
            Console.WriteLine(point);
        };
        Func<int, int> twice = n =>
        {
            return n * 2;
        };
    }
}
C#
using System;

namespace N;

public class Widget {
    private int _x;

    public int X {
        get {
            return _x;
        }
        set {
            _x = value;
        }
    }

    public event EventHandler Changed {
        add {
        }
        remove {
        }
    }

    public void Run() {
        if (X > 0)
        {
            X--;
        }

        var point = new {
            X = 1,
        };
        var copy = new Widget {
            X = 1,
        };
        Action log = delegate {
            Console.WriteLine(point);
        };
        Func<int, int> twice = n => {
            return n * 2;
        };
    }
}
Ini
csharp_new_line_before_open_brace = object_collection_array_initializers
C#
using System;

namespace N;

public class Widget
{
    private int _x;

    public int X
    {
        get
        {
            return _x;
        }
        set
        {
            _x = value;
        }
    }

    public event EventHandler Changed
    {
        add
        {
        }
        remove
        {
        }
    }

    public void Run()
    {
        if (X > 0)
        {
            X--;
        }

        var point = new
        {
            X = 1,
        };
        var copy = new Widget
        {
            X = 1,
        };
        Action log = delegate
        {
            Console.WriteLine(point);
        };
        Func<int, int> twice = n =>
        {
            return n * 2;
        };
    }
}
C#
using System;

namespace N;

public class Widget {
    private int _x;

    public int X {
        get {
            return _x;
        }
        set {
            _x = value;
        }
    }

    public event EventHandler Changed {
        add {
        }
        remove {
        }
    }

    public void Run() {
        if (X > 0) {
            X--;
        }

        var point = new {
            X = 1,
        };
        var copy = new Widget
        {
            X = 1,
        };
        Action log = delegate {
            Console.WriteLine(point);
        };
        Func<int, int> twice = n => {
            return n * 2;
        };
    }
}
Ini
csharp_new_line_before_open_brace = properties
C#
using System;

namespace N;

public class Widget
{
    private int _x;

    public int X
    {
        get
        {
            return _x;
        }
        set
        {
            _x = value;
        }
    }

    public event EventHandler Changed
    {
        add
        {
        }
        remove
        {
        }
    }

    public void Run()
    {
        if (X > 0)
        {
            X--;
        }

        var point = new
        {
            X = 1,
        };
        var copy = new Widget
        {
            X = 1,
        };
        Action log = delegate
        {
            Console.WriteLine(point);
        };
        Func<int, int> twice = n =>
        {
            return n * 2;
        };
    }
}
C#
using System;

namespace N;

public class Widget {
    private int _x;

    public int X
    {
        get {
            return _x;
        }
        set {
            _x = value;
        }
    }

    public event EventHandler Changed
    {
        add {
        }
        remove {
        }
    }

    public void Run() {
        if (X > 0) {
            X--;
        }

        var point = new {
            X = 1,
        };
        var copy = new Widget {
            X = 1,
        };
        Action log = delegate {
            Console.WriteLine(point);
        };
        Func<int, int> twice = n => {
            return n * 2;
        };
    }
}
Ini
csharp_new_line_before_open_brace = events
C#
using System;

namespace N;

public class Widget
{
    private int _x;

    public int X
    {
        get
        {
            return _x;
        }
        set
        {
            _x = value;
        }
    }

    public event EventHandler Changed
    {
        add
        {
        }
        remove
        {
        }
    }

    public void Run()
    {
        if (X > 0)
        {
            X--;
        }

        var point = new
        {
            X = 1,
        };
        var copy = new Widget
        {
            X = 1,
        };
        Action log = delegate
        {
            Console.WriteLine(point);
        };
        Func<int, int> twice = n =>
        {
            return n * 2;
        };
    }
}
C#
using System;

namespace N;

public class Widget {
    private int _x;

    public int X {
        get {
            return _x;
        }
        set {
            _x = value;
        }
    }

    public event EventHandler Changed {
        add {
        }
        remove {
        }
    }

    public void Run() {
        if (X > 0) {
            X--;
        }

        var point = new {
            X = 1,
        };
        var copy = new Widget {
            X = 1,
        };
        Action log = delegate {
            Console.WriteLine(point);
        };
        Func<int, int> twice = n => {
            return n * 2;
        };
    }
}