root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

[*.{csproj,props,targets,xml,axaml,xaml,resx,config}]
indent_size = 2

[*.{json,yml,yaml,md}]
indent_size = 2

[*.cs]
# Language conventions
csharp_style_namespace_declarations = file_scoped:warning
csharp_style_prefer_primary_constructors = true:suggestion
csharp_style_prefer_top_level_statements = false:silent
csharp_using_directive_placement = outside_namespace:warning
dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = false

# License header on every C# file (IDE0073 is enforced during build).
file_header_template = SPDX-License-Identifier: GPL-3.0-or-later\nCopyright (c) CaptureImage Contributors
dotnet_diagnostic.IDE0073.severity = warning

# Style rules enforced during build (EnforceCodeStyleInBuild + TreatWarningsAsErrors).
# The ":warning" suffix on the options above is honored only by IDEs; these lines make
# the compiler report them too.
dotnet_diagnostic.IDE0161.severity = warning # file-scoped namespace
dotnet_diagnostic.IDE0065.severity = warning # using directives outside the namespace
dotnet_diagnostic.IDE0005.severity = warning # unnecessary using (needs GenerateDocumentationFile)
dotnet_diagnostic.IDE0051.severity = warning # unused private member
dotnet_diagnostic.IDE0052.severity = warning # private member assigned but never read
dotnet_diagnostic.IDE0059.severity = warning # value assigned but never used
dotnet_diagnostic.IDE0060.severity = warning # unused parameter
dotnet_code_quality_unused_parameters = non_public

# src/ builds with AnalysisMode=Recommended (src/Directory.Build.props). Rules switched off:
# CA1716 flags names that are keywords in other .NET languages (IWindowWatcher.Stop is "Stop"
# in VB); this is a C#-only app. CA1873 flags argument evaluation in log calls; the ones left
# run once per startup or per error, and LoggerMessage methods check IsEnabled themselves.
dotnet_diagnostic.CA1716.severity = none
dotnet_diagnostic.CA1873.severity = none

# Code style - var
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = true:suggestion

# New line preferences
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

# View models: XAML binds to instance properties even when they return constants.
[src/CaptureImage.ViewModels/**.cs]
dotnet_diagnostic.CA1822.severity = none
