Skip to content

Commit 13bd9df

Browse files
authored
Merge pull request #109 from nils-a/feature/GH-108
(#108) added a reference to stylecop
2 parents ddabf36 + d504c8a commit 13bd9df

9 files changed

+305
-17
lines changed

.editorconfig

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ root = true
55

66
[*]
77
end_of_line = CRLF
8+
trim_trailing_whitespace = true
89

9-
[*.ps1]
10-
indent_style = space
11-
indent_size = 4
10+
[*.md]
11+
trim_trailing_whitespace = false
1212

13-
[*.cs]
13+
[*.{bat,ps1}]
14+
charset = utf-8-bom
15+
end_of_line = crlf
1416
indent_style = space
1517
indent_size = 4
1618

Source/.editorconfig

Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
2+
# This may not be needed, but kept for compatibility with VS
3+
[*.{sln,csproj}]
4+
end_of_line = crlf
5+
indent_size = 2
6+
7+
# C# files
8+
[*.cs]
9+
10+
#### Core EditorConfig Options ####
11+
12+
# Indentation and spacing
13+
indent_size = 4
14+
indent_style = space
15+
tab_width = 4
16+
17+
# New line preferences
18+
end_of_line = crlf
19+
insert_final_newline = true
20+
21+
#### .NET Coding Conventions ####
22+
23+
# Organize usings
24+
dotnet_separate_import_directive_groups = true
25+
dotnet_sort_system_directives_first = true
26+
file_header_template = unset
27+
28+
# this. and Me. preferences
29+
dotnet_style_qualification_for_event = false:warning
30+
dotnet_style_qualification_for_field = false:warning
31+
dotnet_style_qualification_for_method = false:warning
32+
dotnet_style_qualification_for_property = false:warning
33+
34+
# Language keywords vs BCL types preferences
35+
dotnet_style_predefined_type_for_locals_parameters_members = true:warning
36+
dotnet_style_predefined_type_for_member_access = true:warning
37+
38+
# Parentheses preferences
39+
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
40+
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
41+
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
42+
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
43+
44+
# Modifier preferences
45+
dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning
46+
47+
# Expression-level preferences
48+
dotnet_style_coalesce_expression = true:suggestion
49+
dotnet_style_collection_initializer = true:suggestion
50+
dotnet_style_explicit_tuple_names = true:suggestion
51+
dotnet_style_null_propagation = true:suggestion
52+
dotnet_style_object_initializer = true:suggestion
53+
dotnet_style_operator_placement_when_wrapping = beginning_of_line
54+
dotnet_style_prefer_auto_properties = true:silent
55+
dotnet_style_prefer_compound_assignment = true:suggestion
56+
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
57+
dotnet_style_prefer_conditional_expression_over_return = true:silent
58+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
59+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
60+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
61+
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
62+
dotnet_style_prefer_simplified_interpolation = true:suggestion
63+
64+
# Field preferences
65+
dotnet_style_readonly_field = true:suggestion
66+
67+
# Parameter preferences
68+
dotnet_code_quality_unused_parameters = all:suggestion
69+
70+
#### C# Coding Conventions ####
71+
72+
# var preferences
73+
csharp_style_var_elsewhere = false:silent
74+
csharp_style_var_for_built_in_types = false:silent
75+
csharp_style_var_when_type_is_apparent = false:silent
76+
77+
# Expression-bodied members
78+
csharp_style_expression_bodied_accessors = true:silent
79+
csharp_style_expression_bodied_constructors = false:silent
80+
csharp_style_expression_bodied_indexers = true:silent
81+
csharp_style_expression_bodied_lambdas = true:silent
82+
csharp_style_expression_bodied_local_functions = false:silent
83+
csharp_style_expression_bodied_methods = false:silent
84+
csharp_style_expression_bodied_operators = false:silent
85+
csharp_style_expression_bodied_properties = true:silent
86+
87+
# Pattern matching preferences
88+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
89+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
90+
csharp_style_prefer_switch_expression = true:suggestion
91+
92+
# Null-checking preferences
93+
csharp_style_conditional_delegate_call = true:suggestion
94+
95+
# Modifier preferences
96+
csharp_prefer_static_local_function = true:suggestion
97+
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent
98+
99+
# Code-block preferences
100+
csharp_prefer_braces = true:silent
101+
csharp_prefer_simple_using_statement = true:suggestion
102+
103+
# Expression-level preferences
104+
csharp_prefer_simple_default_expression = true:suggestion
105+
csharp_style_deconstructed_variable_declaration = true:suggestion
106+
csharp_style_inlined_variable_declaration = true:suggestion
107+
csharp_style_pattern_local_over_anonymous_function = true:suggestion
108+
csharp_style_prefer_index_operator = true:suggestion
109+
csharp_style_prefer_range_operator = true:suggestion
110+
csharp_style_throw_expression = true:suggestion
111+
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
112+
csharp_style_unused_value_expression_statement_preference = discard_variable:silent
113+
114+
# 'using' directive preferences
115+
csharp_using_directive_placement = outside_namespace:warning
116+
117+
#### C# Formatting Rules ####
118+
119+
# New line preferences
120+
csharp_new_line_before_catch = true
121+
csharp_new_line_before_else = true
122+
csharp_new_line_before_finally = true
123+
csharp_new_line_before_members_in_anonymous_types = true
124+
csharp_new_line_before_members_in_object_initializers = true
125+
csharp_new_line_before_open_brace = all
126+
csharp_new_line_between_query_expression_clauses = true
127+
128+
# Indentation preferences
129+
csharp_indent_block_contents = true
130+
csharp_indent_braces = false
131+
csharp_indent_case_contents = true
132+
csharp_indent_case_contents_when_block = false
133+
csharp_indent_labels = flush_left
134+
csharp_indent_switch_labels = true
135+
136+
# Space preferences
137+
csharp_space_after_cast = false
138+
csharp_space_after_colon_in_inheritance_clause = true
139+
csharp_space_after_comma = true
140+
csharp_space_after_dot = false
141+
csharp_space_after_keywords_in_control_flow_statements = true
142+
csharp_space_after_semicolon_in_for_statement = true
143+
csharp_space_around_binary_operators = before_and_after
144+
csharp_space_around_declaration_statements = false
145+
csharp_space_before_colon_in_inheritance_clause = true
146+
csharp_space_before_comma = false
147+
csharp_space_before_dot = false
148+
csharp_space_before_open_square_brackets = false
149+
csharp_space_before_semicolon_in_for_statement = false
150+
csharp_space_between_empty_square_brackets = false
151+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
152+
csharp_space_between_method_call_name_and_opening_parenthesis = false
153+
csharp_space_between_method_call_parameter_list_parentheses = false
154+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
155+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
156+
csharp_space_between_method_declaration_parameter_list_parentheses = false
157+
csharp_space_between_parentheses = false
158+
csharp_space_between_square_brackets = false
159+
160+
# Wrapping preferences
161+
csharp_preserve_single_line_blocks = true
162+
csharp_preserve_single_line_statements = false
163+
164+
#### Naming styles ####
165+
166+
# Naming rules
167+
168+
dotnet_naming_rule.interface_should_be_begins_with_i.severity = warning
169+
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
170+
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
171+
172+
dotnet_naming_rule.types_should_be_pascal_case.severity = warning
173+
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
174+
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
175+
176+
dotnet_naming_rule.method_should_be_pascal_case.severity = warning
177+
dotnet_naming_rule.method_should_be_pascal_case.symbols = method
178+
dotnet_naming_rule.method_should_be_pascal_case.style = pascal_case
179+
180+
dotnet_naming_rule.public_or_protected_field_should_be_pascal_case.severity = warning
181+
dotnet_naming_rule.public_or_protected_field_should_be_pascal_case.symbols = public_or_protected_field
182+
dotnet_naming_rule.public_or_protected_field_should_be_pascal_case.style = pascal_case
183+
184+
dotnet_naming_rule.private_or_internal_static_field_should_be_pascal_case.severity = warning
185+
dotnet_naming_rule.private_or_internal_static_field_should_be_pascal_case.symbols = private_or_internal_static_field
186+
dotnet_naming_rule.private_or_internal_static_field_should_be_pascal_case.style = pascal_case
187+
188+
dotnet_naming_rule.private_or_internal_field_should_be_camelcase.severity = warning
189+
dotnet_naming_rule.private_or_internal_field_should_be_camelcase.symbols = private_or_internal_field
190+
dotnet_naming_rule.private_or_internal_field_should_be_camelcase.style = camelcase
191+
192+
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = warning
193+
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
194+
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
195+
196+
# Symbol specifications
197+
198+
dotnet_naming_symbols.interface.applicable_kinds = interface
199+
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
200+
dotnet_naming_symbols.interface.required_modifiers =
201+
202+
dotnet_naming_symbols.method.applicable_kinds = method
203+
dotnet_naming_symbols.method.applicable_accessibilities = public
204+
dotnet_naming_symbols.method.required_modifiers =
205+
206+
dotnet_naming_symbols.public_or_protected_field.applicable_kinds = field
207+
dotnet_naming_symbols.public_or_protected_field.applicable_accessibilities = public, protected
208+
dotnet_naming_symbols.public_or_protected_field.required_modifiers =
209+
210+
dotnet_naming_symbols.private_or_internal_field.applicable_kinds = field
211+
dotnet_naming_symbols.private_or_internal_field.applicable_accessibilities = internal, private, private_protected
212+
dotnet_naming_symbols.private_or_internal_field.required_modifiers =
213+
214+
dotnet_naming_symbols.private_or_internal_static_field.applicable_kinds = field
215+
dotnet_naming_symbols.private_or_internal_static_field.applicable_accessibilities = internal, private, private_protected
216+
dotnet_naming_symbols.private_or_internal_static_field.required_modifiers = static
217+
218+
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
219+
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
220+
dotnet_naming_symbols.types.required_modifiers =
221+
222+
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
223+
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
224+
dotnet_naming_symbols.non_field_members.required_modifiers =
225+
226+
# Naming styles
227+
228+
dotnet_naming_style.pascal_case.required_prefix =
229+
dotnet_naming_style.pascal_case.required_suffix =
230+
dotnet_naming_style.pascal_case.word_separator =
231+
dotnet_naming_style.pascal_case.capitalization = pascal_case
232+
233+
dotnet_naming_style.begins_with_i.required_prefix = I
234+
dotnet_naming_style.begins_with_i.required_suffix =
235+
dotnet_naming_style.begins_with_i.word_separator =
236+
dotnet_naming_style.begins_with_i.capitalization = pascal_case
237+
238+
dotnet_naming_style.camelcase.required_prefix =
239+
dotnet_naming_style.camelcase.required_suffix =
240+
dotnet_naming_style.camelcase.word_separator =
241+
dotnet_naming_style.camelcase.capitalization = camel_case
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RuleSet Name="Rules for Cake.DotNetVersionDetector" ToolsVersion="16.0">
3+
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
4+
<Rule Id="SA1101" Action="None" />
5+
<Rule Id="SA1633" Action="None" />
6+
</Rules>
7+
</RuleSet>

Source/Cake.DotNetVersionDetector.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.DotNetVersionDetector"
77
EndProject
88
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.DotNetVersionDetector.Tests", "Cake.DotNetVersionDetector.Tests\Cake.DotNetVersionDetector.Tests.csproj", "{78EB146D-2178-47FE-B999-1FECF1F3407B}"
99
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{3D89E7D0-898E-4F5D-8CB7-E572FC56E317}"
11+
ProjectSection(SolutionItems) = preProject
12+
Cake.DotNetVersionDetector.ruleset = Cake.DotNetVersionDetector.ruleset
13+
Directory.Build.targets = Directory.Build.targets
14+
EndProjectSection
15+
EndProject
1016
Global
1117
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1218
Debug|Any CPU = Debug|Any CPU

Source/Cake.DotNetVersionDetector/Cake.DotNetVersionDetector.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
<NeutralLanguage>en-GB</NeutralLanguage>
88
<AssemblyTitle>Cake DotNetVersionDetector addin</AssemblyTitle>
99
<Company>Cake Contributors</Company>
10+
<CodeAnalysisRuleSet>$(ProjectDir)../Cake.DotNetVersionDetector.ruleset</CodeAnalysisRuleSet>
1011
</PropertyGroup>
1112

1213
<ItemGroup>
14+
<AdditionalFiles Include="$(ProjectDir)../stylecop.json" Link="stylecop.json" />
15+
<None Include="$(ProjectDir)../.editorconfig" Link=".editorconfig" />
1316
<None Include="$(ProjectDir)../../README.md" Link="README.md" PackagePath="" Pack="true" />
1417
</ItemGroup>
1518

@@ -47,9 +50,14 @@
4750
</PackageReference>
4851
<PackageReference Include="Cake.Common" Version="1.0.0" PrivateAssets="All" />
4952
<PackageReference Include="Cake.Core" Version="1.0.0" PrivateAssets="All" />
53+
<PackageReference Include="JetBrains.Annotations" Version="2024.2.0" />
5054
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0">
5155
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
5256
<PrivateAssets>all</PrivateAssets>
5357
</PackageReference>
58+
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
59+
<PrivateAssets>all</PrivateAssets>
60+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
61+
</PackageReference>
5462
</ItemGroup>
5563
</Project>

Source/Cake.DotNetVersionDetector/DotNetVersionDetectorAliases.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
using Cake.Core.Annotations;
44
using Cake.Core.IO;
55

6+
using JetBrains.Annotations;
7+
68
namespace Cake.DotNetVersionDetector
79
{
810
/// <summary>
9-
/// <para>Contains functionality related to the <see href="http://www.asoft.be/prod_netver.html">.Net Version Detector</see> tool.</para>
11+
/// <para>Contains functionality related to the <see href="https://www.asoft.be/prod_netver.html">.Net Version Detector</see> tool.</para>
1012
/// <para>
1113
/// In order to use the commands for this addin, you will need to have the .Net Version Detector tool available. This can be installed via Chocolatey.
1214
/// In addition, you will need to include the following:
@@ -16,10 +18,11 @@ namespace Cake.DotNetVersionDetector
1618
/// </para>
1719
/// </summary>
1820
[CakeAliasCategory("DotNetVersionDetector")]
21+
[PublicAPI]
1922
public static class DotNetVersionDetectorAliases
2023
{
2124
/// <summary>
22-
/// Runs .Net Version Detector, and outputs to specified output FilePath
25+
/// Runs .Net Version Detector, and outputs to specified output FilePath.
2326
/// </summary>
2427
/// <param name="context">The context.</param>
2528
/// <param name="outputFilePath">The output file path.</param>
@@ -34,8 +37,8 @@ public static void DotNetVersionDetector(this ICakeContext context, FilePath out
3437
DotNetVersionDetector(context, outputFilePath, new DotNetVersionDetectorSettings());
3538
}
3639

37-
/// <summary>
38-
/// Runs .Net Version Detector, and outputs to specified output FilePath with the specified DotNetVersionDetectorSettings
40+
/// <summary>
41+
/// Runs .Net Version Detector, and outputs to specified output FilePath with the specified DotNetVersionDetectorSettings.
3942
/// </summary>
4043
/// <param name="context">The context.</param>
4144
/// <param name="outputFilePath">The output file path.</param>
@@ -53,12 +56,12 @@ public static void DotNetVersionDetector(this ICakeContext context, FilePath out
5356
{
5457
if (context == null)
5558
{
56-
throw new ArgumentNullException("context");
59+
throw new ArgumentNullException(nameof(context));
5760
}
5861

5962
if (outputFilePath == null)
6063
{
61-
throw new ArgumentNullException("outputFilePath");
64+
throw new ArgumentNullException(nameof(outputFilePath));
6265
}
6366

6467
var runner = new DotNetVersionDetectorRunner(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);

0 commit comments

Comments
 (0)