@@ -51,8 +51,7 @@ The following table lists the possible severity values and their effects:
51
51
52
52
Severity | Effect
53
53
:------- | ------
54
- ` none ` | Do not show anything to the user when this rule is violated. Code generation features will generate code in this style, however. Rules with ` none ` severity will never participate in ** Format Document** cleanup or appear in the * Quick Actions and Refactorings* menu. In most cases, this is considered "disabled" or "ignored".
55
- ` silent ` (also ` refactoring ` in version 15.8) | Do not show anything to the user when this rule is violated. Code generation features will generate code in this style, however. Rules with ` silent ` severity will participate in cleanup if enabled in the ** Format Document** settings and the * Quick Actions and Refactorings* menu.
54
+ ` none ` or ` silent ` | Do not show anything to the user when this rule is violated. Code generation features will generate code in this style, however. If enabled in the ** Format Document** settings, rules with ` none ` severity appear in the * Quick Actions and Refactorings* menu. In most cases, this is considered "disabled" or "ignored".
56
55
` suggestion ` | When this style rule is violated, show it to the user as a suggestion. Suggestions appear as three gray dots under the first two characters.
57
56
` warning ` | When this style rule is violated, show a compiler warning.
58
57
` error ` | When this style rule is violated, show a compiler error.
@@ -73,20 +72,13 @@ The following list shows the allowable language convention rules:
73
72
- csharp\_ preferred\_ modifier_order
74
73
- visual\_ basic\_ preferred\_ modifier_order
75
74
- dotnet\_ style\_ readonly\_ field
76
- - [ Parentheses preferences] ( #parentheses )
77
- - dotnet\_ style\_ parentheses\_ in\_ arithmetic\_ binary\_ operators
78
- - dotnet\_ style\_ parentheses\_ in\_ other\_ binary\_ operators
79
- - dotnet\_ style\_ parentheses\_ in\_ other\_ operators
80
- - dotnet\_ style\_ parentheses\_ in\_ relational\_ binary\_ operators
81
75
- [ Expression-level preferences] ( #expression_level )
82
76
- dotnet\_ style\_ object_initializer
83
77
- dotnet\_ style\_ collection_initializer
84
78
- dotnet\_ style\_ explicit\_ tuple_names
85
79
- dotnet\_ prefer\_ inferred\_ tuple_names
86
80
- dotnet\_ prefer\_ inferred\_ anonymous\_ type\_ member_names
87
81
- dotnet\_ style\_ prefer\_ auto\_ properties
88
- - dotnet\_ style\_ prefer\_ conditional\_ expression\_ over\_ assignment
89
- - dotnet\_ style\_ prefer\_ conditional\_ expression\_ over\_ return
90
82
- dotnet\_ style\_ prefer\_ is\_ null\_ check\_ over\_ reference\_ equality\_ method
91
83
- [ "Null" checking preferences] ( #null_checking )
92
84
- dotnet\_ style\_ coalesce_expression
@@ -412,125 +404,6 @@ csharp_preferred_modifier_order = public,private,protected,internal,static,exter
412
404
visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async:suggestion
413
405
```
414
406
415
- #### <a name =" parentheses " ></a >Parentheses preferences
416
-
417
- The style rules in this section concern parentheses preferences, including the use of parentheses for arithmetic, relational, and other binary operators.
418
-
419
- The following table shows the rule names, rule IDs, applicable programming languages, default values, and first supported version of Visual Studio:
420
-
421
- | Rule name | Rule ID | Applicable languages | Visual Studio default | Visual Studio 2017 version |
422
- | --------- | ------- | -------------------- | ----------------------| ---- |
423
- | dotnet_style_parentheses_in_arithmetic_binary_operators | IDE0047 | C# and Visual Basic | always_for_clarity: none | 15.8 |
424
- | dotnet_style_parentheses_in_relational_binary_operators | IDE0047 | C# and Visual Basic | always_for_clarity: none | 15.8 |
425
- | dotnet_style_parentheses_in_other_binary_operators | IDE0047 | C# and Visual Basic | always_for_clarity: none | 15.8 |
426
- | dotnet_style_parentheses_in_other_operators | IDE0047 | C# and Visual Basic | never_if_unnecessary: none | 15.8 |
427
-
428
- ** dotnet\_ style\_ parentheses\_ in\_ arithmetic\_ binary_operators**
429
-
430
- - When this rule is set to ** always_for_clarity** , prefer parentheses to clarify arithmetic operator (` * ` , ` / ` , ` % ` , ` + ` , ` - ` , ` << ` , ` >> ` , ` & ` , ` ^ ` , ` | ` ) precedence.
431
- - When this rule is set to ** never_if_unnecessary** , prefer to not have parentheses when arithmetic operator (` * ` , ` / ` , ` % ` , ` + ` , ` - ` , ` << ` , ` >> ` , ` & ` , ` ^ ` , ` | ` ) precedence is obvious.
432
-
433
- Code examples:
434
-
435
- ``` csharp
436
- // dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity
437
- var v = a + (b * c );
438
-
439
- // dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary
440
- var v = a + b * c ;
441
-
442
- ```
443
-
444
- ``` vb
445
- ' dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity
446
- Dim v = a + (b * c)
447
-
448
- ' dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary
449
- Dim v = a + b * c
450
-
451
- ```
452
-
453
- ** dotnet\_ style\_ parentheses\_ in\_ relational\_ binary_operators**
454
-
455
- - When this rule is set to ** always_for_clarity** , prefer parentheses to clarify relational operator (` > ` , ` < ` , ` <= ` , ` >= ` , ` is ` , ` as ` , ` == ` , ` != ` ) precedence .
456
- - When this rule is set to ** never_if_unnecessary** , prefer to not have parentheses when relational operator (` > ` , ` < ` , ` <= ` , ` >= ` , ` is ` , ` as ` , ` == ` , ` != ` ) precedence is obvious.
457
-
458
- Code examples:
459
-
460
- ``` csharp
461
- // dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity
462
- var v = (a < b ) == (c > d );
463
-
464
- // dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary
465
- var v = a < b == c > d ;
466
-
467
- ```
468
-
469
- ``` vb
470
- ' dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity
471
- Dim v = (a < b) = (c > d)
472
-
473
- ' dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary
474
- Dim v = a < b = c > d
475
- ```
476
-
477
- ** dotnet\_ style\_ parentheses\_ in\_ other\_ binary_operators**
478
-
479
- - When this rule is set to ** always_for_clarity** , prefer parentheses to clarify other binary operator (` && ` , ` || ` , ` ?? ` ) precedence.
480
- - When this rule is set to ** never_if_unnecessary** , prefer to not have parentheses when other binary operator (` && ` , ` || ` , ` ?? ` ) precedence is obvious.
481
-
482
- Code examples:
483
-
484
- ``` csharp
485
- // dotnet_style_parentheses_in_other_binary_operators = always_for_clarity
486
- var v = a || (b && c );
487
-
488
- // dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary
489
- var v = a || b && c ;
490
- ```
491
-
492
- ``` vb
493
- ' dotnet_style_parentheses_in_other_binary_operators = always_for_clarity
494
- Dim v = a OrElse (b AndAlso c)
495
-
496
- ' dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary
497
- Dim v = a OrElse b AndAlso c
498
- ```
499
-
500
- ** dotnet\_ style\_ parentheses\_ in\_ other_operators**
501
-
502
- - When this rule is set to ** always_for_clarity** , prefer parentheses to clarify operator precedence.
503
- - When this rule is set to ** never_if_unnecessary** , prefer to not have parentheses when operator precedence is obvious.
504
-
505
- Code examples:
506
-
507
- ``` csharp
508
- // dotnet_style_parentheses_in_other_operators = always_for_clarity
509
- var v = (a .b ).Length ;
510
-
511
- // dotnet_style_parentheses_in_other_operators = never_if_unnecessary
512
- var v = a .b .Length ;
513
- ```
514
-
515
- ``` vb
516
- ' dotnet_style_parentheses_in_other_operators = always_for_clarity
517
- Dim v = (a.b).Length
518
-
519
- ' dotnet_style_parentheses_in_other_operators = never_if_unnecessary
520
- Dim v = a.b.Length
521
- ```
522
-
523
- These rules could appear in an * .editorconfig* file as follows:
524
-
525
- ``` EditorConfig
526
- # CSharp and Visual Basic code style settings:
527
- [*.{cs,vb}]
528
- dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:none
529
- dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:none
530
- dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:none
531
- dotnet_style_parentheses_in_other_operators = never_if_unnecessary:none
532
- ```
533
-
534
407
#### <a name =" expression_level " ></a >Expression-level preferences
535
408
536
409
The style rules in this section concern expression-level preferences, including the use of object initializers, collection initializers, explicit or inferred tuple names, and inferred anonymous types.
@@ -546,8 +419,6 @@ The following table shows the rule names, rule IDs, applicable programming langu
546
419
| dotnet_style_prefer_inferred_anonymous_ type_member_names | IDE0037 | C# and Visual Basic | true: suggestion | 15.6 |
547
420
| dotnet_style_prefer_auto_properties | IDE0032 | C# and Visual Basic | true: none | 15.7 |
548
421
| dotnet_style_prefer_is_null_check_over_reference_equality_method | IDE0041 | C# and Visual Basic | true: suggestion | 15.7 |
549
- | dotnet_style_prefer_conditional_expression_over_assignment | IDE0045 | C# and Visual Basic | true: none | 15.8 |
550
- | dotnet_style_prefer_conditional_expression_over_return | IDE0046 | C# and Visual Basic | true: none | 15.8 |
551
422
552
423
** dotnet\_ style\_ object_initializer**
553
424
@@ -744,77 +615,6 @@ If Object.ReferenceEquals(value, Nothing)
744
615
End If
745
616
```
746
617
747
- ** dotnet\_ style\_ prefer\_ conditional\_ expression\_ over_assignment**
748
-
749
- - When this rule is set to ** true** , prefer assignments with a ternary conditional over an if-else statement.
750
- - When this rule is set to ** false** , prefer assignments with an if-else statement over a ternary conditional.
751
-
752
- Code examples:
753
-
754
- ``` csharp
755
- // dotnet_style_prefer_conditional_expression_over_assignment = true
756
- string s = expr ? " hello" : " world" ;
757
-
758
- // dotnet_style_prefer_conditional_expression_over_assignment = false
759
- string s ;
760
- if (expr )
761
- {
762
- s = " hello" ;
763
- }
764
- else
765
- {
766
- s = " world" ;
767
- }
768
- ```
769
-
770
- ``` vb
771
- ' dotnet_style_prefer_conditional_expression_over_assignment = true
772
- Dim s As String = If (expr, "hello" , "world" )
773
-
774
- ' dotnet_style_prefer_conditional_expression_over_assignment = false
775
- Dim s As String
776
- If expr Then
777
- s = "hello"
778
- Else
779
- s = "world"
780
- End If
781
- ```
782
-
783
- ** dotnet\_ style\_ prefer\_ conditional\_ expression\_ over_return**
784
-
785
- - When this rule is set to ** true** , prefer return statements to use a ternary conditional over an if-else statement.
786
- - When this rule is set to ** false** , prefer return statements to use an if-else statement over a ternary conditional.
787
-
788
- Code examples:
789
-
790
- ``` csharp
791
- // dotnet_style_prefer_conditional_expression_over_return = true
792
- return expr ? " hello" : " world"
793
-
794
- // dotnet_style_prefer_conditional_expression_over_return = false
795
- if (expr )
796
- {
797
- return " hello" ;
798
- }
799
- else
800
- {
801
- return " world" ;
802
- }
803
- ```
804
-
805
- ```vb
806
- ' dotnet_style_prefer_conditional_expression_over_return = true
807
- Return If (expr , " hello" , " world" )
808
-
809
- ' dotnet_style_prefer_conditional_expression_over_return = false
810
- If expr Then
811
- Return " hello"
812
- Else
813
- Return " world"
814
- End If
815
- ```
816
-
817
-
818
618
These rules could appear in an * .editorconfig* file as follows:
819
619
820
620
``` EditorConfig
@@ -826,8 +626,6 @@ dotnet_style_explicit_tuple_names = true:suggestion
826
626
dotnet_style_prefer_inferred_tuple_names = true:suggestion
827
627
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
828
628
dotnet_style_prefer_auto_properties = true:none
829
- dotnet_style_prefer_conditional_expression_over_assignment = true : suggestion
830
- dotnet_style_prefer_conditional_expression_over_return = true : suggestion
831
629
```
832
630
833
631
#### <a name =" null_checking " ></a >Null-checking preferences
@@ -2189,23 +1987,17 @@ charset = utf-8-bom
2189
1987
dotnet_sort_system_directives_first = true
2190
1988
2191
1989
# this. preferences
2192
- dotnet_style_qualification_for_field = false : silent
2193
- dotnet_style_qualification_for_property = false : silent
2194
- dotnet_style_qualification_for_method = false : silent
2195
- dotnet_style_qualification_for_event = false : silent
1990
+ dotnet_style_qualification_for_field = false : none
1991
+ dotnet_style_qualification_for_property = false : none
1992
+ dotnet_style_qualification_for_method = false : none
1993
+ dotnet_style_qualification_for_event = false : none
2196
1994
2197
1995
# Language keywords vs BCL types preferences
2198
- dotnet_style_predefined_type_for_locals_parameters_members = true : silent
2199
- dotnet_style_predefined_type_for_member_access = true : silent
2200
-
2201
- # Parentheses preferences
2202
- dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity : silent
2203
- dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity : silent
2204
- dotnet_style_parentheses_in_other_binary_operators = always_for_clarity : silent
2205
- dotnet_style_parentheses_in_other_operators = never_if_unnecessary : silent
1996
+ dotnet_style_predefined_type_for_locals_parameters_members = true : none
1997
+ dotnet_style_predefined_type_for_member_access = true : none
2206
1998
2207
1999
# Modifier preferences
2208
- dotnet_style_require_accessibility_modifiers = for_non_interface_members : silent
2000
+ dotnet_style_require_accessibility_modifiers = for_non_interface_members : none
2209
2001
dotnet_style_readonly_field = true : suggestion
2210
2002
2211
2003
# Expression-level preferences
@@ -2214,12 +2006,10 @@ dotnet_style_collection_initializer = true:suggestion
2214
2006
dotnet_style_explicit_tuple_names = true : suggestion
2215
2007
dotnet_style_null_propagation = true : suggestion
2216
2008
dotnet_style_coalesce_expression = true : suggestion
2217
- dotnet_style_prefer_is_null_check_over_reference_equality_method = true : silent
2009
+ dotnet_style_prefer_is_null_check_over_reference_equality_method = true : none
2218
2010
dotnet_prefer_inferred_tuple_names = true : suggestion
2219
2011
dotnet_prefer_inferred_anonymous_type_member_names = true : suggestion
2220
- dotnet_style_prefer_auto_properties = true : silent
2221
- dotnet_style_prefer_conditional_expression_over_assignment = true : silent
2222
- dotnet_style_prefer_conditional_expression_over_return = true : silent
2012
+ dotnet_style_prefer_auto_properties = true : none
2223
2013
2224
2014
###############################
2225
2015
# Naming Conventions #
@@ -2241,17 +2031,17 @@ dotnet_naming_symbols.constant_fields.required_modifiers = const
2241
2031
###############################
2242
2032
[* .cs ]
2243
2033
# var preferences
2244
- csharp_style_var_for_built_in_types = true : silent
2245
- csharp_style_var_when_type_is_apparent = true : silent
2246
- csharp_style_var_elsewhere = true : silent
2034
+ csharp_style_var_for_built_in_types = true : none
2035
+ csharp_style_var_when_type_is_apparent = true : none
2036
+ csharp_style_var_elsewhere = true : none
2247
2037
2248
2038
# Expression-bodied members
2249
- csharp_style_expression_bodied_methods = false : silent
2250
- csharp_style_expression_bodied_constructors = false : silent
2251
- csharp_style_expression_bodied_operators = false : silent
2252
- csharp_style_expression_bodied_properties = true : silent
2253
- csharp_style_expression_bodied_indexers = true : silent
2254
- csharp_style_expression_bodied_accessors = true : silent
2039
+ csharp_style_expression_bodied_methods = false : none
2040
+ csharp_style_expression_bodied_constructors = false : none
2041
+ csharp_style_expression_bodied_operators = false : none
2042
+ csharp_style_expression_bodied_properties = true : none
2043
+ csharp_style_expression_bodied_indexers = true : none
2044
+ csharp_style_expression_bodied_accessors = true : none
2255
2045
2256
2046
# Pattern matching preferences
2257
2047
csharp_style_pattern_matching_over_is_with_cast_check = true : suggestion
@@ -2265,7 +2055,7 @@ csharp_style_conditional_delegate_call = true:suggestion
2265
2055
csharp_preferred_modifier_order = public ,private ,protected ,internal ,static ,extern ,new ,virtual ,abstract ,sealed ,override ,readonly ,unsafe ,volatile ,async : suggestion
2266
2056
2267
2057
# Expression-level preferences
2268
- csharp_prefer_braces = true : silent
2058
+ csharp_prefer_braces = true : none
2269
2059
csharp_style_deconstructed_variable_declaration = true : suggestion
2270
2060
csharp_prefer_simple_default_expression = true : suggestion
2271
2061
csharp_style_pattern_local_over_anonymous_function = true : suggestion
0 commit comments