2024-04-30 16:23:14 +03:00
# editorconfig.org
# top-most EditorConfig file
2022-04-26 18:04:27 +03:00
root = true
# All files
[*]
indent_style = space
2024-04-30 16:23:14 +03:00
insert_final_newline = true
trim_trailing_whitespace = true
# (Please don't specify an indent_size here; that has too many unintended consequences.)
2022-04-26 18:04:27 +03:00
2024-07-25 10:23:19 +03:00
vsspell_dictionary_languages = en-US
vsspell_section_id = 842f80e2d4aa4288afdcd0e42833eeaf
2024-07-29 16:06:28 +03:00
vsspell_ignored_words_842f80e2d4aa4288afdcd0e42833eeaf = runsettings|nullable|args|testhost|mutex|trx|vstest|arity|async|bool|inlined|json|jsonite|jsonrpc|localhost|readonly|xml|stylecop|indices|dotnet|lifecycle
2024-07-25 10:23:19 +03:00
# Xml localization files
[*.xlf]
vsspell_spell_check_as_you_type = false
vsspell_include_in_project_spell_check = false
vsspell_code_analyzers_enabled = false
2022-04-26 18:04:27 +03:00
# Shell scripts
[*.sh]
end_of_line = lf
[*.{cmd,bat}]
end_of_line = crlf
# Visual Studio XML project files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
indent_size = 2
2024-04-30 16:23:14 +03:00
charset = utf-8
2022-04-26 18:04:27 +03:00
# Visual Studio and .NET related XML config files
2024-04-30 16:23:14 +03:00
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct,stylecop}]
indent_size = 2
# Xml files
[*.{xml}]
2022-04-26 18:04:27 +03:00
indent_size = 2
# YAML files
[*.{yml,yaml}]
indent_size = 2
2024-04-30 16:23:14 +03:00
# JSON files
[*.json]
indent_size = 2
2022-04-26 18:04:27 +03:00
# Markdown files
[*.md]
indent_size = 2
# PowerShell scripts
[*.ps1]
indent_size = 4
# Code files
[*.{cs,csx,vb,vbx}]
2024-04-30 16:23:14 +03:00
charset = utf-8-bom
2022-04-26 18:04:27 +03:00
indent_size = 4
tab_width = 4
2022-08-30 10:31:32 +03:00
2024-04-30 16:23:14 +03:00
# Dotnet code style settings:
2022-04-26 18:04:27 +03:00
[*.{cs,vb}]
2023-12-11 22:55:26 +03:00
# Do not set end_of_line property, this is causing issues with Linux,
# see https://github.com/dotnet/roslyn/issues/55526
2022-08-30 10:31:32 +03:00
2022-04-26 18:04:27 +03:00
#### .NET Coding Conventions ####
2022-08-30 10:31:32 +03:00
2022-10-10 14:37:49 +03:00
## Organize usings
2022-08-30 10:31:32 +03:00
2022-04-26 18:04:27 +03:00
dotnet_separate_import_directive_groups = true
dotnet_sort_system_directives_first = true
2022-08-30 10:31:32 +03:00
2022-10-10 14:37:49 +03:00
## License header
2022-08-30 10:31:32 +03:00
2022-04-26 18:04:27 +03:00
file_header_template = Copyright (c) Microsoft Corporation. All rights reserved.\nLicensed under the MIT license. See LICENSE file in the project root for full license information.
2022-08-30 10:31:32 +03:00
2022-10-10 14:37:49 +03:00
## Styling conventions
2022-08-30 10:31:32 +03:00
2024-04-30 16:23:14 +03:00
# Code style defaults
2024-08-14 15:29:55 +03:00
dotnet_code_quality_unused_parameters = all:suggestion # IDE0060: Remove unused parameter
2024-04-30 16:23:14 +03:00
dotnet_style_parentheses_in_arithmetic_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
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
2024-08-14 15:29:55 +03:00
dotnet_style_readonly_field = true:warning # IDE0044: Add readonly modifier
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent # IDE0040: Add accessibility modifiers
2022-08-30 10:31:32 +03:00
2024-04-30 16:23:14 +03:00
# Expression-level preferences
dotnet_style_coalesce_expression = true:warning
2024-08-14 15:29:55 +03:00
dotnet_style_collection_initializer = true:warning # IDE0028: Use collection initializers
dotnet_style_explicit_tuple_names = true:warning # IDE0033: Use explicitly provided tuple name
2024-08-15 12:07:35 +03:00
dotnet_style_namespace_match_folder = false # IDE0130: Namespace does not match folder structure
2024-08-14 15:29:55 +03:00
dotnet_style_object_initializer = true:warning # IDE0017: Use object initializers
2022-04-26 18:04:27 +03:00
dotnet_style_operator_placement_when_wrapping = beginning_of_line
2024-08-14 15:29:55 +03:00
dotnet_style_prefer_auto_properties = true:warning # IDE0032: Use auto-implemented property
dotnet_style_prefer_compound_assignment = true:suggestion # IDE0054: Use compound assignment / IDE0074:Use coalesce compound assignment
dotnet_style_prefer_conditional_expression_over_assignment = true:warning # IDE0045: Use conditional expression for assignment
dotnet_style_prefer_conditional_expression_over_return = true:warning # IDE0046: Use conditional expression for return
dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning # IDE0037: Use inferred member name
dotnet_style_prefer_inferred_tuple_names = true:warning # IDE0037: Use inferred member name
dotnet_style_prefer_simplified_boolean_expressions = true:warning # IDE0075: Simplify conditional expression
dotnet_style_prefer_simplified_interpolation = true:suggestion # IDE0071: Simplify interpolation
# Null-checking preferences
csharp_style_conditional_delegate_call = true:warning # IDE1005: Use conditional delegate call
csharp_style_prefer_null_check_over_type_check = true:warning # IDE0150: Prefer null check over type check
csharp_style_throw_expression = true:warning # IDE0016: Use throw expression
dotnet_style_coalesce_expression = true:warning # IDE0029: Use coalesce expression (non-nullable types) / IDE0030: Use coalesce expression (nullable types)
dotnet_style_null_propagation = true:warning # IDE0031: Use null propagation
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning # IDE0041: Use 'is null' check
# Avoid this. unless absolutely necessary (IDE0003 and IDE0009)
2022-04-26 18:04:27 +03:00
dotnet_style_qualification_for_event = false:warning
dotnet_style_qualification_for_field = false:warning
dotnet_style_qualification_for_method = false:warning
dotnet_style_qualification_for_property = false:warning
2022-08-30 10:31:32 +03:00
2024-08-14 15:29:55 +03:00
# Types: use keywords instead of BCL types, and permit var only when the type is clear (IDE0049)
2024-04-30 16:23:14 +03:00
dotnet_style_predefined_type_for_locals_parameters_members = true:warning
dotnet_style_predefined_type_for_member_access = true:warning
2024-08-14 15:29:55 +03:00
dotnet_diagnostic.IDE0004.severity = warning # IDE0004: Remove unnecessary cast
dotnet_diagnostic.IDE0005.severity = warning # IDE0005: Remove unnecessary using directives
dotnet_diagnostic.IDE0011.severity = warning # IDE0011: Add braces
dotnet_diagnostic.IDE0017.severity = warning # IDE0017: Simplify object initialization
dotnet_diagnostic.IDE0018.severity = warning # IDE0018: Inline variable declaration
dotnet_diagnostic.IDE0019.severity = warning # IDE0019: Use pattern matching to avoid 'as' followed by a 'null' check
dotnet_diagnostic.IDE0020.severity = warning # IDE0020: IDE0038: Use pattern matching to avoid 'is' check followed by a cast
dotnet_diagnostic.IDE0028.severity = warning # IDE0028: Simplify collection initialization
dotnet_diagnostic.IDE0031.severity = warning # IDE0031: Use null propagation
dotnet_style_null_propagation = true:warning # IDE0031: Use null propagation
dotnet_diagnostic.IDE0032.severity = warning # IDE0032: Use auto-implemented property
dotnet_diagnostic.IDE0034.severity = warning # IDE0034: Simplify 'default' expression
dotnet_diagnostic.IDE0035.severity = warning # IDE0035: Remove unreachable code
dotnet_diagnostic.IDE0036.severity = warning # IDE0036: Order modifiers
dotnet_diagnostic.IDE0039.severity = warning # IDE0039: Use local function instead of lambda
dotnet_diagnostic.IDE0040.severity = warning # IDE0040: Add accessibility modifiers
dotnet_diagnostic.IDE0041.severity = warning # IDE0041: Use 'is null' check
dotnet_diagnostic.IDE0043.severity = warning # IDE0043: Format string contains invalid placeholder
dotnet_diagnostic.IDE0044.severity = warning # IDE0044: Make field readonly
dotnet_diagnostic.IDE0045.severity = warning # IDE0045: Use conditional expression for assignment
dotnet_diagnostic.IDE0046.severity = warning # IDE0046: Use conditional expression for return
dotnet_diagnostic.IDE0047.severity = warning # IDE0047: Parentheses preferences
dotnet_diagnostic.IDE0048.severity = warning # IDE0048: Parentheses preferences
dotnet_diagnostic.IDE0051.severity = warning # IDE0051: Remove unused private member
dotnet_diagnostic.IDE0052.severity = warning # IDE0052: Remove unread private member
dotnet_diagnostic.IDE0054.severity = warning # IDE0054: Use compound assignment
dotnet_diagnostic.IDE0055.severity = warning # IDE0055: Fix formatting
dotnet_diagnostic.IDE0056.severity = suggestion # IDE0056: Use index operator
dotnet_diagnostic.IDE0057.severity = suggestion # IDE0057: Use range operator
dotnet_diagnostic.IDE0059.severity = warning # IDE0059: Unnecessary assignment to a value
dotnet_diagnostic.IDE0060.severity = warning # IDE0060: Remove unused parameter
dotnet_diagnostic.IDE0062.severity = warning # IDE0062: Make local function static
dotnet_diagnostic.IDE0063.severity = warning # IDE0063: Use simple 'using' statement
dotnet_diagnostic.IDE0065.severity = warning # IDE0065: 'using' directive placement
dotnet_diagnostic.IDE0066.severity = warning # IDE0066: Use switch expression
dotnet_diagnostic.IDE0071.severity = warning # IDE0071: Simplify interpolation
dotnet_diagnostic.IDE0073.severity = warning # IDE0073: File header
dotnet_diagnostic.IDE0074.severity = warning # IDE0074: Use coalesce compound assignment
dotnet_diagnostic.IDE0075.severity = warning # IDE0075: Simplify conditional expression
dotnet_diagnostic.IDE0078.severity = warning # IDE0078: Use pattern matching
dotnet_diagnostic.IDE0082.severity = warning # IDE0082: Convert typeof to nameof
dotnet_diagnostic.IDE0083.severity = warning # IDE0083: Use pattern matching (not operator)
dotnet_diagnostic.IDE0090.severity = warning # IDE0090: Use 'new(...)'
dotnet_diagnostic.IDE0100.severity = warning # IDE0100: Remove unnecessary equality operator
dotnet_diagnostic.IDE0120.severity = warning # IDE0120: Simplify LINQ expression
dotnet_diagnostic.IDE0150.severity = warning # IDE0150: Prefer 'null' check over type check
dotnet_diagnostic.IDE0161.severity = warning # IDE0160: IDE0161: Namespace declaration preferences
dotnet_diagnostic.IDE0170.severity = warning # IDE0170: Prefer extended property pattern
dotnet_diagnostic.IDE0220.severity = warning # IDE0220: Add explicit cast
dotnet_diagnostic.IDE0240.severity = warning # IDE0240: Remove redundant nullable directive
dotnet_diagnostic.IDE0241.severity = warning # IDE0241: Remove unnecessary nullable directive
dotnet_diagnostic.IDE0250.severity = warning # IDE0250: Struct can be made 'readonly'
dotnet_diagnostic.IDE0251.severity = warning # IDE0251: Member can be made 'readonly'
dotnet_diagnostic.IDE0260.severity = warning # IDE0260: Use pattern matching
dotnet_diagnostic.IDE0270.severity = warning # IDE0270: Use coalesce expression
dotnet_diagnostic.IDE0280.severity = warning # IDE0280: Use 'nameof'
dotnet_diagnostic.IDE1005.severity = warning # IDE1005: Use conditional delegate call
dotnet_diagnostic.IDE1006.severity = warning # IDE1006: Naming rule violation
dotnet_diagnostic.IDE2000.severity = warning # IDE2000: Avoid multiple blank lines
2023-11-29 09:42:33 +03:00
dotnet_diagnostic.IDE2002.severity = warning
dotnet_diagnostic.IDE2003.severity = warning
dotnet_diagnostic.IDE2004.severity = warning
dotnet_diagnostic.IDE2005.severity = warning
dotnet_diagnostic.IDE2006.severity = warning
2022-09-07 10:57:09 +03:00
2024-08-14 15:29:55 +03:00
dotnet_diagnostic.CA1000.severity = warning # CA1000: Do not declare static members on generic types
dotnet_diagnostic.CA1001.severity = warning # CA1001: Types that own disposable fields should be disposable
dotnet_diagnostic.CA1010.severity = warning # CA1010: Collections should implement generic interface
dotnet_diagnostic.CA1012.severity = warning # CA1012: Abstract types should not have public constructors
dotnet_diagnostic.CA1304.severity = warning # CA1304: Specify CultureInfo
dotnet_diagnostic.CA1305.severity = warning # CA1305: Specify IFormatProvider
dotnet_diagnostic.CA1309.severity = warning # CA1309: Use ordinal StringComparison
dotnet_diagnostic.CA1310.severity = warning # CA1310: Specify StringComparison for correctness
dotnet_diagnostic.CA1311.severity = warning # CA1311: Specify a culture or use an invariant version
dotnet_diagnostic.CA1507.severity = warning # CA1507: Use nameof in place of string
dotnet_diagnostic.CA1510.severity = none # CA1510: Use ArgumentNullException throw helper
dotnet_diagnostic.CA1708.severity = warning # CA1708: Identifiers should differ by more than case
dotnet_diagnostic.CA1710.severity = warning # CA1710: Identifiers should have correct suffix
dotnet_diagnostic.CA1711.severity = warning # CA1711: Identifiers should not have incorrect suffix
dotnet_diagnostic.CA1712.severity = warning # CA1712: Do not prefix enum values with type name
dotnet_diagnostic.CA1725.severity = warning # CA1725: Parameter names should match base declaration
dotnet_diagnostic.CA1805.severity = warning # CA1805: Do not initialize unnecessarily
dotnet_diagnostic.CA1806.severity = warning # CA1806: Do not ignore method results
dotnet_diagnostic.CA1829.severity = warning # CA1829: Use Length/Count property instead of Count() when available
dotnet_diagnostic.CA1825.severity = warning # CA1825: Avoid zero-length array allocations
dotnet_diagnostic.CA1827.severity = warning # CA1827: Do not use Count() or LongCount() when Any() can be used
dotnet_diagnostic.CA1836.severity = warning # CA1836: Prefer IsEmpty over Count
dotnet_diagnostic.CA1840.severity = warning # CA1840: Use 'Environment.CurrentManagedThreadId'
dotnet_diagnostic.CA1852.severity = warning # CA1852: Seal internal types
dotnet_diagnostic.CA1854.severity = warning # CA1854: Prefer the 'IDictionary.TryGetValue(TKey, out TValue)' method
2023-11-22 16:51:02 +03:00
# Disabled as it's making the code complex to deal with when multi targeting
2024-08-14 15:29:55 +03:00
dotnet_diagnostic.CA1863.severity = none # CA1863: Use 'CompositeFormat'
dotnet_diagnostic.CA2016.severity = warning # CA2016: Forward the 'CancellationToken' parameter to methods
dotnet_diagnostic.CA2208.severity = warning # CA2208: Instantiate argument exceptions correctly
dotnet_diagnostic.CA2211.severity = warning # CA2211: Non-constant fields should not be visible
dotnet_diagnostic.CA2215.severity = warning # CA2215: Dispose methods should call base class dispose
dotnet_diagnostic.CA2219.severity = warning # CA2219: Do not raise exceptions in finally clauses
dotnet_diagnostic.CA2241.severity = warning # CA2241: Provide correct arguments to formatting methods
dotnet_diagnostic.CA2242.severity = warning # CA2242: Test for NaN correctly
dotnet_diagnostic.CA2244.severity = warning # CA2244: Do not duplicate indexed element initializations
dotnet_diagnostic.CA2245.severity = warning # CA2245: Do not assign a property to itself
dotnet_diagnostic.CA2248.severity = warning # CA2248: Provide correct enum argument to Enum.HasFlag
dotnet_public_api_analyzer.require_api_files = true # RS0016: Only enable if API files are present
dotnet_diagnostic.RS0041.severity = none # RS0041: Do not use 'Obsolete' attribute
# Disabled due to bug https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3687
dotnet_diagnostic.SA1010.severity = none # SA1010: Opening square brackets should be spaced correctly
dotnet_diagnostic.SA1101.severity = none # SA1101: Prefix local calls with this
dotnet_diagnostic.SA1115.severity = none # SA1115: Parameter should follow comma
dotnet_diagnostic.SA1117.severity = none # SA1117: Parameters should be on same line or separate lines
dotnet_diagnostic.SA1118.severity = none # SA1118: Parameter should not span multiple lines
dotnet_diagnostic.SA1124.severity = none # SA1124: Do not use regions
dotnet_diagnostic.SA1201.severity = none # SA1201: Elements should appear in the correct order
dotnet_diagnostic.SA1202.severity = none # SA1202: Elements should be ordered by access
dotnet_diagnostic.SA1204.severity = none # SA1204: Static elements should appear before instance elements
dotnet_diagnostic.SA1308.severity = none # SA1308: Variable names should not be prefixed
dotnet_diagnostic.SA1309.severity = none # SA1309: Field names should not begin with underscore
dotnet_diagnostic.SA1313.severity = none # SA1313: Parameter names should begin with lower-case letter
dotnet_diagnostic.SA1402.severity = none # SA1402: File may only contain a single type
dotnet_diagnostic.SA1515.severity = none # SA1515: Single-line comment should be preceded by blank line
dotnet_diagnostic.SA1611.severity = none # SA1611: Element parameters should be documented
dotnet_diagnostic.SA1615.severity = none # SA1615: Element return value should be documented
dotnet_diagnostic.SA1649.severity = none # SA1649: File name should match first type name
# -----------------------------------------------------------------------------------------
2022-10-10 14:37:49 +03:00
# Globally disabled but enabled for src folder
2024-08-14 15:29:55 +03:00
dotnet_diagnostic.SA1600.severity = none # SA1600: Elements should be documented
dotnet_diagnostic.SA1601.severity = none # SA1601: Partial elements should be documented
# -----------------------------------------------------------------------------------------
2023-11-10 16:35:40 +03:00
2024-08-14 15:29:55 +03:00
dotnet_diagnostic.VSTHRD002.severity = none # VSTHRD002 Avoid problematic synchronous waits
dotnet_diagnostic.VSTHRD003.severity = none # VSTHRD003: Avoid awaiting foreign Tasks
dotnet_diagnostic.VSTHRD105.severity = none # VSTHRD105: Avoid method overloads that assume TaskScheduler.Current
2023-11-10 16:35:40 +03:00
2022-08-30 10:31:32 +03:00
#### Naming styles ####
2022-10-10 14:37:49 +03:00
## Naming rules (define naming rule using dotnet_naming_rule.<rule_name>.<option>)
2022-08-30 10:31:32 +03:00
2022-04-26 18:04:27 +03:00
dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
2022-08-30 10:31:32 +03:00
2022-04-26 18:04:27 +03:00
dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
2022-08-30 10:31:32 +03:00
2022-04-26 18:04:27 +03:00
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
2022-08-30 10:31:32 +03:00
2022-04-26 18:04:27 +03:00
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = warning
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case
2022-08-30 11:02:45 +03:00
2022-04-26 18:04:27 +03:00
dotnet_naming_rule.static_readonly_fields_should_be_pascal_case.severity = warning
dotnet_naming_rule.static_readonly_fields_should_be_pascal_case.symbols = static_readonly_fields
dotnet_naming_rule.static_readonly_fields_should_be_pascal_case.style = pascal_case
2022-08-30 11:02:45 +03:00
2022-04-26 18:04:27 +03:00
dotnet_naming_rule.private_static_fields_should_be_s_underscore_camel_case.severity = warning
dotnet_naming_rule.private_static_fields_should_be_s_underscore_camel_case.symbols = private_static_fields
dotnet_naming_rule.private_static_fields_should_be_s_underscore_camel_case.style = s_underscore_camel_case
2022-08-30 11:02:45 +03:00
2022-04-26 18:04:27 +03:00
dotnet_naming_rule.private_fields_should_be_underscore_camel_case.severity = warning
dotnet_naming_rule.private_fields_should_be_underscore_camel_case.symbols = private_fields
dotnet_naming_rule.private_fields_should_be_underscore_camel_case.style = underscore_camel_case
2022-08-30 11:02:45 +03:00
2022-10-10 14:37:49 +03:00
## Symbol specifications (define symbol groups using dotnet_naming_symbols.<group_name>.<options>)
2022-08-30 10:31:32 +03:00
2022-04-26 18:04:27 +03:00
dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
2022-08-30 10:31:32 +03:00
2022-04-26 18:04:27 +03:00
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
2022-08-30 10:31:32 +03:00
2022-04-26 18:04:27 +03:00
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
2022-08-30 10:31:32 +03:00
2022-04-26 18:04:27 +03:00
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.constant_fields.required_modifiers = const
2022-08-30 11:02:45 +03:00
2022-04-26 18:04:27 +03:00
dotnet_naming_symbols.static_readonly_fields.applicable_kinds = field
dotnet_naming_symbols.static_readonly_fields.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.static_readonly_fields.required_modifiers = readonly, static
2022-08-30 11:02:45 +03:00
2022-04-26 18:04:27 +03:00
dotnet_naming_symbols.private_static_fields.applicable_kinds = field
dotnet_naming_symbols.private_static_fields.applicable_accessibilities = private
dotnet_naming_symbols.private_static_fields.required_modifiers = static
2022-08-30 11:02:45 +03:00
2022-04-26 18:04:27 +03:00
dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private
2022-08-30 11:02:45 +03:00
2022-10-10 14:37:49 +03:00
## Naming styles (define naming style using dotnet_naming_style.<style_name>.<option>)
2022-08-30 10:31:32 +03:00
2022-04-26 18:04:27 +03:00
dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case
2022-08-30 10:31:32 +03:00
2022-04-26 18:04:27 +03:00
dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
2022-08-30 11:02:45 +03:00
2022-04-26 18:04:27 +03:00
dotnet_naming_style.underscore_camel_case.required_prefix = _
dotnet_naming_style.underscore_camel_case.required_suffix =
dotnet_naming_style.underscore_camel_case.word_separator =
dotnet_naming_style.underscore_camel_case.capitalization = camel_case
2022-08-30 11:02:45 +03:00
2022-04-26 18:04:27 +03:00
dotnet_naming_style.s_underscore_camel_case.required_prefix = s_
dotnet_naming_style.s_underscore_camel_case.required_suffix =
dotnet_naming_style.s_underscore_camel_case.word_separator =
dotnet_naming_style.s_underscore_camel_case.capitalization = camel_case
2024-04-30 16:23:14 +03:00
#### C# Coding Conventions ####
2024-08-14 15:29:55 +03:00
# Code block preferences
csharp_prefer_braces = true:silent # IDE0011: Add braces
csharp_prefer_simple_using_statement = true:warning # IDE0063: Use simple using statement
2024-04-30 16:23:14 +03:00
2024-08-14 15:29:55 +03:00
# Wrap options
csharp_preserve_single_line_blocks = true:none
csharp_preserve_single_line_statements = false:none
2024-04-30 16:23:14 +03:00
# Code style defaults
csharp_indent_labels = one_less_than_current
2024-08-14 15:29:55 +03:00
csharp_prefer_static_local_function = true:warning # IDE0062: Make local function static
csharp_style_deconstructed_variable_declaration = true:suggestion # IDE0042: Deconstruct variable declaration
csharp_style_implicit_object_creation_when_type_is_apparent = true:warning # IDE0090: Simplify new expression
csharp_style_namespace_declarations = file_scoped:warning # IDE0160: Use block-scoped namespace / IDE0161: Use file-scoped namespace
2024-04-30 16:23:14 +03:00
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_null_check_over_type_check = true:warning
2024-08-14 15:29:55 +03:00
csharp_style_prefer_readonly_struct = true:suggestion # IDE0250: Struct can be made 'readonly'
csharp_style_prefer_readonly_struct_member = true:suggestion # IDE0251: Member can be made 'readonly'
csharp_style_prefer_switch_expression = true:warning # IDE0066
2024-04-30 16:23:14 +03:00
csharp_style_prefer_top_level_statements = true:silent
2024-08-14 15:29:55 +03:00
csharp_style_prefer_tuple_swap = true:suggestion # IDE0180: Use tuple to swap values
csharp_style_prefer_utf8_string_literals = true:suggestion # IDE0230: Use UTF-8 string literal
csharp_style_unused_value_assignment_preference = discard_variable:suggestion # IDE0059: Remove unnecessary value assignment
csharp_style_unused_value_expression_statement_preference = discard_variable:silent # IDE0058: Remove unnecessary expression value
csharp_style_prefer_primary_constructors = false # IDE0290: Use primary constructor
dotnet_style_prefer_collection_expression = false # IDE0300: Simplify collection initialization
csharp_using_directive_placement = outside_namespace:warning # IDE0065: using directive placement
2024-04-30 16:23:14 +03:00
# Indentation preferences
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = true
csharp_indent_switch_labels = true
# roslyn uses flush_left
csharp_indent_labels = one_less_than_current
# Expression-bodied members
2024-08-14 15:29:55 +03:00
csharp_style_expression_bodied_constructors = true:silent # IDE0021: Use expression body for constructors
csharp_style_expression_bodied_methods = true:warning # IDE0022: Use expression body for methods
csharp_style_expression_bodied_operators = true:warning # IDE0023: Use expression body for conversion operators / IDE0024: Use expression body for operators
csharp_style_expression_bodied_properties = true:warning # IDE0025: Use expression body for properties
csharp_style_expression_bodied_indexers = true:warning # IDE0026: Use expression body for indexers
csharp_style_expression_bodied_accessors = true:warning # IDE0027: Use expression body for accessors
csharp_style_expression_bodied_lambdas = true:warning # IDE0053: Use expression body for lambdas
csharp_style_expression_bodied_local_functions = true:warning # IDE0061: Use expression body for local functions
2024-04-30 16:23:14 +03:00
# Expression-level preferences
2024-08-14 15:29:55 +03:00
csharp_prefer_simple_default_expression = true:warning # IDE0034: Simplify default expression
2024-04-30 16:23:14 +03:00
# Pattern matching
2024-08-14 15:29:55 +03:00
csharp_style_prefer_pattern_matching = true:silent # IDE0078: Use pattern matching
csharp_style_inlined_variable_declaration = true:warning # IDE0018: Inline variable declaration
csharp_style_pattern_matching_over_as_with_null_check = true:warning # IDE0019: Use pattern matching to avoid as followed by a null check
csharp_style_pattern_matching_over_is_with_cast_check = true:warning # IDE0020: Use pattern matching to avoid is check followed by a cast (with variable) / IDE0038: Use pattern matching to avoid is check followed by a cast (without variable)
csharp_style_prefer_switch_expression = true:warning # IDE0066: Use switch expression
csharp_style_prefer_pattern_matching = true:warning # IDE0078: Use pattern matching
csharp_style_prefer_not_pattern = true:warning # IDE0083: Use pattern matching (not operator)
csharp_style_prefer_extended_property_pattern = true:warning # IDE0170: Simplify property pattern
2024-04-30 16:23:14 +03:00
# Space preferences
csharp_space_after_cast = false
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_after_comma = true
csharp_space_after_dot = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_after_semicolon_in_for_statement = true
csharp_space_around_binary_operators = before_and_after
csharp_space_around_declaration_statements = do_not_ignore
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_before_comma = false
csharp_space_before_dot = false
csharp_space_before_open_square_brackets = false
csharp_space_before_semicolon_in_for_statement = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_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_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false
# New line preferences
csharp_new_line_before_catch = true
csharp_new_line_before_else = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_open_brace = all
csharp_new_line_between_query_expression_clauses = true
# Types: use keywords instead of BCL types, and permit var only when the type is clear
2024-08-14 15:29:55 +03:00
csharp_style_var_for_built_in_types = false:warning # IDE0007: Use var instead of explicit type / IDE0008: Use explicit type instead of var
csharp_style_var_when_type_is_apparent = true:warning # IDE0007: Use var instead of explicit type / IDE0008: Use explicit type instead of var
csharp_style_var_elsewhere = false:warning # IDE0007: Use var instead of explicit type / IDE0008: Use explicit type instead of var
2024-04-30 16:23:14 +03:00
# Modifiers order
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:warning
# Other features
2024-08-14 15:29:55 +03:00
csharp_style_pattern_local_over_anonymous_function = false:none # IDE0039: Use local function instead of lambda
csharp_style_prefer_index_operator = true:warning # IDE0056: Use index operator
csharp_style_prefer_range_operator = true:warning # IDE0057: Use range operator
2024-04-30 16:23:14 +03:00
2024-08-14 15:29:55 +03:00
# Experimental features
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent
csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true:silent
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false:warning
csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent
dotnet_style_allow_multiple_blank_lines_experimental = false:warning
dotnet_style_allow_statement_immediately_after_block_experimental = false:warning
2024-04-30 16:23:14 +03:00
# IDE0290: Use primary constructor
csharp_style_prefer_primary_constructors = false