1# Allow including user specific analyzers from global .editorconfig
2root = false
3
4[*.cs]
5# By default disable all analyzers
6dotnet_analyzer_diagnostic.severity = none
7
8# Whitespaces
9trim_trailing_whitespace = true
10csharp_space_after_keywords_in_control_flow_statements = false
11# Allow arbitrary number of spaces in decalrations
12csharp_space_around_declaration_statements = ignore
13
14# Indentation options
15indent_size = 4
16indent_style = space
17csharp_indent_case_contents = true
18csharp_indent_case_contents_when_block = false
19csharp_indent_switch_labels = false
20csharp_indent_block_contents = true
21csharp_indent_braces = false
22
23# New line preferences
24csharp_new_line_before_open_brace = all
25csharp_new_line_before_else = true
26csharp_new_line_before_catch = true
27csharp_new_line_before_finally = true
28csharp_new_line_before_members_in_object_initializers = true
29csharp_new_line_before_members_in_anonymous_types = true
30csharp_new_line_between_query_expression_clauses = true
31
32# Prefer "var" everywhere
33csharp_style_var_for_built_in_types = true:suggestion
34csharp_style_var_when_type_is_apparent = true:suggestion
35csharp_style_var_elsewhere = true:suggestion
36
37# Require readonly modifier
38dotnet_diagnostic.IDE0044.severity = warning
39
40# Remove unused using directives
41dotnet_diagnostic.IDE0005.severity = warning
42
43# Remove unused parameters
44dotnet_diagnostic.IDE0060.severity = warning
45
46# Sort using directives alphabetically
47dotnet_sort_system_directives_first = true
48
49# Separate using directives groups with new lines
50dotnet_separate_import_directive_groups = true
51
52# Modifiers order
53csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:warning
54
55# Class members must have explicit accessibility modifiers
56dotnet_style_require_accessibility_modifiers = always:warning
57
58# camel_case_style - Define the camelCase style
59dotnet_naming_style.camel_case_style.capitalization = camel_case
60# pascal_case_style - Define the PascalCase style
61dotnet_naming_style.pascal_case_style.capitalization = pascal_case
62# prefix_interface_with_i_style - Define interfaces style
63dotnet_naming_style.prefix_interface_with_i_style.capitalization = pascal_case
64dotnet_naming_style.prefix_interface_with_i_style.required_prefix = I
65
66# Interfaces use PascalCase and are prefixed with uppercase 'I'
67dotnet_naming_symbols.interface_group.applicable_kinds = interface
68dotnet_naming_rule.interface_rule.symbols              = interface_group
69dotnet_naming_rule.interface_rule.style                = prefix_interface_with_i_style
70dotnet_naming_rule.interface_rule.severity             = warning
71
72# All of the following must be PascalCase:
73# - Namespaces
74# - Classes and Enumerations
75# - Delegates
76# - Constructors, Properties, Events, Methods
77dotnet_naming_symbols.element_group.applicable_kinds = namespace, class, enum, struct, delegate, event, method, property
78dotnet_naming_rule.element_rule.symbols              = element_group
79dotnet_naming_rule.element_rule.style                = pascal_case_style
80dotnet_naming_rule.element_rule.severity             = warning
81
82# All constant fields must be PascalCase
83dotnet_naming_symbols.constant_fields_group.applicable_accessibilities = public, internal, protected_internal, protected, private_protected, private
84dotnet_naming_symbols.constant_fields_group.required_modifiers         = const
85dotnet_naming_symbols.constant_fields_group.applicable_kinds           = field
86dotnet_naming_rule.constant_fields_must_be_pascal_case_rule.symbols    = constant_fields_group
87dotnet_naming_rule.constant_fields_must_be_pascal_case_rule.style      = pascal_case_style
88dotnet_naming_rule.constant_fields_must_be_pascal_case_rule.severity   = warning
89
90# All non-public fields must be camelCase
91dotnet_naming_symbols.fields_group.applicable_accessibilities = public, internal, protected_internal, protected, private_protected, private
92dotnet_naming_symbols.fields_group.applicable_kinds           = field
93dotnet_naming_rule.fields_must_be_camel_case_rule.symbols     = fields_group
94dotnet_naming_rule.fields_must_be_camel_case_rule.style       = camel_case_style
95dotnet_naming_rule.fields_must_be_camel_case_rule.severity    = warning
96
97# All public fields must be PascalCase
98dotnet_naming_symbols.public_fields_group.applicable_accessibilities = public
99dotnet_naming_symbols.public_fields_group.applicable_kinds           = field
100dotnet_naming_rule.fields_must_be_camel_case_rule.symbols            = public_fields_group
101dotnet_naming_rule.fields_must_be_camel_case_rule.style              = pascal_case_style
102dotnet_naming_rule.fields_must_be_camel_case_rule.severity           = warning
103
104# Local variables must be camelCase
105dotnet_naming_symbols.local_variables_group.applicable_accessibilities  = local
106dotnet_naming_symbols.local_variables_group.applicable_kinds            = local
107dotnet_naming_rule.local_variables_must_be_camel_case_rule.symbols      = local_variables_group
108dotnet_naming_rule.local_variables_must_be_camel_case_rule.style        = camel_case_style
109dotnet_naming_rule.local_variables_must_be_camel_case_rule.severity     = warning
110
111# Function parameters use camelCase
112dotnet_naming_symbols.parameters_group.applicable_kinds = parameter
113dotnet_naming_rule.parameters_rule.symbols              = parameters_group
114dotnet_naming_rule.parameters_rule.style                = camel_case_style
115dotnet_naming_rule.parameters_rule.severity             = warning
116
117# Renode specific rules
118dotnet_diagnostic.renode_copyright.severity             = warning
119dotnet_diagnostic.renode_class_members_order.severity   = warning
120
121# Setup StyleCop analyzers
122# List of all analyzers: https://dotnetanalyzers.github.io/StyleCopAnalyzers/
123# Opening braces should not be followed by blank line
124dotnet_diagnostic.SA1505.severity = warning
125# Code should not contain multiple blank lines in a row
126dotnet_diagnostic.SA1507.severity = warning
127# Closing braces should not be preceded by blank line
128dotnet_diagnostic.SA1508.severity = warning
129# Opening braces should not be preceded by blank line
130dotnet_diagnostic.SA1509.severity = warning
131