JetBrains Rider 2025.2 Help

EditorConfig 属性用于 C#: 制表符、缩进、对齐

此页面列出了自定义 JetBrains Rider EditorConfig 属性 ,您可以使用这些属性来配置 C# 中的格式化首选项,特别是如何缩进和对齐不同的代码结构。

常规

缩进样式

属性名称:

indent_style[resharper_]csharp_indent_style

可能的值:

  • 制表符 :制表符

  • 空格 :空格

示例:

制表符

if (condition) { if (condition1) { foo1(); foo2(); } else { foo3(); foo4(); } }

空格

if (condition) { if (condition1) { foo1(); foo2(); } else { foo3(); foo4(); } }

缩进大小

属性名称:

indent_size[resharper_]csharp_indent_size

可能的值:

整数

示例:

值:0

if (condition) { if (condition1) { foo1(); foo2(); } else { foo3(); foo4(); } }

值:1

if (condition) { if (condition1) { foo1(); foo2(); } else { foo3(); foo4(); } }

值:2

if (condition) { if (condition1) { foo1(); foo2(); } else { foo3(); foo4(); } }

制表符宽度

属性名称:

tab_width[resharper_]csharp_tab_width

可能的值:

整数

示例:

值:0

if (condition) { if (condition1) { foo1(); foo2(); } else { foo3(); foo4(); } }

值:1

if (condition) { if (condition1) { foo1(); foo2(); } else { foo3(); foo4(); } }

值:2

if (condition) { if (condition1) { foo1(); foo2(); } else { foo3(); foo4(); } }

连续行缩进乘数

属性名称:

[resharper_]csharp_continuous_indent_multiplier[resharper_]continuous_indent_multiplier

可能的值:

整数

示例:

值:0

int x = foo1() + foo2();

值:1

int x = foo1() + foo2();

值:2

int x = foo1() + foo2();

嵌套语句

缩进嵌套的 'using' 语句

属性名称:

[resharper_]csharp_indent_nested_usings_stmt[resharper_]indent_nested_usings_stmt

可能的值:

true | false

示例:

true

using (A a = new A()) using (B b = new B()) using (C c = new C()) { foo(); }

false

using (A a = new A()) using (B b = new B()) using (C c = new C()) { foo(); }

缩进嵌套的 'fixed' 语句

属性名称:

[resharper_]csharp_indent_nested_fixed_stmt[resharper_]indent_nested_fixed_stmt

可能的值:

true|false

示例:

true

fixed (int* a = &x) fixed (int* b = &y) fixed (int* c = &z) { foo(); }

false

fixed (int* a = &x) fixed (int* b = &y) fixed (int* c = &z) { foo(); }

缩进嵌套的 'lock' 语句

属性名称:

[resharper_]csharp_indent_nested_lock_stmt[resharper_]indent_nested_lock_stmt

可能的值:

true|false

示例:

true

lock (a) lock (b) lock (c) { foo(); }

false

lock (a) lock (b) lock (c) { foo(); }

缩进嵌套的 'for' 语句

属性名称:

[resharper_]csharp_indent_nested_for_stmt[resharper_]indent_nested_for_stmt

可能的值:

true|false

示例:

true

for (int a = 0; a < x; a++) for (int b = 0; b < y; b++) for (int c = 0; c < y; c++) { foo(); }

false

for (int a = 0; a < x; a++) for (int b = 0; b < y; b++) for (int c = 0; c < y; c++) { foo(); }

缩进嵌套的 'foreach' 语句

属性名称:

[resharper_]csharp_indent_nested_foreach_stmt[resharper_]indent_nested_foreach_stmt

可能的值:

true|false

示例:

true

foreach (var a in x) foreach (var b in y) foreach (var c in z) { foo(); }

false

foreach (var a in x) foreach (var b in y) foreach (var c in z) { foo(); }

缩进嵌套的 'while' 语句

属性名称:

[resharper_]csharp_indent_nested_while_stmt[resharper_]indent_nested_while_stmt

可能的值:

true|false

示例:

true

while (a) while (b) while (c) { foo(); }

false

while (a) while (b) while (c) { foo(); }

括号

在圆括号内使用连续行缩进

属性名称:

[resharper_]csharp_use_continuous_indent_inside_parens[resharper_]use_continuous_indent_inside_parens

