# Unified code style for CursorLang. # The rules are understood by Visual Studio, Rider, VS Code and `dotnet format`. # https://learn.microsoft.com/dotnet/fundamentals/code-analysis/code-style-rule-options root = true # ========================================================================== # Common to all files # ========================================================================== [*] charset = utf-8 end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true indent_style = space indent_size = 4 # Build scripts are read by Windows PowerShell 5.1: without a BOM it takes the # file for ANSI and mangles the Russian text in the messages [*.{ps1,psm1,psd1}] charset = utf-8-bom # In Markdown two trailing spaces at the end of a line mean a line break [*.{md,markdown}] trim_trailing_whitespace = false [*.{json,jsonc,yml,yaml}] indent_size = 2 # Project files, XAML and other XML keep the same four spaces as the code [*.{csproj,vbproj,props,targets,sln,slnx,xaml,xml,resx,manifest,config,appxmanifest,nuspec}] indent_size = 4 # Files written by the SDK rather than by a human [{obj,bin,artifacts}/**] generated_code = true # ========================================================================== # C# # ========================================================================== [*.cs] # A guideline for wrapping lines, not a hard limit max_line_length = 120 #### using directives #### # System comes first and in a group separate from the rest dotnet_sort_system_directives_first = true dotnet_separate_import_directive_groups = false # using outside the namespace — more familiar and compatible with file-scoped namespace csharp_using_directive_placement = outside_namespace:warning dotnet_diagnostic.IDE0005.severity = warning #### File layout #### csharp_style_namespace_declarations = file_scoped:warning # The namespace mirrors the file path from the project root dotnet_diagnostic.IDE0130.severity = warning #### this. and Me. #### dotnet_style_qualification_for_field = false:warning dotnet_style_qualification_for_property = false:warning dotnet_style_qualification_for_method = false:warning dotnet_style_qualification_for_event = false:warning #### Language keywords instead of BCL type names #### dotnet_style_predefined_type_for_locals_parameters_members = true:warning dotnet_style_predefined_type_for_member_access = true:warning #### Modifiers #### dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async:suggestion dotnet_style_readonly_field = true:warning csharp_prefer_static_local_function = true:suggestion csharp_prefer_static_anonymous_function = true:suggestion #### var and explicit types #### # The type is written explicitly, except where it is already visible on the right of the equals sign csharp_style_var_for_built_in_types = false:suggestion csharp_style_var_when_type_is_apparent = true:suggestion csharp_style_var_elsewhere = false:suggestion #### Expression-bodied members #### # Allowed but not enforced: for long expressions a block reads better csharp_style_expression_bodied_methods = when_on_single_line:silent csharp_style_expression_bodied_constructors = when_on_single_line:silent csharp_style_expression_bodied_operators = when_on_single_line:silent csharp_style_expression_bodied_properties = true:silent csharp_style_expression_bodied_indexers = true:silent csharp_style_expression_bodied_accessors = true:silent csharp_style_expression_bodied_lambdas = true:silent csharp_style_expression_bodied_local_functions = when_on_single_line:silent #### Pattern matching and null checks #### csharp_style_pattern_matching_over_is_with_cast_check = true:warning csharp_style_pattern_matching_over_as_with_null_check = true:warning csharp_style_prefer_switch_expression = true:suggestion csharp_style_prefer_pattern_matching = true:suggestion csharp_style_prefer_not_pattern = true:warning csharp_style_prefer_extended_property_pattern = true:suggestion csharp_style_conditional_delegate_call = true:warning csharp_style_throw_expression = true:suggestion dotnet_style_coalesce_expression = true:warning dotnet_style_null_propagation = true:warning dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning #### Expressions #### dotnet_style_object_initializer = true:suggestion dotnet_style_collection_initializer = true:suggestion dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion dotnet_style_explicit_tuple_names = true:warning dotnet_style_prefer_inferred_tuple_names = true:suggestion dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion dotnet_style_prefer_auto_properties = true:silent dotnet_style_prefer_conditional_expression_over_assignment = true:silent dotnet_style_prefer_conditional_expression_over_return = true:silent dotnet_style_prefer_compound_assignment = true:suggestion dotnet_style_prefer_simplified_boolean_expressions = true:suggestion dotnet_style_prefer_simplified_interpolation = true:suggestion dotnet_style_operator_placement_when_wrapping = beginning_of_line csharp_style_prefer_index_operator = true:suggestion csharp_style_prefer_range_operator = true:suggestion csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion csharp_prefer_simple_default_expression = true:suggestion csharp_style_deconstructed_variable_declaration = true:suggestion csharp_style_inlined_variable_declaration = true:suggestion csharp_style_unused_value_assignment_preference = discard_variable:suggestion csharp_style_unused_value_expression_statement_preference = discard_variable:silent csharp_prefer_simple_using_statement = true:suggestion csharp_style_prefer_utf8_string_literals = true:suggestion csharp_style_prefer_readonly_struct = true:suggestion csharp_style_prefer_readonly_struct_member = true:suggestion csharp_style_prefer_primary_constructors = false:silent #### Braces and blocks #### # Braces are always used, even around a single line csharp_prefer_braces = true:warning csharp_style_prefer_top_level_statements = false:silent # Parentheses that clarify the order of operations are welcome. The hint is # silent: parentheses around operations of the same precedence also count as # redundant, and in the coordinate calculations they are there on purpose dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent #### Unused code #### dotnet_code_quality_unused_parameters = non_public:suggestion dotnet_remove_unnecessary_suppression_exclusions = none csharp_style_prefer_method_group_conversion = true:silent # ========================================================================== # C#: formatting # ========================================================================== #### Line breaks before a brace — Allman style #### csharp_new_line_before_open_brace = all csharp_new_line_before_else = true csharp_new_line_before_catch = true csharp_new_line_before_finally = true csharp_new_line_before_members_in_object_initializers = true csharp_new_line_before_members_in_anonymous_types = true csharp_new_line_between_query_expression_clauses = true #### Indentation #### csharp_indent_case_contents = true csharp_indent_case_contents_when_block = false csharp_indent_switch_labels = true csharp_indent_labels = one_less_than_current csharp_indent_block_contents = true csharp_indent_braces = false #### Spacing #### csharp_space_after_cast = false csharp_space_after_keywords_in_control_flow_statements = true csharp_space_before_colon_in_inheritance_clause = true csharp_space_after_colon_in_inheritance_clause = true csharp_space_around_binary_operators = before_and_after csharp_space_between_method_declaration_parameter_list_parentheses = false csharp_space_between_method_declaration_empty_parameter_list_parentheses = false csharp_space_between_method_declaration_name_and_open_parenthesis = false csharp_space_between_method_call_parameter_list_parentheses = false csharp_space_between_method_call_empty_parameter_list_parentheses = false csharp_space_between_method_call_name_and_opening_parenthesis = false csharp_space_after_comma = true csharp_space_before_comma = false csharp_space_after_dot = false csharp_space_before_dot = false csharp_space_after_semicolon_in_for_statement = true csharp_space_before_semicolon_in_for_statement = false csharp_space_around_declaration_statements = false csharp_space_before_open_square_brackets = false csharp_space_between_empty_square_brackets = false csharp_space_between_square_brackets = false #### Line wrapping #### # Every statement and every member on its own line csharp_preserve_single_line_statements = false csharp_preserve_single_line_blocks = true # ========================================================================== # C#: naming # The rules are checked top to bottom, the first matching one wins # ========================================================================== #### Naming styles #### dotnet_naming_style.pascal_case.capitalization = pascal_case dotnet_naming_style.camel_case.capitalization = camel_case dotnet_naming_style.underscore_camel_case.capitalization = camel_case dotnet_naming_style.underscore_camel_case.required_prefix = _ dotnet_naming_style.i_pascal_case.capitalization = pascal_case dotnet_naming_style.i_pascal_case.required_prefix = I dotnet_naming_style.t_pascal_case.capitalization = pascal_case dotnet_naming_style.t_pascal_case.required_prefix = T #### Interfaces: IStartupService #### dotnet_naming_symbols.interfaces.applicable_kinds = interface dotnet_naming_symbols.interfaces.applicable_accessibilities = * dotnet_naming_rule.interfaces_are_i_pascal_case.symbols = interfaces dotnet_naming_rule.interfaces_are_i_pascal_case.style = i_pascal_case dotnet_naming_rule.interfaces_are_i_pascal_case.severity = warning #### Type parameters: TValue #### dotnet_naming_symbols.type_parameters.applicable_kinds = type_parameter dotnet_naming_symbols.type_parameters.applicable_accessibilities = * dotnet_naming_rule.type_parameters_are_t_pascal_case.symbols = type_parameters dotnet_naming_rule.type_parameters_are_t_pascal_case.style = t_pascal_case dotnet_naming_rule.type_parameters_are_t_pascal_case.severity = warning #### Types and members: PascalCase #### dotnet_naming_symbols.types.applicable_kinds = class,struct,enum,delegate dotnet_naming_symbols.types.applicable_accessibilities = * dotnet_naming_rule.types_are_pascal_case.symbols = types dotnet_naming_rule.types_are_pascal_case.style = pascal_case dotnet_naming_rule.types_are_pascal_case.severity = warning dotnet_naming_symbols.non_field_members.applicable_kinds = method,property,event,local_function dotnet_naming_symbols.non_field_members.applicable_accessibilities = * dotnet_naming_rule.non_field_members_are_pascal_case.symbols = non_field_members dotnet_naming_rule.non_field_members_are_pascal_case.style = pascal_case dotnet_naming_rule.non_field_members_are_pascal_case.severity = warning #### Constants and static fields: PascalCase #### # Comes before the rule about private fields, otherwise they would fall under _camelCase dotnet_naming_symbols.constants.applicable_kinds = field dotnet_naming_symbols.constants.applicable_accessibilities = * dotnet_naming_symbols.constants.required_modifiers = const dotnet_naming_rule.constants_are_pascal_case.symbols = constants dotnet_naming_rule.constants_are_pascal_case.style = pascal_case dotnet_naming_rule.constants_are_pascal_case.severity = suggestion dotnet_naming_symbols.static_readonly_fields.applicable_kinds = field dotnet_naming_symbols.static_readonly_fields.applicable_accessibilities = * dotnet_naming_symbols.static_readonly_fields.required_modifiers = static,readonly dotnet_naming_rule.static_readonly_fields_are_pascal_case.symbols = static_readonly_fields dotnet_naming_rule.static_readonly_fields_are_pascal_case.style = pascal_case dotnet_naming_rule.static_readonly_fields_are_pascal_case.severity = suggestion #### Public fields: PascalCase #### dotnet_naming_symbols.public_fields.applicable_kinds = field dotnet_naming_symbols.public_fields.applicable_accessibilities = public,internal,protected,protected_internal dotnet_naming_rule.public_fields_are_pascal_case.symbols = public_fields dotnet_naming_rule.public_fields_are_pascal_case.style = pascal_case dotnet_naming_rule.public_fields_are_pascal_case.severity = warning #### Private fields: _camelCase #### dotnet_naming_symbols.private_fields.applicable_kinds = field dotnet_naming_symbols.private_fields.applicable_accessibilities = private,private_protected dotnet_naming_rule.private_fields_are_underscore_camel_case.symbols = private_fields dotnet_naming_rule.private_fields_are_underscore_camel_case.style = underscore_camel_case dotnet_naming_rule.private_fields_are_underscore_camel_case.severity = suggestion #### Parameters and local variables: camelCase #### dotnet_naming_symbols.parameters_and_locals.applicable_kinds = parameter,local dotnet_naming_symbols.parameters_and_locals.applicable_accessibilities = * dotnet_naming_rule.parameters_and_locals_are_camel_case.symbols = parameters_and_locals dotnet_naming_rule.parameters_and_locals_are_camel_case.style = camel_case dotnet_naming_rule.parameters_and_locals_are_camel_case.severity = suggestion # ========================================================================== # Tests # ========================================================================== [CursorLang.Tests/**/*.cs] # A test name is a sentence with underscores instead of spaces: # in the run report it is read by a human, not called by other code dotnet_diagnostic.IDE1006.severity = none # ========================================================================== # Win32 and WinRT wrappers # ========================================================================== [CursorLang/Interop/*.cs] # Function, constant and field names repeat the Windows documentation: they are # easier to search for in the code when written the same way as in the API description dotnet_diagnostic.IDE1006.severity = none