From 0b85fa05e40559a90b2e30d36790a5977ea7f4e1 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Fri, 17 Apr 2020 17:58:29 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Fix=20SA1124=20violation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 195 +++++++++++++++++++++ X10D.Drawing/ImageExtensions.cs | 4 - X10D.Unity/MaterialExtensions.cs | 4 - X10D.Unity/Vector3Extensions.cs | 4 - X10D.WinForms/ControlExtensions.cs | 4 - X10D.WinForms/ListViewExtensions.cs | 4 - X10D.ruleset | 254 ++++++++++++++++++++++++++++ X10D/src/BooleanExtensions.cs | 4 - X10D/src/ByteExtensions.cs | 4 - X10D/src/CharExtensions.cs | 4 - X10D/src/ComparableExtensions.cs | 4 - X10D/src/ConvertibleExtensions.cs | 4 - X10D/src/DateTimeExtensions.cs | 4 - X10D/src/DictionaryExtensions.cs | 4 - X10D/src/DoubleExtensions.cs | 4 - X10D/src/EndPointExtensions.cs | 4 - X10D/src/Int16Extensions.cs | 8 - X10D/src/Int32Extensions.cs | 12 -- X10D/src/Int64Extensions.cs | 8 - X10D/src/ListExtensions.cs | 4 - X10D/src/RandomExtensions.cs | 4 - X10D/src/SingleExtensions.cs | 4 - X10D/src/StreamExtensions.cs | 4 - X10D/src/StringExtensions.cs | 4 - X10D/src/StructExtensions.cs | 4 - X10D/src/TimeSpanParser.cs | 4 - 26 files changed, 449 insertions(+), 112 deletions(-) create mode 100644 .editorconfig create mode 100644 X10D.ruleset diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..8b0f5bc --- /dev/null +++ b/.editorconfig @@ -0,0 +1,195 @@ +# C# files +[*.cs] + +#### Core EditorConfig Options #### + +# Indentation and spacing +indent_size = 4 +indent_style = space +tab_width = 4 + +# New line preferences +end_of_line = crlf +insert_final_newline = true + +#### .NET Coding Conventions #### + +# Organize usings +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = true + +# this. and Me. preferences +dotnet_style_qualification_for_event = true:suggestion +dotnet_style_qualification_for_field = true:suggestion +dotnet_style_qualification_for_method = true:suggestion +dotnet_style_qualification_for_property = true:suggestion + +# Language keywords vs BCL types preferences +dotnet_style_predefined_type_for_locals_parameters_members = true:warning +dotnet_style_predefined_type_for_member_access = true:warning + +# Parentheses preferences +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent + +# Modifier preferences +dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent + +# Expression-level preferences +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_object_initializer = true:suggestion +dotnet_style_prefer_auto_properties = true:silent +dotnet_style_prefer_compound_assignment = true:suggestion +dotnet_style_prefer_conditional_expression_over_assignment = true:silent +dotnet_style_prefer_conditional_expression_over_return = true:silent +dotnet_style_prefer_inferred_anonymous_type_member_names = false:suggestion +dotnet_style_prefer_inferred_tuple_names = false:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion +dotnet_style_prefer_simplified_interpolation = true:suggestion + +# Field preferences +dotnet_style_readonly_field = true:suggestion + +# Parameter preferences +dotnet_code_quality_unused_parameters = all:suggestion + +#### C# Coding Conventions #### + +# var preferences +csharp_style_var_elsewhere = false:warning +csharp_style_var_for_built_in_types = true:warning +csharp_style_var_when_type_is_apparent = true:warning + +# Expression-bodied members +csharp_style_expression_bodied_accessors = true:suggestion +csharp_style_expression_bodied_constructors = false:suggestion +csharp_style_expression_bodied_indexers = true:suggestion +csharp_style_expression_bodied_lambdas = true:silent +csharp_style_expression_bodied_local_functions = false:silent +csharp_style_expression_bodied_methods = false:suggestion +csharp_style_expression_bodied_operators = true:suggestion +csharp_style_expression_bodied_properties = false:suggestion + +# Pattern matching preferences +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_prefer_switch_expression = true:suggestion + +# Null-checking preferences +csharp_style_conditional_delegate_call = true:suggestion + +# Modifier preferences +csharp_prefer_static_local_function = true:suggestion +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent + +# Code-block preferences +csharp_prefer_braces = true:suggestion +csharp_prefer_simple_using_statement = true:suggestion + +# Expression-level preferences +csharp_prefer_simple_default_expression = true:suggestion +csharp_style_deconstructed_variable_declaration = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion +csharp_style_pattern_local_over_anonymous_function = true:suggestion +csharp_style_prefer_index_operator = true:suggestion +csharp_style_prefer_range_operator = true:suggestion +csharp_style_throw_expression = true:suggestion +csharp_style_unused_value_assignment_preference = discard_variable:suggestion +csharp_style_unused_value_expression_statement_preference = discard_variable:silent + +# 'using' directive preferences +csharp_using_directive_placement = inside_namespace:suggestion + +#### C# Formatting Rules #### + +# New line preferences +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_open_brace = all +csharp_new_line_between_query_expression_clauses = true + +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true +csharp_indent_labels = one_less_than_current +csharp_indent_switch_labels = true + +# Space preferences +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_name_and_open_parenthesis = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false + +# Wrapping preferences +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +#### Naming styles #### + +# Naming rules + +dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i + +dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.types_should_be_pascal_case.symbols = types +dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case + +# Symbol specifications + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types.required_modifiers = + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = + +# Naming styles + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case + +dotnet_naming_style.begins_with_i.required_prefix = I +dotnet_naming_style.begins_with_i.required_suffix = +dotnet_naming_style.begins_with_i.word_separator = +dotnet_naming_style.begins_with_i.capitalization = pascal_case diff --git a/X10D.Drawing/ImageExtensions.cs b/X10D.Drawing/ImageExtensions.cs index a22786c..07dfcfa 100644 --- a/X10D.Drawing/ImageExtensions.cs +++ b/X10D.Drawing/ImageExtensions.cs @@ -1,15 +1,11 @@ namespace X10D.Drawing { - #region Using Directives - using System; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.Threading.Tasks; - #endregion - /// /// Extension methods for . /// diff --git a/X10D.Unity/MaterialExtensions.cs b/X10D.Unity/MaterialExtensions.cs index 3f9d7ad..7029ee2 100644 --- a/X10D.Unity/MaterialExtensions.cs +++ b/X10D.Unity/MaterialExtensions.cs @@ -1,12 +1,8 @@ namespace X10D.Unity { - #region Using Directives - using System.Diagnostics.CodeAnalysis; using UnityEngine; - #endregion - /// /// A set of extension methods for . /// diff --git a/X10D.Unity/Vector3Extensions.cs b/X10D.Unity/Vector3Extensions.cs index 2c80cac..6339f22 100644 --- a/X10D.Unity/Vector3Extensions.cs +++ b/X10D.Unity/Vector3Extensions.cs @@ -1,11 +1,7 @@ namespace X10D.Unity { - #region Using Directives - using UnityEngine; - #endregion - /// /// A set of extension methods for . /// diff --git a/X10D.WinForms/ControlExtensions.cs b/X10D.WinForms/ControlExtensions.cs index efbf640..97bee63 100644 --- a/X10D.WinForms/ControlExtensions.cs +++ b/X10D.WinForms/ControlExtensions.cs @@ -1,14 +1,10 @@ namespace X10D.WinForms { - #region Using Directives - using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; - #endregion - /// /// Extension methods for . /// diff --git a/X10D.WinForms/ListViewExtensions.cs b/X10D.WinForms/ListViewExtensions.cs index e0dcd36..a75aad8 100644 --- a/X10D.WinForms/ListViewExtensions.cs +++ b/X10D.WinForms/ListViewExtensions.cs @@ -1,11 +1,7 @@ namespace X10D.WinForms { - #region Using Directives - using System.Windows.Forms; - #endregion - /// /// A set of extension methods for and . /// diff --git a/X10D.ruleset b/X10D.ruleset new file mode 100644 index 0000000..f94a881 --- /dev/null +++ b/X10D.ruleset @@ -0,0 +1,254 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/X10D/src/BooleanExtensions.cs b/X10D/src/BooleanExtensions.cs index 100733a..41eac29 100644 --- a/X10D/src/BooleanExtensions.cs +++ b/X10D/src/BooleanExtensions.cs @@ -1,11 +1,7 @@ namespace X10D { - #region Using Directives - using System; - #endregion - /// /// Extension methods for . /// diff --git a/X10D/src/ByteExtensions.cs b/X10D/src/ByteExtensions.cs index 0469cb4..5617885 100644 --- a/X10D/src/ByteExtensions.cs +++ b/X10D/src/ByteExtensions.cs @@ -1,14 +1,10 @@ namespace X10D { - #region Using Directives - using System; using System.Collections.Generic; using System.Linq; using System.Text; - #endregion - /// /// Extension methods for . /// diff --git a/X10D/src/CharExtensions.cs b/X10D/src/CharExtensions.cs index ab0f64f..1e526f4 100644 --- a/X10D/src/CharExtensions.cs +++ b/X10D/src/CharExtensions.cs @@ -1,14 +1,10 @@ namespace X10D { - #region Using Directives - using System; using System.Collections.Generic; using System.Linq; using System.Text; - #endregion - /// /// Extension methods for . /// diff --git a/X10D/src/ComparableExtensions.cs b/X10D/src/ComparableExtensions.cs index c1bad5b..d0991ca 100644 --- a/X10D/src/ComparableExtensions.cs +++ b/X10D/src/ComparableExtensions.cs @@ -1,11 +1,7 @@ namespace X10D { - #region Using Directives - using System; - #endregion - /// /// Extension methods for . /// diff --git a/X10D/src/ConvertibleExtensions.cs b/X10D/src/ConvertibleExtensions.cs index 39fbefc..51e7b97 100644 --- a/X10D/src/ConvertibleExtensions.cs +++ b/X10D/src/ConvertibleExtensions.cs @@ -1,11 +1,7 @@ namespace X10D { - #region Using Directives - using System; - #endregion - /// /// Extension methods for . /// diff --git a/X10D/src/DateTimeExtensions.cs b/X10D/src/DateTimeExtensions.cs index e505b80..d66e037 100644 --- a/X10D/src/DateTimeExtensions.cs +++ b/X10D/src/DateTimeExtensions.cs @@ -1,11 +1,7 @@ namespace X10D { - #region Using Directives - using System; - #endregion - /// /// Extension methods for . /// diff --git a/X10D/src/DictionaryExtensions.cs b/X10D/src/DictionaryExtensions.cs index d92977f..d4895a9 100644 --- a/X10D/src/DictionaryExtensions.cs +++ b/X10D/src/DictionaryExtensions.cs @@ -1,15 +1,11 @@ namespace X10D { - #region Using Directives - using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Web; - #endregion - /// /// A set of extension methods for . /// diff --git a/X10D/src/DoubleExtensions.cs b/X10D/src/DoubleExtensions.cs index 424a218..f80ad71 100644 --- a/X10D/src/DoubleExtensions.cs +++ b/X10D/src/DoubleExtensions.cs @@ -1,11 +1,7 @@ namespace X10D { - #region Using Directives - using System; - #endregion - /// /// Extension methods for . /// diff --git a/X10D/src/EndPointExtensions.cs b/X10D/src/EndPointExtensions.cs index 80325ee..e6af2f6 100644 --- a/X10D/src/EndPointExtensions.cs +++ b/X10D/src/EndPointExtensions.cs @@ -1,12 +1,8 @@ namespace X10D { - #region Using Directives - using System; using System.Net; - #endregion - /// /// Extension methods for and derived types. /// diff --git a/X10D/src/Int16Extensions.cs b/X10D/src/Int16Extensions.cs index a4272cd..de77f73 100644 --- a/X10D/src/Int16Extensions.cs +++ b/X10D/src/Int16Extensions.cs @@ -1,18 +1,12 @@ namespace X10D { - #region Using Directives - using System; - #endregion - /// /// Extension methods for . /// public static class Int16Extensions { - #region TimeSpan Returns - // TODO change [Obsolete( @@ -123,8 +117,6 @@ return TimeSpan.FromTicks(number); } - #endregion - /// /// Clamps a value between a minimum and a maximum value. /// diff --git a/X10D/src/Int32Extensions.cs b/X10D/src/Int32Extensions.cs index c8b7a2d..a251b63 100644 --- a/X10D/src/Int32Extensions.cs +++ b/X10D/src/Int32Extensions.cs @@ -1,18 +1,12 @@ namespace X10D { - #region Using Directives - using System; - #endregion - /// /// Extension methods for . /// public static class Int32Extensions { - #region DateTime Returns - /// /// Returns a where the month is January. /// @@ -213,10 +207,6 @@ return new DateTime(year, 12, day, hour, minute, second); } - #endregion - - #region TimeSpan Returns - // TODO change [Obsolete( @@ -327,8 +317,6 @@ return TimeSpan.FromTicks(number); } - #endregion - /// /// Clamps a value between a minimum and a maximum value. /// diff --git a/X10D/src/Int64Extensions.cs b/X10D/src/Int64Extensions.cs index 4424e37..0691e0a 100644 --- a/X10D/src/Int64Extensions.cs +++ b/X10D/src/Int64Extensions.cs @@ -1,18 +1,12 @@ namespace X10D { - #region Using Directives - using System; - #endregion - /// /// Extension methods for . /// public static class Int64Extensions { - #region TimeSpan Returns - // TODO change [Obsolete( @@ -114,8 +108,6 @@ return TimeSpan.FromTicks(number); } - #endregion - /// /// Clamps a value between a minimum and a maximum value. /// diff --git a/X10D/src/ListExtensions.cs b/X10D/src/ListExtensions.cs index cc2003e..d98968f 100644 --- a/X10D/src/ListExtensions.cs +++ b/X10D/src/ListExtensions.cs @@ -1,13 +1,9 @@ namespace X10D { - #region Using Directives - using System; using System.Collections.Generic; using System.Linq; - #endregion - /// /// Extension methods for . /// diff --git a/X10D/src/RandomExtensions.cs b/X10D/src/RandomExtensions.cs index 42af3d4..70c4657 100644 --- a/X10D/src/RandomExtensions.cs +++ b/X10D/src/RandomExtensions.cs @@ -1,13 +1,9 @@ namespace X10D { - #region Using Directives - using System; using System.Collections.Generic; using System.Linq; - #endregion - /// /// Extension methods for . /// diff --git a/X10D/src/SingleExtensions.cs b/X10D/src/SingleExtensions.cs index 9a27c85..e098345 100644 --- a/X10D/src/SingleExtensions.cs +++ b/X10D/src/SingleExtensions.cs @@ -1,11 +1,7 @@ namespace X10D { - #region Using Directives - using System; - #endregion - /// /// Extension methods for . /// diff --git a/X10D/src/StreamExtensions.cs b/X10D/src/StreamExtensions.cs index ab1e71a..8cd54d1 100644 --- a/X10D/src/StreamExtensions.cs +++ b/X10D/src/StreamExtensions.cs @@ -1,14 +1,10 @@ namespace X10D { - #region Using Directives - using System; using System.IO; using System.Reflection; using System.Security.Cryptography; - #endregion - /// /// Extension methods for . /// diff --git a/X10D/src/StringExtensions.cs b/X10D/src/StringExtensions.cs index 431a7c5..cd511c2 100644 --- a/X10D/src/StringExtensions.cs +++ b/X10D/src/StringExtensions.cs @@ -1,7 +1,5 @@ namespace X10D { - #region Using Directives - using System; using System.Collections.Generic; using System.Linq; @@ -9,8 +7,6 @@ using System.Security; using System.Text; - #endregion - /// /// Extension methods for . /// diff --git a/X10D/src/StructExtensions.cs b/X10D/src/StructExtensions.cs index f23cac8..6298fcd 100644 --- a/X10D/src/StructExtensions.cs +++ b/X10D/src/StructExtensions.cs @@ -1,11 +1,7 @@ namespace X10D { - #region Using Directives - using System; - #endregion - /// /// Extension methods for types. /// diff --git a/X10D/src/TimeSpanParser.cs b/X10D/src/TimeSpanParser.cs index 1cdd1ca..a2ad5ab 100644 --- a/X10D/src/TimeSpanParser.cs +++ b/X10D/src/TimeSpanParser.cs @@ -1,13 +1,9 @@ namespace X10D { - #region Using Directives - using System; using System.Diagnostics; using System.Text.RegularExpressions; - #endregion - public static class TimeSpanParser { ///