Skip to content

Commit 91c4c77

Browse files
author
Paul Johnson
authored
Switch a lot of warnings to suggestions until we are able to resolve. (#11974)
* Switch a lot of warnings to suggestions until we are able to resolve. * Make stylecop respect more csharp_style rules e.g. csharp_using_directive_placement * Added cheatsheet * Drop sorting requirements for using directives.
1 parent cf410ab commit 91c4c77

File tree

5 files changed

+82
-84
lines changed

5 files changed

+82
-84
lines changed

.editorconfig

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -306,48 +306,6 @@ dotnet_naming_rule.other_public_protected_fields_disallowed_rule.symbols
306306
dotnet_naming_rule.other_public_protected_fields_disallowed_rule.style = disallowed_style
307307
dotnet_naming_rule.other_public_protected_fields_disallowed_rule.severity = error
308308

309-
##########################################
310-
# StyleCop Field Naming Rules
311-
# Naming rules for fields follow the StyleCop analyzers
312-
# This does not override any rules using disallowed_style above
313-
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers
314-
##########################################
315-
316-
# All constant fields must be PascalCase
317-
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1303.md
318-
dotnet_naming_symbols.stylecop_constant_fields_group.applicable_accessibilities = public, internal, protected_internal, protected, private_protected, private
319-
dotnet_naming_symbols.stylecop_constant_fields_group.required_modifiers = const
320-
dotnet_naming_symbols.stylecop_constant_fields_group.applicable_kinds = field
321-
dotnet_naming_rule.stylecop_constant_fields_must_be_pascal_case_rule.symbols = stylecop_constant_fields_group
322-
dotnet_naming_rule.stylecop_constant_fields_must_be_pascal_case_rule.style = pascal_case_style
323-
dotnet_naming_rule.stylecop_constant_fields_must_be_pascal_case_rule.severity = warning
324-
325-
# All static readonly fields must be PascalCase
326-
# Ajusted to ignore private fields.
327-
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1311.md
328-
dotnet_naming_symbols.stylecop_static_readonly_fields_group.applicable_accessibilities = public, internal, protected_internal, protected, private_protected
329-
dotnet_naming_symbols.stylecop_static_readonly_fields_group.required_modifiers = static, readonly
330-
dotnet_naming_symbols.stylecop_static_readonly_fields_group.applicable_kinds = field
331-
dotnet_naming_rule.stylecop_static_readonly_fields_must_be_pascal_case_rule.symbols = stylecop_static_readonly_fields_group
332-
dotnet_naming_rule.stylecop_static_readonly_fields_must_be_pascal_case_rule.style = pascal_case_style
333-
dotnet_naming_rule.stylecop_static_readonly_fields_must_be_pascal_case_rule.severity = warning
334-
335-
# No non-private instance fields are allowed
336-
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1401.md
337-
dotnet_naming_symbols.stylecop_fields_must_be_private_group.applicable_accessibilities = public, internal, protected_internal, protected, private_protected
338-
dotnet_naming_symbols.stylecop_fields_must_be_private_group.applicable_kinds = field
339-
dotnet_naming_rule.stylecop_instance_fields_must_be_private_rule.symbols = stylecop_fields_must_be_private_group
340-
dotnet_naming_rule.stylecop_instance_fields_must_be_private_rule.style = disallowed_style
341-
dotnet_naming_rule.stylecop_instance_fields_must_be_private_rule.severity = error
342-
343-
# Local variables must be camelCase
344-
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1312.md
345-
dotnet_naming_symbols.stylecop_local_fields_group.applicable_accessibilities = local
346-
dotnet_naming_symbols.stylecop_local_fields_group.applicable_kinds = local
347-
dotnet_naming_rule.stylecop_local_fields_must_be_camel_case_rule.symbols = stylecop_local_fields_group
348-
dotnet_naming_rule.stylecop_local_fields_must_be_camel_case_rule.style = camel_case_style
349-
dotnet_naming_rule.stylecop_local_fields_must_be_camel_case_rule.severity = silent
350-
351309
# This rule should never fire. However, it's included for at least two purposes:
352310
# First, it helps to understand, reason about, and root-case certain types of issues, such as bugs in .editorconfig parsers.
353311
# Second, it helps to raise immediate awareness if a new field type is added (as occurred recently in C#).
@@ -357,7 +315,6 @@ dotnet_naming_rule.sanity_check_uncovered_field_case_rule.symbols = sanity_chec
357315
dotnet_naming_rule.sanity_check_uncovered_field_case_rule.style = internal_error_style
358316
dotnet_naming_rule.sanity_check_uncovered_field_case_rule.severity = error
359317

360-
361318
##########################################
362319
# Other Naming Rules
363320
##########################################

.globalconfig

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
is_global = true
2+
3+
##########################################
4+
# StyleCopAnalyzers Settings
5+
##########################################
6+
7+
# All constant fields must be PascalCase
8+
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1303.md
9+
dotnet_naming_symbols.stylecop_constant_fields_group.applicable_accessibilities = public, internal, protected_internal, protected, private_protected, private
10+
dotnet_naming_symbols.stylecop_constant_fields_group.required_modifiers = const
11+
dotnet_naming_symbols.stylecop_constant_fields_group.applicable_kinds = field
12+
dotnet_naming_rule.stylecop_constant_fields_must_be_pascal_case_rule.symbols = stylecop_constant_fields_group
13+
dotnet_naming_rule.stylecop_constant_fields_must_be_pascal_case_rule.style = pascal_case_style
14+
15+
# All static readonly fields must be PascalCase
16+
# Ajusted to ignore private fields.
17+
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1311.md
18+
dotnet_naming_symbols.stylecop_static_readonly_fields_group.applicable_accessibilities = public, internal, protected_internal, protected, private_protected
19+
dotnet_naming_symbols.stylecop_static_readonly_fields_group.required_modifiers = static, readonly
20+
dotnet_naming_symbols.stylecop_static_readonly_fields_group.applicable_kinds = field
21+
dotnet_naming_rule.stylecop_static_readonly_fields_must_be_pascal_case_rule.symbols = stylecop_static_readonly_fields_group
22+
dotnet_naming_rule.stylecop_static_readonly_fields_must_be_pascal_case_rule.style = pascal_case_style
23+
24+
# No non-private instance fields are allowed
25+
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1401.md
26+
dotnet_naming_symbols.stylecop_fields_must_be_private_group.applicable_accessibilities = public, internal, protected_internal, protected, private_protected
27+
dotnet_naming_symbols.stylecop_fields_must_be_private_group.applicable_kinds = field
28+
dotnet_naming_rule.stylecop_instance_fields_must_be_private_rule.symbols = stylecop_fields_must_be_private_group
29+
dotnet_naming_rule.stylecop_instance_fields_must_be_private_rule.style = disallowed_style
30+
31+
# Local variables must be camelCase
32+
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1312.md
33+
dotnet_naming_symbols.stylecop_local_fields_group.applicable_accessibilities = local
34+
dotnet_naming_symbols.stylecop_local_fields_group.applicable_kinds = local
35+
dotnet_naming_rule.stylecop_local_fields_must_be_camel_case_rule.symbols = stylecop_local_fields_group
36+
dotnet_naming_rule.stylecop_local_fields_must_be_camel_case_rule.style = camel_case_style
37+
38+
##########################################
39+
# StyleCopAnalyzers rule severity
40+
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers
41+
##########################################
42+
43+
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.DocumentationRules.severity = suggestion
44+
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.ReadabilityRules.severity = suggestion
45+
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.NamingRules.severity = suggestion
46+
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.SpacingRules.severity = suggestion
47+
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.OrderingRules.severity = suggestion
48+
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.MaintainabilityRules.severity = suggestion
49+
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.LayoutRules.severity = suggestion
50+
51+
dotnet_diagnostic.SA1636.severity = none # SA1636: File header copyright text should match
52+
53+
dotnet_diagnostic.SA1503.severity = warning # BracesMustNotBeOmitted
54+
dotnet_diagnostic.SA1117.severity = warning # ParametersMustBeOnSameLineOrSeparateLines
55+
dotnet_diagnostic.SA1116.severity = warning # SplitParametersMustStartOnLineAfterDeclaration
56+
dotnet_diagnostic.SA1122.severity = warning # UseStringEmptyForEmptyStrings
57+
dotnet_diagnostic.SA1028.severity = warning # CodeMustNotContainTrailingWhitespace
58+
dotnet_diagnostic.SA1500.severity = warning # BracesForMultiLineStatementsMustNotShareLine
59+
dotnet_diagnostic.SA1401.severity = warning # FieldsMustBePrivate
60+
dotnet_diagnostic.SA1519.severity = warning # BracesMustNotBeOmittedFromMultiLineChildStatement
61+
dotnet_diagnostic.SA1111.severity = warning # ClosingParenthesisMustBeOnLineOfLastParameter
62+
dotnet_diagnostic.SA1520.severity = warning # UseBracesConsistently
63+
dotnet_diagnostic.SA1407.severity = warning # ArithmeticExpressionsMustDeclarePrecedence
64+
dotnet_diagnostic.SA1400.severity = warning # AccessModifierMustBeDeclared
65+
dotnet_diagnostic.SA1119.severity = warning # StatementMustNotUseUnnecessaryParenthesis
66+
dotnet_diagnostic.SA1649.severity = warning # FileNameMustMatchTypeName
67+
dotnet_diagnostic.SA1121.severity = warning # UseBuiltInTypeAlias
68+
dotnet_diagnostic.SA1132.severity = warning # DoNotCombineFields
69+
dotnet_diagnostic.SA1134.severity = warning # AttributesMustNotShareLine
70+
dotnet_diagnostic.SA1106.severity = warning # CodeMustNotContainEmptyStatements
71+
dotnet_diagnostic.SA1312.severity = warning # VariableNamesMustBeginWithLowerCaseLetter
72+
dotnet_diagnostic.SA1303.severity = warning # ConstFieldNamesMustBeginWithUpperCaseLetter
73+
dotnet_diagnostic.SA1310.severity = warning # FieldNamesMustNotContainUnderscore
74+
dotnet_diagnostic.SA1130.severity = warning # UseLambdaSyntax
75+
dotnet_diagnostic.SA1405.severity = warning # DebugAssertMustProvideMessageText
76+
dotnet_diagnostic.SA1205.severity = warning # PartialElementsMustDeclareAccess
77+
dotnet_diagnostic.SA1306.severity = warning # FieldNamesMustBeginWithLowerCaseLetter
78+
dotnet_diagnostic.SA1209.severity = warning # UsingAliasDirectivesMustBePlacedAfterOtherUsingDirectives
79+
dotnet_diagnostic.SA1216.severity = warning # UsingStaticDirectivesMustBePlacedAtTheCorrectLocation
80+
dotnet_diagnostic.SA1133.severity = warning # DoNotCombineAttributes
81+
dotnet_diagnostic.SA1135.severity = warning # UsingDirectivesMustBeQualified

Directory.Build.props

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
<Project>
33
<!-- Package references and additional files which are consumed by all projects -->
44
<ItemGroup>
5-
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" IsImplicitlyDefined="true" />
6-
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" />
5+
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.406" PrivateAssets="all" IsImplicitlyDefined="true" />
76
</ItemGroup>
8-
9-
<!-- Specify rule set for all projects -->
10-
<PropertyGroup>
11-
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)codeanalysis.ruleset</CodeAnalysisRuleSet>
12-
</PropertyGroup>
137
</Project>

codeanalysis.ruleset

Lines changed: 0 additions & 18 deletions
This file was deleted.

stylecop.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)