# EditorConfig: https://editorconfig.org
# Shared code style for VS Code, Cursor, Visual Studio, Rider

root = true

[*]
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space

# =========================
# C#
# =========================
[*.cs]
indent_size = 2

# K&R braces (opening brace on same line)
csharp_new_line_before_open_brace = none

# keep else/catch/finally on new line
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true

# indentation
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_indent_labels = one_less_than_current

# spacing
csharp_space_after_cast = false
csharp_space_after_dot = false
csharp_space_after_semicolon_in_for_statement = true
csharp_space_before_semicolon_in_for_statement = false

# Fluent / chained method calls (ReSharper compatibility)
resharper_csharp_continuous_indent_multiplier = 1
resharper_continuous_indent_multiplier = 1
resharper_csharp_align_multiline_calls_chain = false
resharper_align_multiline_calls_chain = false
resharper_csharp_outdent_dots = false
resharper_outdent_dots = false

# Two blank lines between last using and namespace
resharper_csharp_blank_lines_between_using_and_namespace = 2
resharper_blank_lines_between_using_and_namespace = 2

# Usings: System first; blank line between System and other groups (Roslyn)
dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = false
resharper_sort_usings_system_first = true

# Remove unnecessary using directives (dotnet format style --diagnostics IDE0005)
dotnet_diagnostic.IDE0005.severity = warning

# File-scoped namespace declarations (IDE0160)
csharp_style_namespace_declarations = file_scoped:warning
dotnet_diagnostic.IDE0160.severity = warning

# Omit braces on single-line if/else/for/foreach/while/using (IDE0011)
csharp_prefer_braces = when_multiline:none
dotnet_diagnostic.IDE0011.severity = none

# Prefer 'var' over explicit type (IDE0008)
csharp_style_var_for_built_in_types = true:none
csharp_style_var_when_type_is_apparent = true:none
csharp_style_var_elsewhere = true:none
dotnet_diagnostic.IDE0008.severity = none

# Prefer if-return over ternary for conditional returns (IDE0046) — multi-line guards stay readable
dotnet_style_prefer_conditional_expression_over_return = false:none
dotnet_diagnostic.IDE0046.severity = none

# Expression-bodied members: prefer => over { return ...; } (IDE0022–IDE0027)
csharp_style_expression_bodied_methods = true:warning
csharp_style_expression_bodied_properties = true:warning
csharp_style_expression_bodied_accessors = true:warning
csharp_style_expression_bodied_indexers = true:warning
csharp_style_expression_bodied_operators = true:warning
csharp_style_expression_bodied_lambdas = true:none
csharp_style_expression_bodied_local_functions = false:none
csharp_style_expression_bodied_constructors = false:none
dotnet_diagnostic.IDE0022.severity = warning
dotnet_diagnostic.IDE0023.severity = warning
dotnet_diagnostic.IDE0024.severity = warning
dotnet_diagnostic.IDE0025.severity = warning
dotnet_diagnostic.IDE0026.severity = warning
dotnet_diagnostic.IDE0027.severity = warning

# => on signature line; expression indented on next line (no blank line after =>)
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:warning
dotnet_diagnostic.IDE2006.severity = warning
resharper_csharp_wrap_before_arrow_with_expressions = false
resharper_wrap_before_arrow_with_expressions = false


# =========================
# TypeScript / JavaScript
# =========================
[*.{ts,tsx,js,jsx}]
indent_size = 2


# =========================
# JSON / YAML
# =========================
[*.{json,yml,yaml}]
indent_size = 2


# =========================
# Markdown
# =========================
[*.md]
trim_trailing_whitespace = false
