EditorConfig 属性(适用于 C#):空格
此页面列出了自定义 ReSharper EditorConfig 属性 ,您可以使用这些属性配置格式偏好,特别是如何在不同的 C# 结构中插入或移除空格。
保留现有格式
内部多余空格
属性名称:
[resharper_]csharp_extra_spaces, [resharper_]extra_spaces
可能的值:
remove_all:移除所有多余空格leave_tabs:保留多余的制表符leave_multiple:保留多个多余空格leave_all:保留所有多余的空格和制表符
示例:
格式化前 | 格式化之后,remove_all |
|---|---|
{
var x = foo ( 5 ) ;
var xx = foo ( 5 + 6 ) ;
var xxx = foo ( 5 + 6 + 7 ) ;
var tab = foo ( 5 ) ;
var tabx = foo ( 5 + 6 ) ;
var tabxx = foo ( 5 + 6 + 7 ) ;
}
| {
var x = foo(5);
var xx = foo(5 + 6);
var xxx = foo(5 + 6 + 7);
var tab = foo(5);
var tabx = foo(5 + 6);
var tabxx = foo(5 + 6 + 7);
}
|
格式化前 | 格式化之后,leave_tabs |
|---|---|
{
var x = foo ( 5 ) ;
var xx = foo ( 5 + 6 ) ;
var xxx = foo ( 5 + 6 + 7 ) ;
var tab = foo ( 5 ) ;
var tabx = foo ( 5 + 6 ) ;
var tabxx = foo ( 5 + 6 + 7 ) ;
}
| {
var x = foo(5);
var xx = foo(5 + 6);
var xxx = foo(5 + 6 + 7);
var tab = foo ( 5 ) ;
var tabx = foo ( 5 + 6 ) ;
var tabxx = foo ( 5 + 6 + 7 ) ;
}
|
格式化前 | 格式化之后,leave_multiple |
|---|---|
{
var x = foo ( 5 ) ;
var xx = foo ( 5 + 6 ) ;
var xxx = foo ( 5 + 6 + 7 ) ;
var tab = foo ( 5 ) ;
var tabx = foo ( 5 + 6 ) ;
var tabxx = foo ( 5 + 6 + 7 ) ;
}
| {
var x = foo(5 );
var xx = foo(5 + 6 );
var xxx = foo(5 + 6 + 7);
var tab = foo(5);
var tabx = foo(5 + 6);
var tabxx = foo(5 + 6 + 7);
}
|
格式化前 | 格式化之后,leave_all |
|---|---|
{
var x = foo ( 5 ) ;
var xx = foo ( 5 + 6 ) ;
var xxx = foo ( 5 + 6 + 7 ) ;
var tab = foo ( 5 ) ;
var tabx = foo ( 5 + 6 ) ;
var tabxx = foo ( 5 + 6 + 7 ) ;
}
| {
var x = foo ( 5 ) ;
var xx = foo ( 5 + 6 ) ;
var xxx = foo ( 5 + 6 + 7 ) ;
var tab = foo ( 5 ) ;
var tabx = foo ( 5 + 6 ) ;
var tabxx = foo ( 5 + 6 + 7 ) ;
}
|
语句中括号之前
'if' 括号
属性名称:
csharp_space_after_keywords_in_control_flow_statements, [resharper_]csharp_space_before_if_parentheses, [resharper_]space_before_if_parentheses, [resharper_]space_after_keywords_in_control_flow_statements
可能的值:
true | false
示例:
true |
|---|
if (condition)
{
foo();
}
else
{
foo();
}
|
false |
|---|
if(condition)
{
foo();
}
else
{
foo();
}
|
'while' 括号
属性名称:
csharp_space_after_keywords_in_control_flow_statements, [resharper_]csharp_space_before_while_parentheses, [resharper_]space_before_while_parentheses, [resharper_]space_after_keywords_in_control_flow_statements
可能的值:
true | false
示例:
true |
|---|
while (condition)
{
do
{
foo();
} while (condition);
}
|
false |
|---|
while(condition)
{
do
{
foo();
} while(condition);
}
|
'catch' 括号
属性名称:
csharp_space_after_keywords_in_control_flow_statements, [resharper_]csharp_space_before_catch_parentheses, [resharper_]space_before_catch_parentheses, [resharper_]space_after_keywords_in_control_flow_statements
可能的值:
true | false
示例:
true |
|---|
try
{
foo();
}
catch (Exception e)
{
}
|
false |
|---|
try
{
foo();
}
catch(Exception e)
{
}
|
'switch' 括号
属性名称:
csharp_space_after_keywords_in_control_flow_statements, [resharper_]csharp_space_before_switch_parentheses, [resharper_]space_before_switch_parentheses, [resharper_]space_after_keywords_in_control_flow_statements
可能的值:
true|false
示例:
true |
|---|
switch (expr)
{
case 0:
break;
}
|
false |
|---|
switch(expr)
{
case 0:
break;
}
|
'for' 括号
属性名称:
csharp_space_after_keywords_in_control_flow_statements, [resharper_]csharp_space_before_for_parentheses, [resharper_]space_before_for_parentheses, [resharper_]space_after_keywords_in_control_flow_statements
可能的值:
true | false
示例:
true |
|---|
for (int i = 0; i < 10; i++)
{
foo();
}
|
false |
|---|
for(int i = 0; i < 10; i++)
{
foo();
}
|
'foreach' 圆括号
属性名称:
csharp_space_after_keywords_in_control_flow_statements, [resharper_]csharp_space_before_foreach_parentheses, [resharper_]space_before_foreach_parentheses, [resharper_]space_after_keywords_in_control_flow_statements
可能的值:
true | false
示例:
true |
|---|
foreach (object o in collection)
{
foo();
}
|
false |
|---|
foreach(object o in collection)
{
foo();
}
|
'using' 括号
属性名称:
csharp_space_after_keywords_in_control_flow_statements, [resharper_]csharp_space_before_using_parentheses, [resharper_]space_before_using_parentheses, [resharper_]space_after_keywords_in_control_flow_statements
可能的值:
true | false
示例:
true |
|---|
using (C c = new C())
{
foo();
}
|
false |
|---|
using(C c = new C())
{
foo();
}
|
'lock' 括号
属性名称:
csharp_space_after_keywords_in_control_flow_statements, [resharper_]csharp_space_before_lock_parentheses, [resharper_]space_before_lock_parentheses, [resharper_]space_after_keywords_in_control_flow_statements
可能的值:
true|false
示例:
true |
|---|
lock (this)
{
foo();
}
|
false |
|---|
lock(this)
{
foo();
}
|
'fixed' 括号
属性名称:
csharp_space_after_keywords_in_control_flow_statements, [resharper_]csharp_space_before_fixed_parentheses, [resharper_]space_before_fixed_parentheses, [resharper_]space_after_keywords_in_control_flow_statements
可能的值:
true|false
示例:
true |
|---|
fixed (int* fib = new int[1])
{
foo();
}
|
false |
|---|
fixed(int* fib = new int[1])
{
foo();
}
|
其他括号之前
方法调用括号
属性名称:
csharp_space_between_method_call_name_and_opening_parenthesis, [resharper_]csharp_space_before_method_call_parentheses, [resharper_]space_before_method_call_parentheses, [resharper_]space_between_method_call_name_and_opening_parenthesis
可能的值:
true|false
示例:
true |
|---|
void Method()
{
foo1 ("string", true);
foo2();
}
|
false |
|---|
void Method()
{
foo1("string", true);
foo2();
}
|
方法调用空圆括号
属性名称:
csharp_space_between_method_call_name_and_opening_parenthesis, [resharper_]csharp_space_before_empty_method_call_parentheses, [resharper_]space_before_empty_method_call_parentheses, [resharper_]space_between_method_call_name_and_opening_parenthesis
可能的值:
true|false
示例:
true |
|---|
void Method()
{
foo1("string", true);
foo2 ();
}
|
false |
|---|
void Method()
{
foo1("string", true);
foo2();
}
|
方法声明括号
属性名称:
csharp_space_between_method_declaration_name_and_open_parenthesis, [resharper_]csharp_space_before_method_parentheses, [resharper_]space_before_method_parentheses, [resharper_]space_between_method_declaration_name_and_open_parenthesis
可能的值:
true|false
示例:
true |
|---|
class C
{
public abstract void Method1 (string str);
public abstract void Method2();
}
|
false |
|---|
class C
{
public abstract void Method1(string str);
public abstract void Method2();
}
|
方法声明空圆括号
属性名称:
csharp_space_between_method_declaration_name_and_open_parenthesis, [resharper_]csharp_space_before_empty_method_parentheses, [resharper_]space_before_empty_method_parentheses, [resharper_]space_between_method_declaration_name_and_open_parenthesis
可能的值:
true|false
示例:
true |
|---|
class C
{
public abstract void Method1(string str);
public abstract void Method2 ();
}
|
false |
|---|
class C
{
public abstract void Method1(string str);
public abstract void Method2();
}
|
'typeof' 括号
属性名称:
[resharper_]csharp_space_before_typeof_parentheses, [resharper_]space_before_typeof_parentheses
可能的值:
true|false
示例:
true |
|---|
Type t = typeof (bool);
|
false |
|---|
Type t = typeof(bool);
|
'default' 括号
属性名称:
[resharper_]csharp_space_before_default_parentheses, [resharper_]space_before_default_parentheses
可能的值:
true|false
示例:
true |
|---|
return default (int);
|
false |
|---|
return default(int);
|
'checked' 和 'unchecked' 圆括号
属性名称:
[resharper_]csharp_space_before_checked_parentheses, [resharper_]space_before_checked_parentheses
可能的值:
true|false
示例:
true |
|---|
return checked (100000 * 10000) + unchecked (10000 * 10000);
|
false |
|---|
return checked(100000 * 10000) + unchecked(10000 * 10000);
|
'sizeof' 括号
属性名称:
[resharper_]csharp_space_before_sizeof_parentheses, [resharper_]space_before_sizeof_parentheses
可能的值:
true|false
示例:
true |
|---|
int size = sizeof (bool);
|
false |
|---|
int size = sizeof(bool);
|
'nameof' 括号
属性名称:
[resharper_]csharp_space_before_nameof_parentheses, [resharper_]space_before_nameof_parentheses
可能的值:
true|false
示例:
true |
|---|
return nameof (myField);
|
false |
|---|
return nameof(myField);
|
'new' 括号
属性名称:
[resharper_]csharp_space_before_new_parentheses, [resharper_]space_before_new_parentheses
可能的值:
true|false
示例:
true |
|---|
List<int> x = new ();
|
false |
|---|
List<int> x = new();
|
关键字和表达式之间
属性名称:
[resharper_]csharp_space_between_keyword_and_expression, [resharper_]space_between_keyword_and_expression
可能的值:
true|false
示例:
true |
|---|
public SomeType A(object a)
{
return (SomeType)a ?? throw (new Exception());
}
|
false |
|---|
public SomeType A(object a)
{
return(SomeType)a ?? throw(new Exception());
}
|
关键字和类型之间
属性名称:
[resharper_]csharp_space_between_keyword_and_type, [resharper_]space_between_keyword_and_type
可能的值:
true|false
示例:
true |
|---|
public (int, int) A(ref (int, int) a)
{
return a;
}
|
false |
|---|
public(int, int) A(ref(int, int) a)
{
return a;
}
|
语句中括号内
'if' 括号
属性名称:
[resharper_]csharp_space_within_if_parentheses, [resharper_]csharp_space_between_parentheses_of_control_flow_statements, [resharper_]space_within_if_parentheses, [resharper_]space_between_parentheses_of_control_flow_statements
可能的值:
true|false
示例:
true |
|---|
if ( condition )
{
foo();
}
|
false |
|---|
if (condition)
{
foo();
}
|
'while' 括号
属性名称:
[resharper_]csharp_space_within_while_parentheses, [resharper_]csharp_space_between_parentheses_of_control_flow_statements, [resharper_]space_within_while_parentheses, [resharper_]space_between_parentheses_of_control_flow_statements
可能的值:
true|false
示例:
true |
|---|
while ( condition )
{
do
{
foo();
} while ( condition );
}
|
false |
|---|
while (condition)
{
do
{
foo();
} while (condition);
}
|
'catch' 括号
属性名称:
[resharper_]csharp_space_within_catch_parentheses, [resharper_]csharp_space_between_parentheses_of_control_flow_statements, [resharper_]space_within_catch_parentheses, [resharper_]space_between_parentheses_of_control_flow_statements
可能的值:
true|false
示例:
true |
|---|
try
{
foo();
}
catch ( Exception e )
{
}
finally
{
}
|
false |
|---|
try
{
foo();
}
catch (Exception e)
{
}
finally
{
}
|
'switch' 括号
属性名称:
[resharper_]csharp_space_within_switch_parentheses, [resharper_]csharp_space_between_parentheses_of_control_flow_statements, [resharper_]space_within_switch_parentheses, [resharper_]space_between_parentheses_of_control_flow_statements
可能的值:
true|false
示例:
true |
|---|
switch ( expression )
{
default:
break;
}
|
false |
|---|
switch (expression)
{
default:
break;
}
|
'for' 括号
属性名称:
[resharper_]csharp_space_within_for_parentheses, [resharper_]csharp_space_between_parentheses_of_control_flow_statements, [resharper_]space_within_for_parentheses, [resharper_]space_between_parentheses_of_control_flow_statements
可能的值:
true | false
示例:
true |
|---|
for ( int i = 0; i < 10; i++ )
{
foo();
}
|
false |
|---|
for (int i = 0; i < 10; i++)
{
foo();
}
|
'foreach' 圆括号
属性名称:
[resharper_]csharp_space_within_foreach_parentheses, [resharper_]csharp_space_between_parentheses_of_control_flow_statements, [resharper_]space_within_foreach_parentheses, [resharper_]space_between_parentheses_of_control_flow_statements
可能的值:
true | false
示例:
true |
|---|
foreach ( object o in collection )
{
foo();
}
|
false |
|---|
foreach (object o in collection)
{
foo();
}
|
'using' 括号
属性名称:
[resharper_]csharp_space_within_using_parentheses, [resharper_]csharp_space_between_parentheses_of_control_flow_statements, [resharper_]space_within_using_parentheses, [resharper_]space_between_parentheses_of_control_flow_statements
可能的值:
true | false
示例:
true |
|---|
using ( C c = new C() )
{
foo();
}
|
false |
|---|
using (C c = new C())
{
foo();
}
|
'lock' 括号
属性名称:
[resharper_]csharp_space_within_lock_parentheses, [resharper_]csharp_space_between_parentheses_of_control_flow_statements, [resharper_]space_within_lock_parentheses, [resharper_]space_between_parentheses_of_control_flow_statements
可能的值:
true | false
示例:
true |
|---|
lock ( this )
{
foo();
}
|
false |
|---|
lock (this)
{
foo();
}
|
'fixed' 括号
属性名称:
[resharper_]csharp_space_within_fixed_parentheses, [resharper_]csharp_space_between_parentheses_of_control_flow_statements, [resharper_]space_within_fixed_parentheses, [resharper_]space_between_parentheses_of_control_flow_statements
可能的值:
true | false
示例:
true |
|---|
fixed ( int* fib = new int[1] )
{
foo();
}
|
false |
|---|
fixed (int* fib = new int[1])
{
foo();
}
|
其他括号内
圆括号
属性名称:
[resharper_]csharp_space_within_parentheses, [resharper_]space_within_parentheses
可能的值:
true | false
示例:
true |
|---|
a = b * ( c + d );
|
false |
|---|
a = b * (c + d);
|
类型转换括号
属性名称:
[resharper_]csharp_space_between_typecast_parentheses, [resharper_]space_between_typecast_parentheses
可能的值:
true | false
示例:
true |
|---|
int a = ( int )b;
|
false |
|---|
int a = (int)b;
|
方法声明括号
属性名称:
csharp_space_between_method_declaration_parameter_list_parentheses, [resharper_]space_between_method_declaration_parameter_list_parentheses
可能的值:
true | false
示例:
true |
|---|
class C
{
public abstract void Method1( string str );
public abstract void Method2();
}
|
false |
|---|
class C
{
public abstract void Method1(string str);
public abstract void Method2();
}
|
方法声明空圆括号
属性名称:
csharp_space_between_method_declaration_empty_parameter_list_parentheses, [resharper_]space_between_method_declaration_empty_parameter_list_parentheses
可能的值:
true | false
示例:
true |
|---|
class C
{
public abstract void Method1(string str);
public abstract void Method2( );
}
|
false |
|---|
class C
{
public abstract void Method1(string str);
public abstract void Method2();
}
|
方法调用括号
属性名称:
csharp_space_between_method_call_parameter_list_parentheses, [resharper_]space_between_method_call_parameter_list_parentheses
可能的值:
true | false
示例:
true |
|---|
void Method()
{
foo1( "string", true );
foo2();
}
|
false |
|---|
void Method()
{
foo1("string", true);
foo2();
}
|
方法调用空圆括号
属性名称:
csharp_space_between_method_call_empty_parameter_list_parentheses, [resharper_]space_between_method_call_empty_parameter_list_parentheses
可能的值:
true | false
示例:
true |
|---|
void Method()
{
foo1("string", true);
foo2( );
}
|
false |
|---|
void Method()
{
foo1("string", true);
foo2();
}
|
'typeof' 括号
属性名称:
[resharper_]csharp_space_within_typeof_parentheses, [resharper_]space_within_typeof_parentheses
可能的值:
true | false
示例:
true |
|---|
Type t = typeof( bool );
|
false |
|---|
Type t = typeof(bool);
|
'default' 括号
属性名称:
[resharper_]csharp_space_within_default_parentheses, [resharper_]space_within_default_parentheses
可能的值:
true | false
示例:
true |
|---|
return default( int );
|
false |
|---|
return default(int);
|
'checked' 和 'unchecked' 圆括号
属性名称:
[resharper_]csharp_space_within_checked_parentheses, [resharper_]space_within_checked_parentheses
可能的值:
true | false
示例:
true |
|---|
return checked( 100000 * 10000 ) + unchecked( 10000 * 10000 );
|
false |
|---|
return checked(100000 * 10000) + unchecked(10000 * 10000);
|
'sizeof' 括号
属性名称:
[resharper_]csharp_space_within_sizeof_parentheses, [resharper_]space_within_sizeof_parentheses
可能的值:
true | false
示例:
true |
|---|
int size = sizeof( bool );
|
false |
|---|
int size = sizeof(bool);
|
'nameof' 括号
属性名称:
[resharper_]csharp_space_within_nameof_parentheses, [resharper_]space_within_nameof_parentheses
可能的值:
true | false
示例:
true |
|---|
return nameof( myField );
|
false |
|---|
return nameof(myField);
|
'new' 括号
属性名称:
[resharper_]csharp_space_within_new_parentheses, [resharper_]space_within_new_parentheses
可能的值:
true | false
示例:
true |
|---|
List<int> x = new( 5 );
|
false |
|---|
List<int> x = new(5);
|
数组括号周围
数组访问中括号前
属性名称:
csharp_space_before_open_square_brackets, [resharper_]csharp_space_before_array_access_brackets, [resharper_]space_before_array_access_brackets, [resharper_]space_before_open_square_brackets
可能的值:
true | false
示例:
true |
|---|
array [i] = array [i + 1];
|
false |
|---|
array[i] = array[i + 1];
|
数组秩中括号前
属性名称:
csharp_space_before_open_square_brackets, [resharper_]csharp_space_before_array_rank_brackets, [resharper_]space_before_array_rank_brackets, [resharper_]space_before_open_square_brackets
可能的值:
true | false
示例:
true |
|---|
int [] [,] x = null;
|
false |
|---|
int[][,] x = null;
|
数组访问中括号内
属性名称:
csharp_space_between_square_brackets, [resharper_]csharp_space_within_array_access_brackets, [resharper_]space_within_array_access_brackets, [resharper_]space_between_square_brackets
可能的值:
true | false
示例:
true |
|---|
array[ i ] = array[ i + 1 ];
|
false |
|---|
array[i] = array[i + 1];
|
在列表模式和集合表达式中括号内
属性名称:
csharp_space_between_square_brackets, [resharper_]csharp_space_within_list_pattern_brackets, [resharper_]space_within_list_pattern_brackets, [resharper_]space_between_square_brackets
可能的值:
true | false
示例:
true |
|---|
int[] collection = [ 1, 2, 3 ];
var matches = collection is [ 1, > 0, not 42 ];
|
false |
|---|
int[] collection = [1, 2, 3];
var matches = collection is [1, > 0, not 42];
|
数组秩中括号内
属性名称:
csharp_space_between_square_brackets, [resharper_]csharp_space_within_array_rank_brackets, [resharper_]space_within_array_rank_brackets, [resharper_]space_between_square_brackets
可能的值:
true | false
示例:
true |
|---|
int[ , ] x = new int[ 1, 2 ];
|
false |
|---|
int[,] x = new int[1, 2];
|
数组秩空中括号内
属性名称:
csharp_space_between_empty_square_brackets, [resharper_]csharp_space_within_array_rank_empty_brackets, [resharper_]space_within_array_rank_empty_brackets, [resharper_]space_between_empty_square_brackets
可能的值:
true | false
示例:
true |
|---|
int[ ][,] x = null;
|
false |
|---|
int[][,] x = null;
|
尖括号周围
类型形参列表的左尖括号前
属性名称:
[resharper_]csharp_space_before_type_parameter_angle, [resharper_]space_before_type_parameter_angle
可能的值:
true | false
示例:
true |
|---|
class C <T1, T2>
{
}
|
false |
|---|
class C<T1, T2>
{
}
|
类型实参列表的左尖括号前
属性名称:
[resharper_]csharp_space_before_type_argument_angle, [resharper_]space_before_type_argument_angle
可能的值:
true | false
示例:
true |
|---|
foo <int>();
|
false |
|---|
foo<int>();
|
类型形参尖括号
属性名称:
[resharper_]csharp_space_within_type_parameter_angles, [resharper_]space_within_type_parameter_angles
可能的值:
true | false
示例:
true |
|---|
class C< T1, T2 >
{
}
|
false |
|---|
class C<T1, T2>
{
}
|
类型实参尖括号
属性名称:
[resharper_]csharp_space_within_type_argument_angles, [resharper_]space_within_type_argument_angles
可能的值:
true | false
示例:
true |
|---|
foo< int >();
|
false |
|---|
foo<int>();
|
大括号周围
单行访问器块前
属性名称:
[resharper_]csharp_space_before_singleline_accessorholder, [resharper_]space_before_singleline_accessorholder
可能的值:
true | false
示例:
true |
|---|
int Property { get; set; }
|
false |
|---|
int Property{ get; set; }
|
单行访问器内
属性名称:
[resharper_]csharp_space_in_singleline_accessorholder, [resharper_]space_in_singleline_accessorholder
可能的值:
true | false
示例:
true |
|---|
int Property
{
get { return x; }
set { x = value; }
}
|
false |
|---|
int Property
{
get {return x;}
set {x = value;}
}
|
单行属性/事件中的访问器之间
属性名称:
[resharper_]csharp_space_between_accessors_in_singleline_property, [resharper_]space_between_accessors_in_singleline_property
可能的值:
true | false
示例:
true |
|---|
int Property { get; set; }
|
false |
|---|
int Property { get;set; }
|
空大括号之间的空格
属性名称:
[resharper_]csharp_space_within_empty_braces, [resharper_]space_within_empty_braces
可能的值:
true | false
示例:
true |
|---|
class C { }
|
false |
|---|
class C {}
|
单行方法内
属性名称:
[resharper_]csharp_space_in_singleline_method, [resharper_]space_in_singleline_method
可能的值:
true | false
示例:
true |
|---|
void Foo() { DoSomething(); }
|
false |
|---|
void Foo() {DoSomething();}
|
单行匿名方法内
属性名称:
[resharper_]csharp_space_in_singleline_anonymous_method, [resharper_]space_in_singleline_anonymous_method
可能的值:
true | false
示例:
true |
|---|
EventHandler e = delegate { return; };
|
false |
|---|
EventHandler e = delegate {return;};
|
单行表达式大括号内
属性名称:
[resharper_]csharp_space_within_single_line_array_initializer_braces, [resharper_]space_within_single_line_array_initializer_braces
可能的值:
true | false
示例:
true |
|---|
int[] x = new int[] { 0, 1, 2 };
|
false |
|---|
int[] x = new int[] {0, 1, 2};
|
二元运算符周围
赋值运算符(如 '=' 和 '+=')
属性名称:
[resharper_]csharp_space_around_assignment_op, [resharper_]csharp_space_around_binary_operator, [resharper_]space_around_assignment_op, [resharper_]space_around_binary_operator
可能的值:
true | false
示例:
true |
|---|
a += 1;
|
false |
|---|
a+=1;
|
Logical operators (&&,||)
属性名称:
[resharper_]csharp_space_around_logical_op, [resharper_]csharp_space_around_binary_operator, [resharper_]space_around_logical_op, [resharper_]space_around_binary_operator
可能的值:
true | false
示例:
true |
|---|
if (a && b || c)
{
}
|
false |
|---|
if (a&&b||c)
{
}
|
相等运算符(==,!=)
属性名称:
[resharper_]csharp_space_around_equality_op, [resharper_]csharp_space_around_binary_operator, [resharper_]space_around_equality_op, [resharper_]space_around_binary_operator
可能的值:
true | false
示例:
true |
|---|
if (a == b)
{
}
|
false |
|---|
if (a==b)
{
}
|
关系运算符(<、>、<=、>=)
属性名称:
[resharper_]csharp_space_around_relational_op, [resharper_]csharp_space_around_binary_operator, [resharper_]space_around_relational_op, [resharper_]space_around_binary_operator
可能的值:
true|false
示例:
true |
|---|
bool condition = a < b;
|
false |
|---|
bool condition = a<b;
|
Bitwise operators (&,|,^)
属性名称:
[resharper_]csharp_space_around_bitwise_op, [resharper_]csharp_space_around_binary_operator, [resharper_]space_around_bitwise_op, [resharper_]space_around_binary_operator
可能的值:
true|false
示例:
true |
|---|
int a = b ^ c;
|
false |
|---|
int a = b^c;
|
加法运算符(+、-)
属性名称:
[resharper_]csharp_space_around_additive_op, [resharper_]csharp_space_around_binary_operator, [resharper_]space_around_additive_op, [resharper_]space_around_binary_operator
可能的值:
true|false
示例:
true |
|---|
a = a + b - c;
|
false |
|---|
a = a+b-c;
|
乘法运算符 (*,/,%)
属性名称:
[resharper_]csharp_space_around_multiplicative_op, [resharper_]csharp_space_around_binary_operator, [resharper_]space_around_multiplicative_op, [resharper_]space_around_binary_operator
可能的值:
true|false
示例:
true |
|---|
a = a * b / c;
|
false |
|---|
a = a*b/c;
|
移位运算符(<<、>>、>>>)
属性名称:
[resharper_]csharp_space_around_shift_op, [resharper_]csharp_space_around_binary_operator, [resharper_]space_around_shift_op, [resharper_]space_around_binary_operator
可能的值:
true|false
示例:
true |
|---|
x = x << 1;
|
false |
|---|
x = x<<1;
|
null 合并运算符(??)
属性名称:
[resharper_]csharp_space_around_nullcoalescing_op, [resharper_]csharp_space_around_binary_operator, [resharper_]space_around_nullcoalescing_op, [resharper_]space_around_binary_operator
可能的值:
true|false
示例:
true |
|---|
x = a ?? b;
|
false |
|---|
x = a??b;
|
不安全的箭头运算符(->)
属性名称:
[resharper_]csharp_space_around_arrow_op, [resharper_]csharp_space_around_member_access_operator, [resharper_]space_around_arrow_op, [resharper_]space_around_member_access_operator
可能的值:
true|false
示例:
true |
|---|
int b = ptr -> x;
|
false |
|---|
int b = ptr->x;
|
一元运算符后
逻辑非运算符(!)
属性名称:
[resharper_]csharp_space_after_logical_not_op, [resharper_]csharp_space_after_unary_operator, [resharper_]space_after_logical_not_op, [resharper_]space_after_unary_operator
可能的值:
true|false
示例:
true |
|---|
if (! x) return;
|
false |
|---|
if (!x) return;
|
一元减法运算符(-)
属性名称:
[resharper_]csharp_space_after_unary_minus_op, [resharper_]csharp_space_after_unary_operator, [resharper_]space_after_unary_minus_op, [resharper_]space_after_unary_operator
可能的值:
true|false
示例:
true |
|---|
int x = - 5;
|
false |
|---|
int x = -5;
|
一元加法运算符(+)
属性名称:
[resharper_]csharp_space_after_unary_plus_op, [resharper_]csharp_space_after_unary_operator, [resharper_]space_after_unary_plus_op, [resharper_]space_after_unary_operator
可能的值:
true|false
示例:
true |
|---|
int x = + 5;
|
false |
|---|
int x = +5;
|
Unsafe addressof operator (&)
属性名称:
[resharper_]csharp_space_after_ampersand_op, [resharper_]csharp_space_after_unary_operator, [resharper_]space_after_ampersand_op, [resharper_]space_after_unary_operator
可能的值:
true|false
示例:
true |
|---|
int* b = & x;
|
false |
|---|
int* b = &x;
|
不安全的星号运算符(*)
属性名称:
[resharper_]csharp_space_after_asterik_op, [resharper_]csharp_space_after_unary_operator, [resharper_]space_after_asterik_op, [resharper_]space_after_unary_operator
可能的值:
true|false
示例:
true |
|---|
int p = * ptr;
|
false |
|---|
int p = *ptr;
|
++ 和 -- 前/后
属性名称:
[resharper_]csharp_space_near_postfix_and_prefix_op, [resharper_]space_near_postfix_and_prefix_op
可能的值:
true|false
示例:
true |
|---|
void Method(int p)
{
p ++;
-- p;
}
|
false |
|---|
void Method(int p)
{
p++;
--p;
}
|
三元运算符中
'?' 之前
属性名称:
[resharper_]csharp_space_before_ternary_quest, [resharper_]csharp_space_around_ternary_operator, [resharper_]space_before_ternary_quest, [resharper_]space_around_ternary_operator
可能的值:
true|false
示例:
true |
|---|
bool b = condition ? expr1 : expr2;
|
false |
|---|
bool b = condition? expr1 : expr2;
|
在 '?' 后
属性名称:
[resharper_]csharp_space_after_ternary_quest, [resharper_]csharp_space_around_ternary_operator, [resharper_]space_after_ternary_quest, [resharper_]space_around_ternary_operator
可能的值:
true|false
示例:
true |
|---|
bool b = condition ? expr1 : expr2;
|
false |
|---|
bool b = condition ?expr1 : expr2;
|
':' 前
属性名称:
[resharper_]csharp_space_before_ternary_colon, [resharper_]csharp_space_around_ternary_operator, [resharper_]space_before_ternary_colon, [resharper_]space_around_ternary_operator
可能的值:
true|false
示例:
true |
|---|
bool b = condition ? expr1 : expr2;
|
false |
|---|
bool b = condition ? expr1: expr2;
|
':' 之后
属性名称:
[resharper_]csharp_space_after_ternary_colon, [resharper_]csharp_space_around_ternary_operator, [resharper_]space_after_ternary_colon, [resharper_]space_around_ternary_operator
可能的值:
true | false
示例:
true |
|---|
bool b = condition ? expr1 : expr2;
|
false |
|---|
bool b = condition ? expr1 :expr2;
|
逗号和分号周围
在逗号前
属性名称:
csharp_space_before_comma, [resharper_]space_before_comma
可能的值:
true | false
示例:
true |
|---|
foo(a , b , c);
|
false |
|---|
foo(a, b, c);
|
在逗号后
属性名称:
csharp_space_after_comma, [resharper_]space_after_comma
可能的值:
true | false
示例:
true |
|---|
foo(a, b, c);
|
false |
|---|
foo(a,b,c);
|
'for' 分号之前
属性名称:
csharp_space_before_semicolon_in_for_statement, [resharper_]space_before_semicolon_in_for_statement
可能的值:
true | false
示例:
true |
|---|
for (int i = 1 ; i < 10 ; i++)
{
}
|
false |
|---|
for (int i = 1; i < 10; i++)
{
}
|
'for' 分号之后
属性名称:
csharp_space_after_semicolon_in_for_statement, [resharper_]space_after_semicolon_in_for_statement
可能的值:
true | false
示例:
true |
|---|
for (int i = 1; i < 10; i++)
{
}
|
false |
|---|
for (int i = 1;i < 10;i++)
{
}
|
分号之前
属性名称:
[resharper_]csharp_space_before_semicolon, [resharper_]space_before_semicolon
可能的值:
true | false
示例:
true |
|---|
a = b ;
|
false |
|---|
a = b;
|
冒号周围
基类型列表冒号前
属性名称:
csharp_space_before_colon_in_inheritance_clause, [resharper_]space_before_colon_in_inheritance_clause
可能的值:
true | false
示例:
true |
|---|
class Derived : BaseClass, Interface
{
}
|
false |
|---|
class Derived: BaseClass, Interface
{
}
|
基类型列表冒号后
属性名称:
csharp_space_after_colon_in_inheritance_clause, [resharper_]space_after_colon_in_inheritance_clause
可能的值:
true | false
示例:
true |
|---|
class Derived : BaseClass, Interface
{
}
|
false |
|---|
class Derived :BaseClass, Interface
{
}
|
类型形参约束冒号前
属性名称:
[resharper_]csharp_space_before_type_parameter_constraint_colon, [resharper_]space_before_type_parameter_constraint_colon
可能的值:
true | false
示例:
true |
|---|
class C<T1> where T1 : I
{
}
|
false |
|---|
class C<T1> where T1: I
{
}
|
类型形参约束冒号后
属性名称:
[resharper_]csharp_space_after_type_parameter_constraint_colon, [resharper_]space_after_type_parameter_constraint_colon
可能的值:
true | false
示例:
true |
|---|
class C<T1> where T1 : I
{
}
|
false |
|---|
class C<T1> where T1 :I
{
}
|
'case' 语句中的冒号前
属性名称:
[resharper_]csharp_space_before_colon_in_case, [resharper_]space_before_colon_in_case
可能的值:
true | false
示例:
true |
|---|
switch (expr)
{
case 0 :
break;
}
|
false |
|---|
switch (expr)
{
case 0:
break;
}
|
'case' 语句中的冒号后
属性名称:
[resharper_]csharp_space_after_colon_in_case, [resharper_]space_after_colon_in_case
可能的值:
true | false
示例:
true |
|---|
switch (expr)
{
case 0: return A;
case 1: return B;
}
|
false |
|---|
switch (expr)
{
case 0:return A;
case 1:return B;
}
|
其他冒号前
属性名称:
[resharper_]csharp_space_before_attribute_colon, [resharper_]csharp_space_before_colon, [resharper_]space_before_attribute_colon, [resharper_]space_before_colon
可能的值:
true | false
示例:
true |
|---|
[return : Description("returns A")]
public A b()
{
Method(arg1 : 1, arg2 : 3);
var y = (tuple1 : 1, tuple2 : 2);
return null;
}
|
false |
|---|
[return: Description("returns A")]
public A b()
{
Method(arg1: 1, arg2: 3);
var y = (tuple1: 1, tuple2: 2);
return null;
}
|
其他冒号后
属性名称:
[resharper_]csharp_space_after_attribute_colon, [resharper_]csharp_space_after_colon, [resharper_]space_after_attribute_colon, [resharper_]space_after_colon
可能的值:
true | false
示例:
true |
|---|
[return: Description("returns A")]
public A b()
{
Method(arg1: 1, arg2: 3);
var y = (tuple1: 1, tuple2: 2);
return null;
}
|
false |
|---|
[return:Description("returns A")]
public A b()
{
Method(arg1:1, arg2:3);
var y = (tuple1:1, tuple2:2);
return null;
}
|
特性
特性部分之间
属性名称:
[resharper_]csharp_space_between_attribute_sections, [resharper_]space_between_attribute_sections
可能的值:
true | false
示例:
true |
|---|
void Method([NotNull] [ItemNotNull] IList<string> items);
|
false |
|---|
void Method([NotNull][ItemNotNull] IList<string> items);
|
特性中括号内
属性名称:
csharp_space_between_square_brackets, [resharper_]csharp_space_within_attribute_brackets, [resharper_]space_within_attribute_brackets, [resharper_]space_between_square_brackets
可能的值:
true | false
示例:
true |
|---|
[ Attr1, Attr2(true) ]
class C
{
}
|
false |
|---|
[Attr1, Attr2(true)]
class C
{
}
|
特性后
属性名称:
[resharper_]csharp_space_after_attributes, [resharper_]space_after_attributes
可能的值:
true | false
示例:
true |
|---|
void Method([NotNull] [ItemNotNull] IList<string> items);
|
false |
|---|
void Method([NotNull] [ItemNotNull]IList<string> items);
|
其它
类型转换圆括号后
属性名称:
csharp_space_after_cast, [resharper_]space_after_cast
可能的值:
true | false
示例:
true |
|---|
int a = (int) b;
|
false |
|---|
int a = (int)b;
|
点周围
属性名称:
[resharper_]csharp_space_around_dot, [resharper_]csharp_space_around_member_access_operator, [resharper_]space_around_dot, [resharper_]space_around_member_access_operator
可能的值:
true | false
示例:
true |
|---|
a . b . foo();
|
false |
|---|
a.b.foo();
|
lambda 箭头周围
属性名称:
[resharper_]csharp_space_around_lambda_arrow, [resharper_]space_around_lambda_arrow
可能的值:
true | false
示例:
true |
|---|
Action a = x => x + 1;
|
false |
|---|
Action a = x=>x + 1;
|
不安全的指针声明前
属性名称:
[resharper_]csharp_space_before_pointer_asterik_declaration, [resharper_]space_before_pointer_asterik_declaration
可能的值:
true | false
示例:
true |
|---|
int * x;
|
false |
|---|
int* x;
|
可以为 null 的标记前
属性名称:
[resharper_]csharp_space_before_nullable_mark, [resharper_]space_before_nullable_mark
可能的值:
true | false
示例:
true |
|---|
int ? i = null;
|
false |
|---|
int? i = null;
|
命名空间别名指令中的 '=' 周围
属性名称:
[resharper_]csharp_space_around_alias_eq, [resharper_]space_around_alias_eq
可能的值:
true | false
示例:
true |
|---|
using X = A.B;
|
false |
|---|
using X=A.B;
|
行尾注释前
属性名称:
[resharper_]csharp_space_before_trailing_comment, [resharper_]space_before_trailing_comment
可能的值:
true | false
示例:
true |
|---|
var x = 4; // x = 4
|
false |
|---|
var x = 4;// x = 4
|
运算符关键字后
属性名称:
[resharper_]csharp_space_after_operator_keyword, [resharper_]space_after_operator_keyword
可能的值:
true|false
示例:
true |
|---|
public static bool operator ==(C x, C y)
{
}
|
false |
|---|
public static bool operator==(C x, C y)
{
}
|
在切片模式中的 '..' 之后
属性名称:
[resharper_]csharp_space_within_slice_pattern, [resharper_]space_within_slice_pattern
可能的值:
true|false
示例:
true |
|---|
bool matches = sourceObject is [1, 2, .. var tail];
|
false |
|---|
bool matches = sourceObject is [1, 2, ..var tail];
|