다음을 통해 공유


코드 스타일 규칙

.NET 코드 스타일 분석은 코드베이스에서 일관된 스타일을 기본 것을 목표로 하는 규칙을 제공합니다. 이러한 규칙에는 규칙 ID에 “IDE” 접두사가 있습니다.

코드 스타일 규칙은 다음 하위 범주로 구성됩니다.

  • 언어 및 불필요한 코드 규칙

    C# 또는 Visual Basic 언어와 관련된 규칙입니다. 예를 들어 변수를 정의할 때 var 사용과 관련된 규칙을 지정하거나 식 본문 멤버를 기본 설정으로 지정할지 여부에 관한 규칙을 지정할 수 있습니다. 이 범주에는 메서드 또는 사용되지 않는 프라이빗 필드, 속성 또는 메서드 내에서 연결할 수 없는 코드와 같이 불필요한 코드를 찾는 규칙도 포함됩니다.

  • 서식 지정 규칙

    보다 쉽게 읽을 수 있도록 만들기 위한 코드의 레이아웃 및 구조체와 관련된 규칙입니다. 예를 들어 제어 블록의 공백이 기본 설정인지 여부를 정의하는 서식 옵션을 지정할 수 있습니다.

  • 명명 규칙

    코드 요소의 이름 지정과 관련된 규칙입니다. 예를 들어 async 메서드 이름에 “Async” 접미사가 있어야 함을 지정할 수 있습니다.

  • 기타 규칙

    다른 범주에 속하지 않는 규칙입니다.

색인

다음 표에서는 ID 및 옵션(있는 경우)으로 모든 코드 스타일 규칙을 나열합니다.