可能的值:

true|false

示例:

true

var x = Method( parameter1, parameter2 );

false

var x = Method( parameter1, parameter2 );

缩进方法声明的圆括号

属性名称:

[resharper_]csharp_indent_method_decl_pars[resharper_]indent_method_decl_pars

可能的值:

  • 内部 :括号内(BSD/K&R 风格)

  • 外部 :括号和内部对齐(Whitesmiths 风格)

  • 外部和内部 :括号 1 次,内部 2 次(GNU 风格)

  • :无缩进

示例:

内部

void Method( int parameter1, int parameter2 );

外部

void Method( int parameter1, int parameter2 );

外部和内部

void Method( int parameter1, int parameter2 );

void Method( int parameter1, int parameter2 );

缩进主构造函数声明的圆括号

属性名称:

[resharper_]csharp_indent_primary_constructor_decl_pars[resharper_]indent_primary_constructor_decl_pars

可能的值:

  • 内部 :括号内(BSD/K&R 风格)

  • 外部 :括号和内部对齐(Whitesmiths 风格)

  • 外部和内部 :括号 1 次,内部 2 次(GNU 风格)

  • :无缩进

示例:

内部

record Person( string Name, int Age );

外部

record Person( string Name, int Age );

外部和内部

record Person( string Name, int Age );

record Person( string Name, int Age );

缩进方法调用的圆括号

属性名称:

[resharper_]csharp_indent_invocation_pars[resharper_]indent_invocation_pars

可能的值:

  • 内部 :括号内(BSD/K&R 风格)

  • 外部 :括号和内部对齐(Whitesmiths 风格)

  • 外部和内部 :括号 1 次,内部 2 次(GNU 风格)

  • :无缩进

示例:

内部

var x = Method( parameter1, parameter2 );

外部

var x = Method( parameter1, parameter2 );

外部和内部

var x = Method( parameter1, parameter2 );

var x = Method( parameter1, parameter2 );

缩进语句(if、while、for 等)圆括号

属性名称:

[resharper_]csharp_indent_statement_pars[resharper_]indent_statement_pars

可能的值:

  • 内部 :括号内(BSD/K&R 风格)

  • 外部 :括号和内部对齐(Whitesmiths 风格)

  • 外部和内部 :括号 1 次,内部 2 次(GNU 风格)

  • :无缩进

示例:

内部

if ( condition1 && condition2 ) return;

外部

if ( condition1 && condition2 ) return;

外部和内部

if ( condition1 && condition2 ) return;

if ( condition1 && condition2 ) return;

缩进类型形参的尖括号

属性名称:

[resharper_]csharp_indent_typeparam_angles[resharper_]indent_typeparam_angles

可能的值:

  • 内部 :括号内(BSD/K&R 风格)

  • 外部 :括号和内部对齐(Whitesmiths 风格)

  • 外部和内部 :括号 1 次,内部 2 次(GNU 风格)

  • :无缩进

示例:

内部

void Method< T1, T2 >();

外部

void Method< T1, T2 >();

外部和内部

void Method< T1, T2 >();

void Method< T1, T2 >();

缩进类型实参的尖括号

属性名称:

[resharper_]csharp_indent_typearg_angles[resharper_]indent_typearg_angles

可能的值:

  • 内部 :括号内(BSD/K&R 风格)

  • 外部 :括号和内部对齐(Whitesmiths 风格)

  • 外部和内部 :括号 1 次,内部 2 次(GNU 风格)

  • :无缩进

示例:

内部

var x = Method< Class1, Class2 >();

外部

var x = Method< Class1, Class2 >();

外部和内部

var x = Method< Class1, Class2 >();

var x = Method< Class1, Class2 >();

缩进其他圆括号和中括号

属性名称:

[resharper_]csharp_indent_pars[resharper_]indent_pars

可能的值:

  • 内部 :括号内(BSD/K&R 风格)

  • 外部 :括号和内部对齐(Whitesmiths 风格)

  • 外部和内部 :括号 1 次,内部 2 次(GNU 风格)

  • :无缩进

示例:

内部

var x = 1 * checked( 5 + 6 );

外部

var x = 1 * checked( 5 + 6 );

外部和内部

var x = 1 * checked( 5 + 6 );

var x = 1 * checked( 5 + 6 );

预处理器指令

