ReSharper 2025.3 ヘルプ

C# の EditorConfig プロパティ: 波括弧レイアウト

このページでは、C# でフォーマット設定を構成するために使用できるカスタム ReSharper EditorConfig プロパティをリストします。具体的には、ReSharper が新しいコードを生成して既存のコードを再フォーマットするときにブレースを配置する方法です。特に、if または for 演算子の後にブレースを配置する方法はいくつかあります。

波括弧レイアウト

型と名前空間の宣言

プロパティ名:

[resharper_]csharp_type_declaration_braces[resharper_]csharp_brace_style[resharper_]type_declaration_braces[resharper_]brace_style

使用可能な値:

  • end_of_line : 行末 (K&R スタイル)

  • end_of_line_no_space : 行末 (空白なし)

  • next_line : 次の行に (BSD スタイル)

  • next_line_shifted : 次の行のインデント時に (ホワイトスミススタイル)

  • next_line_shifted_2 : 次の行インデント 2 (GNU スタイル)

  • pico : コンパクト (ピコスタイル)

例:

end_of_line

namespace N { interface I { void foo(); } class C { } }

end_of_line_no_space

namespace N{ interface I{ void foo(); } class C{ } }

next_line

namespace N { interface I { void foo(); } class C { } }

next_line_shifted

namespace N { interface I { void foo(); } class C { } }

next_line_shifted_2

namespace N { interface I { void foo(); } class C { } }

ピコ

namespace N { interface I { void foo(); } class C { } }

内側の名前空間宣言をインデントする

プロパティ名:

[resharper_]csharp_indent_inside_namespace , [resharper_]indent_inside_namespace

使用可能な値:

true | false

例:

true

namespace N { interface I { void foo(); } class C { } }

false

namespace N { interface I { void foo(); } class C { } }

メソッド宣言

プロパティ名:

[resharper_]csharp_invocable_declaration_braces[resharper_]csharp_brace_style[resharper_]invocable_declaration_braces[resharper_]brace_style

使用可能な値:

  • end_of_line : 行末 (K&R スタイル)

  • end_of_line_no_space : 行末 (空白なし)

  • next_line : 次の行に (BSD スタイル)

  • next_line_shifted : 次の行のインデント時に (ホワイトスミススタイル)

  • next_line_shifted_2 : 次の行インデント 2 (GNU スタイル)

  • pico : コンパクト (ピコスタイル)

例:

end_of_line

class C { void Method() { foo(); foo1(); } }

end_of_line_no_space

class C { void Method(){ foo(); foo1(); } }

next_line

class C { void Method() { foo(); foo1(); } }

next_line_shifted

class C { void Method() { foo(); foo1(); } }

next_line_shifted_2

class C { void Method() { foo(); foo1(); } }

ピコ

class C { void Method() { foo(); foo1(); } }

ラムダと代理人 (無名メソッド宣言)

プロパティ名:

[resharper_]csharp_anonymous_method_declaration_braces[resharper_]csharp_brace_style[resharper_]anonymous_method_declaration_braces[resharper_]brace_style

使用可能な値:

  • end_of_line : 行末 (K&R スタイル)

  • end_of_line_no_space : 行末 (空白なし)

  • next_line : 次の行に (BSD スタイル)

  • next_line_shifted : 次の行のインデント時に (ホワイトスミススタイル)

  • next_line_shifted_2 : 次の行インデント 2 (GNU スタイル)

  • pico : コンパクト (ピコスタイル)

例:

end_of_line

D d = delegate() { int x = 0; return x; }

end_of_line_no_space

D d = delegate(){ int x = 0; return x; }

next_line

D d = delegate() { int x = 0; return x; }

next_line_shifted

D d = delegate() { int x = 0; return x; }

next_line_shifted_2

D d = delegate() { int x = 0; return x; }

ピコ

D d = delegate() { int x = 0; return x; }

プロパティ宣言

プロパティ名:

