The .editorconfig file provided in this repo contains opinionated settings. Feel free to use as is or update to your liking.
For descriptions and examples of the rules in the editor config, see below
(Includes Table of Content)
- 1. indent_size
- 2. indent_style
- 3. tab_width
- 4. end_of_line
- 5. insert_final_newline
- 6. dotnet_separate_import_directive_groups
- 7. dotnet_sort_system_directives_first
- 8. file_header_template
- 9. dotnet_style_qualification_for_event
- 10. dotnet_style_qualification_for_field
- 11. dotnet_style_qualification_for_method
- 12. dotnet_style_qualification_for_property
- 13. dotnet_style_predefined_type_for_locals_parameters_members
- 14. dotnet_style_predefined_type_for_member_access
- 15. dotnet_style_parentheses_in_arithmetic_binary_operators
- 16. dotnet_style_parentheses_in_other_binary_operators
- 17. dotnet_style_parentheses_in_other_operators
- 18. dotnet_style_parentheses_in_relational_binary_operators
- 19. dotnet_style_require_accessibility_modifiers
- 20. dotnet_style_coalesce_expression
- 21. dotnet_style_collection_initializer
- 22. dotnet_style_explicit_tuple_names
- 23. dotnet_style_namespace_match_folder
- 24. dotnet_style_null_propagation
- 25. dotnet_style_object_initializer
- 26. dotnet_style_operator_placement_when_wrapping
- 27. dotnet_style_prefer_auto_properties
- 28. dotnet_style_prefer_collection_expression
- 29. dotnet_style_prefer_compound_assignment
- 30. dotnet_style_prefer_conditional_expression_over_assignment
- 31. dotnet_style_prefer_conditional_expression_over_return
- 32. dotnet_style_prefer_foreach_explicit_cast_in_source
- 33. dotnet_style_prefer_inferred_anonymous_type_member_names
- 34. dotnet_style_prefer_inferred_tuple_names
- 35. dotnet_style_prefer_is_null_check_over_reference_equality_method
- 36. dotnet_style_prefer_simplified_boolean_expressions
- 37. dotnet_style_prefer_simplified_interpolation
- 38. dotnet_style_readonly_field
- 39. dotnet_code_quality_unused_parameters
- 40. dotnet_remove_unnecessary_suppression_exclusions
- 41. dotnet_style_allow_multiple_blank_lines_experimental
- 42. dotnet_style_allow_statement_immediately_after_block_experimental
- 43. csharp_style_var_elsewhere
- 44. csharp_style_var_for_built_in_types
- 45. csharp_style_var_when_type_is_apparent
- 46. csharp_style_expression_bodied_accessors
- 47. csharp_style_expression_bodied_constructors
- 48. csharp_style_expression_bodied_indexers
- 49. csharp_style_expression_bodied_lambdas
- 50. csharp_style_expression_bodied_local_functions
- 51. csharp_style_expression_bodied_methods
- 52. csharp_style_expression_bodied_operators
- 53. csharp_style_expression_bodied_properties
- 54. csharp_style_pattern_matching_over_as_with_null_check
- 55. csharp_style_pattern_matching_over_is_with_cast_check
- 56. csharp_style_prefer_extended_property_pattern
- 57. csharp_style_prefer_not_pattern
- 58. csharp_style_prefer_pattern_matching
- 59. csharp_style_prefer_switch_expression
- 60. csharp_style_conditional_delegate_call
- 61. csharp_prefer_static_anonymous_function
- 62. csharp_prefer_static_local_function
- 63. csharp_preferred_modifier_order
- 64. csharp_style_prefer_readonly_struct
- 65. csharp_style_prefer_readonly_struct_member
- 66. csharp_prefer_braces
- 67. csharp_prefer_simple_using_statement
- 68. csharp_style_namespace_declarations
- 69. csharp_style_prefer_method_group_conversion
- 70. csharp_style_prefer_primary_constructors
- 71. csharp_style_prefer_top_level_statements
- 72. csharp_prefer_simple_default_expression
- 73. csharp_style_deconstructed_variable_declaration
- 74. csharp_style_implicit_object_creation_when_type_is_apparent
- 75. csharp_style_inlined_variable_declaration
- 76. csharp_style_prefer_index_operator
- 77. csharp_style_prefer_local_over_anonymous_function
- 78. csharp_style_prefer_null_check_over_type_check
- 79. csharp_style_prefer_range_operator
- 80. csharp_style_prefer_tuple_swap
- 81. csharp_style_prefer_utf8_string_literals
- 82. csharp_style_throw_expression
- 83. csharp_style_unused_value_assignment_preference
- 84. csharp_style_unused_value_expression_statement_preference
- 85. csharp_using_directive_placement
- 86. csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental
- 87. csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental
- 88. csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental
- 89. csharp_style_allow_blank_lines_between_consecutive_braces_experimental
- 90. csharp_style_allow_embedded_statements_on_same_line_experimental
- 91. csharp_new_line_before_catch
- 92. csharp_new_line_before_else
- 93. csharp_new_line_before_finally
- 94. csharp_new_line_before_members_in_anonymous_types
- 95. csharp_new_line_before_members_in_object_initializers
- 96. csharp_new_line_before_open_brace
- 97. csharp_new_line_between_query_expression_clauses
- 98. csharp_indent_block_contents
- 99. csharp_indent_braces
- 100. csharp_indent_case_contents
- 101. csharp_indent_case_contents_when_block
- 102. csharp_indent_labels
- 103. csharp_indent_switch_labels
- 104. csharp_space_after_cast
- 105. csharp_space_after_colon_in_inheritance_clause
- 106. csharp_space_after_comma
- 107. csharp_space_after_dot
- 108. csharp_space_after_keywords_in_control_flow_statements
- 109. csharp_space_after_semicolon_in_for_statement
- 110. csharp_space_around_binary_operators
- 111. csharp_space_around_declaration_statements
- 112. csharp_space_before_colon_in_inheritance_clause
- 113. csharp_space_before_comma
- 114. csharp_space_before_dot
- 115. csharp_space_before_open_square_brackets
- 116. csharp_space_before_semicolon_in_for_statement
- 117. csharp_space_between_empty_square_brackets
- 118. csharp_space_between_method_call_empty_parameter_list_parentheses
- 119. csharp_space_between_method_call_name_and_opening_parenthesis
- 120. csharp_space_between_method_call_parameter_list_parentheses
- 121. csharp_space_between_method_declaration_empty_parameter_list_parentheses
- 122. csharp_space_between_method_declaration_name_and_open_parenthesis
- 123. csharp_space_between_method_declaration_parameter_list_parentheses
- 124. csharp_space_between_parentheses
- 125. csharp_space_between_square_brackets
- 126. csharp_preserve_single_line_blocks
- 127. csharp_preserve_single_line_statements
- 128. dotnet_naming_rule.interface_should_be_begins_with_i
- 129. dotnet_naming_rule.types_should_be_pascal_case
- 130. dotnet_naming_rule.non_field_members_should_be_pascal_case
- 131. trim_trailing_whitespace
- 132. dotnet_diagnostic.IDE0005.severity
- 133. dotnet_diagnostic.IDE1006.severity
- 134. dotnet_diagnostic.CS8019.severity
- 135. dotnet_diagnostic.IDE0079.severity
- 136. dotnet_diagnostic.IDE0130.severity
- 137. dotnet_diagnostic.CS1591.severity
- 138. csharp_prefer_system_threading_lock
Description: Defines the number of spaces used for each indentation level.
Description: Defines whether to use spaces or tabs for indentation.
Description: Sets the number of columns used to represent a tab character if indent_style=tab
.
Description: Sets the line ending character(s) to use (e.g., crlf
for Windows).
Description: Specifies whether to ensure the file ends with a newline.
Description: Controls whether using directives are separated into groups by blank lines.
Description: Enforces whether 'System' namespaces come first in usings.
Description: Controls the file header text inserted in new files.
Description: Enforces use of this.
qualifier for events.
Examples
When True
this.eventHandler?.Invoke(this, EventArgs.Empty);
When False
eventHandler?.Invoke(this, EventArgs.Empty);
Description: Enforces use of this.
qualifier for fields.
Examples
When True
this.myField = 10;
When False
myField = 10;
Description: Enforces use of this.
qualifier for methods.
Examples
When True
this.DoSomething();
When False
DoSomething();
Description: Enforces use of this.
qualifier for properties.
Examples
When True
this.MyProperty = 5;
When False
MyProperty = 5;
Description: Prefers language keywords (e.g., int
) over BCL types (e.g., Int32
).
Examples
When True
int x = 0;
When False
Int32 x = 0;
Description: Prefers language keywords when accessing static members.
Examples
When True
string.Empty;
When False
String.Empty;
Description: Enforces parentheses around arithmetic expressions for clarity.
Examples
Option 1
(a + b) * c;
Option 2
a + b * c;
Description: Enforces parentheses for non-arithmetic binary operators.
Examples
Option 1
(x & y) == 0;
Option 2
x & y == 0;
Description: Controls parentheses usage for cast/unary operators.
Examples
Option 1
(int)x + 1;
Option 2
(int)x + (1);
Description: Enforces parentheses around relational operators.
Examples
Option 1
(a < b) == true;
Option 2
a < b == true;
Description: Enforces accessibility keywords on members.
Examples
When True
public void MyMethod() { }
When False
void MyMethod() { }
Description: Prefers ??
operator over conditional expressions for null checks.
Examples
When True
var result = value ?? "default";
When False
var result = value != null ? value : "default";
Description: Enforces using collection initializers.
Examples
When True
var list = new List<int> { 1, 2, 3 };
When False
var list = new List<int>();
list.Add(1);
list.Add(2);
list.Add(3);
Description: Ensures tuple elements have explicit names.
Examples
When True
(int Id, string Name) person = (1, "John");
When False
(int, string) person = (1, "John");
Description: Enforces that namespaces match the folder structure.
Examples
When True
// File: MyProject/Utilities/Logger.cs
namespace MyProject.Utilities;
When False
// File: MyProject/Utilities/Logger.cs
namespace SomeRandomName;
Description: Prefers ?.
operator over explicit null checks.
Examples
When True
var length = str?.Length;
When False
var length = str == null ? 0 : str.Length;
Description: Enforces using object initializers.
Examples
When True
var person = new Person { Name = "Alice", Age = 30 };
When False
var person = new Person();
person.Name = "Alice";
person.Age = 30;
Description: Sets operator placement when wrapping lines.
Examples
Option 1 (beginning_of_line):
var sum = a
+ b
+ c;
Option 2 (end_of_line):
var sum = a +
b +
c;
Description: Prefers auto-properties over explicit backing fields.
Examples
When True
public int Age { get; set; }
When False
private int _age;
public int Age { get => _age; set => _age = value; }
Description: Prefers collection expressions (e.g., [1, 2, 3]
).
Examples
Option 1
var list = [1, 2, 3];
Option 2
var list = new List<int> { 1, 2, 3 };
Description: Prefers compound assignment operators (e.g., +=
).
Examples
When True
x += 1;
When False
x = x + 1;
Description: Prefers conditional expressions over if
statements for assignments.
Examples
When True
var result = condition ? "Yes" : "No";
When False
string result;
if (condition) result = "Yes";
else result = "No";
Description: Prefers conditional expressions over if
statements for returns.
Examples
When True
return condition ? "Yes" : "No";
When False
if (condition) return "Yes";
return "No";
Description: Prefers explicit casting in foreach
loops when types are known.
Examples
Option 1
foreach (string x in collectionOfObjects) { }
Option 2
foreach (var x in collectionOfObjects.Cast<string>()) { }
Description: Omits redundant property names in anonymous types.
Examples
When True
var anon = new { FirstName, LastName };
When False
var anon = new { FirstName = FirstName, LastName = LastName };
Description: Omits redundant tuple element names.
Examples
When True
var person = (firstName, lastName);
When False
var person = (firstName: firstName, lastName: lastName);
Description: Prefers is null
over ReferenceEquals(obj, null)
.
Examples
When True
if (obj is null) { }
When False
if (ReferenceEquals(obj, null)) { }
Description: Prefers simplified boolean expressions.
Examples
When True
if (flag) { }
When False
if (flag == true) { }
Description: Prefers simplified string interpolation.
Examples
When True
$"Hello {name}";
When False
$"Hello {name.ToString()}";
Description: Enforces readonly
for immutable fields.
Examples
When True
private readonly int _count = 0;
When False
private int _count = 0;
Description: Configures how unused parameters are handled.
Examples
Option 1 (align with interface):
void IInterface.Method(int unused) { }
Option 2 (warning):
void Method(int unused) { } // Warning
Description: Controls which suppressions are considered unnecessary.
Description: Controls whether multiple consecutive blank lines are allowed.
Description: Controls whether statements can follow closing braces on the same line.
Examples
When True
if (condition)
{
DoSomething();
} DoSomethingElse();
When False
if (condition)
{
DoSomething();
}
DoSomethingElse();
Description: Controls var
usage for non-built-in types.
Examples
When True
int x = 0;
When False
var x = 0;
Description: Enforces var
for built-in types.
Examples
When True
var x = 0;
When False
int x = 0;
Description: Enforces var
when the type is obvious.
Examples
When True
var stream = new MemoryStream();
When False
MemoryStream stream = new MemoryStream();
Description: Enforces expression-bodied syntax for property accessors.
Examples
When True
public int Age => _age;
When False
public int Age { get { return _age; } }
Description: Enforces expression-bodied syntax for constructors.
Examples
When True
public Person() => Name = "Unknown";
When False
public Person()
{
Name = "Unknown";
}
Description: Enforces expression-bodied syntax for indexers.
Examples
When True
public int this[int index] => _items[index];
When False
public int this[int index]
{
get { return _items[index]; }
}
Description: Enforces expression-bodied syntax for lambdas.
Examples
When True
var func = x => x * 2;
When False
var func = x =>
{
return x * 2;
};
Description: Enforces expression-bodied syntax for local functions.
Examples
When True
int Sum(int a, int b) => a + b;
When False
int Sum(int a, int b)
{
return a + b;
}
Description: Enforces expression-bodied syntax for methods.
Examples
When True
public int GetValue() => 42;
When False
public int GetValue()
{
return 42;
}
Description: Enforces expression-bodied syntax for operator overloads.
Examples
When True
public static Vector operator +(Vector a, Vector b) => new(a.X + b.X, a.Y + b.Y);
When False
public static Vector operator +(Vector a, Vector b)
{
return new Vector(a.X + b.X, a.Y + b.Y);
}
Description: Enforces expression-bodied syntax for properties.
Examples
When True
public int MyProperty => _myField;
When False
public int MyProperty
{
get { return _myField; }
}
Description: Prefers pattern matching over as
+ null check.
Examples
When True
if (obj is MyClass c) { }
When False
var c = obj as MyClass;
if (c != null) { }
Description: Prefers pattern matching over is
+ cast.
Examples
When True
if (obj is MyClass c) { /* ... */ }
When False
if (obj is MyClass) { var c = (MyClass)obj; /* ... */ }
Description: Prefers extended property patterns (e.g., { Property: 10 }
).
Examples
When True
if (obj is { Property: 10 }) { /* ... */ }
When False
if (obj is MyClass { Property: 10 }) { /* ... */ }
Description: Prefers not
pattern over !
operator for negation.
Examples
When True
if (obj is not null) { /* ... */ }
When False
if (!(obj is null)) { /* ... */ }
Description: Prefers pattern matching expressions overall when possible.
Examples
When True
if (obj is MyClass c) { /* ... */ }
When False
if (obj is MyClass) { var c = (MyClass)obj; /* ... */ }
Description: Prefers switch expressions over switch statements.
Examples
When True
return input switch { 1 => "one", 2 => "two", _ => "other" };
When False
switch (input)
{
case 1: return "one";
case 2: return "two";
default: return "other";
}
Description: Prefers ?.Invoke()
syntax over explicit null checks for delegates.
Examples
When True
MyEvent?.Invoke(this, EventArgs.Empty);
When False
if (MyEvent != null) { MyEvent(this, EventArgs.Empty); }
Description: Prefers static
anonymous functions when they don’t capture outer variables.
Examples
When True
Func<int, int> sq = static x => x * x;
When False
Func<int, int> sq = x => x * x;
Description: Prefers static
local functions when they don’t capture outer variables.
Examples
When True
static int Add(int a, int b) => a + b;
When False
int Add(int a, int b) => a + b;
Description: Enforces the order of modifiers (e.g., public static
over static public
).
Examples
Correct Order
public static int MyValue;
Incorrect Order
static public int MyValue;
Description: Enforces readonly struct
for immutable structs.
Examples
When True
public readonly struct MyStruct { /* ... */ }
When False
public struct MyStruct { /* ... */ }
Description: Enforces readonly
on struct members where possible.
Examples
When True
public readonly int GetValue() => _value;
When False
public int GetValue() => _value;
Description: Enforces braces for control flow statements.
Examples
When True
if (condition)
{
DoSomething();
}
When False
if (condition) DoSomething();
Description: Enforces simplified using
statements (C# 8+).
Examples
When True
using var file = new FileStream(...);
When False
using (var file = new FileStream(...)) { /* ... */ }
Description: Enforces file-scoped or block-scoped namespace declarations.
Examples
File-Scoped
namespace MyNamespace;
Block-Scoped
namespace MyNamespace
{
// ...
}
Description: Prefers method groups over lambda expressions when equivalent.
Examples
When True
list.ForEach(Console.WriteLine);
When False
list.ForEach(x => Console.WriteLine(x));
Description: Prefers primary constructors for classes.
Examples
When True
public class Person(string name) { /* ... */ }
When False
public class Person
{
public Person(string name) { /* ... */ }
}
Description: Prefers top-level statements over explicit Program
class.
Examples
When True
Console.WriteLine("Hello, World!");
When False
class Program
{
static void Main()
{
Console.WriteLine("Hello, World!");
}
}
Description: Prefers default
over default(T)
.
Examples
When True
var value = default;
When False
var value = default(int);
Description: Prefers var (x, y)
syntax for deconstruction.
Examples
When True
var (x, y) = GetValues();
When False
(int x, int y) = GetValues();
Description: Prefers new()
over explicit type when apparent.
Examples
When True
List<int> numbers = new();
When False
List<int> numbers = new List<int>();
Description: Prefers inline variable declarations (e.g., out int x
).
Examples
When True
if (int.TryParse(str, out int x)) { /* ... */ }
When False
int x;
if (int.TryParse(str, out x)) { /* ... */ }
Description: Prefers ^
operator for end-based indexing.
Examples
When True
var lastItem = array[^1];
When False
var lastItem = array[array.Length - 1];
Description: Prefers local functions over anonymous lambdas.
Examples
When True
int Sum(int a, int b) => a + b;
When False
Func<int, int, int> sum = (a, b) => a + b;
Description: Prefers null checks over type checks (e.g., obj is null
).
Examples
When True
if (obj is null) { /* ... */ }
When False
if (!(obj is SomeType)) { /* ... */ }
Description: Prefers ..
operator for slicing.
Examples
When True
var slice = array[1..3];
When False
var slice = array.Skip(1).Take(2);
Description: Prefers tuple swap syntax (e.g., (x, y) = (y, x)
).
Examples
When True
(x, y) = (y, x);
When False
var temp = x;
x = y;
y = temp;
Description: Prefers u8
suffix for UTF-8 string literals.
Examples
When True
var bytes = "Hello"u8;
When False
var bytes = Encoding.UTF8.GetBytes("Hello");
Description: Prefers throw
expressions over separate if
checks.
Examples
When True
var person = value ?? throw new ArgumentNullException(nameof(value));
When False
if (value == null) throw new ArgumentNullException(nameof(value));
Description: Defines handling of unused assignments (e.g., _ = ...
).
Examples
Option 1 (discard):
_ = SomeMethod();
Option 2 (unused local):
var unused = SomeMethod();
Description: Defines handling of unused expression statements.
Examples
Option 1 (discard):
_ = SomeMethod();
Option 2 (remove):
SomeMethod();
Description: Enforces placement of using
directives (inside/outside namespace).
Examples
Outside Namespace
using System;
namespace MyNamespace;
Inside Namespace
namespace MyNamespace
{
using System;
}
Description: Allows/disallows blank lines after :
in constructor initializers.
Examples
When True
public MyClass() :
base() { }
When False
public MyClass() : base() { }
Description: Allows/disallows blank lines after =>
in expression-bodied members.
Examples
When True
public int GetValue() =>
42;
When False
public int GetValue() => 42;
Description: Allows/disallows blank lines after ?
/:
in ternary expressions.
Examples
When True
var result = condition ?
"Yes" :
"No";
When False
var result = condition ? "Yes" : "No";
Description: Allows/disallows blank lines between consecutive braces.
Examples
When True
{
{
}
}
When False
{
{
}
}
Description: Allows/disallows embedded statements on the same line.
Examples
When True
if (x) { y++; }
When False
if (x)
{
y++;
}
Description: Enforces new line before catch
.
Examples
When True
try
{
}
catch
{
}
When False
try { } catch { }
Description: Enforces new line before else
.
Examples
When True
if (condition)
{
}
else
{
}
When False
if (condition) { } else { }
Description: Enforces new line before finally
.
Examples
When True
try
{
}
finally
{
}
When False
try { } finally { }
Description: Enforces new lines between members in anonymous types.
Examples
When True
var anon = new
{
Name = "Alice",
Age = 30
};
When False
var anon = new { Name = "Alice", Age = 30 };
Description: Enforces new lines between members in object initializers.
Examples
When True
var person = new Person
{
Name = "Bob",
Age = 20
};
When False
var person = new Person { Name = "Bob", Age = 20 };
Description: Enforces new line before opening braces.
Examples
When True
if (condition)
{
}
When False
if (condition) {
}
Description: Enforces new lines between query clauses.
Examples
When True
var result = from x in collection
where x > 0
select x;
When False
var result = from x in collection where x > 0 select x;
Description: Enforces indentation of block contents.
Examples
When True
{
statement;
}
When False
{
statement;
}
Description: Controls whether braces are indented.
Examples
When True
if (condition)
{
statement;
}
When False
if (condition)
{
statement;
}
Description: Enforces indentation of case
contents in switch
.
Examples
When True
switch (value)
{
case 1:
DoSomething();
break;
}
When False
switch (value)
{
case 1:
DoSomething();
break;
}
Description: Enforces indentation of case
blocks with braces.
Examples
When True
case 1:
{
DoSomething();
break;
}
When False
case 1:
{
DoSomething();
break;
}
Description: Controls indentation level of labels.
Examples
Option 1 (one_less_than_current):
labelName:
DoSomething();
Option 2:
labelName:
DoSomething();
Description: Enforces indentation of switch
labels (case
, default
).
Examples
When True
switch (value)
{
case 1:
break;
}
When False
switch (value)
{
case 1:
break;
}
Description: Controls spacing after cast operators.
Examples
When True
(int) x;
When False
(int)x;
Description: Controls spacing after :
in base class/interface list.
Examples
When True
class Derived : Base { }
When False
class Derived :Base { }
Description: Controls spacing after commas.
Examples
When True
var tuple = (1, 2);
When False
var tuple = (1,2);
Description: Controls spacing after a dot.
Examples
When True
obj. Property;
When False
obj.Property;
Description: Enforces spacing after keywords like if
, for
, while
, etc.
Examples
When True
if (condition) { }
When False
if(condition) { }
Description: Enforces spacing after semicolons in for
statements.
Examples
When True
for (int i = 0; i < 10; i++) { }
When False
for (int i = 0;i < 10;i++) { }
Description: Controls spacing around binary operators.
Examples
When True
a + b;
When False
a+b;
Description: Controls spacing around declaration statements.
Examples
When True
int x = 0;
When False
int x = 0;
Description: Controls spacing before :
in base class/interface list.
Examples
When True
class Derived : Base { }
When False
class Derived: Base { }
Description: Controls spacing before commas.
Examples
When True
var tuple = (1 , 2);
When False
var tuple = (1, 2);
Description: Controls spacing before a dot.
Examples
When True
obj .Property;
When False
obj.Property;
Description: Controls spacing before [
in attributes or indexers.
Examples
When True
[ Obsolete]
When False
[Obsolete]
Description: Controls spacing before semicolons in for
statements.
Examples
When True
for (int i = 0 ; i < 10 ; i++) { }
When False
for (int i = 0; i < 10; i++) { }
Description: Controls spacing between empty brackets []
.
Examples
When True
new int[ 0 ];
When False
new int[0];
Description: Controls spacing in empty parameter lists.
Examples
When True
Method( );
When False
Method();
Description: Controls spacing between method name and (
.
Examples
When True
Method (arg);
When False
Method(arg);
Description: Controls spacing within parameter parentheses.
Examples
When True
Method(a, b);
When False
Method(a,b);
Description: Controls spacing in empty parameter lists for methods.
Examples
When True
void Method( );
When False
void Method();
Description: Controls spacing between method name and (
.
Examples
When True
void Method (string x);
When False
void Method(string x);
Description: Controls spacing within method parameter parentheses.
Examples
When True
void Method(int x, int y);
When False
void Method(int x,int y);
Description: Controls spacing inside parentheses in expressions.
Examples
When True
( x + y );
When False
(x + y);
Description: Controls spacing inside square brackets.
Examples
When True
array[ 0 ];
When False
array[0];
Description: Controls whether single-line blocks are kept on one line.
Examples
When True
if (condition) { DoSomething(); }
When False
if (condition)
{
DoSomething();
}
Description: Controls whether single-line statements remain on one line.
Examples
When True
if (condition) DoSomething();
When False
if (condition)
{
DoSomething();
}
Description: Enforces interface names to start with I
.
Examples
When True
public interface IMyInterface { }
When False
public interface MyInterface { }
Description: Enforces PascalCase for types (class, struct, enum, interface).
Examples
When True
public class MyClass { }
When False
public class myClass { }
Description: Enforces PascalCase for non-field members (properties, events, methods).
Examples
When True
public void MyMethod() { }
When False
public void myMethod() { }
Description: Enforces removing trailing whitespace at the end of lines.
Examples
When True
"Line with no trailing spaces"
When False
"Line with trailing spaces "
Description: Configures severity for unnecessary usings (Roslyn analyzers).
Examples
When True
using System; // if actually needed
When False
using System; // if not used
Description: Configures severity for naming rule violations.
Description: Configures severity for unnecessary usings (C# compiler).
Description: Configures severity for redundant suppression of diagnostics.
Description: Configures severity for inconsistent nameof
usage.
Description: Configures severity for missing XML comment warnings.
Description: Enforces using lock
keyword over Monitor.Enter
.
Examples
When True
lock (locker) { /* ... */ }
When False
Monitor.Enter(locker); // manually