규칙 ID 타이틀 옵션
IDE0001 이름 단순화
IDE0002 멤버 액세스 단순화
IDE0003 this 또는 Me 한정 제거 dotnet_style_qualification_for_field
dotnet_style_qualification_for_property
dotnet_style_qualification_for_method
dotnet_style_qualification_for_event
IDE0004 불필요한 캐스트 제거
IDE0005 불필요한 가져오기 제거
IDE0007 명시적 형식 대신 var 사용 csharp_style_var_for_built_in_types
csharp_style_var_when_type_is_apparent
csharp_style_var_elsewhere
IDE0008 var 대신 명시적 형식 사용 csharp_style_var_for_built_in_types
csharp_style_var_when_type_is_apparent
csharp_style_var_elsewhere
IDE0009 this 또는 Me 한정 추가 dotnet_style_qualification_for_field
dotnet_style_qualification_for_property
dotnet_style_qualification_for_method
dotnet_style_qualification_for_event
IDE0010 switch 문에 누락된 사례 추가
IDE0011 중괄호 추가 csharp_prefer_braces
IDE0016 throw 식 사용 csharp_style_throw_expression
IDE0017 개체 이니셜라이저 사용 dotnet_style_object_initializer
IDE0018 인라인 변수 선언 csharp_style_inlined_variable_declaration
IDE0019 패턴 일치를 사용하여 as 이후 null 검사 방지 csharp_style_pattern_matching_over_as_with_null_검사
IDE0020 패턴 일치를 사용하여 is 검사 이후 캐스트 방지(변수 포함) csharp_style_pattern_matching_over_is_with_cast_검사
IDE0021 생성자에 식 본문 사용 csharp_style_expression_bodied_constructors
IDE0022 메서드에 식 본문 사용 csharp_style_expression_bodied_methods
IDE0023 변환 연산자에 식 본문 사용 csharp_style_expression_bodied_operators
IDE0024 연산자에 식 본문 사용 csharp_style_expression_bodied_operators
IDE0025 속성에 식 본문 사용 csharp_style_expression_bodied_properties
IDE0026 인덱서에 식 본문 사용 csharp_style_expression_bodied_indexers
IDE0027 접근자에 식 본문 사용 csharp_style_expression_bodied_accessors
IDE0028 컬렉션 이니셜라이저 사용 dotnet_style_collection_initializer
dotnet_style_prefer_collection_expression(C#에만 해당)
IDE0029 Null 검사 간소화할 수 있습니다. dotnet_style_coalesce_expression
IDE0030 Null 검사 간소화할 수 있습니다. dotnet_style_coalesce_expression
IDE0031 null 전파 사용 dotnet_style_null_propagation
IDE0032 auto 속성 사용 dotnet_style_prefer_auto_properties
IDE0033 명시적으로 제공된 튜플 이름 사용 dotnet_style_explicit_tuple_names
IDE0034 default 식 단순화 csharp_prefer_simple_default_expression
IDE0035 접근할 수 없는 코드 제거
IDE0036 순서 한정자 csharp_preferred_modifier_order
visual_basic_preferred_modifier_order
IDE0037 유추 멤버 이름 사용 dotnet_style_prefer_inferred_tuple_names
dotnet_style_prefer_inferred_anonymous_type_member_names
IDE0038 패턴 일치를 사용하여 is 검사 이후 캐스트 방지(변수 제외) csharp_style_pattern_matching_over_is_with_cast_검사
IDE0039 람다 대신 로컬 함수 사용 csharp_style_prefer_local_over_anonymous_function
IDE0040 내게 필요한 옵션 한정자 추가 dotnet_style_require_accessibility_modifiers
IDE0041 is null 검사 사용 dotnet_style_prefer_is_null_check_over_reference_equality_method
IDE0042 변수 선언 분해 csharp_style_deconstructed_variable_declaration
IDE0044 읽기 전용 한정자 추가 dotnet_style_readonly_field
IDE0045 대입에 조건식 사용 dotnet_style_prefer_conditional_expression_over_assignment
IDE0046 반환에 조건식 사용 dotnet_style_prefer_conditional_expression_over_return
IDE0047 불필요한 괄호 제거 dotnet_style_parentheses_in_arithmetic_binary_operators
dotnet_style_parentheses_in_relational_binary_operators
dotnet_style_parentheses_in_other_binary_operators
dotnet_style_parentheses_in_other_operators
IDE0048 명확하게 하기 위해 괄호 추가 dotnet_style_parentheses_in_arithmetic_binary_operators
dotnet_style_parentheses_in_relational_binary_operators
dotnet_style_parentheses_in_other_binary_operators
dotnet_style_parentheses_in_other_operators
IDE0049 형식 참조를 위한 프레임워크 형식 이름 대신 언어 키워드 사용 dotnet_style_predefined_type_for_locals_parameters_members
dotnet_style_predefined_type_for_member_access
IDE0050 익명 형식을 튜플로 변환
IDE0051 사용되지 않는 private 멤버 제거
IDE0052 읽지 않은 private 멤버 제거
IDE0053 람다에 식 본문 사용 csharp_style_expression_bodied_lambdas
IDE0054 복합형 할당 사용 dotnet_style_prefer_compound_assignment
IDE0055 서식 수정 (여기에 나열할 수 있는 항목이 너무 많습니다. .NET 서식 옵션C# 서식 옵션을 참조하세요.)
IDE0056 인덱스 연산자 사용 csharp_style_prefer_index_operator
IDE0057 범위 연산자 사용 csharp_style_prefer_range_operator
IDE0058 사용되지 않는 식 값 제거 csharp_style_unused_value_expression_statement_preference
visual_basic_style_unused_value_expression_statement_preference
IDE0059 불필요한 값 대입 제거 csharp_style_unused_value_assignment_preference
visual_basic_style_unused_value_assignment_preference
IDE0060 사용하지 않는 매개 변수 제거 dotnet_code_quality_unused_parameters
IDE0061 로컬 함수에 식 본문 사용 csharp_style_expression_bodied_local_functions
IDE0062 로컬 함수를 정적으로 지정 csharp_prefer_static_local_function
IDE0063 간단한 using 문 사용 csharp_prefer_simple_using_statement
IDE0064 구조체 필드를 쓰기 가능으로 설정
IDE0065 using 지시문 배치 csharp_using_directive_placement
IDE0066 switch 식 사용 csharp_style_prefer_switch_expression
IDE0070 System.HashCode.Combine 사용
IDE0071 보간 간소화 dotnet_style_prefer_simplified_interpolation
IDE0072 switch 식에 누락된 사례 추가
IDE0073 파일 헤더 사용 file_header_template
IDE0074 coalesce 복합 대입 사용 dotnet_style_prefer_compound_assignment
IDE0075 조건식 간소화 dotnet_style_prefer_simplified_boolean_expressions
IDE0076 잘못된 전역 SuppressMessageAttribute 제거
IDE0077 전역 SuppressMessageAttribute에서 레거시 형식 대상 방지
IDE0078 패턴 일치 사용 csharp_style_prefer_pattern_matching
IDE0079 불필요한 비표시 제거 dotnet_remove_unnecessary_suppression_exclusions
IDE0080 불필요한 비표시 연산자 제거
IDE0081 ByVal 제거
IDE0082 typeofnameof로 변환
IDE0083 패턴 일치 사용(not 연산자) csharp_style_prefer_not_pattern
IDE0084 패턴 일치 사용(IsNot 연산자) visual_basic_style_prefer_isnot_expression
IDE0090 new 식 단순화 csharp_style_implicit_object_creation_when_type_is_apparent
IDE0100 불필요한 같음 연산자 제거
IDE0110 불필요한 무시 항목 제거
IDE0120 LINQ 식 간소화
IDE0130 네임스페이스가 폴더 구조와 일치하지 않음 dotnet_style_namespace_match_folder
IDE0140 개체 만들기 간소화 visual_basic_style_prefer_simplified_object_creation
IDE0150 null 형식보다 검사 검사 csharp_style_prefer_null_검사_over_type_검사
IDE0160 블록 범위 네임스페이스 사용 csharp_style_namespace_declarations
IDE0161 파일 범위 네임스페이스 사용 csharp_style_namespace_declarations
IDE0170 속성 패턴 간소화 csharp_style_prefer_extended_property_pattern
IDE0180 튜플을 사용하여 값 교환 csharp_style_prefer_tuple_swap
IDE0200 불필요한 람다 식 제거 csharp_style_prefer_method_group_conversion
IDE0210 최상위 문으로 변환 csharp_style_prefer_top_level_statements
IDE0211 'Program.Main' 스타일 프로그램으로 변환 csharp_style_prefer_top_level_statements
IDE0220 foreach 루프에 명시적 캐스트 추가 dotnet_style_prefer_foreach_explicit_cast_in_source
IDE0230 UTF-8 문자열 리터럴 사용 csharp_style_prefer_utf8_string_literals
IDE0240 Nullable 지시문이 중복됩니다.
IDE0241 Nullable 지시문이 필요하지 않습니다.
IDE0250 구조체는 '읽기 전용'으로 만들 수 있습니다. csharp_style_prefer_readonly_struct
IDE0251 멤버를 '읽기 전용'으로 만들 수 있습니다. csharp_style_prefer_readonly_struct_member
IDE0260 패턴 일치 사용 csharp_style_pattern_matching_over_as_with_null_검사
IDE0270 Null 검사 간소화할 수 있습니다. dotnet_style_coalesce_expression
IDE0280 nameof 사용
IDE0290 기본 생성자 사용 csharp_style_prefer_primary_constructors
IDE0300 배열에 컬렉션 식 사용 dotnet_style_prefer_collection_expression
IDE0301 비어 있는 경우 컬렉션 식 사용 dotnet_style_prefer_collection_expression
IDE0302 stackalloc에 컬렉션 식 사용 dotnet_style_prefer_collection_expression
IDE0303 에 대한 컬렉션 식 사용 Create() dotnet_style_prefer_collection_expression
IDE0304 작성기에서 컬렉션 식 사용 dotnet_style_prefer_collection_expression
IDE0305 흐름에 컬렉션 식 사용 dotnet_style_prefer_collection_expression
IDE1005 조건부 대리자 호출 사용 csharp_style_conditional_delegate_call
IDE1006 명명 스타일

참고 항목

Visual Studio IDE에만 표시되는 몇 가지 규칙이 있으며 이러한 규칙은 JSON 및 정규식 패턴 문자열을 고려합니다. 자세한 내용은 JSON001, JSON002RE0001을 참조하세요.

범례

다음 표에서는 참조 설명서의 각 규칙에 대해 제공되는 정보 유형을 보여줍니다.

항목 설명
규칙 ID 규칙의 고유 식별자입니다. 규칙 심각도를 구성하고 코드 파일에서 경고를 표시하지 않는 데 사용됩니다.
제목 규칙의 제목입니다.
범주 규칙의 범주입니다.
하위 범주 언어 규칙, 서식 규칙 또는 명명 규칙과 같은 규칙의 하위 범주입니다.
해당 언어 해당하는 경우 최소 언어 버전과 함께 적용 가능한 .NET 언어(C# 또는 Visual Basic)입니다.
도입된 버전 규칙이 처음 도입되었을 때 .NET SDK 또는 Visual Studio 버전입니다.
옵션 규칙에 사용할 수 있는 모든 옵션입니다.

참고 항목