root = true

# =========================

# Global settings

# =========================

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

# =========================

# C# files

# =========================

[*.cs]

# ---- Formatting ----

indent_style = space
indent_size = 4
tab_width = 4

# ---- Newline preferences ----

csharp_new_line_before_open_brace = all

# ---- Avoid modern syntax (Mono compatibility) ----

csharp_prefer_simple_using_statement = false
csharp_style_var_for_built_in_types = false
csharp_style_var_elsewhere = false
csharp_style_var_when_type_is_apparent = false

# ---- Expression/style preferences (keep conservative) ----

csharp_style_expression_bodied_methods = false:suggestion
csharp_style_expression_bodied_constructors = false:suggestion
csharp_style_expression_bodied_properties = false:suggestion

# ---- Naming ----

dotnet_naming_rule.private_fields_should_be_camel_case.severity = suggestion
dotnet_naming_rule.private_fields_should_be_camel_case.symbols = private_fields
dotnet_naming_rule.private_fields_should_be_camel_case.style = camel_case_style

dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private

dotnet_naming_style.camel_case_style.capitalization = camel_case

# ---- Using directives ----

dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = true

# =========================

# Analyzer rules (important)

# =========================

# IDisposable handling (VERY important for GDAL/OGR)

dotnet_diagnostic.CA2000.severity = warning   # Dispose objects before losing scope
dotnet_diagnostic.CA2213.severity = warning   # Disposable fields should be disposed

# Interop / correctness

dotnet_diagnostic.CA1401.severity = warning   # P/Invoke visibility
dotnet_diagnostic.CA1416.severity = none      # Platform compatibility (noisy in cross builds)

# Globalization (optional but useful)

dotnet_diagnostic.CA1305.severity = warning   # Specify IFormatProvider

# General quality

dotnet_diagnostic.CA1508.severity = warning   # Avoid dead conditional code
dotnet_diagnostic.CA1062.severity = suggestion # Validate arguments

# Style (keep low noise)

dotnet_diagnostic.IDE0003.severity = suggestion
dotnet_diagnostic.IDE0009.severity = suggestion
dotnet_diagnostic.IDE0063.severity = none     # "using var" (disabled for Mono)

# =========================

# Generated code (SWIG)

# =========================

[**/swig/**]
generated_code = true

# Disable analyzers for generated bindings

dotnet_analyzer_diagnostic.severity = none

# =========================

# Test / sample apps (relaxed rules)

# =========================

[**/apps/**.cs]
dotnet_diagnostic.CA2000.severity = suggestion
dotnet_diagnostic.CA1305.severity = suggestion
