Code-style rules overview - .NET (original) (raw)
Simplify name
Simplify member access
Remove this
or Me
qualification
dotnet_style_qualification_for_field
dotnet_style_qualification_for_property
dotnet_style_qualification_for_method
dotnet_style_qualification_for_event
Remove unnecessary cast
Remove unnecessary import
Use var
instead of explicit type
csharp_style_var_for_built_in_types
csharp_style_var_when_type_is_apparent
csharp_style_var_elsewhere
Use explicit type instead of var
csharp_style_var_for_built_in_types
csharp_style_var_when_type_is_apparent
csharp_style_var_elsewhere
Add this
or Me
qualification
dotnet_style_qualification_for_field
dotnet_style_qualification_for_property
dotnet_style_qualification_for_method
dotnet_style_qualification_for_event
Add missing cases to switch statement
Add braces
Use throw expression
Use object initializers
dotnet_style_object_initializer
Inline variable declaration
csharp_style_inlined_variable_declaration
Use pattern matching to avoid as
followed by a null
check
csharp_style_pattern_matching_over_as_with_null_check
Use pattern matching to avoid is
check followed by a cast (with variable)
csharp_style_pattern_matching_over_is_with_cast_check
Use expression body for constructors
csharp_style_expression_bodied_constructors
Use expression body for methods
csharp_style_expression_bodied_methods
Use expression body for conversion operators
csharp_style_expression_bodied_operators
Use expression body for operators
csharp_style_expression_bodied_operators
Use expression body for properties
csharp_style_expression_bodied_properties
Use expression body for indexers
csharp_style_expression_bodied_indexers
Use expression body for accessors
csharp_style_expression_bodied_accessors
Use collection initializers
dotnet_style_collection_initializer
dotnet_style_prefer_collection_expression
Null check can be simplified
dotnet_style_coalesce_expression
Null check can be simplified
dotnet_style_coalesce_expression
Use null propagation
Use auto property
dotnet_style_prefer_auto_properties
Use explicitly provided tuple name
dotnet_style_explicit_tuple_names
Simplify default
expression
csharp_prefer_simple_default_expression
Remove unreachable code
Order modifiers
csharp_preferred_modifier_order
visual_basic_preferred_modifier_order
Use inferred member name
dotnet_style_prefer_inferred_tuple_names
dotnet_style_prefer_inferred_anonymous_type_member_names
Use pattern matching to avoid is
check followed by a cast (without variable)
csharp_style_pattern_matching_over_is_with_cast_check
Use local function instead of lambda
csharp_style_prefer_local_over_anonymous_function
Add accessibility modifiers
dotnet_style_require_accessibility_modifiers
Use is null check
dotnet_style_prefer_is_null_check_over_reference_equality_method
Deconstruct variable declaration
csharp_style_deconstructed_variable_declaration
Add readonly modifier
Use conditional expression for assignment
dotnet_style_prefer_conditional_expression_over_assignment
Use conditional expression for return
dotnet_style_prefer_conditional_expression_over_return
Remove unnecessary parentheses
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
Add parentheses for clarity
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
Use language keywords instead of framework type names for type references
dotnet_style_predefined_type_for_locals_parameters_members
dotnet_style_predefined_type_for_member_access
Convert anonymous type to tuple
Remove unused private member
Remove unread private member
Use expression body for lambdas
csharp_style_expression_bodied_lambdas
Use compound assignment
dotnet_style_prefer_compound_assignment
Fix formatting
(Too many to list here. See .NET formatting options and C# formatting options.)
Use index operator
csharp_style_prefer_index_operator
Use range operator
csharp_style_prefer_range_operator
Remove unused expression value
csharp_style_unused_value_expression_statement_preference
visual_basic_style_unused_value_expression_statement_preference
Remove unnecessary value assignment
csharp_style_unused_value_assignment_preference
visual_basic_style_unused_value_assignment_preference
Remove unused parameter
dotnet_code_quality_unused_parameters
Use expression body for local functions
csharp_style_expression_bodied_local_functions
Make local function static
csharp_prefer_static_local_function
Use simple using
statement
csharp_prefer_simple_using_statement
Make struct fields writable
using
directive placement
csharp_using_directive_placement
Use switch expression
csharp_style_prefer_switch_expression
Simplify interpolation
dotnet_style_prefer_simplified_interpolation
Add missing cases to switch expression
Use file header
Use coalesce compound assignment
dotnet_style_prefer_compound_assignment
Simplify conditional expression
dotnet_style_prefer_simplified_boolean_expressions
Remove invalid global SuppressMessageAttribute
Avoid legacy format target in global SuppressMessageAttribute
Use pattern matching
csharp_style_prefer_pattern_matching
Remove unnecessary suppression
dotnet_remove_unnecessary_suppression_exclusions
Remove unnecessary suppression operator
Remove ByVal
Convert typeof
to nameof
Use pattern matching (not
operator)
csharp_style_prefer_not_pattern
Use pattern matching (IsNot
operator)
visual_basic_style_prefer_isnot_expression
Simplify new
expression
csharp_style_implicit_object_creation_when_type_is_apparent
Remove unnecessary equality operator
Remove unnecessary discard
Simplify LINQ expression
Simplify LINQ type check and cast
Namespace does not match folder structure
dotnet_style_namespace_match_folder
Simplify object creation
visual_basic_style_prefer_simplified_object_creation
Prefer null
check over type check
csharp_style_prefer_null_check_over_type_check
Use block-scoped namespace
csharp_style_namespace_declarations
Use file-scoped namespace
csharp_style_namespace_declarations
Simplify property pattern
csharp_style_prefer_extended_property_pattern
Use tuple to swap values
csharp_style_prefer_tuple_swap
Remove unnecessary lambda expression
csharp_style_prefer_method_group_conversion
Convert to top-level statements
csharp_style_prefer_top_level_statements
Convert to 'Program.Main' style program
csharp_style_prefer_top_level_statements
Add explicit cast in foreach loop
dotnet_style_prefer_foreach_explicit_cast_in_source
Use UTF-8 string literal
csharp_style_prefer_utf8_string_literals
Nullable directive is redundant
Nullable directive is unnecessary
Struct can be made 'readonly'
csharp_style_prefer_readonly_struct
Member can be made 'readonly'
csharp_style_prefer_readonly_struct_member
Use pattern matching
csharp_style_pattern_matching_over_as_with_null_check
Null check can be simplified
dotnet_style_coalesce_expression
Use nameof
Use primary constructor
csharp_style_prefer_primary_constructors
Use collection expression for array
dotnet_style_prefer_collection_expression
Use collection expression for empty
dotnet_style_prefer_collection_expression
Use collection expression for stackalloc
dotnet_style_prefer_collection_expression
Use collection expression for Create()
dotnet_style_prefer_collection_expression
Use collection expression for builder
dotnet_style_prefer_collection_expression
Use collection expression for fluent
dotnet_style_prefer_collection_expression
Use collection expression for new
dotnet_style_prefer_collection_expression
Make anonymous function static
csharp_prefer_static_anonymous_function
Prefer 'System.Threading.Lock'
csharp_prefer_system_threading_lock
Use unbound generic type
csharp_style_prefer_unbound_generic_type_in_nameof
Use implicitly typed lambda
csharp_style_prefer_implicitly_typed_lambda_expression
Use conditional delegate call
csharp_style_conditional_delegate_call
Naming styles