[resharper_]csharp_accessor_owner_declaration_braces[resharper_]csharp_brace_style[resharper_]accessor_owner_declaration_braces[resharper_]brace_style

使用可能な値:

  • end_of_line : 行末 (K&R スタイル)

  • end_of_line_no_space : 行末 (空白なし)

  • next_line : 次の行に (BSD スタイル)

  • next_line_shifted : 次の行のインデント時に (ホワイトスミススタイル)

  • next_line_shifted_2 : 次の行インデント 2 (GNU スタイル)

  • pico : コンパクト (ピコスタイル)

例:

end_of_line

class C { int Property { get { return null; } set { } } }

end_of_line_no_space

class C { int Property{ get { return null; } set { } } }

next_line

class C { int Property { get { return null; } set { } } }

next_line_shifted

class C { int Property { get { return null; } set { } } }

next_line_shifted_2

class C { int Property { get { return null; } set { } } }

ピコ

class C { int Property { get { return null; } set { } } }

アクセサー宣言

プロパティ名:

[resharper_]csharp_accessor_declaration_braces[resharper_]csharp_brace_style[resharper_]accessor_declaration_braces[resharper_]brace_style

使用可能な値:

  • end_of_line : 行末 (K&R スタイル)

  • end_of_line_no_space : 行末 (空白なし)

  • next_line : 次の行に (BSD スタイル)

  • next_line_shifted : 次の行のインデント時に (ホワイトスミススタイル)

  • next_line_shifted_2 : 次の行インデント 2 (GNU スタイル)

  • pico : コンパクト (ピコスタイル)

例:

end_of_line

class C { int Property { get { return null; } set { Notify(value); Set(value); } } }

end_of_line_no_space

class C { int Property { get{ return null; } set{ Notify(value); Set(value); } } }

next_line

class C { int Property { get { return null; } set { Notify(value); Set(value); } } }

next_line_shifted

class C { int Property { get { return null; } set { Notify(value); Set(value); } } }

next_line_shifted_2

class C { int Property { get { return null; } set { Notify(value); Set(value); } } }

ピコ

class C { int Property { get { return null; } set { Notify(value); Set(value); } } }

'case' ラベルのブロック

プロパティ名:

[resharper_]csharp_case_block_braces[resharper_]csharp_brace_style[resharper_]case_block_braces[resharper_]brace_style

使用可能な値:

  • end_of_line : 行末 (K&R スタイル)

  • end_of_line_no_space : 行末 (空白なし)

  • next_line : 次の行に (BSD スタイル)

  • next_line_shifted : 次の行のインデント時に (ホワイトスミススタイル)

  • next_line_shifted_2 : 次の行インデント 2 (GNU スタイル)

  • pico : コンパクト (ピコスタイル)

例:

end_of_line

switch (expression) { case 0: { foo(); break; } }

end_of_line_no_space

switch (expression) { case 0:{ foo(); break; } }

next_line

switch (expression) { case 0: { foo(); break; } }

next_line_shifted

switch (expression) { case 0: { foo(); break; } }

next_line_shifted_2

switch (expression) { case 0: { foo(); break; } }

ピコ

switch (expression) { case 0: { foo(); break; } }

式 (イニシャライザー、switch 式、パターン、コレクション式)

プロパティ名:

[resharper_]csharp_initializer_braces[resharper_]csharp_brace_style[resharper_]initializer_braces[resharper_]brace_style

使用可能な値:

  • end_of_line : 行末 (K&R スタイル)

  • end_of_line_no_space : 行末 (空白なし)

  • next_line : 次の行に (BSD スタイル)

  • next_line_shifted : 次の行のインデント時に (ホワイトスミススタイル)

  • next_line_shifted_2 : 次の行インデント 2 (GNU スタイル)

  • pico : コンパクト (ピコスタイル)

例:

end_of_line

int[] array = new int[] { 1, 2, 3 }

end_of_line_no_space

