|
| 1 | +# References |
| 2 | +# https://docs.microsoft.com/en-us/visualstudio/code-quality/use-roslyn-analyzers?view=vs-2022 |
| 3 | +# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/language-rules |
| 4 | +# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/naming-rules |
| 5 | +# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ |
| 6 | +# https://rules.sonarsource.com/csharp |
| 7 | +# https://editorconfig.org/ |
| 8 | + |
| 9 | +root = true |
| 10 | + |
| 11 | +[**/*] |
| 12 | +# Sensible Defaults |
| 13 | +file_header_template = SPDX-License-Identifier: Apache-2.0\nLicensed to the Ed-Fi Alliance under one or more agreements.\nThe Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.\nSee the LICENSE and NOTICES files in the project root for more information. |
| 14 | +indent_style=space |
| 15 | +indent_size=4 |
| 16 | +tab_width=2 |
| 17 | +insert_final_newline = true |
| 18 | +charset = utf-8 |
| 19 | +trim_trailing_whitespace = true |
| 20 | +max_line_length = 110 |
| 21 | + |
| 22 | +[**/*.md] |
| 23 | +trim_trailing_whitespace = false |
| 24 | + |
| 25 | +[**/*.{cs,cshtml,csx}] |
| 26 | +indent_style = space |
| 27 | +indent_size = 4 |
| 28 | +tab_width = 4 |
| 29 | +end_of_line = lf |
| 30 | +csharp_new_line_before_members_in_object_initializers = false |
| 31 | +csharp_preferred_modifier_order = private, public, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion |
| 32 | + |
| 33 | +dotnet_diagnostic.IDE0073.severity=error # File header template required |
| 34 | + |
| 35 | +# Formatting rules |
| 36 | +dotnet_diagnostic.IDE0055.severity=warning |
| 37 | +csharp_new_line_before_open_brace = all # Allman style |
| 38 | +csharp_new_line_before_else = true |
| 39 | +csharp_new_line_before_catch = true |
| 40 | +csharp_new_line_before_finally = true |
| 41 | +csharp_new_line_before_members_in_object_initializers = true |
| 42 | +csharp_new_line_before_members_in_anonymous_types = true |
| 43 | +csharp_new_line_between_query_expression_clauses = true |
| 44 | +csharp_indent_case_contents = true |
| 45 | +csharp_indent_switch_labels = true |
| 46 | +csharp_indent_labels = no_change |
| 47 | +csharp_indent_block_contents = true |
| 48 | +csharp_indent_braces = false |
| 49 | +csharp_indent_case_contents_when_block = true |
| 50 | +csharp_space_after_cast = false |
| 51 | +csharp_space_after_keywords_in_control_flow_statements = true |
| 52 | +csharp_space_between_parentheses = none |
| 53 | +csharp_space_before_colon_in_inheritance_clause = true |
| 54 | +csharp_space_after_colon_in_inheritance_clause = true |
| 55 | +csharp_space_around_binary_operators = before_and_after |
| 56 | +csharp_space_between_method_declaration_parameter_list_parentheses = false |
| 57 | +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false |
| 58 | +csharp_space_between_method_declaration_name_and_open_parenthesis = false |
| 59 | +csharp_space_between_method_call_parameter_list_parentheses = false |
| 60 | +csharp_space_between_method_call_empty_parameter_list_parentheses = false |
| 61 | +csharp_space_between_method_call_name_and_opening_parenthesis = false |
| 62 | +csharp_space_after_comma = true |
| 63 | +csharp_space_before_comma = false |
| 64 | +csharp_space_after_dot = false |
| 65 | +csharp_space_before_dot = false |
| 66 | +csharp_space_after_semicolon_in_for_statement = true |
| 67 | +csharp_space_before_semicolon_in_for_statement = false |
| 68 | +csharp_space_around_declaration_statements = false |
| 69 | +csharp_space_before_open_square_brackets = false |
| 70 | +csharp_space_between_empty_square_brackets = false |
| 71 | +csharp_space_between_square_brackets = false |
| 72 | +csharp_preserve_single_line_blocks = true |
| 73 | +csharp_preserve_single_line_statements = false |
| 74 | + |
| 75 | +# Naming rules |
| 76 | +dotnet_naming_rule.local_constants_rule.severity = warning |
| 77 | +dotnet_naming_rule.local_constants_rule.style = upper_camel_case_style |
| 78 | +dotnet_naming_rule.local_constants_rule.symbols = local_constants_symbols |
| 79 | +dotnet_naming_rule.private_constants_rule.import_to_resharper = as_predefined |
| 80 | +dotnet_naming_rule.private_constants_rule.severity = warning |
| 81 | +dotnet_naming_rule.private_constants_rule.style = upper_camel_case_style |
| 82 | +dotnet_naming_rule.private_constants_rule.symbols = private_constants_symbols |
| 83 | +dotnet_naming_rule.private_static_readonly_rule.import_to_resharper = as_predefined |
| 84 | +dotnet_naming_rule.private_static_readonly_rule.severity = warning |
| 85 | +dotnet_naming_rule.private_static_readonly_rule.style = lower_camel_case_style |
| 86 | +dotnet_naming_rule.private_static_readonly_rule.symbols = private_static_readonly_symbols |
| 87 | +dotnet_naming_style.lower_camel_case_style.capitalization = camel_case |
| 88 | +dotnet_naming_style.lower_camel_case_style.required_prefix = _ |
| 89 | +dotnet_naming_style.upper_camel_case_style.capitalization = pascal_case |
| 90 | +dotnet_naming_symbols.local_constants_symbols.applicable_accessibilities = * |
| 91 | +dotnet_naming_symbols.local_constants_symbols.applicable_kinds = local |
| 92 | +dotnet_naming_symbols.local_constants_symbols.required_modifiers = const |
| 93 | +dotnet_naming_symbols.private_constants_symbols.applicable_accessibilities = private |
| 94 | +dotnet_naming_symbols.private_constants_symbols.applicable_kinds = field |
| 95 | +dotnet_naming_symbols.private_constants_symbols.required_modifiers = const |
| 96 | +dotnet_naming_symbols.private_static_readonly_symbols.applicable_accessibilities = private |
| 97 | +dotnet_naming_symbols.private_static_readonly_symbols.applicable_kinds = field |
| 98 | +dotnet_naming_symbols.private_static_readonly_symbols.required_modifiers = static,readonly |
| 99 | + |
| 100 | +# Misc style |
| 101 | +dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:none |
| 102 | +dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:none |
| 103 | +dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none |
| 104 | +dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion |
| 105 | +dotnet_style_predefined_type_for_member_access = true:suggestion |
| 106 | +dotnet_style_qualification_for_event = false:suggestion |
| 107 | +dotnet_style_qualification_for_field = false:suggestion |
| 108 | +dotnet_style_qualification_for_method = false:suggestion |
| 109 | +dotnet_style_qualification_for_property = false:suggestion |
| 110 | +dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning |
| 111 | +dotnet_style_operator_placement_when_wrapping = beginning_of_line |
| 112 | +dotnet_sort_system_directives_first = true |
| 113 | +dotnet_separate_import_directive_groups = false |
| 114 | + |
| 115 | +# We *like* var |
| 116 | +dotnet_diagnostic.IDE0008.severity=none # IDE0008: Use explicit type |
| 117 | +csharp_style_var_elsewhere = false:none |
| 118 | +csharp_style_var_for_built_in_types = false:suggestion |
| 119 | + |
| 120 | +# Using statements |
| 121 | +csharp_using_directive_placement=outside_namespace:warning |
| 122 | +dotnet_diagnostic.IDE0065.severity=warning # placement of using statements |
| 123 | +dotnet_diagnostic.IDE0005.severity=suggestion # Remove unnecessary using directives |
| 124 | + |
| 125 | +# Lower the priority |
| 126 | +dotnet_diagnostic.S4136.severity=suggestion # Method overloads should be grouped together |
| 127 | +dotnet_diagnostic.S1135.severity=suggestion # Complete TODO comments |
| 128 | +dotnet_diagnostic.S112.severity=suggestion # 'System.Exception' should not be thrown by user code. |
| 129 | +dotnet_diagnostic.S3247.severity=suggestion # Remove redundant cast - getting false positives |
| 130 | + |
| 131 | +# Allow empty records for discriminated union types |
| 132 | +dotnet_diagnostic.S2094.severity=none # S2094: Classes should not be empty |
| 133 | + |
| 134 | +[**/tests/**/*.cs] |
| 135 | +# Allow our strange test class naming convention |
| 136 | +dotnet_naming_symbols.amt_tests.applicable_kinds = class,method |
| 137 | +dotnet_naming_symbols.amt_tests.word_separator = "_" |
| 138 | +dotnet_naming_symbols.amt_tests.capitalization = first_word_upper |
| 139 | +dotnet_diagnostic.IDE1006.severity=none |
| 140 | +dotnet_diagnostic.S101.severity=none |
| 141 | + |
| 142 | +# SonarLint doesn't understand implied assertions from FakeItEasy |
| 143 | +dotnet_diagnostic.S2699.severity=none # S2699: Tests should include assertions |
0 commit comments