缩进 #if、#else、#elif、#endif

属性名称:

[resharper_]csharp_indent_preprocessor_if[resharper_]indent_preprocessor_if

可能的值:

  • 无缩进 :无缩进

  • 按常规缩进: 按常规缩进

  • 减少缩进: 减少缩进

  • 不要更改 :不要更改

示例:

无缩进

namespace N { class C { #if !HideSomething int myField; #endif } }

按常规缩进

namespace N { class C { #if !HideSomething int myField; #endif } }

减少缩进

namespace N { class C { #if !HideSomething int myField; #endif } }

不要更改

namespace N { class C { #if !HideSomething int myField; #endif } }

缩进 #region、#endregion

属性名称:

[resharper_]csharp_indent_preprocessor_region[resharper_]indent_preprocessor_region

可能的值:

  • 无缩进 :无缩进

  • 按常规缩进: 按常规缩进

  • 减少缩进: 减少缩进

  • 不要更改 :不要更改

示例:

无缩进

namespace N { class C { #region Fields int myField; #endregion } }

按常规缩进

namespace N { class C { #region Fields int myField; #endregion } }

减少缩进

namespace N { class C { #region Fields int myField; #endregion } }

不要更改

namespace N { class C { #region Fields int myField; #endregion } }

缩进其他预处理程序指令

属性名称:

[resharper_]csharp_indent_preprocessor_other[resharper_]indent_preprocessor_other

可能的值:

  • 无缩进 :无缩进

  • 按常规缩进: 按常规缩进

  • 减少缩进: 减少缩进

  • 不要更改 :不要更改

示例:

无缩进

namespace N { class C { #pragma warning disable CS3021 int myField; #warning Fixme } }

按常规缩进

namespace N { class C { #pragma warning disable CS3021 int myField; #warning Fixme } }

减少缩进

namespace N { class C { #pragma warning disable CS3021 int myField; #warning Fixme } }

不要更改

namespace N { class C { #pragma warning disable CS3021 int myField; #warning Fixme } }

其他缩进

缩进 'switch' 中的 'case'

属性名称:

csharp_indent_switch_labels[resharper_]indent_switch_labels

可能的值:

true|false

示例:

true

switch (expression) { case 0: break; }

false

switch (expression) { case 0: break; }

减少缩进语句标签

属性名称:

[resharper_]csharp_outdent_statement_labels[resharper_]outdent_statement_labels

可能的值:

true|false

示例:

true

{ int a = 5; MyLabel: a--; if (a > 0) goto MyLabel; }

false

{ int a = 5; MyLabel: a--; if (a > 0) goto MyLabel; }

缩进类型约束

属性名称:

[resharper_]csharp_indent_type_constraints[resharper_]indent_type_constraints

可能的值:

true|false

示例:

true

class C1<T1> where T1 : I1 { }

false

class C1<T1> where T1 : I1 { }

不缩进从第一列开始的注释

属性名称:

[resharper_]csharp_stick_comment[resharper_]stick_comment

可能的值:

true|false

示例:

格式化之前

格式化之后,真

namespace N { // Some comment class C { } }
namespace N { // Some comment class C { } }

格式化之前

格式化之后,假

namespace N { // Some comment class C { } }
namespace N { // Some comment class C { } }

注释掉代码时将注释置于第一列

属性名称:

[resharper_]csharp_place_comments_at_first_column[resharper_]place_comments_at_first_column

Place comments at the first column when commenting out code. Otherwise, comments will use the indentation level of the commented code.

可能的值:

true | false

在部分格式上使用上一个元素的缩进

属性名称:

[resharper_]csharp_use_indent_from_previous_element[resharper_]use_indent_from_previous_element

When formatting only a part of the file, try to take the indent from elements on previous lines (previous statements/class members/etc). If turned off, the indent will be the parent element's (usually the parent block) indent plus the indent from the indent settings.

可能的值:

true | false

缩进语句条件内的大括号

属性名称:

[resharper_]csharp_indent_braces_inside_statement_conditions[resharper_]indent_braces_inside_statement_conditions

可能的值:

true | false

示例:

true

while (x is IMyInterface { Prop1: 1, Prop2: 2 }) { DoSomething(); }

false

while (x is IMyInterface { Prop1: 1, Prop2: 2 }) { DoSomething(); }

对齐多行结构

制表符用于缩进时如何对齐

属性名称:

[resharper_]csharp_alignment_tab_fill_style[resharper_]alignment_tab_fill_style

可能的值:

  • 使用空格: 使用空格(在任何制表符大小下看起来都对齐)

  • 仅使用制表符: 仅使用制表符(不准确)

  • 最佳填充 :混合使用制表符和空格以实现最佳填充

示例:

使用空格

SomeMyMethod(param1, param2);

仅使用制表符

SomeMyMethod(param1, param2);

最佳填充

SomeMyMethod(param1, param2);

即使结果缩进过大也要对齐

属性名称:

[resharper_]csharp_allow_far_alignment[resharper_]allow_far_alignment

Allow alignment even if construct is located too far to the right, more than 2/3 of `Hard wrap at` limit

可能的值:

true | false

方法参数

属性名称:

[resharper_]csharp_align_multiline_parameter[resharper_]align_multiline_parameter

可能的值:

true | false

示例:

true

void fooCall(int firstParameter, int secondParameter) { }

false

void fooCall(int firstParameter, int secondParameter) { }

基类和接口列表

属性名称:

[resharper_]csharp_align_multiline_extends_list[resharper_]align_multiline_extends_list

可能的值:

true | false

示例:

true

class C : BaseClass, SomeInterface { }

false

class C : BaseClass, SomeInterface { }

LINQ 查询

属性名称:

[resharper_]csharp_align_linq_query[resharper_]align_linq_query

可能的值:

true | false

示例:

true

var q = from x in xs where x != null select x;

false

var q = from x in xs where x != null select x;

二項式

属性名称:

[resharper_]csharp_align_multiline_binary_expressions_chain[resharper_]align_multiline_binary_expressions_chain

可能的值:

true | false

示例:

true

var a = someOperand + operand2 + operand3 + operand4;

false

var a = someOperand + operand2 + operand3 + operand4;

减少缩进二元运算符

属性名称:

[resharper_]csharp_outdent_binary_ops[resharper_]outdent_binary_ops

可能的值:

true | false

示例:

true

{ var a = someOperand + operand2 + operand3 + operand4; var b = someOperand + operand2 + operand3 + operand4; }

false

{ var a = someOperand + operand2 + operand3 + operand4; var b = someOperand + operand2 + operand3 + operand4; }

链式方法调用

属性名称:

[resharper_]csharp_align_multiline_calls_chain[resharper_]align_multiline_calls_chain

可能的值:

true | false

示例:

true

MyVar.SomeMethod() .OtherMethod() .ThirdMethod();

false

MyVar.SomeMethod() .OtherMethod() .ThirdMethod();

减少缩进链式方法调用中的点

属性名称:

[resharper_]csharp_outdent_dots[resharper_]outdent_dots

可能的值:

true | false

示例:

true

{ var a = MyVar .SomeMethod() ?.OtherMethod() .ThirdMethod(); var b = MyVar .SomeMethod() ?.OtherMethod() .ThirdMethod(); }

false

{ var a = MyVar .SomeMethod() ?.OtherMethod() .ThirdMethod(); var b = MyVar .SomeMethod() ?.OtherMethod() .ThirdMethod(); }

数组、对象和集合初始值设定项

属性名称:

[resharper_]csharp_align_multiline_array_and_object_initializer[resharper_]align_multiline_array_and_object_initializer

可能的值:

true | false

示例:

true

StudentName student = new StudentName { FirstName = "John", LastName = "Smith", ID = 116 }

false

StudentName student = new StudentName { FirstName = "John", LastName = "Smith", ID = 116 }

Switch 表达式

属性名称:

[resharper_]csharp_align_multiline_switch_expression[resharper_]align_multiline_switch_expression

可能的值:

true | false

示例:

true

var z = op switch { op.Add => x + y, op.Subtract => x - y, op.Multiply => x * y, op.Divide => x / y }

false

var z = op switch { op.Add => x + y, op.Subtract => x - y, op.Multiply => x * y, op.Divide => x / y }

属性模式

属性名称:

[resharper_]csharp_align_multiline_property_pattern[resharper_]align_multiline_property_pattern

可能的值:

true | false

示例:

true

bool matches = sourceObject is MyType { Field1: 1, Field2: 2, };

false

bool matches = sourceObject is MyType { Field1: 1, Field2: 2, };

列表模式和集合表达式

属性名称:

[resharper_]csharp_align_multiline_list_pattern[resharper_]align_multiline_list_pattern

可能的值:

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 ];

二元模式

属性名称:

[resharper_]csharp_align_multiline_binary_patterns[resharper_]align_multiline_binary_patterns

可能的值:

true | false

示例:

true

var a = e is someOperand or operand2 or operand3 or operand4;

false

var a = e is someOperand or operand2 or operand3 or operand4;

减少缩进二元模式

属性名称:

[resharper_]csharp_outdent_binary_pattern_ops[resharper_]outdent_binary_pattern_ops

可能的值:

true | false

示例:

true

{ var a = e is someOperand or operand2 or operand3 or operand4; var b = e is someOperand or operand2 or operand3 or operand4; }

false

{ var a = e is someOperand or operand2 or operand3 or operand4; var b = e is someOperand or operand2 or operand3 or operand4; }

匿名方法体

属性名称:

[resharper_]csharp_indent_anonymous_method_block[resharper_]indent_anonymous_method_block

可能的值:

true | false

示例:

true

FooCall(delegate { DoSomething(); return 0; });

false

FooCall(delegate { DoSomething(); return 0; });

将调用实参对齐到 '('

属性名称:

[resharper_]csharp_align_first_arg_by_paren[resharper_]align_first_arg_by_paren

可能的值:

true | false

示例:

true

fooCall( firstParameter, secondParameter);

false

fooCall( firstParameter, secondParameter);

调用参数

属性名称:

[resharper_]csharp_align_multiline_argument[resharper_]align_multiline_argument

可能的值:

true | false

示例:

true

fooCall(firstParameter, secondParameter);

false

fooCall(firstParameter, secondParameter);

元组组件

属性名称:

[resharper_]csharp_align_tuple_components[resharper_]align_tuple_components

可能的值:

true | false

示例:

true

var tuple = (firstParameter, secondParameter);

false

var tuple = (firstParameter, secondParameter);

其他表达式

属性名称:

[resharper_]csharp_align_multiline_expression[resharper_]align_multiline_expression

可能的值:

true | false

示例:

true

destination = source1 ? source2 : source3

false

destination = source1 ? source2 : source3

圆括号内的语句条件

属性名称:

[resharper_]csharp_align_multiline_statement_conditions[resharper_]align_multiline_statement_conditions

可能的值:

true | false

示例:

true

while (x is IMyInterface or IMyInterface2 or IMyInterface3 { Prop1: 1, Prop2: 2 }) { DoSomething(); }

false

while (x is IMyInterface or IMyInterface2 or IMyInterface3 { Prop1: 1, Prop2: 2 }) { DoSomething(); }

'for' 语句头

属性名称:

[resharper_]csharp_align_multiline_for_stmt[resharper_]align_multiline_for_stmt

可能的值:

true | false

示例:

true

for (int i = 0; i < 10; i++) { }

false

for (int i = 0; i < 10; i++) { }

多个声明

属性名称:

[resharper_]csharp_align_multiple_declaration[resharper_]align_multiple_declaration

可能的值:

true | false

示例:

true

class C { private int i = 0, j = 10; }

false

class C { private int i = 0, j = 10; }

类型参数列表

属性名称:

[resharper_]csharp_align_multline_type_parameter_list[resharper_]align_multline_type_parameter_list

可能的值:

true | false

示例:

true

class Class<T1, T2, T3> { }

false

class Class<T1, T2, T3> { }

类型形参约束

属性名称:

[resharper_]csharp_align_multline_type_parameter_constrains[resharper_]align_multline_type_parameter_constrains

可能的值:

true | false

示例:

true

class C<T1, T2> where T1 : I1 where T2 : I1 { }

false

class C<T1, T2> where T1 : I1 where T2 : I1 { }

减少缩进逗号

属性名称:

[resharper_]csharp_outdent_commas[resharper_]outdent_commas

可能的值:

true | false

示例:

true

class Class< T1 , T3> : Base , SomeInterface { void fooCall( int firstParameter , int secondParameter) { fooCall( firstParameter , secondParameter); } }

false

class Class< T1 , T3> : Base , SomeInterface { void fooCall( int firstParameter , int secondParameter) { fooCall( firstParameter , secondParameter); } }

将多行注释与星号对齐

属性名称:

[resharper_]csharp_align_multiline_comments[resharper_]align_multiline_comments

可能的值:

true | false

示例:

true

DoSomething(); /* This is * badly aligned * comment */

false

DoSomething(); /* This is * badly aligned * comment */

如何缩进原始字符串字面量

属性名称:

[resharper_]csharp_indent_raw_literal_string[resharper_]indent_raw_literal_string

可能的值:

