# top-most EditorConfig file
root = true

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

# C# code style
[*.cs]
dotnet_sort_system_directives_first = true
csharp_style_namespace_declarations = file_scoped:suggestion
csharp_prefer_primary_constructors = true:suggestion

# var preferences - Performance-focused style
# Use explicit types for built-in types (int, bool, etc.) for clarity
csharp_style_var_for_built_in_types = false:suggestion
# Use var when type is obvious from the right side
csharp_style_var_when_type_is_apparent = true:suggestion
# Use var for complex types (less verbose)
csharp_style_var_elsewhere = true:silent

csharp_new_line_before_open_brace = all
csharp_new_line_between_query_expression_clauses = true

# Code block preferences - Always use braces for safety
csharp_prefer_braces = true:suggestion
csharp_style_prefer_primary_constructors = true:suggestion

csharp_style_expression_bodied_methods = when_possible:suggestion
csharp_style_expression_bodied_properties = when_possible:suggestion
csharp_style_expression_bodied_accessors = when_possible:suggestion

csharp_style_prefer_switch_expression = true:suggestion
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
csharp_style_prefer_readonly_struct = true:suggestion
csharp_style_prefer_static_local_function = true:suggestion
csharp_prefer_simple_default_expression = true:suggestion

# Dotnet code style
[*.{cs,vb}]
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion

dotnet_style_null_propagation = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion

# Naming conventions
dotnet_naming_rule.private_fields_should_be_camel_case.symbols = private_fields
dotnet_naming_rule.private_fields_should_be_camel_case.style = camel_case

# symbol group
dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private

# style
dotnet_naming_style.camel_case.capitalization = camel_case

# ============================================================================
# ReSharper Settings - Performance Oriented
# ============================================================================

# Code block preferences - Always require braces
resharper_braces_for_ifelse = required
resharper_braces_for_for = required
resharper_braces_for_foreach = required
resharper_braces_for_while = required
resharper_braces_for_dowhile = required
resharper_braces_for_using = required
resharper_braces_for_lock = required
resharper_braces_for_fixed = required
resharper_braces_redundant = false

# Disable readability-over-performance suggestions
resharper_loop_can_be_converted_to_query_highlighting = none
resharper_foreach_can_be_converted_to_query_using_another_get_enumerator_highlighting = none
resharper_loop_can_be_partly_converted_to_query_highlighting = none
resharper_foreach_can_be_partly_converted_to_query_using_another_get_enumerator_highlighting = none
resharper_for_can_be_converted_to_foreach_highlighting = suggestion

# Enable performance warnings
resharper_possible_multiple_enumeration_highlighting = warning
resharper_multiple_enumeration_highlighting = warning
resharper_boxing_allocation_highlighting = warning
resharper_loop_can_be_converted_to_linq_highlighting = none

# Struct performance
resharper_struct_can_be_made_readonly_highlighting = suggestion
resharper_struct_member_can_be_made_read_only_highlighting = suggestion

# Collection expressions - be careful with performance
resharper_use_collection_expression_highlighting = suggestion

# Allocation-related warnings
resharper_closure_can_be_eliminated_highlighting = suggestion
resharper_foreach_on_array_highlighting = suggestion

# ============================================================================
# Hot Path Files - Extra Strict Performance Rules  
# ============================================================================

[**/TypeHelper*.cs]
resharper_for_can_be_converted_to_foreach_highlighting = none
resharper_loop_can_be_converted_to_query_highlighting = none
resharper_boxing_allocation_highlighting = warning

[**/InvokeHelper*.cs]
resharper_for_can_be_converted_to_foreach_highlighting = none
resharper_loop_can_be_converted_to_query_highlighting = none
resharper_boxing_allocation_highlighting = warning

# ============================================================================
# Test Files - More Relaxed for Readability
# ============================================================================