int[] array = new int[]{ 1, 2, 3 }

next_line

int[] array = new int[] { 1, 2, 3 }

next_line_shifted

int[] array = new int[] { 1, 2, 3 }

next_line_shifted_2

int[] array = new int[] { 1, 2, 3 }

ピコ

int[] array = new int[] { 1, 2, 3 }

式中括弧内で連続行インデントを使用する

プロパティ名:

[resharper_]csharp_use_continuous_indent_inside_initializer_braces , [resharper_]use_continuous_indent_inside_initializer_braces

使用可能な値:

true | false

例:

true

int[] array = new int[] { 1, 2, 3 }

false

int[] array = new int[] { 1, 2, 3 }

その他

プロパティ名:

[resharper_]csharp_other_braces[resharper_]csharp_brace_style[resharper_]other_braces[resharper_]brace_style

使用可能な値:

  • end_of_line : 行末 (K&R スタイル)

  • end_of_line_no_space : 行末 (空白なし)

  • next_line : 次の行に (BSD スタイル)

  • next_line_shifted : 次の行のインデント時に (ホワイトスミススタイル)

  • next_line_shifted_2 : 次の行インデント 2 (GNU スタイル)

  • pico : コンパクト (ピコスタイル)

例:

end_of_line

if (condition) { foo(); } else { foo(); }

end_of_line_no_space

if (condition){ foo(); } else{ foo(); }

next_line

if (condition) { foo(); } else { foo(); }

next_line_shifted

if (condition) { foo(); } else { foo(); }

next_line_shifted_2

if (condition) { foo(); } else { foo(); }

ピコ

if (condition) { foo(); } else { foo(); }

'{' の後のコメントを許可する

プロパティ名:

[resharper_]csharp_allow_comment_after_lbrace , [resharper_]allow_comment_after_lbrace

使用可能な値:

true | false

例:

true

if (condition) { // comment statement; }

false

if (condition) { // comment statement; }

空の波括弧フォーマット

プロパティ名:

[resharper_]csharp_empty_block_style , [resharper_]empty_block_style

使用可能な値:

  • multiline : 異なる行

  • together : 波括弧を一緒に配置する

  • together_same_line : 一緒に同じ行に

例:

multiline

class C { void EmptyMethod() { } }

together

class C { void EmptyMethod() { } }

together_same_line

class C { void EmptyMethod() { } }
2024 年 5 月 26 日

関連ページ:

EditorConfig を使用する

ReSharper は、EditorConfig 形式で定義されたコード形式スタイル、コード構文スタイル、C# の命名スタイル、コードインスペクション重大度レベルをサポートします。まず、この 2 分間の概要ビデオを見て、Matt Ellis が EditorConfig を使用してフォーマットルールの構成全体を維持するのに ReSharper がどのように役立つかを説明します。EditorConfig とは何ですか? ReSharper はどのようにそれを拡張しますか? :EditorConfig...

フォーマットルールを適用する

編集および貼り付けられたコードの自動フォーマット:エディターでコードを入力すると、セミコロンを入力するとすぐに ReSharper によって式が再フォーマットされ、閉じ括弧を入力するとすぐにコードブロックが再フォーマットされます必要に応じて、ReSharper オプション Alt+R, O のページでこれらの種類の自動フォーマットを無効にすることができます。ReSharper では、コードを貼り付けるときにフォーマットルールを自動的に適用することもできます。デフォルトでは、貼り付けられたコードは完...

C# の EditorConfig プロパティ: 空白行

このページでは、C# でフォーマット設定を構成するために使用できるカスタム ReSharperEditorConfig プロパティを一覧表示します。具体的には、ReSharper が名前空間、メンバー、リージョン、インポートディレクティブのグループの周囲の空白行の数を増やすか減らすかを指定します。一般:領域の周囲プロパティ名:, 使用可能な値: 整数例:abstract class C { protected abstract void Method1(); #region Region Desc...