|
| 1 | +[*.cs] |
| 2 | + |
| 3 | +############################### |
| 4 | +# .NET Coding Conventions # |
| 5 | +############################### |
| 6 | + |
| 7 | +# Organize usings |
| 8 | +dotnet_separate_import_directive_groups = false |
| 9 | +dotnet_sort_system_directives_first = false |
| 10 | + |
| 11 | +# this. and Me. preferences |
| 12 | +dotnet_style_qualification_for_event = false:error |
| 13 | +dotnet_style_qualification_for_field = false:error |
| 14 | +dotnet_style_qualification_for_method = false:error |
| 15 | +dotnet_style_qualification_for_property = false:error |
| 16 | + |
| 17 | +# Language keywords vs BCL types preferences |
| 18 | +dotnet_style_predefined_type_for_locals_parameters_members = true:error |
| 19 | +dotnet_style_predefined_type_for_member_access = true:error |
| 20 | + |
| 21 | +# Parentheses preferences |
| 22 | +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent |
| 23 | +dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:warning |
| 24 | +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:error |
| 25 | +dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:warning |
| 26 | + |
| 27 | +# Modifier preferences |
| 28 | +dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent |
| 29 | + |
| 30 | +# Expression-level preferences |
| 31 | +dotnet_style_coalesce_expression = true:warning |
| 32 | +dotnet_style_collection_initializer = true:warning |
| 33 | +dotnet_style_explicit_tuple_names = true:warning |
| 34 | +dotnet_style_null_propagation = true:warning |
| 35 | +dotnet_style_object_initializer = true:warning |
| 36 | +dotnet_style_prefer_auto_properties = true:warning |
| 37 | +dotnet_style_prefer_compound_assignment = true:warning |
| 38 | +dotnet_style_prefer_conditional_expression_over_assignment = true:warning |
| 39 | +dotnet_style_prefer_conditional_expression_over_return = true:suggestion |
| 40 | +dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning |
| 41 | +dotnet_style_prefer_inferred_tuple_names = true:warning |
| 42 | +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning |
| 43 | +dotnet_style_prefer_simplified_interpolation = true:suggestion |
| 44 | + |
| 45 | +# Field preferences |
| 46 | +dotnet_style_readonly_field = true:warning |
| 47 | + |
| 48 | +# Parameter preferences |
| 49 | +dotnet_code_quality_unused_parameters = all:warning |
| 50 | + |
| 51 | +############################### |
| 52 | +# C# NET Coding Conventions # |
| 53 | +############################### |
| 54 | + |
| 55 | +# var preferences |
| 56 | +csharp_style_var_elsewhere = true:silent |
| 57 | +csharp_style_var_for_built_in_types = false:silent |
| 58 | +csharp_style_var_when_type_is_apparent = true:silent |
| 59 | + |
| 60 | +# Expression-bodied members |
| 61 | +csharp_style_expression_bodied_accessors = true:error |
| 62 | +csharp_style_expression_bodied_constructors = false:error |
| 63 | +csharp_style_expression_bodied_indexers = true:error |
| 64 | +csharp_style_expression_bodied_lambdas = true:error |
| 65 | +csharp_style_expression_bodied_local_functions = true:error |
| 66 | +csharp_style_expression_bodied_methods = true:error |
| 67 | +csharp_style_expression_bodied_operators = true:error |
| 68 | +csharp_style_expression_bodied_properties = true:error |
| 69 | + |
| 70 | +# Pattern matching preferences |
| 71 | +csharp_style_pattern_matching_over_as_with_null_check = true:warning |
| 72 | +csharp_style_pattern_matching_over_is_with_cast_check = true:warning |
| 73 | +csharp_style_prefer_switch_expression = true:warning |
| 74 | + |
| 75 | +# Null-checking preferences |
| 76 | +csharp_style_conditional_delegate_call = true:warning |
| 77 | + |
| 78 | +# Modifier preferences |
| 79 | +csharp_prefer_static_local_function = true:warning |
| 80 | +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent |
| 81 | + |
| 82 | +# Code-block preferences |
| 83 | +csharp_prefer_braces = when_multiline:error |
| 84 | +csharp_prefer_simple_using_statement = true:warning |
| 85 | + |
| 86 | +# Expression-level preferences |
| 87 | +csharp_prefer_simple_default_expression = true:warning |
| 88 | +csharp_style_deconstructed_variable_declaration = true:suggestion |
| 89 | +csharp_style_inlined_variable_declaration = true:error |
| 90 | +csharp_style_pattern_local_over_anonymous_function = true:warning |
| 91 | +csharp_style_prefer_index_operator = true:suggestion |
| 92 | +csharp_style_prefer_range_operator = true:suggestion |
| 93 | +csharp_style_throw_expression = true:warning |
| 94 | +csharp_style_unused_value_assignment_preference = discard_variable:suggestion |
| 95 | +csharp_style_unused_value_expression_statement_preference = discard_variable:silent |
| 96 | + |
| 97 | +# 'using' directive preferences |
| 98 | +csharp_using_directive_placement = outside_namespace:warning |
| 99 | + |
| 100 | +############################### |
| 101 | +# Additional Analysis Rules # |
| 102 | +############################### |
| 103 | + |
| 104 | +# CA1000: Do not declare static members on generic types |
| 105 | +dotnet_diagnostic.CA1000.severity = none |
| 106 | + |
| 107 | +# CA1034: Nested types should not be visible |
| 108 | +dotnet_diagnostic.CA1034.severity = none |
| 109 | + |
| 110 | +# CA1043: Use Integral Or String Argument For Indexers |
| 111 | +dotnet_diagnostic.CA1043.severity = none |
| 112 | + |
| 113 | +# CA1062: Validate arguments of public methods |
| 114 | +dotnet_diagnostic.CA1062.severity = none |
| 115 | + |
| 116 | +# CA1304: Specify CultureInfo |
| 117 | +dotnet_diagnostic.CA1304.severity = none |
| 118 | + |
| 119 | +# CA1305: Specify IFormatProvider |
| 120 | +dotnet_diagnostic.CA1305.severity = none |
| 121 | + |
| 122 | +# CA1707: Identifiers should not contain underscores |
| 123 | +dotnet_diagnostic.CA1707.severity = none |
| 124 | + |
| 125 | +# CA1720: Identifier contains type name |
| 126 | +dotnet_diagnostic.CA1720.severity = none |
| 127 | + |
| 128 | +# CA1721: Property names should not match get methods |
| 129 | +dotnet_diagnostic.CA1721.severity = none |
| 130 | + |
| 131 | +# CA1801: Review unused parameters |
| 132 | +dotnet_diagnostic.CA1801.severity = none |
| 133 | + |
| 134 | +# CA1815: Override equals and operator equals on value types |
| 135 | +dotnet_diagnostic.CA1815.severity = none |
| 136 | + |
| 137 | +# CA2225: Operator overloads have named alternates |
| 138 | +dotnet_diagnostic.CA2225.severity = silent |
| 139 | + |
| 140 | +# IDE0060: Remove unused parameter |
| 141 | +dotnet_code_quality_unused_parameters = all:silent |
| 142 | + |
| 143 | +# CA1814: Prefer jagged arrays over multidimensional |
| 144 | +dotnet_diagnostic.CA1814.severity = none |
| 145 | + |
| 146 | +# Default severity for analyzer diagnostics with category 'Globalization' |
| 147 | +dotnet_analyzer_diagnostic.category-Globalization.severity = suggestion |
| 148 | + |
| 149 | +# CA1040: Avoid empty interfaces |
| 150 | +dotnet_diagnostic.CA1040.severity = none |
| 151 | + |
| 152 | +# CA1027: Mark enums with FlagsAttribute |
| 153 | +dotnet_diagnostic.CA1027.severity = none |
| 154 | + |
| 155 | +# CA1003: Use generic event handler instances |
| 156 | +dotnet_diagnostic.CA1003.severity = none |
| 157 | + |
| 158 | +# CA1008: Enums should have zero value |
| 159 | +dotnet_diagnostic.CA1008.severity = none |
| 160 | + |
| 161 | +# ----------------------------------------------------------------------------- |
| 162 | +# NOTE: We are currently suppressing "unnecessary supressions" since these |
| 163 | +# warnings are generated by the net471 build only. However, these suppressions |
| 164 | +# are required for the .net50 build. |
| 165 | +# ----------------------------------------------------------------------------- |
| 166 | +# IDE0079: Remove unnecessary suppression |
| 167 | +dotnet_diagnostic.IDE0079.severity = none |
0 commit comments