From 78719acdc7582eaaab2657191ec9ec8a570d937c Mon Sep 17 00:00:00 2001 From: Westin Musser <127992899+westin-m@users.noreply.github.com> Date: Fri, 11 Oct 2024 14:29:38 -0700 Subject: [PATCH] align editor config with other libraries (#3079) --- .editorconfig | 55 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/.editorconfig b/.editorconfig index d40e99305..7f5816d5c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,7 +1,4 @@ -# Note: MSAL rules used as a starting point - # editorconfig.org -# Copied from the .NET Core repo https://github.com/dotnet/corefx/blob/master/.editorconfig # top-most EditorConfig file root = true @@ -13,7 +10,7 @@ root = true insert_final_newline = true indent_style = space indent_size = 4 -dotnet_diagnostic.CA1308.severity=warning +trim_trailing_whitespace = true [project.json] indent_size = 2 @@ -33,6 +30,7 @@ csharp_new_line_between_query_expression_clauses = true csharp_indent_block_contents = true csharp_indent_braces = false csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true csharp_indent_switch_labels = true csharp_indent_labels = one_less_than_current @@ -84,9 +82,18 @@ dotnet_naming_style.camel_case_underscore_style.required_prefix = _ dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case # Code style defaults +csharp_using_directive_placement = outside_namespace:suggestion dotnet_sort_system_directives_first = true -csharp_preserve_single_line_blocks = true -csharp_preserve_single_line_statements = false +csharp_prefer_braces = true:silent +csharp_preserve_single_line_blocks = true:none +csharp_preserve_single_line_statements = false:none +csharp_prefer_static_local_function = true:suggestion +csharp_prefer_simple_using_statement = false:none +csharp_style_prefer_switch_expression = true:suggestion + +# Code quality +dotnet_style_readonly_field = true:suggestion +dotnet_code_quality_unused_parameters = non_public:suggestion # Expression-level preferences dotnet_style_object_initializer = true:suggestion @@ -94,14 +101,23 @@ dotnet_style_collection_initializer = true:suggestion dotnet_style_explicit_tuple_names = true:suggestion dotnet_style_coalesce_expression = true:suggestion dotnet_style_null_propagation = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion +dotnet_style_prefer_inferred_tuple_names = true:suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_auto_properties = true:suggestion +dotnet_style_prefer_conditional_expression_over_assignment = true:silent +dotnet_style_prefer_conditional_expression_over_return = true:silent +csharp_prefer_simple_default_expression = true:suggestion # Expression-bodied members -csharp_style_expression_bodied_methods = false:none -csharp_style_expression_bodied_constructors = false:none -csharp_style_expression_bodied_operators = false:none -csharp_style_expression_bodied_properties = true:none -csharp_style_expression_bodied_indexers = true:none -csharp_style_expression_bodied_accessors = true:none +csharp_style_expression_bodied_methods = true:silent +csharp_style_expression_bodied_constructors = true:silent +csharp_style_expression_bodied_operators = true:silent +csharp_style_expression_bodied_properties = true:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_accessors = true:silent +csharp_style_expression_bodied_lambdas = true:silent +csharp_style_expression_bodied_local_functions = true:silent # Pattern matching csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion @@ -112,6 +128,11 @@ csharp_style_inlined_variable_declaration = true:suggestion csharp_style_throw_expression = true:suggestion csharp_style_conditional_delegate_call = true:suggestion +# Other features +csharp_style_prefer_index_operator = false:none +csharp_style_prefer_range_operator = false:none +csharp_style_pattern_local_over_anonymous_function = false:none + # Space preferences csharp_space_after_cast = false csharp_space_after_colon_in_inheritance_clause = true @@ -136,6 +157,10 @@ csharp_space_between_method_declaration_parameter_list_parentheses = false csharp_space_between_parentheses = false csharp_space_between_square_brackets = false +# Analyzers +dotnet_code_quality.CA1802.api_surface = private, internal +dotnet_code_quality.CA2208.api_surface = public + # Id Web Rules # RS0030: Do not used banned APIs @@ -238,6 +263,9 @@ dotnet_diagnostic.CA1067.severity = error # CA1068: CancellationToken parameters must come last dotnet_diagnostic.CA1068.severity = error +# CA1308: Normalize strings to uppercase +dotnet_diagnostic.CA1308.severity=warning + # CA1505: Avoid unmaintainable code dotnet_diagnostic.CA1505.severity = error @@ -558,6 +586,9 @@ indent_brace_style = Allman [*.{csproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}] indent_size = 2 +[*.{csproj,vbproj,proj,nativeproj,locproj}] +charset = utf-8 + # Xml build files [*.builds] indent_size = 2