-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.editorconfig
4350 lines (3850 loc) · 286 KB
/
.editorconfig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
## Simplify name (IDE0001)
## This rule concerns the use of simplified type names in declarations and executable code, when possible. You can remove unnecessary name qualification to simplify code and improve readability.
## using System.IO;
## class C
## {
## // IDE0001: 'System.IO.FileInfo' can be simplified to 'FileInfo'
## System.IO.FileInfo file;
##
## // Fixed code
## FileInfo file;
## }
# dotnet_diagnostic.IDE0001.severity =
## Simplify member access (IDE0002)
## This rule concerns use of simplified type member access in declarations and executable code, when possible. Unnecessary qualification can be removed to simplify code and improve readability.
## static void M1() { }
## static void M2()
## {
## // IDE0002: 'C.M1' can be simplified to 'M1'
## C.M1();
##
## // Fixed code
## M1();
## }
# dotnet_diagnostic.IDE0002.severity =
## Remove this or Me qualification (IDE0003)
## Add this or Me qualification (IDE0009)
## These two rules define whether or not you prefer the use of this (C#) and Me. (Visual Basic) qualifiers. To enforce that the qualifiers aren't present, set the severity of IDE0003 to warning or error. To enforce that the qualifiers are present, set the severity of IDE0009 to warning or error.
## For example, if you prefer qualifiers for fields and properties but not for methods or events, then you can enable IDE0009 and set the options dotnet_style_qualification_for_field and dotnet_style_qualification_for_property to true. However, this configuration would not flag methods and events that do have this and Me qualifiers. To also enforce that methods and events don't have qualifiers, enable IDE0003.
# dotnet_diagnostic.IDE0003.severity =
# dotnet_diagnostic.IDE0009.severity =
## Options:
## dotnet_style_qualification_for_field
## - true - Prefer fields to be prefaced with this. in C# or Me. in Visual Basic
## - false - Prefer fields not to be prefaced with this. or Me.
## // dotnet_style_qualification_for_field = true
## this.capacity = 0;
##
## // dotnet_style_qualification_for_field = false
## capacity = 0;
# dotnet_style_qualification_for_field =
## dotnet_style_qualification_for_property
## - true - Prefer properties to be prefaced with this. in C# or Me. in Visual Basic.
## - false - Prefer properties not to be prefaced with this. or Me..
## // dotnet_style_qualification_for_property = true
## this.ID = 0;
##
## // dotnet_style_qualification_for_property = false
## ID = 0;
# dotnet_style_qualification_for_property =
## dotnet_style_qualification_for_method
## - true - Prefer methods to be prefaced with this. in C# or Me. in Visual Basic.
## - false - Prefer methods not to be prefaced with this. or Me..
## // dotnet_style_qualification_for_method = true
## this.Display();
##
## // dotnet_style_qualification_for_method = false
## Display();
# dotnet_style_qualification_for_method =
## dotnet_style_qualification_for_event
## - true - Prefer events to be prefaced with this. in C# or Me. in Visual Basic.
## - false - Prefer events not to be prefaced with this. or Me..
## // dotnet_style_qualification_for_event = true
## this.Elapsed += Handler;
##
## // dotnet_style_qualification_for_event = false
## Elapsed += Handler;
# dotnet_style_qualification_for_event =
## Remove unnecessary cast (IDE0004)
## This rule flags unnecessary type casts. A cast expression is unnecessary if the code semantics would be identical with or without it.
## // Code with violations
## int v = (int)0;
##
## // Fixed code
## int v = 0;
# dotnet_diagnostic.IDE0004.severity =
## Remove unnecessary import (IDE0005)
## This rule flags the following unnecessary constructs. If unnecessary, these constructs can be removed without changing the semantics of the code:
## using directives (C#).
## Import statements (Visual Basic).
## [!NOTE]
## To enable this rule on build, you need to enable XML documentation comments for the project. For more information, see dotnet/roslyn issue 41640.
## // Code with violations
## using System;
## using System.IO; // IDE0005: Using directive is unnecessary
## class C
## {
## public static void M()
## {
## Console.WriteLine("Hello");
## }
## }
##
## // Fixed code
## using System;
## class C
## {
## public static void M()
## {
## Console.WriteLine("Hello");
## }
## }
# dotnet_diagnostic.IDE0005.severity =
## Use var instead of explicit type (IDE0007)
## Use explicit type instead of var (IDE0008)
## These two style rules define whether the var keyword or an explicit type should be used in a variable declaration. To enforce that var is used, set the severity of IDE0007 to warning or error. To enforce that the explicit type is used, set the severity of IDE0008 to warning or error.
# dotnet_diagnostic.IDE0007.severity =
# dotnet_diagnostic.IDE0008.severity =
## Options:
## csharp_style_var_for_built_in_types
## - true - Prefer var is used to declare variables with built-in system types such as int
## - false - Prefer explicit type over var to declare variables with built-in system types such as int
## // csharp_style_var_for_built_in_types = true
## var x = 5;
##
## // csharp_style_var_for_built_in_types = false
## int x = 5;
# csharp_style_var_for_built_in_types =
## csharp_style_var_when_type_is_apparent
## - true - Prefer var when the type is already mentioned on the right-hand side of a declaration expression
## - false - Prefer explicit type when the type is already mentioned on the right-hand side of a declaration expression
## // csharp_style_var_when_type_is_apparent = true
## var obj = new Customer();
##
## // csharp_style_var_when_type_is_apparent = false
## Customer obj = new Customer();
# csharp_style_var_when_type_is_apparent =
## csharp_style_var_elsewhere
## - true - Prefer var over explicit type in all cases, unless overridden by another code style rule
## - false - Prefer explicit type over var in all cases, unless overridden by another code style rule
## // csharp_style_var_elsewhere = true
## var f = this.Init();
##
## // csharp_style_var_elsewhere = false
## bool f = this.Init();
# csharp_style_var_elsewhere =
## Add missing cases to switch statement (IDE0010)
## This rule concerns specifying all the missing switch cases for a switch statement. A switch statement is considered incomplete in the following scenarios:
## An enum switch statement that's missing cases for one or more enum members.
## A switch statement with a missing default case.
## enum E
## {
## A,
## B
## }
##
## class C
## {
## // Code with violations
## int M(E e)
## {
## // IDE0010: Add missing cases
## switch (e)
## {
## case E.A:
## return 0;
## }
##
## return -1;
## }
##
## // Fixed code
## int M(E e)
## {
## switch (e)
## {
## case E.A:
## return 0;
## case E.B:
## return 1;
## default:
## return -1;
## }
## }
## }
# dotnet_diagnostic.IDE0010.severity =
## Add braces (IDE0011)
## This style rule concerns the use of curly braces { } to surround code blocks.
# dotnet_diagnostic.IDE0011.severity =
## Options:
## csharp_prefer_braces
## - true - Prefer curly braces even for one line of code
## - false - Prefer no curly braces if allowed
## - when_multiline - Prefer curly braces on multiple lines
## // csharp_prefer_braces = true
## if (test) { this.Display(); }
##
## // csharp_prefer_braces = false
## if (test) this.Display();
##
## // csharp_prefer_braces = when_multiline
## if (test) this.Display();
## else { this.Display(); Console.WriteLine("Multiline"); }
# csharp_prefer_braces =
## Use throw expression (IDE0016)
## This style rule concerns the use of throw expressions instead of throw statements. Set the severity of rule IDE0016 to define how the rule should be enforced, for example, as a warning or an error.
# dotnet_diagnostic.IDE0016.severity =
## Options:
## csharp_style_throw_expression
## - true - Prefer to use throw expressions instead of throw statements
## - false - Prefer to use throw statements instead of throw expressions
## // csharp_style_throw_expression = true
## this.s = s ?? throw new ArgumentNullException(nameof(s));
##
## // csharp_style_throw_expression = false
## if (s == null) { throw new ArgumentNullException(nameof(s)); }
## this.s = s;
# csharp_style_throw_expression =
## Use object initializers (IDE0017)
## This style rule concerns the use of object initializers for object initialization.
# dotnet_diagnostic.IDE0017.severity =
## Options:
## dotnet_style_object_initializer
## - true - Prefer objects to be initialized using object initializers when possible
## - false - Prefer objects to not be initialized using object initializers
## // dotnet_style_object_initializer = true
## var c = new Customer() { Age = 21 };
##
## // dotnet_style_object_initializer = false
## var c = new Customer();
## c.Age = 21;
# dotnet_style_object_initializer =
## Inline variable declaration (IDE0018)
## This style rule concerns whether out variables are declared inline or not. Starting in C# 7, you can declare an out variable in the argument list of a method call, rather than in a separate variable declaration.
# dotnet_diagnostic.IDE0018.severity =
## Options:
## csharp_style_inlined_variable_declaration
## - true - Prefer out variables to be declared inline in the argument list of a method call when possible
## - false - Prefer out variables to be declared before the method call
## // csharp_style_inlined_variable_declaration = true
## if (int.TryParse(value, out int i)) {...}
##
## // csharp_style_inlined_variable_declaration = false
## int i;
## if (int.TryParse(value, out i)) {...}
# csharp_style_inlined_variable_declaration =
## Use pattern matching to avoid as followed by a null check (IDE0019)
## This style rule concerns the use of C# pattern matching over an as expression followed by a null check. This rule is similar to IDE0260, which flags the use of an as expression followed by a member read through the null-conditional operator.
# dotnet_diagnostic.IDE0019.severity =
## Options:
## csharp_style_pattern_matching_over_as_with_null_check
## - true - Prefer pattern matching to determine if something is of a particular type
## - false - Prefer as expressions with null checks to determine if something is of a particular type
## // csharp_style_pattern_matching_over_as_with_null_check = true
## if (o is string s) {...}
##
## // csharp_style_pattern_matching_over_as_with_null_check = false
## var s = o as string;
## if (s != null) {...}
# csharp_style_pattern_matching_over_as_with_null_check =
## Use pattern matching to avoid is check followed by a cast (with variable) (IDE0020)
## Use pattern matching to avoid is check followed by a cast (without variable) (IDE0038)
## This style rule concerns the use of C# pattern matching, for example, o is int i, over an is check followed by a cast, for example, if (o is int) { ... (int)o ... }. Enable either IDE0020 or IDE0038 based on whether or not the cast expression should be saved into a separate local variable:
## IDE0020: Cast expression is saved into a local variable. For example, if (o is int) { var i = (int)o; } saves the result of (int)o in a local variable.
## IDE0038: Cast expression is not saved into a local variable. For example, if (o is int) { if ((int)o == 1) { ... } } does not save the result of (int)o into a local variable.
# dotnet_diagnostic.IDE0020.severity =
# dotnet_diagnostic.IDE0038.severity =
## Options:
## csharp_style_pattern_matching_over_is_with_cast_check
## - true - Prefer pattern matching instead of is expressions with type casts
## - false - Prefer is expressions with type casts instead of pattern matching
## // csharp_style_pattern_matching_over_is_with_cast_check = true
## if (o is int i) {...}
##
## // csharp_style_pattern_matching_over_is_with_cast_check = false
## if (o is int) {var i = (int)o; ... }
# csharp_style_pattern_matching_over_is_with_cast_check =
## Use expression body for constructors (IDE0021)
## This style rule concerns the use of expression bodies versus block bodies for constructors.
# dotnet_diagnostic.IDE0021.severity =
## Options:
## csharp_style_expression_bodied_constructors
## - true - Prefer expression bodies for constructors
## - when_on_single_line - Prefer expression bodies for constructors when they will be a single line
## - false - Prefer block bodies for constructors
## // csharp_style_expression_bodied_constructors = true
## public Customer(int age) => Age = age;
##
## // csharp_style_expression_bodied_constructors = false
## public Customer(int age) { Age = age; }
# csharp_style_expression_bodied_constructors =
## Use expression body for methods (IDE0022)
## This style rule concerns the use of expression bodies versus block bodies for methods.
# dotnet_diagnostic.IDE0022.severity =
## Options:
## csharp_style_expression_bodied_methods
## - true - Prefer expression bodies for methods
## - when_on_single_line - Prefer expression bodies for methods when they will be a single line
## - false - Prefer block bodies for methods
## // csharp_style_expression_bodied_methods = true
## public int GetAge() => this.Age;
##
## // csharp_style_expression_bodied_methods = false
## public int GetAge() { return this.Age; }
# csharp_style_expression_bodied_methods =
## Use expression body for conversion operators (IDE0023)
## Use expression body for operators (IDE0024)
## This style rule concerns the use of expression bodies versus block bodies for operators.
# dotnet_diagnostic.IDE0023.severity =
# dotnet_diagnostic.IDE0024.severity =
## Options:
## csharp_style_expression_bodied_operators
## - true - Prefer expression bodies for operators
## - when_on_single_line - Prefer expression bodies for operators when they will be a single line
## - false - Prefer block bodies for operators
## // csharp_style_expression_bodied_operators = true
## public static ComplexNumber operator + (ComplexNumber c1, ComplexNumber c2)
## => new ComplexNumber(c1.Real + c2.Real, c1.Imaginary + c2.Imaginary);
##
## // csharp_style_expression_bodied_operators = false
## public static ComplexNumber operator + (ComplexNumber c1, ComplexNumber c2)
## { return new ComplexNumber(c1.Real + c2.Real, c1.Imaginary + c2.Imaginary); }
# csharp_style_expression_bodied_operators =
## Use expression body for properties (IDE0025)
## This style rule concerns the use of expression bodies versus block bodies for properties.
# dotnet_diagnostic.IDE0025.severity =
## Options:
## csharp_style_expression_bodied_properties
## - true - Prefer expression bodies for properties
## - when_on_single_line - Prefer expression bodies for properties when they will be a single line
## - false - Prefer block bodies for properties
## // csharp_style_expression_bodied_properties = true
## public int Age => _age;
##
## // csharp_style_expression_bodied_properties = false
## public int Age { get { return _age; }}
# csharp_style_expression_bodied_properties =
## Use expression body for indexers (IDE0026)
## This style rule concerns the use of expression bodies versus block bodies for indexers.
# dotnet_diagnostic.IDE0026.severity =
## Options:
## csharp_style_expression_bodied_indexers
## - true - Prefer expression bodies for indexers
## - when_on_single_line - Prefer expression bodies for indexers when they will be a single line
## - false - Prefer block bodies for indexers
## // csharp_style_expression_bodied_indexers = true
## public T this[int i] => _values[i];
##
## // csharp_style_expression_bodied_indexers = false
## public T this[int i] { get { return _values[i]; } }
# csharp_style_expression_bodied_indexers =
## Use expression body for accessors (IDE0027)
## This style rule concerns the use of expression bodies versus block bodies for accessors.
# dotnet_diagnostic.IDE0027.severity =
## Options:
## csharp_style_expression_bodied_accessors
## - true - Prefer expression bodies for accessors
## - when_on_single_line - Prefer expression bodies for accessors when they will be a single line
## - false - Prefer block bodies for accessors
## // csharp_style_expression_bodied_accessors = true
## public int Age { get => _age; set => _age = value; }
##
## // csharp_style_expression_bodied_accessors = false
## public int Age { get { return _age; } set { _age = value; } }
# csharp_style_expression_bodied_accessors =
## Use collection initializers (IDE0028)
## This style rule concerns the use of collection initializers for collection initialization.
# dotnet_diagnostic.IDE0028.severity =
## Options:
## dotnet_style_collection_initializer
## - true - Prefer collections to be initialized using collection initializers when possible
## - false - Prefer collections to not be initialized using collection initializers
## // dotnet_style_collection_initializer = true
## var list = new List<int> { 1, 2, 3 };
##
## // dotnet_style_collection_initializer = false
## var list = new List<int>();
## list.Add(1);
## list.Add(2);
## list.Add(3);
# dotnet_style_collection_initializer =
## Null check can be simplified (ternary conditional check) (IDE0029)
## Null check can be simplified (nullable ternary conditional check) (IDE0030)
## Null check can be simplified (if null check) (IDE0270)
## Rules IDE0029 and IDE0030 concern the use of null-coalescing expressions, for example, x ?? y, versus ternary conditional expressions with null checks, for example, x != null ? x : y. The rules differ with respect to the nullability of the expressions:
## IDE0029: Used when non-nullable expressions are involved. For example, this rule could recommend x ?? y instead of x != null ? x : y when x and y are non-nullable reference types.
## IDE0030: Used when nullable expressions are involved. For example, this rule could recommend x ?? y instead of x != null ? x : y when x and y are nullable value types or nullable reference types.
## Rule IDE0270 flags the use of a null check (== null or is null) instead of the null-coalescing operator (??).
# dotnet_diagnostic.IDE0029.severity =
# dotnet_diagnostic.IDE0030.severity =
# dotnet_diagnostic.IDE0270.severity =
## Options:
## dotnet_style_coalesce_expression
## - true - Prefer null-coalescing expressions.
## - false - Disables the rule.
# dotnet_style_coalesce_expression =
## Use null propagation (IDE0031)
## This style rule concerns the use of the null-conditional operator versus a ternary conditional expression with null check.
# dotnet_diagnostic.IDE0031.severity =
## Options:
## dotnet_style_null_propagation
## - true - Prefer to use null-conditional operator when possible
## - false - Prefer to use ternary null checking where possible
## // dotnet_style_null_propagation = true
## var v = o?.ToString();
##
## // dotnet_style_null_propagation = false
## var v = o == null ? null : o.ToString(); // or
## var v = o != null ? o.ToString() : null;
# dotnet_style_null_propagation =
## Use auto-implemented property (IDE0032)
## This style rule concerns the use of auto-implemented properties versus properties with private backing fields.
# dotnet_diagnostic.IDE0032.severity =
## Options:
## dotnet_style_prefer_auto_properties
## - true - Prefer auto-implemented properties
## - false - Prefer properties with private backing fields
## // dotnet_style_prefer_auto_properties = true
## public int Age { get; }
##
## // dotnet_style_prefer_auto_properties = false
## private int age;
##
## public int Age
## {
## get
## {
## return age;
## }
## }
# dotnet_style_prefer_auto_properties =
## Use explicitly provided tuple name (IDE0033)
## This style rule concerns the use of explicit tuple names versus implicit 'ItemX' properties when accessing tuple fields.
# dotnet_diagnostic.IDE0033.severity =
## Options:
## dotnet_style_explicit_tuple_names
## - true - Prefer tuple names to ItemX properties
## - false - Prefer ItemX properties to tuple names
## // dotnet_style_explicit_tuple_names = true
## (string name, int age) customer = GetCustomer();
## var name = customer.name;
##
## // dotnet_style_explicit_tuple_names = false
## (string name, int age) customer = GetCustomer();
## var name = customer.Item1;
# dotnet_style_explicit_tuple_names =
## Simplify default expression (IDE0034)
## This style rule concerns using the default literal for default value expressions when the compiler can infer the type of the expression.
# dotnet_diagnostic.IDE0034.severity =
## Options:
## csharp_prefer_simple_default_expression
## - true - Prefer default over default(T)
## - false - Prefer default(T) over default
## // csharp_prefer_simple_default_expression = true
## void DoWork(CancellationToken cancellationToken = default) { ... }
##
## // csharp_prefer_simple_default_expression = false
## void DoWork(CancellationToken cancellationToken = default(CancellationToken)) { ... }
# csharp_prefer_simple_default_expression =
## Remove unreachable code (IDE0035)
## This rule flags executable code within methods and properties that can never be reached, and hence can be removed.
## // Code with violations
## void M()
## {
## throw new System.Exception();
##
## // IDE0035: Remove unreachable code
## int v = 0;
## }
##
## // Fixed code
## void M()
## {
## throw new System.Exception();
## }
# dotnet_diagnostic.IDE0035.severity =
## Order modifiers (IDE0036)
## This rule lets you enforce a desired modifier sort order.
## When this rule is enabled and the associated options are set to a list of modifiers, prefer the specified ordering.
## When this rule is not enabled, no specific modifier order is preferred.
# dotnet_diagnostic.IDE0036.severity =
## Options:
## csharp_preferred_modifier_order
## - One or more C# modifiers, such as public, private, and protected -
## // csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async
## class MyClass
## {
## private static readonly int _daysInYear = 365;
## }
# csharp_preferred_modifier_order =
## Use inferred member name (IDE0037)
## This rule enforces whether inferred tuple element names and inferred anonymous type member names are preferred when the tuple or anonymous type is declared.
# dotnet_diagnostic.IDE0037.severity =
## Options:
## dotnet_style_prefer_inferred_tuple_names
## - true - Prefer inferred tuple element names
## - false - Prefer explicit tuple element names
## // dotnet_style_prefer_inferred_tuple_names = true
## var tuple = (age, name);
##
## // dotnet_style_prefer_inferred_tuple_names = false
## var tuple = (age: age, name: name);
# dotnet_style_prefer_inferred_tuple_names =
## dotnet_style_prefer_inferred_anonymous_type_member_names
## - true - Prefer inferred anonymous type member names
## - false - Prefer explicit anonymous type member names
## // dotnet_style_prefer_inferred_anonymous_type_member_names = true
## var anon = new { age, name };
##
## // dotnet_style_prefer_inferred_anonymous_type_member_names = false
## var anon = new { age = age, name = name };
# dotnet_style_prefer_inferred_anonymous_type_member_names =
## Use local function instead of lambda (IDE0039)
## This style rule concerns the use of local functions versus lambda expressions (anonymous functions).
# dotnet_diagnostic.IDE0039.severity =
## Options:
## csharp_style_prefer_local_over_anonymous_function
## - true - Prefer local functions over anonymous functions
## - false - Prefer anonymous functions over local functions
## // csharp_style_prefer_local_over_anonymous_function = true
## int fibonacci(int n)
## {
## return n <= 1 ? 1 : fibonacci(n-1) + fibonacci(n-2);
## }
##
## // csharp_style_prefer_local_over_anonymous_function = false
## Func<int, int> fibonacci = (int n) =>
## {
## return n <= 1 ? 1 : fibonacci(n - 1) + fibonacci(n - 2);
## };
# csharp_style_prefer_local_over_anonymous_function =
## Add accessibility modifiers (IDE0040)
## This style rule concerns requiring accessibility modifiers in declarations.
# dotnet_diagnostic.IDE0040.severity =
## Options:
## dotnet_style_require_accessibility_modifiers
## - always - Prefer accessibility modifiers to be specified.
## - for_non_interface_members - Prefer accessibility modifiers except for public interface members.
## - never - Do not prefer accessibility modifiers to be specified.
## - omit_if_default - Prefer accessibility modifiers except if they are the default modifier.
## // dotnet_style_require_accessibility_modifiers = always
## // dotnet_style_require_accessibility_modifiers = for_non_interface_members
## class MyClass
## {
## private const string thisFieldIsConst = "constant";
## }
##
## // dotnet_style_require_accessibility_modifiers = never
## class MyClass
## {
## const string thisFieldIsConst = "constant";
## }
# dotnet_style_require_accessibility_modifiers =
## Use 'is null' check (IDE0041)
## This style rule concerns the use of a null check with pattern matching versus the use of the equality operator (==) or calling System.Object.ReferenceEquals(System.Object,System.Object).
# dotnet_diagnostic.IDE0041.severity =
## Options:
## dotnet_style_prefer_is_null_check_over_reference_equality_method
## - true - Prefer is null check
## - false - Prefer reference equality method
## // dotnet_style_prefer_is_null_check_over_reference_equality_method = true
## if (value is null)
## return;
##
## // dotnet_style_prefer_is_null_check_over_reference_equality_method = false
## if (object.ReferenceEquals(value, null))
## return;
##
## // dotnet_style_prefer_is_null_check_over_reference_equality_method = false
## if ((object)o == null)
## return;
# dotnet_style_prefer_is_null_check_over_reference_equality_method =
## Deconstruct variable declaration (IDE0042)
## This style rule concerns the use of deconstruction in variable declarations, when possible.
# dotnet_diagnostic.IDE0042.severity =
## Options:
## csharp_style_deconstructed_variable_declaration
## - true - Prefer deconstructed variable declaration
## - false - Do not prefer deconstruction in variable declarations
## // csharp_style_deconstructed_variable_declaration = true
## var (name, age) = GetPersonTuple();
## Console.WriteLine($"{name} {age}");
##
## (int x, int y) = GetPointTuple();
## Console.WriteLine($"{x} {y}");
##
## // csharp_style_deconstructed_variable_declaration = false
## var person = GetPersonTuple();
## Console.WriteLine($"{person.name} {person.age}");
##
## (int x, int y) point = GetPointTuple();
## Console.WriteLine($"{point.x} {point.y}");
# csharp_style_deconstructed_variable_declaration =
## Add readonly modifier (IDE0044)
## This style rule concerns specifying the readonly (C#) or ReadOnly (Visual Basic) modifier for private fields that are initialized (either inline or inside of a constructor) but never reassigned.
# dotnet_diagnostic.IDE0044.severity =
## Options:
## dotnet_style_readonly_field
## - true - Prefer that private fields be marked readonly if they're only ever assigned inline or in a constructor
## - false - Specify no preference over whether private fields are marked readonly
## // dotnet_style_readonly_field = true
## class MyClass
## {
## private readonly int _daysInYear = 365;
## }
# dotnet_style_readonly_field =
## Use conditional expression for assignment (IDE0045)
## This style rule concerns the use of a ternary conditional expression versus an if-else statement for assignments that require conditional logic.
# dotnet_diagnostic.IDE0045.severity =
## Options:
## dotnet_style_prefer_conditional_expression_over_assignment
## - true - Prefer assignments with a ternary conditional
## - false - Prefer assignments with an if-else statement
## // dotnet_style_prefer_conditional_expression_over_assignment = true
## string s = expr ? "hello" : "world";
##
## // dotnet_style_prefer_conditional_expression_over_assignment = false
## string s;
## if (expr)
## {
## s = "hello";
## }
## else
## {
## s = "world";
## }
# dotnet_style_prefer_conditional_expression_over_assignment =
## Use conditional expression for return (IDE0046)
## This style rule concerns the use of a ternary conditional expression versus an if-else statement for return statements that require conditional logic.
# dotnet_diagnostic.IDE0046.severity =
## Options:
## dotnet_style_prefer_conditional_expression_over_return
## - true - Prefer return statements to use a ternary conditional
## - false - Prefer return statements to use an if-else statement
## // dotnet_style_prefer_conditional_expression_over_return = true
## return expr ? "hello" : "world"
##
## // dotnet_style_prefer_conditional_expression_over_return = false
## if (expr)
## {
## return "hello";
## }
## else
## {
## return "world";
## }
# dotnet_style_prefer_conditional_expression_over_return =
## Remove unnecessary parentheses (IDE0047)
## Add parentheses for clarity (IDE0048)
## The style rules in this section concern parentheses preferences, including the use of parentheses to clarify precedence for arithmetic, relational, and other binary operators.
# dotnet_diagnostic.IDE0047.severity =
# dotnet_diagnostic.IDE0048.severity =
## Options:
## dotnet_style_parentheses_in_arithmetic_binary_operators
## - always_for_clarity - Prefer parentheses to clarify arithmetic operator precedence
## - never_if_unnecessary - Prefer no parentheses when arithmetic operator precedence is obvious
## // dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity
## var v = a + (b * c);
##
## // dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary
## var v = a + b * c;
# dotnet_style_parentheses_in_arithmetic_binary_operators =
## dotnet_style_parentheses_in_relational_binary_operators
## - always_for_clarity - Prefer parentheses to clarify relational operator precedence
## - never_if_unnecessary - Prefer to not have parentheses when relational operator precedence is obvious
## // dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity
## var v = (a < b) == (c > d);
##
## // dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary
## var v = a < b == c > d;
# dotnet_style_parentheses_in_relational_binary_operators =
## dotnet_style_parentheses_in_other_binary_operators
## - always_for_clarity - Prefer parentheses to clarify other binary operator precedence
## - never_if_unnecessary - Prefer to not have parentheses when other binary operator precedence is obvious
## // dotnet_style_parentheses_in_other_binary_operators = always_for_clarity
## var v = a || (b && c);
##
## // dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary
## var v = a || b && c;
# dotnet_style_parentheses_in_other_binary_operators =
## dotnet_style_parentheses_in_other_operators
## - always_for_clarity - Prefer parentheses to clarify other operator precedence
## - never_if_unnecessary - Prefer to not have parentheses when other operator precedence is obvious
## // dotnet_style_parentheses_in_other_operators = always_for_clarity
## var v = (a.b).Length;
##
## // dotnet_style_parentheses_in_other_operators = never_if_unnecessary
## var v = a.b.Length;
# dotnet_style_parentheses_in_other_operators =
## Use language keywords instead of framework type names for type references (IDE0049)
## This rule concerns the use of language keywords, where they exist, instead of framework type names.
# dotnet_diagnostic.IDE0049.severity =
## Options:
## dotnet_style_predefined_type_for_locals_parameters_members
## - true - Prefer the language keyword for local variables, method parameters, and class members
## - false - Prefer the type name for local variables, method parameters, and class members
## // dotnet_style_predefined_type_for_locals_parameters_members = true
## private int _member;
##
## // dotnet_style_predefined_type_for_locals_parameters_members = false
## private Int32 _member;
# dotnet_style_predefined_type_for_locals_parameters_members =
## dotnet_style_predefined_type_for_member_access
## - true - Prefer the language keyword for member access expressions
## - false - Prefer the type name for member access expressions
## // dotnet_style_predefined_type_for_member_access = true
## var local = int.MaxValue;
##
## // dotnet_style_predefined_type_for_member_access = false
## var local = Int32.MaxValue;
# dotnet_style_predefined_type_for_member_access =
## Convert anonymous type to tuple (IDE0050)
## This rule recommends use of tuples over anonymous types, when the anonymous type has two or more fields.
## // Code with violations
## var t1 = new { a = 1, b = 2 };
##
## // Fixed code
## var t1 = (a: 1, b: 2);
# dotnet_diagnostic.IDE0050.severity =
## Remove unused private member (IDE0051)
## This rule flags unused private methods, fields, properties, and events that have no read or write references.
## // Code with violations
## class C
## {
## // IDE0051: Remove unused private members
## private readonly int _fieldPrivate;
## private int PropertyPrivate => 1;
## private int GetNumPrivate() => 1;
##
## // No IDE0051
## internal readonly int FieldInternal;
## private readonly int _fieldPrivateUsed;
## public int PropertyPublic => _fieldPrivateUsed;
## private int GetNumPrivateUsed() => 1;
## internal int GetNumInternal() => GetNumPrivateUsed();
## public int GetNumPublic() => GetNumPrivateUsed();
## }
##
## // Fixed code
## class C
## {
## // No IDE0051
## internal readonly int FieldInternal;
## private readonly int _fieldPrivateUsed;
## public int PropertyPublic => _fieldPrivateUsed;
## private int GetNumPrivateUsed() => 1;
## internal int GetNumInternal() => GetNumPrivateUsed();
## public int GetNumPublic() => GetNumPrivateUsed();
## }
# dotnet_diagnostic.IDE0051.severity =
## Remove unread private member (IDE0052)
## This rule flags private fields and properties that have one or more write references but no read references. In this scenario, some parts of the code can be refactored or removed to fix maintainability, performance, or functional issues.
## // Code with violations
## class C
## {
## // IDE0052: Remove unread private members
## private readonly int _field1;
## private int _field2;
## private int Property { get; set; }
##
## public C()
## {
## _field1 = 0;
## }
##
## public void SetMethod()
## {
## _field2 = 0;
## Property = 0;
## }
## }
##
## // Fixed code
## class C
## {
## public C()
## {
## }
##
## public void SetMethod()
## {
## }
## }
# dotnet_diagnostic.IDE0052.severity =
## Use expression body for lambdas (IDE0053)
## This style rule concerns the use of expression bodies versus block bodies for lambda expressions.
# dotnet_diagnostic.IDE0053.severity =
## Options:
## csharp_style_expression_bodied_lambdas
## - true - Prefer expression bodies for lambdas
## - when_on_single_line - Prefer expression bodies for lambdas when they'll be a single line
## - false - Prefer block bodies for lambdas
## // csharp_style_expression_bodied_lambdas = true
## Func<int, int> square = x => x * x;
##
## // csharp_style_expression_bodied_lambdas = false
## Func<int, int> square = x => { return x * x; };
# csharp_style_expression_bodied_lambdas =
## Use compound assignment (IDE0054)
## Use coalesce compound assignment (IDE0074)
## These rules concern the use of compound assignment. IDE0074 is reported for coalesce compound assignments and IDE0054 is reported for other compound assignments.
# dotnet_diagnostic.IDE0054.severity =
# dotnet_diagnostic.IDE0074.severity =
## Options:
## dotnet_style_prefer_compound_assignment
## - true - Prefer compound assignment expressions
## - false - Don't prefer compound assignment expressions
## // dotnet_style_prefer_compound_assignment = true
## x += 5;
##
## // dotnet_style_prefer_compound_assignment = false
## x = x + 5;
# dotnet_style_prefer_compound_assignment =
## Formatting rule (IDE0055)
##
# dotnet_diagnostic.IDE0055.severity =
## Options:
## dotnet_sort_system_directives_first
## - true - Sort System.* using directives alphabetically, and place them before other using directives.
## - false - Do not place System.* using directives before other using directives.
## // dotnet_sort_system_directives_first = true
## using System.Collections.Generic;
## using System.Threading.Tasks;
## using Octokit;
##
## // dotnet_sort_system_directives_first = false
## using System.Collections.Generic;
## using Octokit;
## using System.Threading.Tasks;
# dotnet_sort_system_directives_first =
## dotnet_separate_import_directive_groups
## - true - Place a blank line between using directive groups.
## - false - Do not place a blank line between using directive groups.
## // dotnet_separate_import_directive_groups = true
## using System.Collections.Generic;
## using System.Threading.Tasks;
##
## using Octokit;
##
## // dotnet_separate_import_directive_groups = false
## using System.Collections.Generic;
## using System.Threading.Tasks;
## using Octokit;
# dotnet_separate_import_directive_groups =
## csharp_new_line_before_open_brace
## - all - Require braces to be on a new line for all expressions ("Allman" style).
## - none - Require braces to be on the same line for all expressions ("K&R").
## - accessors, anonymous_methods, anonymous_types, control_blocks, events, indexers,lambdas, local_functions, methods, object_collection_array_initializers, properties, types - Require braces to be on a new line for the specified code element ("Allman" style).
## // csharp_new_line_before_open_brace = all
## void MyMethod()
## {
## if (...)
## {
## ...
## }
## }
##
## // csharp_new_line_before_open_brace = none
## void MyMethod() {
## if (...) {
## ...
## }
## }
# csharp_new_line_before_open_brace =
## csharp_new_line_before_else
## - true - Place else statements on a new line.
## - false - Place else statements on the same line.
## // csharp_new_line_before_else = true
## if (...) {
## ...
## }
## else {
## ...
## }
##
## // csharp_new_line_before_else = false
## if (...) {
## ...
## } else {
## ...
## }
# csharp_new_line_before_else =
## csharp_new_line_before_catch
## - true - Place catch statements on a new line.
## - false - Place catch statements on the same line.
## // csharp_new_line_before_catch = true
## try {
## ...
## }
## catch (Exception e) {
## ...
## }
##
## // csharp_new_line_before_catch = false
## try {
## ...
## } catch (Exception e) {
## ...
## }
# csharp_new_line_before_catch =
## csharp_new_line_before_finally
## - true - Require finally statements to be on a new line after the closing brace.
## - false - Require finally statements to be on the same line as the closing brace.
## // csharp_new_line_before_finally = true
## try {
## ...
## }
## catch (Exception e) {
## ...
## }
## finally {
## ...
## }
##
## // csharp_new_line_before_finally = false
## try {
## ...
## } catch (Exception e) {
## ...
## } finally {