C# 서식 옵션

이 문서의 서식 옵션은 C# 코드에만 적용됩니다. 코드 스타일 규칙 IDE0055 대한 옵션입니다.

줄 바꿈 옵션

새 줄 옵션은 새 줄을 사용하여 코드 서식을 지정하는 경우와 관련이 있습니다.

예제 .editorconfig 파일:

#  CSharp formatting rules:
[*.cs]
csharp_new_line_before_open_brace = methods, properties, control_blocks, types
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true

csharp_new_line_before_open_brace

이 옵션은 열린 중괄호 { 를 앞의 코드와 동일한 줄에 배치해야 하는지 또는 새 줄에 배치해야 하는지와 관련이 있습니다. 이 규칙의 경우 모두, 없음 또는 하나 이상의 코드 요소(예: 메서드 또는 속성)를 지정하여 이 규칙을 적용할 시점을 정의합니다. 여러 개의 코드 요소를 지정하려면 쉼표(,)로 구분합니다.

속성 설명
옵션 이름 csharp_new_line_before_open_brace
해당 언어 C#
도입된 버전 Visual Studio 2017
옵션 값 all 모든 식("Allman" 스타일)의 새 줄에 중괄호가 있어야 합니다.
none 모든 식에 대해 중괄호가 동일한 줄에 있어야 합니다("K&R").
accessors, anonymous_methods, anonymous_types, control_blocks, events, indexers,
lambdas, local_functions, methods, object_collection_array_initializerspropertiestypes
지정된 코드 요소("Allman" 스타일)의 새 줄에 중괄호가 있어야 합니다.
기본 옵션 값 all

코드 예제:

// csharp_new_line_before_open_brace = all
void MyMethod()
{
    if (...)
    {
        ...
    }
}

// csharp_new_line_before_open_brace = none
void MyMethod() {
    if (...) {
        ...
    }
}

csharp_new_line_before_else

속성 설명
옵션 이름 csharp_new_line_before_else
해당 언어 C#
도입된 버전 Visual Studio 2017
옵션 값 true 새 줄에 else 문을 배치합니다.
false 동일한 줄에 else 문을 배치합니다.
기본 옵션 값 true

코드 예제:

// csharp_new_line_before_else = true
if (...) {
    ...
}
else {
    ...
}

// csharp_new_line_before_else = false
if (...) {
    ...
} else {
    ...
}

csharp_new_line_before_catch

속성 설명
옵션 이름 csharp_new_line_before_catch
해당 언어 C#
도입된 버전 Visual Studio 2017
옵션 값 true 새 줄에 catch 문을 배치합니다.
false 동일한 줄에 catch 문을 배치합니다.
기본 옵션 값 true

코드 예제:

// csharp_new_line_before_catch = true
try {
    ...
}
catch (Exception e) {
    ...
}

// csharp_new_line_before_catch = false
try {
    ...
} catch (Exception e) {
    ...
}

csharp_new_line_before_finally

속성 설명
옵션 이름 csharp_new_line_before_finally
해당 언어 C#
도입된 버전 Visual Studio 2017
옵션 값 true finally 문을 닫는 괄호 뒤의 새 줄에 배치해야 합니다.
false finally 문을 닫는 괄호인 동일한 줄에 배치해야 합니다.
기본 옵션 값 true

코드 예제:

// csharp_new_line_before_finally = true
try {
    ...
}
catch (Exception e) {
    ...
}
finally {
    ...
}

// csharp_new_line_before_finally = false
try {
    ...
} catch (Exception e) {
    ...
} finally {
    ...
}

csharp_new_line_before_members_in_object_initializers

속성 설명
옵션 이름 csharp_new_line_before_members_in_object_initializers
해당 언어 C#
도입된 버전 Visual Studio 2017
옵션 값 true 개체 이니셜라이저의 멤버가 별도의 줄에 있어야 합니다.
false 개체 이니셜라이저의 멤버가 동일한 줄에 있어야 합니다.
기본 옵션 값 true

코드 예제:

// csharp_new_line_before_members_in_object_initializers = true
var z = new B()
{
    A = 3,
    B = 4
}

// csharp_new_line_before_members_in_object_initializers = false
var z = new B()
{
    A = 3, B = 4
}

csharp_new_line_before_members_in_anonymous_types

속성 설명
옵션 이름 csharp_new_line_before_members_in_anonymous_types
해당 언어 C#
도입된 버전 Visual Studio 2017
옵션 값 true 익명 형식의 멤버가 별도의 줄에 있어야 합니다.
false 익명 형식의 멤버가 동일한 줄에 있어야 합니다.
기본 옵션 값 true

코드 예제:

// csharp_new_line_before_members_in_anonymous_types = true
var z = new
{
    A = 3,
    B = 4
}

// csharp_new_line_before_members_in_anonymous_types = false
var z = new
{
    A = 3, B = 4
}

csharp_new_line_between_query_expression_clauses

속성 설명
옵션 이름 csharp_new_line_between_query_expression_clauses
해당 언어 C#
도입된 버전 Visual Studio 2017
옵션 값 true 쿼리 식 절의 요소가 별도의 줄에 있어야 합니다.
false 쿼리 식 절의 요소가 동일한 줄에 있어야 합니다.
기본 옵션 값 true

코드 예제:

// csharp_new_line_between_query_expression_clauses = true
var q = from a in e
        from b in e
        select a * b;

// csharp_new_line_between_query_expression_clauses = false
var q = from a in e from b in e
        select a * b;

들여쓰기 옵션

들여쓰기 옵션은 들여쓰기를 사용하여 코드의 서식을 지정하는 경우와 관련이 있습니다.

예제 .editorconfig 파일:

#  CSharp formatting rules:
[*.cs]
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_indent_labels = flush_left
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents_when_block = true

csharp_indent_case_contents

속성 설명
옵션 이름 csharp_indent_case_contents
해당 언어 C#
도입된 버전 Visual Studio 2017
옵션 값 true switch 대/소문자 콘텐츠 들여쓰기
false switch 대/소문자 콘텐츠 들여쓰지 않기
기본 옵션 값 true

코드 예제:

// csharp_indent_case_contents = true
switch(c) {
    case Color.Red:
        Console.WriteLine("The color is red");
        break;
    case Color.Blue:
        Console.WriteLine("The color is blue");
        break;
    default:
        Console.WriteLine("The color is unknown.");
        break;
}

// csharp_indent_case_contents = false
switch(c) {
    case Color.Red:
    Console.WriteLine("The color is red");
    break;
    case Color.Blue:
    Console.WriteLine("The color is blue");
    break;
    default:
    Console.WriteLine("The color is unknown.");
    break;
}

csharp_indent_switch_labels

속성 설명
옵션 이름 csharp_indent_switch_labels
해당 언어 C#
도입된 버전 Visual Studio 2017
옵션 값 true switch 레이블 들여쓰기
false switch 레이블 들여쓰지 않음
기본 옵션 값 true

코드 예제:

// csharp_indent_switch_labels = true
switch(c) {
    case Color.Red:
        Console.WriteLine("The color is red");
        break;
    case Color.Blue:
        Console.WriteLine("The color is blue");
        break;
    default:
        Console.WriteLine("The color is unknown.");
        break;
}

// csharp_indent_switch_labels = false
switch(c) {
case Color.Red:
    Console.WriteLine("The color is red");
    break;
case Color.Blue:
    Console.WriteLine("The color is blue");
    break;
default:
    Console.WriteLine("The color is unknown.");
    break;
}

csharp_indent_labels

속성 설명
옵션 이름 csharp_indent_labels
해당 언어 C#
도입된 버전 Visual Studio 2017
옵션 값 flush_left 레이블은 가장 왼쪽 열에 배치됩니다.
one_less_than_current 레이블은 현재 컨텍스트에 하나 적은 들여쓰기로 배치됩니다.
no_change 레이블은 현재 컨텍스트와 동일한 들여쓰기로 배치됩니다.
기본 옵션 값 one_less_than_current

코드 예제:

// csharp_indent_labels= flush_left
class C
{
    private string MyMethod(...)
    {
        if (...) {
            goto error;
        }
error:
        throw new Exception(...);
    }
}

// csharp_indent_labels = one_less_than_current
class C
{
    private string MyMethod(...)
    {
        if (...) {
            goto error;
        }
    error:
        throw new Exception(...);
    }
}

// csharp_indent_labels= no_change
class C
{
    private string MyMethod(...)
    {
        if (...) {
            goto error;
        }
        error:
        throw new Exception(...);
    }
}

csharp_indent_block_contents

속성 설명
옵션 이름 csharp_indent_block_contents
해당 언어 C#
옵션 값 true 들여쓰기 블록 내용입니다.
false 콘텐츠를 들여쓰지 마세요.
기본 옵션 값 true

코드 예제:

// csharp_indent_block_contents = true
static void Hello()
{
    Console.WriteLine("Hello");
}

// csharp_indent_block_contents = false
static void Hello()
{
Console.WriteLine("Hello");
}

csharp_indent_braces

속성 설명
옵션 이름 csharp_indent_braces
해당 언어 C#
옵션 값 true 들여쓰기 중괄호
false 중괄호를 들여쓰지 마세요.
기본 옵션 값 false

코드 예제:

// csharp_indent_braces = true
static void Hello()
    {
    Console.WriteLine("Hello");
    }

// csharp_indent_braces = false
static void Hello()
{
    Console.WriteLine("Hello");
}

csharp_indent_case_contents_when_block

속성 설명
옵션 이름 csharp_indent_case_contents_when_block
해당 언어 C#
옵션 값 true 블록인 경우 문 목록을 들여쓰고 switch 문의 사례에 대해 중괄호를 중괄호로 묶습니다.
false 블록인 경우 switch 문의 사례에 대해 문 목록과 중괄호를 들여쓰지 마세요.
기본 옵션 값 true

코드 예제:

// csharp_indent_case_contents_when_block = true
case 0:
    {
        Console.WriteLine("Hello");
        break;
    }

// csharp_indent_case_contents_when_block = false
case 0:
{
    Console.WriteLine("Hello");
    break;
}

간격 옵션

간격 옵션은 공백 문자를 사용하여 코드 서식을 지정하는 경우와 관련이 있습니다.

예제 .editorconfig 파일:

#  CSharp formatting rules:
[*.cs]
csharp_space_after_cast = true
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_parentheses = control_flow_statements, type_casts
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_around_binary_operators = before_and_after
csharp_space_between_method_declaration_parameter_list_parentheses = true
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_declaration_name_and_open_parenthesis = false
csharp_space_between_method_call_parameter_list_parentheses = true
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_after_comma = true
csharp_space_before_comma = false
csharp_space_after_dot = false
csharp_space_before_dot = false
csharp_space_after_semicolon_in_for_statement = true
csharp_space_before_semicolon_in_for_statement = false
csharp_space_around_declaration_statements = false
csharp_space_before_open_square_brackets = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_square_brackets = false

csharp_space_after_cast

속성 설명
옵션 이름 csharp_space_after_cast
해당 언어 C#
도입된 버전 Visual Studio 2017
옵션 값 true 캐스트와 값 사이에 공백 문자를 배치합니다.
false 캐스트와 값 사이의 공백 제거
기본 옵션 값 false

코드 예제:

// csharp_space_after_cast = true
int y = (int) x;

// csharp_space_after_cast = false
int y = (int)x;

csharp_space_after_keywords_in_control_flow_statements

속성 설명
옵션 이름 csharp_space_after_keywords_in_control_flow_statements
해당 언어 C#
도입된 버전 Visual Studio 2017
옵션 값 true 루프와 같은 제어 흐름 문에서 키워드(keyword) 뒤의 공백 문자를 배치합니다for.
false 루프와 같은 for 제어 흐름 문에서 키워드(keyword) 뒤의 공간 제거
기본 옵션 값 true

코드 예제:

// csharp_space_after_keywords_in_control_flow_statements = true
for (int i;i<x;i++) { ... }

// csharp_space_after_keywords_in_control_flow_statements = false
for(int i;i<x;i++) { ... }

csharp_space_between_parentheses

속성 설명
옵션 이름 csharp_space_between_parentheses
해당 언어 C#
도입된 버전 Visual Studio 2017
옵션 값 control_flow_statements 제어 흐름 문의 괄호 간에 공백 배치
expressions 식의 괄호 간에 공백 배치
type_casts 형식 캐스트의 괄호 간에 공백 배치
false (또는 다른 값) 괄호 사이에 공백을 추가하지 마세요.

이 규칙을 생략하거나 control_flow_statements, expressions 또는 type_casts 이외의 값을 사용하면 설정이 적용되지 않습니다.

코드 예제:

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

// csharp_space_between_parentheses = expressions
var z = ( x * y ) - ( ( y - x ) * 3 );

// csharp_space_between_parentheses = type_casts
int y = ( int )x;

// csharp_space_between_parentheses = false
int y = (int)x;

csharp_space_before_colon_in_inheritance_clause

속성 설명
옵션 이름 csharp_space_before_colon_in_inheritance_clause
해당 언어 C#
도입된 버전 Visual Studio 2017
옵션 값 true 형식 선언에서 기본 또는 인터페이스의 콜론 앞에 공백 문자를 배치합니다.
false 형식 선언에서 기본 또는 인터페이스에 대한 콜론 앞의 공간 제거
기본 옵션 값 true

코드 예제:

// csharp_space_before_colon_in_inheritance_clause = true
interface I
{

}

class C : I
{

}

// csharp_space_before_colon_in_inheritance_clause = false
interface I
{

}

class C: I
{

}

csharp_space_after_colon_in_inheritance_clause

속성 설명
옵션 이름 csharp_space_after_colon_in_inheritance_clause
해당 언어 C#
도입된 버전 Visual Studio 2017
옵션 값 true 형식 선언에서 기본 또는 인터페이스의 콜론 다음에 공백 문자를 배치합니다.
false 형식 선언에서 기본 또는 인터페이스에 대한 콜론 뒤의 공백 제거
기본 옵션 값 true

코드 예제:

// csharp_space_after_colon_in_inheritance_clause = true
interface I
{

}

class C : I
{

}

// csharp_space_after_colon_in_inheritance_clause = false
interface I
{

}

class C :I
{

}

csharp_space_around_binary_operators

속성 설명
옵션 이름 csharp_space_around_binary_operators
해당 언어 C#
도입된 버전 Visual Studio 2017
옵션 값 before_and_after 이항 연산자의 앞뒤에 공백 삽입
none 이항 연산자의 앞뒤에 공백 제거
ignore 이항 연산자 주위의 공백 무시
기본 옵션 값 before_and_after

코드 예제:

// csharp_space_around_binary_operators = before_and_after
return x * (x - y);

// csharp_space_around_binary_operators = none
return x*(x-y);

// csharp_space_around_binary_operators = ignore
return x  *  (x-y);

csharp_space_between_method_declaration_parameter_list_parentheses

속성 설명
옵션 이름 csharp_space_between_method_declaration_parameter_list_parentheses
해당 언어 C#
도입된 버전 Visual Studio 2017
옵션 값 true 여는 괄호 뒤와 메서드 선언 매개 변수 목록의 닫는 괄호 앞에 공백 문자를 배치합니다.
false 여는 괄호 뒤와 메서드 선언 매개 변수 목록의 닫는 괄호 앞에 공백 문자를 제거합니다.
기본 옵션 값 false

코드 예제:

// csharp_space_between_method_declaration_parameter_list_parentheses = true
void Bark( int x ) { ... }

// csharp_space_between_method_declaration_parameter_list_parentheses = false
void Bark(int x) { ... }

csharp_space_between_method_declaration_empty_parameter_list_parentheses

속성 설명
옵션 이름 csharp_space_between_method_declaration_empty_parameter_list_parentheses
해당 언어 C#
도입된 버전 Visual Studio 2017
옵션 값 true 메서드 선언에 대한 빈 매개 변수 목록 괄호 안에 공백 삽입
false 메서드 선언에 대한 빈 매개 변수 목록 괄호 내의 공백 제거
기본 옵션 값 false

코드 예제:

// csharp_space_between_method_declaration_empty_parameter_list_parentheses = true
void Goo( )
{
    Goo(1);
}

void Goo(int x)
{
    Goo();
}

// csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
void Goo()
{
    Goo(1);
}

void Goo(int x)
{
    Goo();
}

csharp_space_between_method_declaration_name_and_open_parenthesis

속성 설명
옵션 이름 csharp_space_between_method_declaration_name_and_open_parenthesis
해당 언어 C#
옵션 값 true 메서드 선언에서 메서드 이름과 여는 괄호 사이에 공백 문자를 배치합니다.
false 메서드 선언에서 메서드 이름과 여는 괄호 사이의 공백 문자 제거
기본 옵션 값 false

코드 예제:

// csharp_space_between_method_declaration_name_and_open_parenthesis = true
void M () { }

// csharp_space_between_method_declaration_name_and_open_parenthesis = false
void M() { }

csharp_space_between_method_call_parameter_list_parentheses

속성 설명
옵션 이름 csharp_space_between_method_call_parameter_list_parentheses
해당 언어 C#
도입된 버전 Visual Studio 2017
옵션 값 true 여는 괄호 뒤와 메서드 호출의 닫는 괄호 앞에 공백 문자를 배치합니다.
false 여는 괄호 뒤와 메서드 호출의 닫는 괄호 앞에 공백 문자를 제거합니다.
기본 옵션 값 false

코드 예제:

// csharp_space_between_method_call_parameter_list_parentheses = true
MyMethod( argument );

// csharp_space_between_method_call_parameter_list_parentheses = false
MyMethod(argument);

csharp_space_between_method_call_empty_parameter_list_parentheses

속성 설명
옵션 이름 csharp_space_between_method_call_empty_parameter_list_parentheses
해당 언어 C#
도입된 버전 Visual Studio 2017
옵션 값 true 빈 인수 목록 괄호 내부에 공백 삽입
false 빈 인수 목록 괄호 안의 공백 제거
기본 옵션 값 false

코드 예제:

// csharp_space_between_method_call_empty_parameter_list_parentheses = true
void Goo()
{
    Goo(1);
}

void Goo(int x)
{
    Goo( );
}

// csharp_space_between_method_call_empty_parameter_list_parentheses = false
void Goo()
{
    Goo(1);
}

void Goo(int x)
{
    Goo();
}

csharp_space_between_method_call_name_and_opening_parenthesis

속성 설명
옵션 이름 csharp_space_between_method_call_name_and_opening_parenthesis
해당 언어 C#
도입된 버전 Visual Studio 2017
옵션 값 true 메서드 호출 이름과 여는 괄호 사이에 공백 삽입
false 메서드 호출 이름과 여는 괄호 사이의 공백 제거
기본 옵션 값 false

코드 예제:

// csharp_space_between_method_call_name_and_opening_parenthesis = true
void Goo()
{
    Goo (1);
}

void Goo(int x)
{
    Goo ();
}

// csharp_space_between_method_call_name_and_opening_parenthesis = false
void Goo()
{
    Goo(1);
}

void Goo(int x)
{
    Goo();
}

csharp_space_after_comma

속성 설명
옵션 이름 csharp_space_after_comma
해당 언어 C#
옵션 값 true 쉼표 뒤에 공백 삽입
false 쉼표 뒤의 공백 제거
기본 옵션 값 true

코드 예제:

// csharp_space_after_comma = true
int[] x = new int[] { 1, 2, 3, 4, 5 };

// csharp_space_after_comma = false
int[] x = new int[] { 1,2,3,4,5 };

csharp_space_before_comma

속성 설명
옵션 이름 csharp_space_before_comma
해당 언어 C#
옵션 값 true 쉼표 앞에 공백 삽입
false 쉼표 앞의 공백 제거
기본 옵션 값 false

코드 예제:

// csharp_space_before_comma = true
int[] x = new int[] { 1 , 2 , 3 , 4 , 5 };

// csharp_space_before_comma = false
int[] x = new int[] { 1, 2, 3, 4, 5 };

csharp_space_after_dot

속성 설명
옵션 이름 csharp_space_after_dot
해당 언어 C#
옵션 값 true 점 뒤에 공백 삽입
false 점 뒤의 공백 제거
기본 옵션 값 false

코드 예제:

// csharp_space_after_dot = true
this. Goo();

// csharp_space_after_dot = false
this.Goo();

csharp_space_before_dot

속성 설명
옵션 이름 csharp_space_before_dot
해당 언어 C#
옵션 값 true 점 앞에 공백 삽입
false 점 앞의 공간 제거
기본 옵션 값 false

코드 예제:

// csharp_space_before_dot = true
this .Goo();

// csharp_space_before_dot = false
this.Goo();

csharp_space_after_semicolon_in_for_statement

속성 설명
옵션 이름 csharp_space_after_semicolon_in_for_statement
해당 언어 C#
옵션 값 true 문의 각 세미콜론 for 뒤에 공백 삽입
false 문에서 각 세미콜론 뒤의 for 공백 제거
기본 옵션 값 true

코드 예제:

// csharp_space_after_semicolon_in_for_statement = true
for (int i = 0; i < x.Length; i++)

// csharp_space_after_semicolon_in_for_statement = false
for (int i = 0;i < x.Length;i++)

csharp_space_before_semicolon_in_for_statement

속성 설명
옵션 이름 csharp_space_before_semicolon_in_for_statement
해당 언어 C#
옵션 값 true 문의 각 세미콜론 for 앞에 공백 삽입
false 문의 각 세미콜론 앞에 공백 for 제거
기본 옵션 값 false

코드 예제:

// csharp_space_before_semicolon_in_for_statement = true
for (int i = 0 ; i < x.Length ; i++)

// csharp_space_before_semicolon_in_for_statement = false
for (int i = 0; i < x.Length; i++)

csharp_space_around_declaration_statements

속성 설명
옵션 이름 csharp_space_around_declaration_statements
해당 언어 C#
옵션 값 ignore 선언 문에서 추가 공백 문자를 제거하지 마세요.
false 선언 문에서 추가 공백 문자 제거
기본 옵션 값 false

코드 예제:

// csharp_space_around_declaration_statements = ignore
int    x    =    0   ;

// csharp_space_around_declaration_statements = false
int x = 0;

csharp_space_before_open_square_brackets

속성 설명
옵션 이름 csharp_space_before_open_square_brackets
해당 언어 C#
옵션 값 true 대괄호를 열기 전에 공백 삽입 [
false 대괄호를 열기 전에 공백 제거 [
기본 옵션 값 false

코드 예제:

// csharp_space_before_open_square_brackets = true
int [] numbers = new int [] { 1, 2, 3, 4, 5 };

// csharp_space_before_open_square_brackets = false
int[] numbers = new int[] { 1, 2, 3, 4, 5 };

csharp_space_between_empty_square_brackets

속성 설명
옵션 이름 csharp_space_between_empty_square_brackets
해당 언어 C#
옵션 값 true 빈 대괄호 사이에 공백 삽입 [ ]
false 빈 대괄호 사이의 공백 제거 []
기본 옵션 값 false

코드 예제:

// csharp_space_between_empty_square_brackets = true
int[ ] numbers = new int[ ] { 1, 2, 3, 4, 5 };

// csharp_space_between_empty_square_brackets = false
int[] numbers = new int[] { 1, 2, 3, 4, 5 };

csharp_space_between_square_brackets

속성 설명
옵션 이름 csharp_space_between_square_brackets
해당 언어 C#
옵션 값 true 비어있지 않은 대괄호에 공백 문자 삽입 [ 0 ]
false 비어있지 않은 대괄호에서 공백 문자 제거 [0]
기본 옵션 값 false

코드 예제:

// csharp_space_between_square_brackets = true
int index = numbers[ 0 ];

// csharp_space_between_square_brackets = false
int index = numbers[0];

줄 바꿈 옵션

줄 바꿈 서식 옵션은 문 및 코드 블록에 대해 한 줄과 별도의 줄을 사용하는 것과 관련이 있습니다.

예제 .editorconfig 파일:

#  CSharp formatting rules:
[*.cs]
csharp_preserve_single_line_statements = true
csharp_preserve_single_line_blocks = true

csharp_preserve_single_line_statements

속성 설명
옵션 이름 csharp_preserve_single_line_statements
해당 언어 C#
도입된 버전 Visual Studio 2017
옵션 값 true 문과 멤버 선언을 동일한 줄에 유지
false 문과 멤버 선언을 다른 줄에 유지
기본 옵션 값 true

코드 예제:

//csharp_preserve_single_line_statements = true
int i = 0; string name = "John";

//csharp_preserve_single_line_statements = false
int i = 0;
string name = "John";

csharp_preserve_single_line_blocks

속성 설명
옵션 이름 csharp_preserve_single_line_blocks
해당 언어 C#
도입된 버전 Visual Studio 2017
옵션 값 true 코드 블록을 한 줄에 남겨 둡니다.
false 코드 블록을 별도의 줄에 둡니다.
기본 옵션 값 true

코드 예제:

//csharp_preserve_single_line_blocks = true
public int Foo { get; set; }

//csharp_preserve_single_line_blocks = false
public int MyProperty
{
    get; set;
}

참고 항목