# dotnet-awesome-humans template | targets: net10.0, csharp-14 | last-reviewed: 2026-08-21 | last-used: 2026-09-24 | sources: ms-learn, meziantou # Copy to the repository root. Trim rules you disagree with, but disagree deliberately. root = true [*] charset = utf-8 end_of_line = lf insert_final_newline = true indent_style = space indent_size = 4 trim_trailing_whitespace = true [*.{json,jsonc,yml,yaml,props,targets,csproj,fsproj,slnx,slnf,xml,config}] indent_size = 2 [*.md] trim_trailing_whitespace = false [*.{cs,fs}] dotnet_analyzer_diagnostic.severity = warning [*.cs] # --- Language version and style: latest, expression-oriented, explicit intent --- csharp_style_var_for_built_in_types = false:suggestion csharp_style_var_when_type_is_apparent = true:suggestion csharp_style_var_elsewhere = false:suggestion csharp_style_expression_bodied_methods = when_on_single_line:suggestion # Constructors too. Left unset, the default (block bodies) is raised to a warning by the bulk # severity above and fails every one-line constructor (IDE0021). csharp_style_expression_bodied_constructors = when_on_single_line:suggestion csharp_style_expression_bodied_properties = true:suggestion csharp_style_namespace_declarations = file_scoped:warning csharp_style_prefer_primary_constructors = true:suggestion csharp_style_prefer_switch_expression = true:warning csharp_style_pattern_matching_over_as_with_null_check = true:warning csharp_style_prefer_null_check_over_type_check = true:warning csharp_prefer_simple_using_statement = true:warning csharp_style_prefer_top_level_statements = true:suggestion csharp_style_prefer_method_group_conversion = true:suggestion csharp_using_directive_placement = outside_namespace:warning # Prefer auto-implemented properties over trivial hand-written backing fields. Severity is set # here rather than on dotnet_style_prefer_auto_properties below, which is the same rule: # a dotnet_diagnostic entry wins over the option's trailing severity, so carrying both # would leave one of them silently dead. dotnet_diagnostic.IDE0032.severity = warning # The bulk severity above raises IDE0058 (unused expression value) to a warning, which demands # `_ =` on every discarded result, including each Assert.Throws in a test project. Keep it silent. dotnet_diagnostic.IDE0058.severity = silent # The one globalization rule AnalysisLevel=latest-recommended leaves silent: string.Equals # without a StringComparison. CA1304/1305/1309/1310/1311 already warn (opinions/globalization.md). dotnet_diagnostic.CA1307.severity = warning # The one Meziantou.Analyzer TimeProvider rule that ships disabled: prefer overloads taking a # TimeProvider. MA0166/MA0188 ship enabled at info severity and are raised to warnings by the # bulk dotnet_analyzer_diagnostic.severity above (opinions/datetime.md). dotnet_diagnostic.MA0167.severity = warning # --- Nullability and correctness --- dotnet_style_require_accessibility_modifiers = always:warning dotnet_style_readonly_field = true:warning dotnet_style_prefer_auto_properties = true # severity: IDE0032 above dotnet_style_collection_initializer = true:suggestion dotnet_style_prefer_collection_expression = true:warning dotnet_style_object_initializer = true:suggestion dotnet_style_coalesce_expression = true:warning dotnet_style_null_propagation = true:warning # --- Naming: standard .NET conventions --- dotnet_naming_rule.interfaces_begin_with_i.severity = warning dotnet_naming_rule.interfaces_begin_with_i.symbols = interfaces dotnet_naming_rule.interfaces_begin_with_i.style = prefix_i dotnet_naming_symbols.interfaces.applicable_kinds = interface dotnet_naming_style.prefix_i.required_prefix = I dotnet_naming_style.prefix_i.capitalization = pascal_case # Constants take PascalCase. A rule with required_modifiers is more specific than the private-field # rule below, so it wins for consts; without it, a private const needs an underscore prefix. dotnet_naming_rule.constants_pascal_case.severity = warning dotnet_naming_rule.constants_pascal_case.symbols = constants dotnet_naming_rule.constants_pascal_case.style = pascal_case dotnet_naming_symbols.constants.applicable_kinds = field, local dotnet_naming_symbols.constants.applicable_accessibilities = * dotnet_naming_symbols.constants.required_modifiers = const dotnet_naming_style.pascal_case.capitalization = pascal_case dotnet_naming_rule.private_fields_camel_underscore.severity = warning dotnet_naming_rule.private_fields_camel_underscore.symbols = private_fields dotnet_naming_rule.private_fields_camel_underscore.style = underscore_camel dotnet_naming_symbols.private_fields.applicable_kinds = field dotnet_naming_symbols.private_fields.applicable_accessibilities = private dotnet_naming_style.underscore_camel.required_prefix = _ dotnet_naming_style.underscore_camel.capitalization = camel_case [*.fs] fsharp_multiline_bracket_style = stroustrup