[**/*Tests.cs]
resharper_for_can_be_converted_to_foreach_highlighting = suggestion
resharper_loop_can_be_converted_to_query_highlighting = hint

[**/Benchmarks/*.cs]
resharper_for_can_be_converted_to_foreach_highlighting = none
resharper_loop_can_be_converted_to_query_highlighting = none
resharper_boxing_allocation_highlighting = error

# ============================================================================
# Code Analysis Rules
# ============================================================================

[*.cs]
# CA1707: Identifiers should not contain underscores - Test method names often use underscores for readability
dotnet_diagnostic.CA1707.severity = none

# CA1711: Identifiers should not have incorrect suffix - Enum<T> is intentional
dotnet_diagnostic.CA1711.severity = none

# CA1716: Identifiers should not match keywords - Enum<T> is intentional
dotnet_diagnostic.CA1716.severity = none

# CA1720: Identifier contains type name - Sometimes necessary for clarity
dotnet_diagnostic.CA1720.severity = suggestion

# CA1710: Identifiers should have correct suffix
dotnet_diagnostic.CA1710.severity = suggestion

# CA2211: Non-constant fields should not be visible - Some public fields are intentional
dotnet_diagnostic.CA2211.severity = suggestion

# CA1051: Do not declare visible instance fields
dotnet_diagnostic.CA1051.severity = suggestion

# CA1852: Seal internal types - Performance optimization for test classes
dotnet_diagnostic.CA1852.severity = suggestion

# CA1000: Do not declare static members on generic types - Sometimes necessary
dotnet_diagnostic.CA1000.severity = suggestion

# CA1822: Mark members as static - Sometimes intentional for extensibility
dotnet_diagnostic.CA1822.severity = suggestion

# CA1305: Specify IFormatProvider - Enable but as warning
dotnet_diagnostic.CA1305.severity = warning

# CA1309: Use ordinal string comparison - Enable
dotnet_diagnostic.CA1309.severity = warning

# CA1310: Specify StringComparison for correctness
dotnet_diagnostic.CA1310.severity = warning

# CA1304: Specify CultureInfo
dotnet_diagnostic.CA1304.severity = warning

# CA1311: Specify a culture or use an invariant version
dotnet_diagnostic.CA1311.severity = warning

# CA2201: Do not raise reserved exception types - Enable
dotnet_diagnostic.CA2201.severity = suggestion

# CA2208: Instantiate argument exceptions correctly
dotnet_diagnostic.CA2208.severity = suggestion

# CA1825: Avoid zero-length array allocations - Use Array.Empty<T>()
dotnet_diagnostic.CA1825.severity = suggestion

# CA1861: Avoid constant arrays as arguments
dotnet_diagnostic.CA1861.severity = suggestion

# CA1510: Use ArgumentNullException throw helper
dotnet_diagnostic.CA1510.severity = suggestion

# CA2263: Prefer generic overload when available
dotnet_diagnostic.CA2263.severity = suggestion

# CA1805: Do not initialize unnecessarily
dotnet_diagnostic.CA1805.severity = suggestion

# CA1841: Prefer Dictionary Contains methods
dotnet_diagnostic.CA1841.severity = warning

# CA1847: Use string.Contains(char) instead of string.Contains(string)
dotnet_diagnostic.CA1847.severity = warning

# CA1850: Prefer static HashData method over ComputeHash
dotnet_diagnostic.CA1850.severity = warning

# CA1854: Prefer the IDictionary.TryGetValue(TKey, out TValue) method
dotnet_diagnostic.CA1854.severity = warning

# CA1859: Use concrete types when possible for improved performance
dotnet_diagnostic.CA1859.severity = suggestion

# CA1860: Avoid using 'Enumerable.Any()' extension method
dotnet_diagnostic.CA1860.severity = suggestion

# CA1514: Avoid redundant length argument
dotnet_diagnostic.CA1514.severity = suggestion

# CA1841: Prefer Dictionary Contains methods - Already fixed line 209
dotnet_diagnostic.CA1841.severity = suggestion

# CA1847: Use string.Contains(char) instead of string.Contains(string) - Already fixed line 211
dotnet_diagnostic.CA1847.severity = suggestion

# CA1850: Prefer static HashData method over ComputeHash - Already fixed line 213
dotnet_diagnostic.CA1850.severity = suggestion

# CA1854: Prefer the IDictionary.TryGetValue(TKey, out TValue) method - Already fixed line 215
dotnet_diagnostic.CA1854.severity = suggestion

[**/*Tests.cs]
# Relax rules for test files
dotnet_diagnostic.CA1707.severity = none
dotnet_diagnostic.CA1852.severity = none
dotnet_diagnostic.CA1822.severity = none
dotnet_diagnostic.CA2201.severity = suggestion
dotnet_diagnostic.CA1305.severity = suggestion
dotnet_diagnostic.CA1861.severity = none
