C# の EditorConfig プロパティ: 構文スタイル
このページには、コード構文スタイルルールの構成に使用できるカスタム ReSharper EditorConfig プロパティがリストされています。一部のプロパティは 1 つの言語に適用され、他のプロパティは一度に複数の言語に適用されることに注意してください。ただし、各多言語プロパティには、特定の言語に対してそれをオーバーライドできるプロパティがあります (例: default_private_modifier および csharp_default_private_modifier)。
宣言における 'var' の使用箇所
ビルトインタイプの場合
プロパティ名:
[resharper_]csharp_for_built_in_types , [resharper_]for_built_in_types
使用可能な値:
use_var: 'var' を使うuse_var_when_evident: 明確な場合は 'var' を使用するuse_explicit_type: 明示的な型を使用する
例:
use_var |
|---|
int count = 42;
var builder = new StringBuilder();
int length = builder.Length;
Dictionary<string, string> dictionary = new Dictionary<string, string>();
bool hasValue = dictionary.TryGetValue("key", out string value); |
use_var_when_evident |
|---|
int count = 42;
var builder = new StringBuilder();
int length = builder.Length;
Dictionary<string, string> dictionary = new Dictionary<string, string>();
bool hasValue = dictionary.TryGetValue("key", out string value); |
use_explicit_type |
|---|
int count = 42;
var builder = new StringBuilder();
int length = builder.Length;
Dictionary<string, string> dictionary = new Dictionary<string, string>();
bool hasValue = dictionary.TryGetValue("key", out string value); |
単純型の場合
プロパティ名:
[resharper_]csharp_for_simple_types , [resharper_]for_simple_types
使用可能な値:
use_var: 'var' を使うuse_var_when_evident: 明確な場合は 'var' を使用するuse_explicit_type: 明示的な型を使用する
例:
use_var |
|---|
int count = 42;
var builder = new StringBuilder();
int length = builder.Length;
Dictionary<string, string> dictionary = new Dictionary<string, string>();
bool hasValue = dictionary.TryGetValue("key", out string value); |
use_var_when_evident |
|---|
int count = 42;
var builder = new StringBuilder();
int length = builder.Length;
Dictionary<string, string> dictionary = new Dictionary<string, string>();
bool hasValue = dictionary.TryGetValue("key", out string value); |
use_explicit_type |
|---|
int count = 42;
StringBuilder builder = new StringBuilder();
int length = builder.Length;
Dictionary<string, string> dictionary = new Dictionary<string, string>();
bool hasValue = dictionary.TryGetValue("key", out string value); |
他の場所
プロパティ名:
[resharper_]csharp_for_other_types , [resharper_]for_other_types
使用可能な値:
use_var: 'var' を使うuse_var_when_evident: 明確な場合は 'var' を使用するuse_explicit_type: 明示的な型を使用する
例:
use_var |
|---|
int count = 42;
var builder = new StringBuilder();
int length = builder.Length;
Dictionary<string, string> dictionary = new Dictionary<string, string>();
bool hasValue = dictionary.TryGetValue("key", out string value); |
use_var_when_evident |
|---|
int count = 42;
var builder = new StringBuilder();
int length = builder.Length;
Dictionary<string, string> dictionary = new Dictionary<string, string>();
bool hasValue = dictionary.TryGetValue("key", out string value); |
use_explicit_type |
|---|
int count = 42;
var builder = new StringBuilder();
int length = builder.Length;
Dictionary<string, string> dictionary = new Dictionary<string, string>();
bool hasValue = dictionary.TryGetValue("key", out string value); |
型の証拠には Roslyn(Visual Studio)ロジックを優先する
プロパティ名:
[resharper_]csharp_use_roslyn_logic_for_evident_types , [resharper_]use_roslyn_logic_for_evident_types
使用可能な値:
true | false
展開された変数の宣言を別にすること
プロパティ名:
[resharper_]csharp_prefer_separate_deconstructed_variables_declaration , [resharper_]prefer_separate_deconstructed_variables_declaration
使用可能な値:
true | false
例:
true |
|---|
void ApplySetting(KeyValuePair<string, object> setting, KeyValuePair<string, object>? optionalSetting)
{
(var settingName, var value) = setting;
// apply
if (optionalSetting is (var optionalSettingName, var optionalSettingValue))
{
// apply
}
} |
false |
|---|
void ApplySetting(KeyValuePair<string, object> setting, KeyValuePair<string, object>? optionalSetting)
{
var (settingName, value) = setting;
// apply
if (optionalSetting is var (optionalSettingName, optionalSettingValue))
{
// apply
}
} |
破棄には 'var' キーワードを使用する
プロパティ名:
[resharper_]csharp_prefer_explicit_discard_declaration , [resharper_]prefer_explicit_discard_declaration
使用可能な値:
true | false
例:
true |
|---|
bool RepresentsInteger(string value)
{
return int.TryParse(value, out var _);
} |
false |
|---|
bool RepresentsInteger(string value)
{
return int.TryParse(value, out _);
} |
インスタンスメンバーの資格
'this.' 修飾子を使用する
プロパティ名:
[resharper_]csharp_instance_members_qualify_members , [resharper_]instance_members_qualify_members
使用可能な値:
nonefieldpropertyeventmethodall
例:
なし |
|---|
using System;
internal class Person
{
public Person(string name, int age)
{
_id = GenerateId();
Name = name;
Age = age;
AgeChanged += (_, newAge) => Age = newAge;
}
private readonly int _id;
public string Name { get; }
public int Age { get; private set; }
public event EventHandler<int> AgeChanged;
public int GenerateId()
{
return 42;
}
} |
フィールド |
|---|
using System;
internal class Person
{
public Person(string name, int age)
{
this._id = GenerateId();
Name = name;
Age = age;
AgeChanged += (_, newAge) => Age = newAge;
}
private readonly int _id;
public string Name { get; }
public int Age { get; private set; }
public event EventHandler<int> AgeChanged;
public int GenerateId()
{
return 42;
}
} |
プロパティ |
|---|
using System;
internal class Person
{
public Person(string name, int age)
{
_id = GenerateId();
this.Name = name;
this.Age = age;
AgeChanged += (_, newAge) => this.Age = newAge;
}
private readonly int _id;
public string Name { get; }
public int Age { get; private set; }
public event EventHandler<int> AgeChanged;
public int GenerateId()
{
return 42;
}
} |
イベント |
|---|
using System;
internal class Person
{
public Person(string name, int age)
{
_id = GenerateId();
Name = name;
Age = age;
this.AgeChanged += (_, newAge) => Age = newAge;
}
private readonly int _id;
public string Name { get; }
public int Age { get; private set; }
public event EventHandler<int> AgeChanged;
public int GenerateId()
{
return 42;
}
} |
メソッド |
|---|
using System;
internal class Person
{
public Person(string name, int age)
{
_id = this.GenerateId();
Name = name;
Age = age;
AgeChanged += (_, newAge) => Age = newAge;
}
private readonly int _id;
public string Name { get; }
public int Age { get; private set; }
public event EventHandler<int> AgeChanged;
public int GenerateId()
{
return 42;
}
} |
すべて |
|---|
using System;
internal class Person
{
public Person(string name, int age)
{
this._id = this.GenerateId();
this.Name = name;
this.Age = age;
this.AgeChanged += (_, newAge) => this.Age = newAge;
}
private readonly int _id;
public string Name { get; }
public int Age { get; private set; }
public event EventHandler<int> AgeChanged;
public int GenerateId()
{
return 42;
}
} |
宣言されたメンバー資格
プロパティ名:
[resharper_]csharp_instance_members_qualify_declared_in , [resharper_]instance_members_qualify_declared_in
使用可能な値:
this_class: 同じクラスbase_class: 基本クラス
例:
this_class |
|---|
using System;
internal class Person
{
public Person(string name, int age)
{
_id = GenerateId();
Name = name;
Age = age;
AgeChanged += (_, newAge) => Age = newAge;
}
private readonly int _id;
public string Name { get; }
public int Age { get; private set; }
public event EventHandler<int> AgeChanged;
public int GenerateId()
{
return 42;
}
} |
base_class |
|---|
using System;
internal class Person
{
public Person(string name, int age)
{
_id = GenerateId();
Name = name;
Age = age;
AgeChanged += (_, newAge) => Age = newAge;
}
private readonly int _id;
public string Name { get; }
public int Age { get; private set; }
public event EventHandler<int> AgeChanged;
public int GenerateId()
{
return 42;
}
} |
静的メンバー資格
名前で修飾する
プロパティ名:
[resharper_]csharp_static_members_qualify_with , [resharper_]static_members_qualify_with
使用可能な値:
current_type: 現在のタイプdeclared_type: 宣言された型
例:
current_type |
|---|
using System;
internal class WeatherService
{
static WeatherService()
{
Console.WriteLine(Name);
Console.WriteLine(Version);
GotRequest += (_, _) => { };
}
public static string Name = GetString();
public static Version Version => new(1, 2, 3);
public static EventHandler GotRequest;
public static string GetString()
{
return "abc";
}
} |
declared_type |
|---|
using System;
internal class WeatherService
{
static WeatherService()
{
Console.WriteLine(Name);
Console.WriteLine(Version);
GotRequest += (_, _) => { };
}
public static string Name = GetString();
public static Version Version => new(1, 2, 3);
public static EventHandler GotRequest;
public static string GetString()
{
return "abc";
}
} |
修飾するメンバー
プロパティ名:
[resharper_]csharp_static_members_qualify_members , [resharper_]static_members_qualify_members
使用可能な値:
nonefieldpropertyeventmethodall
例:
なし |
|---|
using System;
internal class WeatherService
{
static WeatherService()
{
Console.WriteLine(Name);
Console.WriteLine(Version);
GotRequest += (_, _) => { };
}
public static string Name = GetString();
public static Version Version => new(1, 2, 3);
public static EventHandler GotRequest;
public static string GetString()
{
return "abc";
}
} |
フィールド |
|---|
using System;
internal class WeatherService
{
static WeatherService()
{
Console.WriteLine(WeatherService.Name);
Console.WriteLine(Version);
WeatherService.GotRequest += (_, _) => { };
}
public static string Name = GetString();
public static Version Version => new(1, 2, 3);
public static EventHandler GotRequest;
public static string GetString()
{
return "abc";
}
} |
プロパティ |
|---|
using System;
internal class WeatherService
{
static WeatherService()
{
Console.WriteLine(Name);
Console.WriteLine(WeatherService.Version);
GotRequest += (_, _) => { };
}
public static string Name = GetString();
public static Version Version => new(1, 2, 3);
public static EventHandler GotRequest;
public static string GetString()
{
return "abc";
}
} |
イベント |
|---|
using System;
internal class WeatherService
{
static WeatherService()
{
Console.WriteLine(Name);
Console.WriteLine(Version);
GotRequest += (_, _) => { };
}
public static string Name = GetString();
public static Version Version => new(1, 2, 3);
public static EventHandler GotRequest;
public static string GetString()
{
return "abc";
}
} |
メソッド |
|---|
using System;
internal class WeatherService
{
static WeatherService()
{
Console.WriteLine(Name);
Console.WriteLine(Version);
GotRequest += (_, _) => { };
}
public static string Name = WeatherService.GetString();
public static Version Version => new(1, 2, 3);
public static EventHandler GotRequest;
public static string GetString()
{
return "abc";
}
} |
すべて |
|---|
using System;
internal class WeatherService
{
static WeatherService()
{
Console.WriteLine(WeatherService.Name);
Console.WriteLine(WeatherService.Version);
WeatherService.GotRequest += (_, _) => { };
}
public static string Name = WeatherService.GetString();
public static Version Version => new(1, 2, 3);
public static EventHandler GotRequest;
public static string GetString()
{
return "abc";
}
} |
ビルトイン型
ローカル、メンバー、パラメーター
プロパティ名:
[resharper_]csharp_builtin_type_reference_style , [resharper_]builtin_type_reference_style
使用可能な値:
use_keyword: キーワードuse_clr_name: CLR タイプ名
例:
use_keyword |
|---|
void SetFont(string fontFamily, int fontSize, byte[] fontData, bool useKerning)
{
if (string.IsNullOrEmpty(fontFamily))
throw new ArgumentException("Invalid font family ", nameof(fontFamily));
if (int.IsNegative(fontSize))
throw new ArgumentOutOfRangeException(nameof(fontSize));
} |
use_clr_name |
|---|
void SetFont(string fontFamily, int fontSize, byte[] fontData, bool useKerning)
{
if (string.IsNullOrEmpty(fontFamily))
throw new ArgumentException("Invalid font family ", nameof(fontFamily));
if (int.IsNegative(fontSize))
throw new ArgumentOutOfRangeException(nameof(fontSize));
} |
メンバーアクセス式で優先
プロパティ名:
[resharper_]csharp_builtin_type_reference_for_member_access_style , [resharper_]builtin_type_reference_for_member_access_style
使用可能な値:
use_keyword: キーワードuse_clr_name: CLR タイプ名
例:
use_keyword |
|---|
void SetFont(string fontFamily, int fontSize, byte[] fontData, bool useKerning)
{
if (string.IsNullOrEmpty(fontFamily))
throw new ArgumentException("Invalid font family ", nameof(fontFamily));
if (int.IsNegative(fontSize))
throw new ArgumentOutOfRangeException(nameof(fontSize));
} |
use_clr_name |
|---|
void SetFont(string fontFamily, int fontSize, byte[] fontData, bool useKerning)
{
if (string.IsNullOrEmpty(fontFamily))
throw new ArgumentException("Invalid font family ", nameof(fontFamily));
if (int.IsNegative(fontSize))
throw new ArgumentOutOfRangeException(nameof(fontSize));
} |
ネイティブサイズの整数型にも適用
プロパティ名:
[resharper_]csharp_builtin_type_apply_to_native_integer , [resharper_]builtin_type_apply_to_native_integer
使用可能な値:
true | false
例:
true |
|---|
using System;
internal struct Buffer
{
public IntPtr Pointer;
public int SizeInBytes;
} |
false |
|---|
using System;
internal struct Buffer
{
public IntPtr Pointer;
public int SizeInBytes;
} |
参照修飾および 'using' ディレクティブ
完全修飾参照を推奨する
プロパティ名:
[resharper_]csharp_prefer_qualified_reference , [resharper_]prefer_qualified_reference
使用可能な値:
true | false
最も深いスコープに 'using' ディレクティブを追加する
プロパティ名:
[resharper_]csharp_add_imports_to_deepest_scope , [resharper_]add_imports_to_deepest_scope
使用可能な値:
true | false
'using' ディレクティブをソートするときは、'System.*' および 'Windows.*' の名前空間を最初に配置する
プロパティ名:
dotnet_sort_system_directives_first、[resharper_]csharp_sort_usings_with_system_first、[resharper_]sort_usings_with_system_first
使用可能な値:
true | false
ネストしたスコープで完全修飾名を使用することを推奨する
プロパティ名:
[resharper_]csharp_qualified_using_at_nested_scope , [resharper_]qualified_using_at_nested_scope
使用可能な値:
true | false
別名ディレクティブを使用して競合を解決する
プロパティ名:
[resharper_]csharp_allow_alias , [resharper_]allow_alias
使用可能な値:
true | false
グローバル: : プリフィックスの使用を許可する
プロパティ名:
[resharper_]csharp_can_use_global_alias , [resharper_]can_use_global_alias
使用可能な値:
true | false
修飾子
型メンバーの明示的 / 暗黙的な private 修飾子を優先する
プロパティ名:
[resharper_]csharp_default_private_modifier , [resharper_]default_private_modifier
使用可能な値:
explicit: 明示的implicit: 暗黙的
例:
フォーマット前 | フォーマット後 explicit |
|---|---|
class C
{
int a;
private int b;
} | internal class C
{
private int a;
private int b;
} |
フォーマット前 | フォーマット後 implicit |
|---|---|
class C
{
int a;
private int b;
} | internal class C
{
int a;
int b;
} |
型の明示的 / 暗黙的な内部修飾子を使用する
プロパティ名:
[resharper_]csharp_default_internal_modifier , [resharper_]default_internal_modifier
使用可能な値:
explicit: 明示的implicit: 暗黙的
例:
フォーマット前 | フォーマット後 explicit |
|---|---|
namespace N
{
class C
{
}
internal class D
{
}
} | namespace N;
internal class C
{
}
internal class D
{
} |
フォーマット前 | フォーマット後 implicit |
|---|---|
namespace N
{
class C
{
}
internal class D
{
}
} | namespace N;
class C
{
}
class D
{
} |
修飾子の順序
プロパティ名:
[resharper_]csharp_modifiers_order , [resharper_]modifiers_order
引数
単一の引数をスキップする
プロパティ名:
[resharper_]csharp_arguments_skip_single , [resharper_]arguments_skip_single
使用可能な値:
true | false
リテラル値
プロパティ名:
[resharper_]csharp_arguments_literal , [resharper_]arguments_literal
使用可能な値:
positional: 位置引数named: 名前付き引数
例:
フォーマット前 | フォーマット後 positional |
|---|---|
public class Arguments
{
public void Style()
{
Bar(1, d, true, "abc", Fx.F1, () => Bar(1));
Bar(1, d, true, "abc", Fx.F1, action: () => Bar(1));
Bar(1, d, true, "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(x: 1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
}
public void Bar(int x, int y, bool b, string s, Fx e, Action action = null)
{
}
private enum Fx
{
F1,
F2,
F3
}
} | public class Arguments
{
public void Style()
{
Bar(1, d, true, "abc", Fx.F1, () => Bar(1));
Bar(1, d, true, "abc", Fx.F1, action: () => Bar(1));
Bar(1, d, true, "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(x: 1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
}
public void Bar(int x, int y, bool b, string s, Fx e, Action action = null)
{
}
private enum Fx
{
F1,
F2,
F3
}
} |
フォーマット前 | フォーマット後 named |
|---|---|
public class Arguments
{
public void Style()
{
Bar(1, d, true, "abc", Fx.F1, () => Bar(1));
Bar(1, d, true, "abc", Fx.F1, action: () => Bar(1));
Bar(1, d, true, "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(x: 1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
}
public void Bar(int x, int y, bool b, string s, Fx e, Action action = null)
{
}
private enum Fx
{
F1,
F2,
F3
}
} | public class Arguments
{
public void Style()
{
Bar(x: 1, d, b: true, "abc", Fx.F1, () => Bar(x: 1));
Bar(x: 1, d, b: true, "abc", Fx.F1, action: () => Bar(x: 1));
Bar(x: 1, d, b: true, "abc", e: Fx.F1, action: () => Bar(x: 1));
Bar(x: 1, d, b: true, s: "abc", e: Fx.F1, action: () => Bar(x: 1));
Bar(x: 1, d, b: true, s: "abc", e: Fx.F1, action: () => Bar(x: 1));
Bar(x: 1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(x: 1));
Bar(x: 1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(x: 1));
}
public void Bar(int x, int y, bool b, string s, Fx e, Action action = null)
{
}
private enum Fx
{
F1,
F2,
F3
}
} |
文字列リテラル値
プロパティ名:
[resharper_]csharp_arguments_string_literal , [resharper_]arguments_string_literal
使用可能な値:
positional: 位置引数named: 名前付き引数
例:
フォーマット前 | フォーマット後 positional |
|---|---|
public class Arguments
{
public void Style()
{
Bar(1, d, true, "abc", Fx.F1, () => Bar(1));
Bar(1, d, true, "abc", Fx.F1, action: () => Bar(1));
Bar(1, d, true, "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(x: 1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
}
public void Bar(int x, int y, bool b, string s, Fx e, Action action = null)
{
}
private enum Fx
{
F1,
F2,
F3
}
} | public class Arguments
{
public void Style()
{
Bar(1, d, true, "abc", Fx.F1, () => Bar(1));
Bar(1, d, true, "abc", Fx.F1, action: () => Bar(1));
Bar(1, d, true, "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(x: 1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
}
public void Bar(int x, int y, bool b, string s, Fx e, Action action = null)
{
}
private enum Fx
{
F1,
F2,
F3
}
} |
フォーマット前 | フォーマット後 named |
|---|---|
public class Arguments
{
public void Style()
{
Bar(1, d, true, "abc", Fx.F1, () => Bar(1));
Bar(1, d, true, "abc", Fx.F1, action: () => Bar(1));
Bar(1, d, true, "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(x: 1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
}
public void Bar(int x, int y, bool b, string s, Fx e, Action action = null)
{
}
private enum Fx
{
F1,
F2,
F3
}
} | public class Arguments
{
public void Style()
{
Bar(1, d, true, s: "abc", Fx.F1, () => Bar(1));
Bar(1, d, true, s: "abc", Fx.F1, action: () => Bar(1));
Bar(1, d, true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(x: 1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
}
public void Bar(int x, int y, bool b, string s, Fx e, Action action = null)
{
}
private enum Fx
{
F1,
F2,
F3
}
} |
名前付き式 (変数、プロパティ、メソッドなど)
プロパティ名:
[resharper_]csharp_arguments_named , [resharper_]arguments_named
使用可能な値:
positional: 位置引数named: 名前付き引数
例:
フォーマット前 | フォーマット後 positional |
|---|---|
public class Arguments
{
public void Style()
{
Bar(1, d, true, "abc", Fx.F1, () => Bar(1));
Bar(1, d, true, "abc", Fx.F1, action: () => Bar(1));
Bar(1, d, true, "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(x: 1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
}
public void Bar(int x, int y, bool b, string s, Fx e, Action action = null)
{
}
private enum Fx
{
F1,
F2,
F3
}
} | public class Arguments
{
public void Style()
{
Bar(1, d, true, "abc", Fx.F1, () => Bar(1));
Bar(1, d, true, "abc", Fx.F1, action: () => Bar(1));
Bar(1, d, true, "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(x: 1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
}
public void Bar(int x, int y, bool b, string s, Fx e, Action action = null)
{
}
private enum Fx
{
F1,
F2,
F3
}
} |
フォーマット前 | フォーマット後 named |
|---|---|
public class Arguments
{
public void Style()
{
Bar(1, d, true, "abc", Fx.F1, () => Bar(1));
Bar(1, d, true, "abc", Fx.F1, action: () => Bar(1));
Bar(1, d, true, "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(x: 1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
}
public void Bar(int x, int y, bool b, string s, Fx e, Action action = null)
{
}
private enum Fx
{
F1,
F2,
F3
}
} | public class Arguments
{
public void Style()
{
Bar(1, y: d, true, "abc", e: Fx.F1, () => Bar(1));
Bar(1, y: d, true, "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, y: d, true, "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, y: d, true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(x: 1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
}
public void Bar(int x, int y, bool b, string s, Fx e, Action action = null)
{
}
private enum Fx
{
F1,
F2,
F3
}
} |
無名メソッド (代理人とラムダ)
プロパティ名:
[resharper_]csharp_arguments_anonymous_function , [resharper_]arguments_anonymous_function
使用可能な値:
positional: 位置引数named: 名前付き引数
例:
フォーマット前 | フォーマット後 positional |
|---|---|
public class Arguments
{
public void Style()
{
Bar(1, d, true, "abc", Fx.F1, () => Bar(1));
Bar(1, d, true, "abc", Fx.F1, action: () => Bar(1));
Bar(1, d, true, "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(x: 1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
}
public void Bar(int x, int y, bool b, string s, Fx e, Action action = null)
{
}
private enum Fx
{
F1,
F2,
F3
}
} | public class Arguments
{
public void Style()
{
Bar(1, d, true, "abc", Fx.F1, () => Bar(1));
Bar(1, d, true, "abc", Fx.F1, action: () => Bar(1));
Bar(1, d, true, "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(x: 1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
}
public void Bar(int x, int y, bool b, string s, Fx e, Action action = null)
{
}
private enum Fx
{
F1,
F2,
F3
}
} |
フォーマット前 | フォーマット後 named |
|---|---|
public class Arguments
{
public void Style()
{
Bar(1, d, true, "abc", Fx.F1, () => Bar(1));
Bar(1, d, true, "abc", Fx.F1, action: () => Bar(1));
Bar(1, d, true, "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(x: 1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
}
public void Bar(int x, int y, bool b, string s, Fx e, Action action = null)
{
}
private enum Fx
{
F1,
F2,
F3
}
} | public class Arguments
{
public void Style()
{
Bar(1, d, true, "abc", Fx.F1, action: () => Bar(1));
Bar(1, d, true, "abc", Fx.F1, action: () => Bar(1));
Bar(1, d, true, "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(x: 1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
}
public void Bar(int x, int y, bool b, string s, Fx e, Action action = null)
{
}
private enum Fx
{
F1,
F2,
F3
}
} |
その他
プロパティ名:
[resharper_]csharp_arguments_other , [resharper_]arguments_other
使用可能な値:
positional: 位置引数named: 名前付き引数
例:
フォーマット前 | フォーマット後 positional |
|---|---|
public class Arguments
{
public void Style()
{
Bar(1, d, true, "abc", Fx.F1, () => Bar(1));
Bar(1, d, true, "abc", Fx.F1, action: () => Bar(1));
Bar(1, d, true, "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(x: 1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
}
public void Bar(int x, int y, bool b, string s, Fx e, Action action = null)
{
}
private enum Fx
{
F1,
F2,
F3
}
} | public class Arguments
{
public void Style()
{
Bar(1, d, true, "abc", Fx.F1, () => Bar(1));
Bar(1, d, true, "abc", Fx.F1, action: () => Bar(1));
Bar(1, d, true, "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(x: 1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
}
public void Bar(int x, int y, bool b, string s, Fx e, Action action = null)
{
}
private enum Fx
{
F1,
F2,
F3
}
} |
フォーマット前 | フォーマット後 named |
|---|---|
public class Arguments
{
public void Style()
{
Bar(1, d, true, "abc", Fx.F1, () => Bar(1));
Bar(1, d, true, "abc", Fx.F1, action: () => Bar(1));
Bar(1, d, true, "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(x: 1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
}
public void Bar(int x, int y, bool b, string s, Fx e, Action action = null)
{
}
private enum Fx
{
F1,
F2,
F3
}
} | public class Arguments
{
public void Style()
{
Bar(1, d, true, "abc", Fx.F1, () => Bar(1));
Bar(1, d, true, "abc", Fx.F1, action: () => Bar(1));
Bar(1, d, true, "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
Bar(x: 1, y: d, b: true, s: "abc", e: Fx.F1, action: () => Bar(1));
}
public void Bar(int x, int y, bool b, string s, Fx e, Action action = null)
{
}
private enum Fx
{
F1,
F2,
F3
}
} |
丸括弧
冗長なカッコを除去
プロパティ名:
[resharper_]csharp_parentheses_redundancy_style , [resharper_]parentheses_redundancy_style
使用可能な値:
remove: 常時remove_if_not_clarifies_precedence: 優先順位を明確にしない場合
例:
フォーマット前 | フォーマット後 remove |
|---|---|
void Calculate()
{
var x = 12 - ((3 % 4) * 12);
var y = ((9 >> ((12 + x) - 1)) << (2 + 1)) & ((6 + (4 * 12)) - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
} | internal void Calculate()
{
var x = 12 - 3 % 4 * 12;
var y = 9 >> 12 + x - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var z = (2 | 7) + 1 & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
} |
フォーマット前 | フォーマット後 remove_if_not_clarifies_precedence |
|---|---|
void Calculate()
{
var x = 12 - ((3 % 4) * 12);
var y = ((9 >> ((12 + x) - 1)) << (2 + 1)) & ((6 + (4 * 12)) - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
} | internal void Calculate()
{
var x = 12 - 3 % 4 * 12;
var y = ((9 >> (12 + x - 1)) << (2 + 1)) & (6 + 4 * 12 - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = ((9 >> (12 + a - 1)) << (2 + 1)) & (6 + 4 * 12 - 1);
var c = ((2 | 7) + 1) & b;
} |
明白でない優先順位を避けるために括弧を追加する
以下の操作のオペランドの周囲
プロパティ名:
[resharper_]csharp_parentheses_non_obvious_operations , [resharper_]parentheses_non_obvious_operations
使用可能な値:
nonemultiplicative: * / %additive: + -arithmetic: * / % + -shift: << >>relational: <> <=> =equality: == !=bitwise_and: &bitwise_exclusive_or: ^bitwise_inclusive_or: |bitwise: &^ |conditional_and: &&conditional_or: ||conditional: && | |null_coalescing: ??range: ..
例:
フォーマット前 | フォーマット後 none |
|---|---|
void Calculate()
{
var x = 12 - ((3 % 4) * 12);
var y = ((9 >> ((12 + x) - 1)) << (2 + 1)) & ((6 + (4 * 12)) - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = x > 5 && y < 6 || z == 7;
} | internal void Calculate()
{
var x = 12 - 3 % 4 * 12;
var y = 9 >> 12 + x - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var z = (2 | 7) + 1 & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = (x > 5 && y < 6) || z == 7;
} |
フォーマット前 | フォーマット後 multiplicative |
|---|---|
void Calculate()
{
var x = 12 - ((3 % 4) * 12);
var y = ((9 >> ((12 + x) - 1)) << (2 + 1)) & ((6 + (4 * 12)) - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = x > 5 && y < 6 || z == 7;
} | internal void Calculate()
{
var x = 12 - (3 % 4) * 12;
var y = 9 >> 12 + x - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var z = (2 | 7) + 1 & y;
var a = 12 - (3 % 4) * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = (x > 5 && y < 6) || z == 7;
} |
フォーマット前 | フォーマット後 additive |
|---|---|
void Calculate()
{
var x = 12 - ((3 % 4) * 12);
var y = ((9 >> ((12 + x) - 1)) << (2 + 1)) & ((6 + (4 * 12)) - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = x > 5 && y < 6 || z == 7;
} | internal void Calculate()
{
var x = 12 - (3 % 4 * 12);
var y = 9 >> (12 + x) - 1 << 2 + 1 & (6 + (4 * 12)) - 1;
var z = (2 | 7) + 1 & y;
var a = 12 - (3 % 4 * 12);
var b = 9 >> (12 + a) - 1 << 2 + 1 & (6 + (4 * 12)) - 1;
var c = (2 | 7) + 1 & b;
var d = (x > 5 && y < 6) || z == 7;
} |
フォーマット前 | フォーマット後 arithmetic |
|---|---|
void Calculate()
{
var x = 12 - ((3 % 4) * 12);
var y = ((9 >> ((12 + x) - 1)) << (2 + 1)) & ((6 + (4 * 12)) - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = x > 5 && y < 6 || z == 7;
} | internal void Calculate()
{
var x = 12 - ((3 % 4) * 12);
var y = 9 >> (12 + x) - 1 << 2 + 1 & (6 + (4 * 12)) - 1;
var z = (2 | 7) + 1 & y;
var a = 12 - ((3 % 4) * 12);
var b = 9 >> (12 + a) - 1 << 2 + 1 & (6 + (4 * 12)) - 1;
var c = (2 | 7) + 1 & b;
var d = (x > 5 && y < 6) || z == 7;
} |
フォーマット前 | フォーマット後 shift |
|---|---|
void Calculate()
{
var x = 12 - ((3 % 4) * 12);
var y = ((9 >> ((12 + x) - 1)) << (2 + 1)) & ((6 + (4 * 12)) - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = x > 5 && y < 6 || z == 7;
} | internal void Calculate()
{
var x = 12 - 3 % 4 * 12;
var y = (9 >> (12 + x - 1)) << (2 + 1) & 6 + 4 * 12 - 1;
var z = (2 | 7) + 1 & y;
var a = 12 - 3 % 4 * 12;
var b = (9 >> (12 + a - 1)) << (2 + 1) & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = (x > 5 && y < 6) || z == 7;
} |
フォーマット前 | フォーマット後 relational |
|---|---|
void Calculate()
{
var x = 12 - ((3 % 4) * 12);
var y = ((9 >> ((12 + x) - 1)) << (2 + 1)) & ((6 + (4 * 12)) - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = x > 5 && y < 6 || z == 7;
} | internal void Calculate()
{
var x = 12 - 3 % 4 * 12;
var y = 9 >> 12 + x - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var z = (2 | 7) + 1 & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = (x > 5 && y < 6) || z == 7;
} |
フォーマット前 | フォーマット後 equality |
|---|---|
void Calculate()
{
var x = 12 - ((3 % 4) * 12);
var y = ((9 >> ((12 + x) - 1)) << (2 + 1)) & ((6 + (4 * 12)) - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = x > 5 && y < 6 || z == 7;
} | internal void Calculate()
{
var x = 12 - 3 % 4 * 12;
var y = 9 >> 12 + x - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var z = (2 | 7) + 1 & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = (x > 5 && y < 6) || z == 7;
} |
フォーマット前 | フォーマット後 bitwise_and |
|---|---|
void Calculate()
{
var x = 12 - ((3 % 4) * 12);
var y = ((9 >> ((12 + x) - 1)) << (2 + 1)) & ((6 + (4 * 12)) - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = x > 5 && y < 6 || z == 7;
} | internal void Calculate()
{
var x = 12 - 3 % 4 * 12;
var y = (9 >> 12 + x - 1 << 2 + 1) & (6 + 4 * 12 - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = (9 >> 12 + a - 1 << 2 + 1) & (6 + 4 * 12 - 1);
var c = ((2 | 7) + 1) & b;
var d = (x > 5 && y < 6) || z == 7;
} |
フォーマット前 | フォーマット後 bitwise_exclusive_or |
|---|---|
void Calculate()
{
var x = 12 - ((3 % 4) * 12);
var y = ((9 >> ((12 + x) - 1)) << (2 + 1)) & ((6 + (4 * 12)) - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = x > 5 && y < 6 || z == 7;
} | internal void Calculate()
{
var x = 12 - 3 % 4 * 12;
var y = 9 >> 12 + x - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var z = (2 | 7) + 1 & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = (x > 5 && y < 6) || z == 7;
} |
フォーマット前 | フォーマット後 bitwise_inclusive_or |
|---|---|
void Calculate()
{
var x = 12 - ((3 % 4) * 12);
var y = ((9 >> ((12 + x) - 1)) << (2 + 1)) & ((6 + (4 * 12)) - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = x > 5 && y < 6 || z == 7;
} | internal void Calculate()
{
var x = 12 - 3 % 4 * 12;
var y = 9 >> 12 + x - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var z = (2 | 7) + 1 & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = (x > 5 && y < 6) || z == 7;
} |
フォーマット前 | フォーマット後 bitwise |
|---|---|
void Calculate()
{
var x = 12 - ((3 % 4) * 12);
var y = ((9 >> ((12 + x) - 1)) << (2 + 1)) & ((6 + (4 * 12)) - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = x > 5 && y < 6 || z == 7;
} | internal void Calculate()
{
var x = 12 - 3 % 4 * 12;
var y = (9 >> 12 + x - 1 << 2 + 1) & (6 + 4 * 12 - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = (9 >> 12 + a - 1 << 2 + 1) & (6 + 4 * 12 - 1);
var c = ((2 | 7) + 1) & b;
var d = (x > 5 && y < 6) || z == 7;
} |
フォーマット前 | フォーマット後 conditional_and |
|---|---|
void Calculate()
{
var x = 12 - ((3 % 4) * 12);
var y = ((9 >> ((12 + x) - 1)) << (2 + 1)) & ((6 + (4 * 12)) - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = x > 5 && y < 6 || z == 7;
} | internal void Calculate()
{
var x = 12 - 3 % 4 * 12;
var y = 9 >> 12 + x - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var z = (2 | 7) + 1 & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = ((x > 5) && (y < 6)) || z == 7;
} |
フォーマット前 | フォーマット後 conditional_or |
|---|---|
void Calculate()
{
var x = 12 - ((3 % 4) * 12);
var y = ((9 >> ((12 + x) - 1)) << (2 + 1)) & ((6 + (4 * 12)) - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = x > 5 && y < 6 || z == 7;
} | internal void Calculate()
{
var x = 12 - 3 % 4 * 12;
var y = 9 >> 12 + x - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var z = (2 | 7) + 1 & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = (x > 5 && y < 6) || (z == 7);
} |
フォーマット前 | フォーマット後 conditional |
|---|---|
void Calculate()
{
var x = 12 - ((3 % 4) * 12);
var y = ((9 >> ((12 + x) - 1)) << (2 + 1)) & ((6 + (4 * 12)) - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = x > 5 && y < 6 || z == 7;
} | internal void Calculate()
{
var x = 12 - 3 % 4 * 12;
var y = 9 >> 12 + x - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var z = (2 | 7) + 1 & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = ((x > 5) && (y < 6)) || (z == 7);
} |
フォーマット前 | フォーマット後 null_coalescing |
|---|---|
void Calculate()
{
var x = 12 - ((3 % 4) * 12);
var y = ((9 >> ((12 + x) - 1)) << (2 + 1)) & ((6 + (4 * 12)) - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = x > 5 && y < 6 || z == 7;
} | internal void Calculate()
{
var x = 12 - 3 % 4 * 12;
var y = 9 >> 12 + x - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var z = (2 | 7) + 1 & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = (x > 5 && y < 6) || z == 7;
} |
フォーマット前 | フォーマット後 range |
|---|---|
void Calculate()
{
var x = 12 - ((3 % 4) * 12);
var y = ((9 >> ((12 + x) - 1)) << (2 + 1)) & ((6 + (4 * 12)) - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = x > 5 && y < 6 || z == 7;
} | internal void Calculate()
{
var x = 12 - 3 % 4 * 12;
var y = 9 >> 12 + x - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var z = (2 | 7) + 1 & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = (x > 5 && y < 6) || z == 7;
} |
次のグループの操作がネストされている場合
プロパティ名:
[resharper_]csharp_parentheses_group_non_obvious_operations , [resharper_]parentheses_group_non_obvious_operations
使用可能な値:
nonearithmetic: * /%+-<< >> &^ |relational: <> <=> = ==!=conditional: && | | ??
例:
フォーマット前 | フォーマット後 none |
|---|---|
void Calculate()
{
var x = 12 - ((3 % 4) * 12);
var y = ((9 >> ((12 + x) - 1)) << (2 + 1)) & ((6 + (4 * 12)) - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = x > 5 && y < 6 || z == 7;
var e = x > 6 != y > 6 && x != null == (y != null);
} | internal void Calculate()
{
var x = 12 - 3 % 4 * 12;
var y = ((9 >> (12 + x - 1)) << (2 + 1)) & (6 + 4 * 12 - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = ((9 >> (12 + a - 1)) << (2 + 1)) & (6 + 4 * 12 - 1);
var c = ((2 | 7) + 1) & b;
var d = x > 5 && y < 6 || z == 7;
var e = x > 6 != y > 6 && x != null == (y != null);
} |
フォーマット前 | フォーマット後 arithmetic |
|---|---|
void Calculate()
{
var x = 12 - ((3 % 4) * 12);
var y = ((9 >> ((12 + x) - 1)) << (2 + 1)) & ((6 + (4 * 12)) - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = x > 5 && y < 6 || z == 7;
var e = x > 6 != y > 6 && x != null == (y != null);
} | internal void Calculate()
{
var x = 12 - (3 % 4 * 12);
var y = ((9 >> (12 + x - 1)) << (2 + 1)) & (6 + (4 * 12) - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - (3 % 4 * 12);
var b = ((9 >> (12 + a - 1)) << (2 + 1)) & (6 + (4 * 12) - 1);
var c = ((2 | 7) + 1) & b;
var d = x > 5 && y < 6 || z == 7;
var e = x > 6 != y > 6 && x != null == (y != null);
} |
フォーマット前 | フォーマット後 relational |
|---|---|
void Calculate()
{
var x = 12 - ((3 % 4) * 12);
var y = ((9 >> ((12 + x) - 1)) << (2 + 1)) & ((6 + (4 * 12)) - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = x > 5 && y < 6 || z == 7;
var e = x > 6 != y > 6 && x != null == (y != null);
} | internal void Calculate()
{
var x = 12 - 3 % 4 * 12;
var y = ((9 >> (12 + x - 1)) << (2 + 1)) & (6 + 4 * 12 - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = ((9 >> (12 + a - 1)) << (2 + 1)) & (6 + 4 * 12 - 1);
var c = ((2 | 7) + 1) & b;
var d = x > 5 && y < 6 || z == 7;
var e = (x > 6) != (y > 6) && x != null == (y != null);
} |
フォーマット前 | フォーマット後 conditional |
|---|---|
void Calculate()
{
var x = 12 - ((3 % 4) * 12);
var y = ((9 >> ((12 + x) - 1)) << (2 + 1)) & ((6 + (4 * 12)) - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = 9 >> 12 + a - 1 << 2 + 1 & 6 + 4 * 12 - 1;
var c = (2 | 7) + 1 & b;
var d = x > 5 && y < 6 || z == 7;
var e = x > 6 != y > 6 && x != null == (y != null);
} | internal void Calculate()
{
var x = 12 - 3 % 4 * 12;
var y = ((9 >> (12 + x - 1)) << (2 + 1)) & (6 + 4 * 12 - 1);
var z = ((2 | 7) + 1) & y;
var a = 12 - 3 % 4 * 12;
var b = ((9 >> (12 + a - 1)) << (2 + 1)) & (6 + 4 * 12 - 1);
var c = ((2 | 7) + 1) & b;
var d = (x > 5 && y < 6) || z == 7;
var e = x > 6 != y > 6 && x != null == (y != null);
} |
同じタイプの操作がネストされている場合でも
プロパティ名:
[resharper_]csharp_parentheses_same_type_operations , [resharper_]parentheses_same_type_operations
使用可能な値:
true | false
例:
true |
|---|
internal void Calculate()
{
var x = 5 + 3 - 2 * 3 / 4;
var e = x != null == (y != null);
} |
false |
|---|
internal void Calculate()
{
var x = 5 + 3 - 2 * 3 / 4;
var e = x != null == (y != null);
} |
波括弧
'if' ステートメント内
プロパティ名:
[resharper_]csharp_braces_for_ifelse , [resharper_]braces_for_ifelse
使用可能な値:
not_required: 強制しないnot_required_for_both: 波括弧が必要な部品がある場合に強制するrequired: 常に強制するrequired_for_multiline: 本文が複数行の場合に強制するrequired_for_multiline_statement: 文が複数行である場合に強制する
例:
フォーマット前 | フォーマット後 not_required |
|---|---|
public void Preview(int a, int b)
{
int c;
if (a > b)
{
c = a * b;
}
else if (a == b)
c = a + b;
else
{
c = a / b;
}
} | public void Preview(int a, int b)
{
int c;
if (a > b)
c = a * b;
else if (a == b)
c = a + b;
else
c = a / b;
} |
フォーマット前 | フォーマット後 not_required_for_both |
|---|---|
public void Preview(int a, int b)
{
int c;
if (a > b)
{
c = a * b;
}
else if (a == b)
c = a + b;
else
{
c = a / b;
}
} | public void Preview(int a, int b)
{
int c;
if (a > b)
c = a * b;
else if (a == b)
c = a + b;
else
c = a / b;
} |
フォーマット前 | フォーマット後 required |
|---|---|
public void Preview(int a, int b)
{
int c;
if (a > b)
{
c = a * b;
}
else if (a == b)
c = a + b;
else
{
c = a / b;
}
} | public void Preview(int a, int b)
{
int c;
if (a > b)
{
c = a * b;
}
else if (a == b)
{
c = a + b;
}
else
{
c = a / b;
}
} |
フォーマット前 | フォーマット後 required_for_multiline |
|---|---|
public void Preview(int a, int b)
{
int c;
if (a > b)
{
c = a * b;
}
else if (a == b)
c = a + b;
else
{
c = a / b;
}
} | public void Preview(int a, int b)
{
int c;
if (a > b)
c = a * b;
else if (a == b)
c = a + b;
else
c = a / b;
} |
フォーマット前 | フォーマット後 required_for_multiline_statement |
|---|---|
public void Preview(int a, int b)
{
int c;
if (a > b)
{
c = a * b;
}
else if (a == b)
c = a + b;
else
{
c = a / b;
}
} | public void Preview(int a, int b)
{
int c;
if (a > b)
{
c = a * b;
}
else if (a == b)
{
c = a + b;
}
else
{
c = a / b;
}
} |
'for' ステートメント内
プロパティ名:
[resharper_]csharp_braces_for_for , [resharper_]braces_for_for
使用可能な値:
not_required: 強制しないrequired: 常に強制するrequired_for_multiline: 本文が複数行の場合に強制するrequired_for_multiline_statement: 文が複数行である場合に強制する
例:
フォーマット前 | フォーマット後 not_required |
|---|---|
public void Preview(int a, int b)
{
var c = 0;
for (var i = a; i < b; i++)
c += System.Linq.Enumerable.Range(i, a + b).Sum();
for (var i = a; i < b; i++)
{
c += System.Linq.Enumerable
.Range(i, a + b)
.Sum();
}
} | public void Preview(int a, int b)
{
var c = 0;
for (var i = a; i < b; i++)
c += System.Linq.Enumerable.Range(i, a + b).Sum();
for (var i = a; i < b; i++)
c += System.Linq.Enumerable
.Range(i, a + b)
.Sum();
} |
フォーマット前 | フォーマット後 required |
|---|---|
public void Preview(int a, int b)
{
var c = 0;
for (var i = a; i < b; i++)
c += System.Linq.Enumerable.Range(i, a + b).Sum();
for (var i = a; i < b; i++)
{
c += System.Linq.Enumerable
.Range(i, a + b)
.Sum();
}
} | public void Preview(int a, int b)
{
var c = 0;
for (var i = a; i < b; i++)
{
c += System.Linq.Enumerable.Range(i, a + b).Sum();
}
for (var i = a; i < b; i++)
{
c += System.Linq.Enumerable
.Range(i, a + b)
.Sum();
}
} |
フォーマット前 | フォーマット後 required_for_multiline |
|---|---|
public void Preview(int a, int b)
{
var c = 0;
for (var i = a; i < b; i++)
c += System.Linq.Enumerable.Range(i, a + b).Sum();
for (var i = a; i < b; i++)
{
c += System.Linq.Enumerable
.Range(i, a + b)
.Sum();
}
} | public void Preview(int a, int b)
{
var c = 0;
for (var i = a; i < b; i++)
c += System.Linq.Enumerable.Range(i, a + b).Sum();
for (var i = a; i < b; i++)
{
c += System.Linq.Enumerable
.Range(i, a + b)
.Sum();
}
} |
フォーマット前 | フォーマット後 required_for_multiline_statement |
|---|---|
public void Preview(int a, int b)
{
var c = 0;
for (var i = a; i < b; i++)
c += System.Linq.Enumerable.Range(i, a + b).Sum();
for (var i = a; i < b; i++)
{
c += System.Linq.Enumerable
.Range(i, a + b)
.Sum();
}
} | public void Preview(int a, int b)
{
var c = 0;
for (var i = a; i < b; i++)
{
c += System.Linq.Enumerable.Range(i, a + b).Sum();
}
for (var i = a; i < b; i++)
{
c += System.Linq.Enumerable
.Range(i, a + b)
.Sum();
}
} |
'foreach' ステートメント内
プロパティ名:
[resharper_]csharp_braces_for_foreach , [resharper_]braces_for_foreach
使用可能な値:
not_required: 強制しないrequired: 常に強制するrequired_for_multiline: 本文が複数行の場合に強制するrequired_for_multiline_statement: 文が複数行である場合に強制する
例:
フォーマット前 | フォーマット後 not_required |
|---|---|
public void Preview(int a, int b)
{
var c = 0;
foreach (var num in System.Linq.Enumerable.Range(a, b))
c += System.Linq.Enumerable.Range(a, b).Sum();
foreach (var num in System.Linq.Enumerable.Range(a, b))
{
c += System.Linq.Enumerable
.Range(a, b)
.Sum();
}
} | public void Preview(int a, int b)
{
var c = 0;
foreach (var num in System.Linq.Enumerable.Range(a, b))
c += System.Linq.Enumerable.Range(a, b).Sum();
foreach (var num in System.Linq.Enumerable.Range(a, b))
c += System.Linq.Enumerable
.Range(a, b)
.Sum();
} |
フォーマット前 | フォーマット後 required |
|---|---|
public void Preview(int a, int b)
{
var c = 0;
foreach (var num in System.Linq.Enumerable.Range(a, b))
c += System.Linq.Enumerable.Range(a, b).Sum();
foreach (var num in System.Linq.Enumerable.Range(a, b))
{
c += System.Linq.Enumerable
.Range(a, b)
.Sum();
}
} | public void Preview(int a, int b)
{
var c = 0;
foreach (var num in System.Linq.Enumerable.Range(a, b))
{
c += System.Linq.Enumerable.Range(a, b).Sum();
}
foreach (var num in System.Linq.Enumerable.Range(a, b))
{
c += System.Linq.Enumerable
.Range(a, b)
.Sum();
}
} |
フォーマット前 | フォーマット後 required_for_multiline |
|---|---|
public void Preview(int a, int b)
{
var c = 0;
foreach (var num in System.Linq.Enumerable.Range(a, b))
c += System.Linq.Enumerable.Range(a, b).Sum();
foreach (var num in System.Linq.Enumerable.Range(a, b))
{
c += System.Linq.Enumerable
.Range(a, b)
.Sum();
}
} | public void Preview(int a, int b)
{
var c = 0;
foreach (var num in System.Linq.Enumerable.Range(a, b))
c += System.Linq.Enumerable.Range(a, b).Sum();
foreach (var num in System.Linq.Enumerable.Range(a, b))
{
c += System.Linq.Enumerable
.Range(a, b)
.Sum();
}
} |
フォーマット前 | フォーマット後 required_for_multiline_statement |
|---|---|
public void Preview(int a, int b)
{
var c = 0;
foreach (var num in System.Linq.Enumerable.Range(a, b))
c += System.Linq.Enumerable.Range(a, b).Sum();
foreach (var num in System.Linq.Enumerable.Range(a, b))
{
c += System.Linq.Enumerable
.Range(a, b)
.Sum();
}
} | public void Preview(int a, int b)
{
var c = 0;
foreach (var num in System.Linq.Enumerable.Range(a, b))
{
c += System.Linq.Enumerable.Range(a, b).Sum();
}
foreach (var num in System.Linq.Enumerable.Range(a, b))
{
c += System.Linq.Enumerable
.Range(a, b)
.Sum();
}
} |
'while' ステートメント内
プロパティ名:
[resharper_]csharp_braces_for_while , [resharper_]braces_for_while
使用可能な値:
not_required: 強制しないrequired: 常に強制するrequired_for_multiline: 本文が複数行の場合に強制するrequired_for_multiline_statement: 文が複数行である場合に強制する
例:
フォーマット前 | フォーマット後 not_required |
|---|---|
public void Preview(int a, int b)
{
while (a > b)
b += System.Linq.Enumerable.Range(a, b).Sum();
while (a > b)
{
b += System.Linq.Enumerable
.Range(a, b)
.Sum();
}
} | public void Preview(int a, int b)
{
while (a > b)
b += System.Linq.Enumerable.Range(a, b).Sum();
while (a > b)
b += System.Linq.Enumerable
.Range(a, b)
.Sum();
} |
フォーマット前 | フォーマット後 required |
|---|---|
public void Preview(int a, int b)
{
while (a > b)
b += System.Linq.Enumerable.Range(a, b).Sum();
while (a > b)
{
b += System.Linq.Enumerable
.Range(a, b)
.Sum();
}
} | public void Preview(int a, int b)
{
while (a > b)
{
b += System.Linq.Enumerable.Range(a, b).Sum();
}
while (a > b)
{
b += System.Linq.Enumerable
.Range(a, b)
.Sum();
}
} |
フォーマット前 | フォーマット後 required_for_multiline |
|---|---|
public void Preview(int a, int b)
{
while (a > b)
b += System.Linq.Enumerable.Range(a, b).Sum();
while (a > b)
{
b += System.Linq.Enumerable
.Range(a, b)
.Sum();
}
} | public void Preview(int a, int b)
{
while (a > b)
b += System.Linq.Enumerable.Range(a, b).Sum();
while (a > b)
{
b += System.Linq.Enumerable
.Range(a, b)
.Sum();
}
} |
フォーマット前 | フォーマット後 required_for_multiline_statement |
|---|---|
public void Preview(int a, int b)
{
while (a > b)
b += System.Linq.Enumerable.Range(a, b).Sum();
while (a > b)
{
b += System.Linq.Enumerable
.Range(a, b)
.Sum();
}
} | public void Preview(int a, int b)
{
while (a > b)
{
b += System.Linq.Enumerable.Range(a, b).Sum();
}
while (a > b)
{
b += System.Linq.Enumerable
.Range(a, b)
.Sum();
}
} |
'do-while' ステートメント内
プロパティ名:
[resharper_]csharp_braces_for_dowhile , [resharper_]braces_for_dowhile
使用可能な値:
not_required: 強制しないrequired: 常に強制するrequired_for_multiline: 本文が複数行の場合に強制するrequired_for_multiline_statement: 文が複数行である場合に強制する
例:
フォーマット前 | フォーマット後 not_required |
|---|---|
public void Preview(int a, int b)
{
do
b += System.Linq.Enumerable.Range(a, b).Sum();
while (a > b);
do
{
b += System.Linq.Enumerable
.Range(a, b)
.Sum();
} while (a > b);
} | public void Preview(int a, int b)
{
do
b += System.Linq.Enumerable.Range(a, b).Sum();
while (a > b);
do
b += System.Linq.Enumerable
.Range(a, b)
.Sum();
while (a > b);
} |
フォーマット前 | フォーマット後 required |
|---|---|
public void Preview(int a, int b)
{
do
b += System.Linq.Enumerable.Range(a, b).Sum();
while (a > b);
do
{
b += System.Linq.Enumerable
.Range(a, b)
.Sum();
} while (a > b);
} | public void Preview(int a, int b)
{
do
{
b += System.Linq.Enumerable.Range(a, b).Sum();
} while (a > b);
do
{
b += System.Linq.Enumerable
.Range(a, b)
.Sum();
} while (a > b);
} |
フォーマット前 | フォーマット後 required_for_multiline |
|---|---|
public void Preview(int a, int b)
{
do
b += System.Linq.Enumerable.Range(a, b).Sum();
while (a > b);
do
{
b += System.Linq.Enumerable
.Range(a, b)
.Sum();
} while (a > b);
} | public void Preview(int a, int b)
{
do
b += System.Linq.Enumerable.Range(a, b).Sum();
while (a > b);
do
{
b += System.Linq.Enumerable
.Range(a, b)
.Sum();
} while (a > b);
} |
フォーマット前 | フォーマット後 required_for_multiline_statement |
|---|---|
public void Preview(int a, int b)
{
do
b += System.Linq.Enumerable.Range(a, b).Sum();
while (a > b);
do
{
b += System.Linq.Enumerable
.Range(a, b)
.Sum();
} while (a > b);
} | public void Preview(int a, int b)
{
do
{
b += System.Linq.Enumerable.Range(a, b).Sum();
} while (a > b);
do
{
b += System.Linq.Enumerable
.Range(a, b)
.Sum();
} while (a > b);
} |
'using' ステートメント内
プロパティ名:
[resharper_]csharp_braces_for_using , [resharper_]braces_for_using
使用可能な値:
not_required: 強制しないrequired: 常に強制するrequired_for_multiline: 本文が複数行の場合に強制するrequired_for_multiline_statement: 文が複数行である場合に強制する
例:
フォーマット前 | フォーマット後 not_required |
|---|---|
public void Preview(System.IDisposable disposable)
{
var c = 0;
using (disposable)
c += System.Linq.Enumerable.Range(1, 42).Sum();
for (var i = a; i < b; i++)
{
c += System.Linq.Enumerable
.Range(1, 42)
.Sum();
}
} | public void Preview(System.IDisposable disposable)
{
var c = 0;
using (disposable)
c += System.Linq.Enumerable.Range(1, 42).Sum();
for (var i = a; i < b; i++)
c += System.Linq.Enumerable
.Range(1, 42)
.Sum();
} |
フォーマット前 | フォーマット後 required |
|---|---|
public void Preview(System.IDisposable disposable)
{
var c = 0;
using (disposable)
c += System.Linq.Enumerable.Range(1, 42).Sum();
for (var i = a; i < b; i++)
{
c += System.Linq.Enumerable
.Range(1, 42)
.Sum();
}
} | public void Preview(System.IDisposable disposable)
{
var c = 0;
using (disposable)
{
c += System.Linq.Enumerable.Range(1, 42).Sum();
}
for (var i = a; i < b; i++)
c += System.Linq.Enumerable
.Range(1, 42)
.Sum();
} |
フォーマット前 | フォーマット後 required_for_multiline |
|---|---|
public void Preview(System.IDisposable disposable)
{
var c = 0;
using (disposable)
c += System.Linq.Enumerable.Range(1, 42).Sum();
for (var i = a; i < b; i++)
{
c += System.Linq.Enumerable
.Range(1, 42)
.Sum();
}
} | public void Preview(System.IDisposable disposable)
{
var c = 0;
using (disposable)
c += System.Linq.Enumerable.Range(1, 42).Sum();
for (var i = a; i < b; i++)
c += System.Linq.Enumerable
.Range(1, 42)
.Sum();
} |
フォーマット前 | フォーマット後 required_for_multiline_statement |
|---|---|
public void Preview(System.IDisposable disposable)
{
var c = 0;
using (disposable)
c += System.Linq.Enumerable.Range(1, 42).Sum();
for (var i = a; i < b; i++)
{
c += System.Linq.Enumerable
.Range(1, 42)
.Sum();
}
} | public void Preview(System.IDisposable disposable)
{
var c = 0;
using (disposable)
{
c += System.Linq.Enumerable.Range(1, 42).Sum();
}
for (var i = a; i < b; i++)
c += System.Linq.Enumerable
.Range(1, 42)
.Sum();
} |
'lock' ステートメント内
プロパティ名:
[resharper_]csharp_braces_for_lock , [resharper_]braces_for_lock
使用可能な値:
not_required: 強制しないrequired: 常に強制するrequired_for_multiline: 本文が複数行の場合に強制するrequired_for_multiline_statement: 文が複数行である場合に強制する
例:
フォーマット前 | フォーマット後 not_required |
|---|---|
public void Preview(object lockObject)
{
var c = 0;
lock (lockObject)
c += System.Linq.Enumerable.Range(1, 42).Sum();
lock (lockObject)
{
c += System.Linq.Enumerable
.Range(1, 42)
.Sum();
}
} | public void Preview(object lockObject)
{
var c = 0;
lock (lockObject)
c += System.Linq.Enumerable.Range(1, 42).Sum();
lock (lockObject)
c += System.Linq.Enumerable
.Range(1, 42)
.Sum();
} |
フォーマット前 | フォーマット後 required |
|---|---|
public void Preview(object lockObject)
{
var c = 0;
lock (lockObject)
c += System.Linq.Enumerable.Range(1, 42).Sum();
lock (lockObject)
{
c += System.Linq.Enumerable
.Range(1, 42)
.Sum();
}
} | public void Preview(object lockObject)
{
var c = 0;
lock (lockObject)
{
c += System.Linq.Enumerable.Range(1, 42).Sum();
}
lock (lockObject)
{
c += System.Linq.Enumerable
.Range(1, 42)
.Sum();
}
} |
フォーマット前 | フォーマット後 required_for_multiline |
|---|---|
public void Preview(object lockObject)
{
var c = 0;
lock (lockObject)
c += System.Linq.Enumerable.Range(1, 42).Sum();
lock (lockObject)
{
c += System.Linq.Enumerable
.Range(1, 42)
.Sum();
}
} | public void Preview(object lockObject)
{
var c = 0;
lock (lockObject)
c += System.Linq.Enumerable.Range(1, 42).Sum();
lock (lockObject)
{
c += System.Linq.Enumerable
.Range(1, 42)
.Sum();
}
} |
フォーマット前 | フォーマット後 required_for_multiline_statement |
|---|---|
public void Preview(object lockObject)
{
var c = 0;
lock (lockObject)
c += System.Linq.Enumerable.Range(1, 42).Sum();
lock (lockObject)
{
c += System.Linq.Enumerable
.Range(1, 42)
.Sum();
}
} | public void Preview(object lockObject)
{
var c = 0;
lock (lockObject)
{
c += System.Linq.Enumerable.Range(1, 42).Sum();
}
lock (lockObject)
{
c += System.Linq.Enumerable
.Range(1, 42)
.Sum();
}
} |
'fixed' ステートメント内
プロパティ名:
[resharper_]csharp_braces_for_fixed , [resharper_]braces_for_fixed
使用可能な値:
not_required: 強制しないrequired: 常に強制するrequired_for_multiline: 本文が複数行の場合に強制するrequired_for_multiline_statement: 文が複数行である場合に強制する
例:
フォーマット前 | フォーマット後 not_required |
|---|---|
public unsafe void Preview(string str)
{
var c = 0;
fixed (char* p = str)
p[42] = 'c';
fixed (char* p = str)
{
p[42]
=
'c';
}
} | public unsafe void Preview(string str)
{
var c = 0;
fixed (char* p = str)
p[42] = 'c';
fixed (char* p = str)
p[42]
=
'c';
} |
フォーマット前 | フォーマット後 required |
|---|---|
public unsafe void Preview(string str)
{
var c = 0;
fixed (char* p = str)
p[42] = 'c';
fixed (char* p = str)
{
p[42]
=
'c';
}
} | public unsafe void Preview(string str)
{
var c = 0;
fixed (char* p = str)
{
p[42] = 'c';
}
fixed (char* p = str)
{
p[42]
=
'c';
}
} |
フォーマット前 | フォーマット後 required_for_multiline |
|---|---|
public unsafe void Preview(string str)
{
var c = 0;
fixed (char* p = str)
p[42] = 'c';
fixed (char* p = str)
{
p[42]
=
'c';
}
} | public unsafe void Preview(string str)
{
var c = 0;
fixed (char* p = str)
p[42] = 'c';
fixed (char* p = str)
{
p[42]
=
'c';
}
} |
フォーマット前 | フォーマット後 required_for_multiline_statement |
|---|---|
public unsafe void Preview(string str)
{
var c = 0;
fixed (char* p = str)
p[42] = 'c';
fixed (char* p = str)
{
p[42]
=
'c';
}
} | public unsafe void Preview(string str)
{
var c = 0;
fixed (char* p = str)
{
p[42] = 'c';
}
fixed (char* p = str)
{
p[42]
=
'c';
}
} |
冗長波括弧を取り外す
プロパティ名:
[resharper_]csharp_braces_redundant , [resharper_]braces_redundant
使用可能な値:
true | false
コード本体
メソッドと演算子
プロパティ名:
[resharper_]csharp_method_or_operator_body , [resharper_]method_or_operator_body
使用可能な値:
expression_body: 式本体block_body: ブロック本文
例:
フォーマット前 | フォーマット後 expression_body |
|---|---|
class Preview
{
int Add(int a, int b)
{
return a + b;
}
void SideEffect(DB db)
{
Drop(db);
}
static bool operator true(Preview p)
{
return false;
}
} | internal class Preview
{
private int Add(int a, int b) => a + b;
private void SideEffect(DB db)
{
Drop(db);
}
static bool operator true(Preview p) => false;
} |
フォーマット前 | フォーマット後 block_body |
|---|---|
class Preview
{
int Add(int a, int b)
{
return a + b;
}
void SideEffect(DB db)
{
Drop(db);
}
static bool operator true(Preview p)
{
return false;
}
} | internal class Preview
{
private int Add(int a, int b)
{
return a + b;
}
private void SideEffect(DB db)
{
Drop(db);
}
static bool operator true(Preview p)
{
return false;
}
} |
ローカル関数
プロパティ名:
[resharper_]csharp_local_function_body , [resharper_]local_function_body
使用可能な値:
expression_body: 式本体block_body: ブロック本文
例:
フォーマット前 | フォーマット後 expression_body |
|---|---|
class Demo
{
public void Preview()
{
int CalculateTheAnswer()
{
return 42;
}
int answer = CalculateTheAnswer();
Output(answer);
}
} | internal class Demo
{
public void Preview()
{
int CalculateTheAnswer() => 42;
int answer = CalculateTheAnswer();
Output(answer);
}
} |
フォーマット前 | フォーマット後 block_body |
|---|---|
class Demo
{
public void Preview()
{
int CalculateTheAnswer()
{
return 42;
}
int answer = CalculateTheAnswer();
Output(answer);
}
} | internal class Demo
{
public void Preview()
{
int CalculateTheAnswer()
{
return 42;
}
int answer = CalculateTheAnswer();
Output(answer);
}
} |
コンストラクターとデストラクタ
プロパティ名:
[resharper_]csharp_constructor_or_destructor_body , [resharper_]constructor_or_destructor_body
使用可能な値:
expression_body: 式本体block_body: ブロック本文
例:
フォーマット前 | フォーマット後 expression_body |
|---|---|
class Preview
{
public Preview(string message)
{
Message = message;
}
~Preview()
{
throw new Exception();
}
} | internal class Preview
{
public Preview(string message) => Message = message;
~Preview() => throw new Exception();
} |
フォーマット前 | フォーマット後 block_body |
|---|---|
class Preview
{
public Preview(string message)
{
Message = message;
}
~Preview()
{
throw new Exception();
}
} | internal class Preview
{
public Preview(string message)
{
Message = message;
}
~Preview()
{
throw new Exception();
}
} |
プロパティ、インデクサー、イベント
プロパティ名:
[resharper_]csharp_accessor_owner_body , [resharper_]accessor_owner_body
使用可能な値:
expression_body: 式本体accessors_with_expression_body: 式本体を持つアクセサーaccessors_with_block_body: ブロック本体付きアクセッサ
例:
フォーマット前 | フォーマット後 expression_body |
|---|---|
class Preview
{
int PropertyA
{
get { return field; }
set { field = value; }
}
int PropertyB => field;
int this[int i]
{
get { return array[i]; }
set { array[i] = value; }
}
event EventHandler MissionComplete
{
add { action += value; }
remove { action -= value; }
}
} | internal class Preview
{
private int PropertyA
{
get => field;
set => field = value;
}
private int PropertyB => field;
private int this[int i]
{
get => array[i];
set => array[i] = value;
}
private event EventHandler MissionComplete
{
add => action += value;
remove => action -= value;
}
} |
フォーマット前 | フォーマット後 accessors_with_expression_body |
|---|---|
class Preview
{
int PropertyA
{
get { return field; }
set { field = value; }
}
int PropertyB => field;
int this[int i]
{
get { return array[i]; }
set { array[i] = value; }
}
event EventHandler MissionComplete
{
add { action += value; }
remove { action -= value; }
}
} | internal class Preview
{
private int PropertyA
{
get => field;
set => field = value;
}
private int PropertyB
{
get => field;
}
private int this[int i]
{
get => array[i];
set => array[i] = value;
}
private event EventHandler MissionComplete
{
add => action += value;
remove => action -= value;
}
} |
フォーマット前 | フォーマット後 accessors_with_block_body |
|---|---|
class Preview
{
int PropertyA
{
get { return field; }
set { field = value; }
}
int PropertyB => field;
int this[int i]
{
get { return array[i]; }
set { array[i] = value; }
}
event EventHandler MissionComplete
{
add { action += value; }
remove { action -= value; }
}
} | internal class Preview
{
private int PropertyA
{
get { return field; }
set { field = value; }
}
private int PropertyB
{
get { return field; }
}
private int this[int i]
{
get { return array[i]; }
set { array[i] = value; }
}
private event EventHandler MissionComplete
{
add { action += value; }
remove { action -= value; }
}
} |
名前空間
プロパティ名:
[resharper_]csharp_namespace_body , [resharper_]namespace_body
使用可能な値:
file_scoped: ファイルスコープblock_scoped: ブロックスコープ
例:
フォーマット前 | フォーマット後 file_scoped |
|---|---|
namespace PreviewNamespace
{
public class C
{
}
} | namespace PreviewNamespace;
public class C
{
} |
フォーマット前 | フォーマット後 block_scoped |
|---|---|
namespace PreviewNamespace
{
public class C
{
}
} | namespace PreviewNamespace
{
public class C
{
}
} |
スタイルヒューリスティックを適用する
プロパティ名:
[resharper_]csharp_use_heuristics_for_body_style , [resharper_]use_heuristics_for_body_style
使用可能な値:
true | false
例:
フォーマット前 | フォーマット後 true |
|---|---|
class Preview
{
void VoidReturningMethod(DB db)
{
Drop(db);
}
int Assignment(int value)
{
return Property = value;
}
Action ReturnStatementBodiedLambda()
{
return () => { Foo(); };
}
} | internal class Preview
{
private void VoidReturningMethod(DB db)
{
Drop(db);
}
private int Assignment(int value)
{
return Property = value;
}
private Action ReturnStatementBodiedLambda()
{
return () => { Foo(); };
}
} |
フォーマット前 | フォーマット後 false |
|---|---|
class Preview
{
void VoidReturningMethod(DB db)
{
Drop(db);
}
int Assignment(int value)
{
return Property = value;
}
Action ReturnStatementBodiedLambda()
{
return () => { Foo(); };
}
} | internal class Preview
{
private void VoidReturningMethod(DB db)
{
Drop(db);
}
private int Assignment(int value)
{
return Property = value;
}
private Action ReturnStatementBodiedLambda()
{
return () => { Foo(); };
}
} |
属性
セクション内の属性の結合または分離
プロパティ名:
[resharper_]csharp_force_attribute_style , [resharper_]force_attribute_style
使用可能な値:
join: 結合separate: 別々
例:
フォーマット前 | フォーマット後 join |
|---|---|
namespace N
{
[Attr1, Attr2]
[Attr3]
class C
{
}
} | namespace N;
[Attr1, Attr2, Attr3]
internal class C
{
} |
フォーマット前 | フォーマット後 separate |
|---|---|
namespace N
{
[Attr1, Attr2]
[Attr3]
class C
{
}
} | namespace N;
[Attr1]
[Attr2]
[Attr3]
internal class C
{
} |
末尾のコンマ
複数行リストの改行の前
プロパティ名:
[resharper_]csharp_trailing_comma_in_multiline_lists , [resharper_]trailing_comma_in_multiline_lists
使用可能な値:
true | false
例:
true |
|---|
var myArray = new[]
{
item1,
item2,
}; |
false |
|---|
var myArray = new[]
{
item1,
item2
}; |
最後の要素の後に改行がない場合
プロパティ名:
[resharper_]csharp_trailing_comma_in_singleline_lists , [resharper_]trailing_comma_in_singleline_lists
使用可能な値:
true | false
例:
true |
|---|
var myArray = new[] { item1, item2, }; |
false |
|---|
var myArray = new[] { item1, item2 }; |
オブジェクトの作成
作成されたタイプが使用箇所から明らかな場合
プロパティ名:
[resharper_]csharp_object_creation_when_type_evident , [resharper_]object_creation_when_type_evident
使用可能な値:
target_typed: タイプを省略: 'new()'explicitly_typed: タイプの指定: 「新しい T()」
例:
target_typed |
|---|
using System;
internal class MyService : ServiceBase
{
public override Version Version => new Version(1, 2, 3);
} |
explicitly_typed |
|---|
using System;
internal class MyService : ServiceBase
{
public override Version Version => new Version(1, 2, 3);
} |
作成されたタイプが使用箇所から明らかでない場合
プロパティ名:
[resharper_]csharp_object_creation_when_type_not_evident , [resharper_]object_creation_when_type_not_evident
使用可能な値:
target_typed: タイプを省略: 'new()'explicitly_typed: タイプの指定: 「新しい T()」
例:
target_typed |
|---|
using System;
Version GetVersion()
{
// many lines of code
// ...
return new Version(1, 2, 3);
} |
explicitly_typed |
|---|
using System;
Version GetVersion()
{
// many lines of code
// ...
return new Version(1, 2, 3);
} |
デフォルト値
タイプが使用箇所から明らかな場合
プロパティ名:
[resharper_]csharp_default_value_when_type_evident , [resharper_]default_value_when_type_evident
使用可能な値:
default_literal: タイプを省略: 'default'default_expression: タイプの指定: 'default(T)'
例:
default_literal |
|---|
using System;
internal class MyService : ServiceBase
{
public override Guid Guid => default(Guid);
} |
default_expression |
|---|
using System;
internal class MyService : ServiceBase
{
public override Guid Guid => default(Guid);
} |
タイプが使用箇所から明らかでない場合
プロパティ名:
[resharper_]csharp_default_value_when_type_not_evident , [resharper_]default_value_when_type_not_evident
使用可能な値:
default_literal: タイプを省略: 'default'default_expression: タイプの指定: 'default(T)'
例:
default_literal |
|---|
using System;
Guid GetGuid()
{
// many lines of code
// ...
return default(Guid);
} |
default_expression |
|---|
using System;
Guid GetGuid()
{
// many lines of code
// ...
return default(Guid);
} |
パターン
null チェックパターンスタイル
プロパティ名:
[resharper_]csharp_null_checking_pattern_style , [resharper_]null_checking_pattern_style
使用可能な値:
empty_recursive_pattern: '{ }' パターンnot_null_pattern: 'not null' パターン
例:
empty_recursive_pattern |
|---|
public void Log(string? text)
{
if (text is not null)
Console.WriteLine(text);
} |
not_null_pattern |
|---|
public void Log(string? text)
{
if (text is not null)
Console.WriteLine(text);
} |
関連ページ:
構文スタイル
コードスタイルの側面の 1 つは、互換性のある言語構文構造を使用する方法です。例: 以下の 2 つのメソッド定義は、コンパイラーの観点からは同じですが、構文構造の選択により、それらは異なって見えます。[Conditional(
EditorConfig を使用する
ReSharper は、EditorConfig 形式で定義されたコード形式スタイル、コード構文スタイル、C# の命名スタイル、コードインスペクション重大度レベルをサポートします。まず、この 2 分間の概要ビデオを見て、Matt Ellis が EditorConfig を使用してフォーマットルールの構成全体を維持するのに ReSharper がどのように役立つかを説明します。EditorConfig とは何ですか? ReSharper はどのようにそれを拡張しますか? :EditorConfig...
C# の EditorConfig プロパティ: 波括弧レイアウト
このページでは、C# でフォーマット設定を構成するために使用できるカスタム ReSharperEditorConfig プロパティをリストします。具体的には、ReSharper が新しいコードを生成して既存のコードを再フォーマットするときにブレースを配置する方法です。特に、または演算子の後にブレースを配置する方法はいくつかあります。波括弧レイアウト:型と名前空間の宣言プロパティ名:、、使用可能な値:: 行末 (K&R スタイル)、: 行末 (空白なし)、: 次の行に (BSD スタイル)、:...