  • 对齐: 对齐

  • 缩进: 缩进到上一行

  • 不要更改 :不要更改

示例:

对齐

string x = """ Some literal text with indents or without """;

缩进

string x = """ Some literal text with indents or without """;

不要更改

string x = """ Some literal text with indents or without """;

在列中对齐相似代码

修正相邻行中的列对齐

属性名称:

[resharper_]csharp_int_align_fix_in_adjacent[resharper_]int_align_fix_in_adjacent

When formatting selected code, also fix column alignment in the adjacent lines if needed

可能的值:

true | false

字段和常量

属性名称:

[resharper_]csharp_int_align_fields[resharper_]csharp_int_align[resharper_]int_align_fields[resharper_]int_align

可能的值:

true | false

示例:

true

class C { [Attr] private string x = "x"; [Attr(2)] public SomeClass xxxxx = "xxxxx"; [Attr, Attr3] private string xxx; }

false

class C { [Attr] private string x = "x"; [Attr(2)] public SomeClass xxxxx = "xxxxx"; [Attr, Attr3] private string xxx; }

属性和事件

属性名称:

[resharper_]csharp_int_align_properties, [resharper_]csharp_int_align, [resharper_]int_align_properties, [resharper_]int_align

可能的值:

true | false

示例:

true

class C { [Attr] private string x { get; set; } = "x"; [Attr(2)] public SomeClass xxxxx { get; set; } = SomeClass.Default; [Attr, Attr3] private string xxx { get; } [Attr] private string x2 => "x"; [Attr(2)] public SomeClass xxxxx2 => "xxxxx"; [Attr, Attr3] private string xxx2 => "xxx"; }

false

class C { [Attr] private string x { get; set; } = "x"; [Attr(2)] public SomeClass xxxxx { get; set; } = SomeClass.Default; [Attr, Attr3] private string xxx { get; } [Attr] private string x2 => "x"; [Attr(2)] public SomeClass xxxxx2 => "xxxxx"; [Attr, Attr3] private string xxx2 => "xxx"; }

简单方法、运算符、委托

属性名称:

[resharper_]csharp_int_align_methods[resharper_]csharp_int_align[resharper_]int_align_methods[resharper_]int_align

可能的值:

true | false

示例:

true

class C { [Attr] private string x(int p) { return "x" + p; }; [Attr(2)] public SomeClass xxxxx(string b) { return b.ToSomeClass(); } [Attr, Attr3] private string xxx() { return null; } [Attr] private string x2(int p) => "x" + p; [Attr(2)] public SomeClass xxxxx2(string b) => b.ToSomeClass(); [Attr, Attr3] private string xxx() => null; }

false

class C { [Attr] private string x(int p) { return "x" + p; }; [Attr(2)] public SomeClass xxxxx(string b) { return b.ToSomeClass(); } [Attr, Attr3] private string xxx() { return null; } [Attr] private string x2(int p) => "x" + p; [Attr(2)] public SomeClass xxxxx2(string b) => b.ToSomeClass(); [Attr, Attr3] private string xxx() => null; }

多行方法签名

属性名称:

[resharper_]csharp_int_align_parameters[resharper_]csharp_int_align[resharper_]int_align_parameters[resharper_]int_align

可能的值:

true | false

示例:

true

void MyMethod( [Attr, Attr3] string xxx, [Attr] string x = "x", [Attr(2)] SomeClass xxxxx = "xxxxx") { }

false

void MyMethod( [Attr, Attr3] string xxx, [Attr] string x = "x", [Attr(2)] SomeClass xxxxx = "xxxxx") { }

变量和局部常量

属性名称:

[resharper_]csharp_int_align_variables, [resharper_]csharp_int_align, [resharper_]int_align_variables, [resharper_]int_align

可能的值:

true | false

示例:

true

{ var x = 1; var xxxxx = 2; var xxx = 2; }

false

{ var x = 1; var xxxxx = 2; var xxx = 2; }

其他赋值和初始值设定项

属性名称:

[resharper_]csharp_int_align_assignments, [resharper_]csharp_int_align, [resharper_]int_align_assignments, [resharper_]int_align

可能的值:

true|false

示例:

true

{ x = 1; xxxxx = 2; xxx = 2; }

false

{ x = 1; xxxxx = 2; xxx = 2; }

属性模式

属性名称:

[resharper_]csharp_int_align_property_patterns, [resharper_]csharp_int_align, [resharper_]int_align_property_patterns, [resharper_]int_align

可能的值:

true|false

示例:

true

bool matches = sourceObject is MyType { FShort : 1, FieldLongLong: 2, };

false

bool matches = sourceObject is MyType { FShort: 1, FieldLongLong: 2, };

嵌套三元运算符

属性名称:

[resharper_]csharp_int_align_nested_ternary, [resharper_]csharp_int_align, [resharper_]int_align_nested_ternary, [resharper_]int_align

可能的值:

true|false

示例:

true

var x = y == "a" ? 1 : y == "aaaa" ? 4 : y == "aa" ? 2 : 0;

false

var x = y == "a" ? 1 : y == "aaaa" ? 4 : y == "aa" ? 2 : 0;

相同方法的调用

属性名称:

[resharper_]csharp_int_align_invocations[resharper_]csharp_int_align[resharper_]int_align_invocations[resharper_]int_align

可能的值:

true|false

示例:

true

[Attr("x", 1234567)] [Attr("xxxxx", 1)] [Attr(MyEnum.MyConstant, 124)] void MyMethod() { CallMe("x", 1234567); CallMe("xxxxx", 1); CallMe(MyEnum.MyConstant, 124); }

false

[Attr("x", 1234567)] [Attr("xxxxx", 1)] [Attr(MyEnum.MyConstant, 124)] void MyMethod() { CallMe("x", 1234567); CallMe("xxxxx", 1); CallMe(MyEnum.MyConstant, 124); }

二項式

属性名称:

[resharper_]csharp_int_align_binary_expressions, [resharper_]csharp_int_align, [resharper_]int_align_binary_expressions, [resharper_]int_align

可能的值:

true|false

示例:

true

if ( zzz || someCondition && otherCondition || aa && bb || x == "a" || xxxxxxx != "aaaa" || xx > "aa") { DoSomething(); }

false

if ( zzz || someCondition && otherCondition || aa && bb || x == "a" || xxxxxxx != "aaaa" || xx > "aa") { DoSomething(); }

结束注释

属性名称:

[resharper_]csharp_int_align_comments[resharper_]csharp_int_align[resharper_]int_align_comments[resharper_]int_align

可能的值:

true|false

示例:

true

{ DoSomething(); // I'm var y = 6; // forced while (y > 0) y--; // to DoSomethingElse(); /* document */ var z = 10; /* my code */ while (z < 100) z++; /* profusely */ }

false

{ DoSomething(); // I'm var y = 6; // forced while (y > 0) y--; // to DoSomethingElse(); /* document */ var z = 10; /* my code */ while (z < 100) z++; /* profusely */ }

简单 switch 部分

属性名称:

[resharper_]csharp_int_align_switch_sections[resharper_]csharp_int_align[resharper_]int_align_switch_sections[resharper_]int_align

可能的值:

true|false

示例:

true

switch (op) { case op.Add: return x + y; case op.Subtract: return x - y; case op.Multiply: return x * y; case op.Divide: return x / y; }

false

switch (op) { case op.Add: return x + y; case op.Subtract: return x - y; case op.Multiply: return x * y; case op.Divide: return x / y; }

Switch 表达式

属性名称:

[resharper_]csharp_int_align_switch_expressions[resharper_]csharp_int_align[resharper_]int_align_switch_expressions[resharper_]int_align

可能的值:

true|false

示例:

true

var z = op switch { op.Add => x + y, op.Subtract => x - y, op.Multiply => x * y, op.Divide => x / y }

false

var z = op switch { op.Add => x + y, op.Subtract => x - y, op.Multiply => x * y, op.Divide => x / y }
最后修改日期: 2025年 9月 26日