diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 96b7185..c62edc8 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "dotnet-reportgenerator-globaltool": { - "version": "5.5.0", + "version": "5.5.9", "commands": [ "reportgenerator" ], diff --git a/.editorconfig b/.editorconfig index 322d8cd..3fb61cd 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,30 +1,38 @@ -# Remove the line below if you want to inherit .editorconfig settings from higher directories -# @see: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options root = true +# All files [*] -# New line preferences -end_of_line = crlf +indent_style = space -[*.{json,graphql,css}] +# Xml files +[*.xml] +indent_size = 2 + +# Xml project files +[*.{csproj,fsproj,vbproj,proj,slnx}] +indent_size = 2 + +# Xml config files +[*.{props,targets,config,nuspec}] +indent_size = 2 + +[*.json] indent_size = 2 -indent_style = space -tab_width = 2 -# C# / Razor files +# C# files [*.cs] #### Core EditorConfig Options #### # Indentation and spacing indent_size = 4 -indent_style = space tab_width = 4 # New line preferences -insert_final_newline = true +insert_final_newline = false #### .NET Coding Conventions #### +[*.{cs,vb}] # Organize usings dotnet_separate_import_directive_groups = false @@ -32,123 +40,114 @@ dotnet_sort_system_directives_first = false file_header_template = unset # this. and Me. preferences -dotnet_style_qualification_for_event = false -dotnet_style_qualification_for_field = false -dotnet_style_qualification_for_method = false -dotnet_style_qualification_for_property = false +dotnet_style_qualification_for_event = false:silent +dotnet_style_qualification_for_field = false:silent +dotnet_style_qualification_for_method = false:silent +dotnet_style_qualification_for_property = false:silent # Language keywords vs BCL types preferences -dotnet_style_predefined_type_for_locals_parameters_members = true -dotnet_style_predefined_type_for_member_access = true +dotnet_style_predefined_type_for_locals_parameters_members = true:silent +dotnet_style_predefined_type_for_member_access = true:silent # Parentheses preferences -dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity -dotnet_style_parentheses_in_other_binary_operators = always_for_clarity -dotnet_style_parentheses_in_other_operators = never_if_unnecessary -dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity +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 +dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent # Expression-level preferences -dotnet_style_coalesce_expression = true -dotnet_style_collection_initializer = true -dotnet_style_explicit_tuple_names = true -dotnet_style_namespace_match_folder = true -dotnet_style_null_propagation = true -dotnet_style_object_initializer = true +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_namespace_match_folder = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_object_initializer = true:suggestion dotnet_style_operator_placement_when_wrapping = beginning_of_line -dotnet_style_prefer_auto_properties = true -dotnet_style_prefer_collection_expression = when_types_loosely_match -dotnet_style_prefer_compound_assignment = true -dotnet_style_prefer_conditional_expression_over_assignment = true -dotnet_style_prefer_conditional_expression_over_return = true -dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed -dotnet_style_prefer_inferred_anonymous_type_member_names = true -dotnet_style_prefer_inferred_tuple_names = true -dotnet_style_prefer_is_null_check_over_reference_equality_method = true -dotnet_style_prefer_simplified_boolean_expressions = true -dotnet_style_prefer_simplified_interpolation = true +dotnet_style_prefer_auto_properties = true:suggestion +dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion +dotnet_style_prefer_compound_assignment = true:suggestion +dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion +dotnet_style_prefer_conditional_expression_over_return = true:suggestion +dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed:suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_inferred_tuple_names = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion +dotnet_style_prefer_simplified_boolean_expressions = true:suggestion +dotnet_style_prefer_simplified_interpolation = true:suggestion # Field preferences -dotnet_style_readonly_field = true +dotnet_style_readonly_field = true:warning # Parameter preferences -dotnet_code_quality_unused_parameters = all:silent +dotnet_code_quality_unused_parameters = all:suggestion # Suppression preferences dotnet_remove_unnecessary_suppression_exclusions = none -# New line preferences -dotnet_style_allow_multiple_blank_lines_experimental = true -dotnet_style_allow_statement_immediately_after_block_experimental = true - #### C# Coding Conventions #### +[*.cs] # var preferences -csharp_style_var_elsewhere = true -csharp_style_var_for_built_in_types = true -csharp_style_var_when_type_is_apparent = true +csharp_style_var_elsewhere = true:silent +csharp_style_var_for_built_in_types = true:silent +csharp_style_var_when_type_is_apparent = true:silent # Expression-bodied members -csharp_style_expression_bodied_accessors = true -csharp_style_expression_bodied_constructors = false -csharp_style_expression_bodied_indexers = true -csharp_style_expression_bodied_lambdas = true -csharp_style_expression_bodied_local_functions = true -csharp_style_expression_bodied_methods = true -csharp_style_expression_bodied_operators = true -csharp_style_expression_bodied_properties = true +csharp_style_expression_bodied_accessors = true:silent +csharp_style_expression_bodied_constructors = false:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_lambdas = true:suggestion +csharp_style_expression_bodied_local_functions = true:silent +csharp_style_expression_bodied_methods = true:silent +csharp_style_expression_bodied_operators = true:silent +csharp_style_expression_bodied_properties = true:silent # Pattern matching preferences -csharp_style_pattern_matching_over_as_with_null_check = true -csharp_style_pattern_matching_over_is_with_cast_check = true -csharp_style_prefer_extended_property_pattern = true -csharp_style_prefer_not_pattern = true -csharp_style_prefer_pattern_matching = true -csharp_style_prefer_switch_expression = true +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_extended_property_pattern = true:suggestion +csharp_style_prefer_not_pattern = true:suggestion +csharp_style_prefer_pattern_matching = true:silent +csharp_style_prefer_switch_expression = true:suggestion # Null-checking preferences -csharp_style_conditional_delegate_call = true +csharp_style_conditional_delegate_call = true:suggestion # Modifier preferences -csharp_prefer_static_local_function = true -csharp_preferred_modifier_order = public, private, protected, internal, file, static, extern, new, virtual, abstract, sealed, override, readonly, unsafe, required, volatile, async -csharp_style_prefer_readonly_struct = true -csharp_style_prefer_readonly_struct_member = true +csharp_prefer_static_anonymous_function = true:suggestion +csharp_prefer_static_local_function = true:warning +csharp_preferred_modifier_order = public, private, protected, internal, file, const, static, extern, new, virtual, abstract, sealed, override, readonly, unsafe, required, volatile, async:suggestion +csharp_style_prefer_readonly_struct = true:suggestion +csharp_style_prefer_readonly_struct_member = true:suggestion # Code-block preferences -csharp_prefer_braces = when_multiline -csharp_prefer_simple_using_statement = true -csharp_style_namespace_declarations = file_scoped -csharp_style_prefer_method_group_conversion = true -csharp_style_prefer_primary_constructors = true -csharp_style_prefer_top_level_statements = true +csharp_prefer_braces = when_multiline:silent +csharp_prefer_simple_using_statement = true:suggestion +csharp_style_namespace_declarations = file_scoped:suggestion +csharp_style_prefer_method_group_conversion = true:silent +csharp_style_prefer_primary_constructors = true:suggestion +csharp_style_prefer_top_level_statements = true:silent # Expression-level preferences -csharp_prefer_simple_default_expression = true -csharp_style_deconstructed_variable_declaration = true -csharp_style_implicit_object_creation_when_type_is_apparent = true -csharp_style_inlined_variable_declaration = true -csharp_style_prefer_index_operator = true -csharp_style_prefer_local_over_anonymous_function = true -csharp_style_prefer_null_check_over_type_check = true -csharp_style_prefer_range_operator = true -csharp_style_prefer_tuple_swap = true -csharp_style_prefer_utf8_string_literals = true -csharp_style_throw_expression = true -csharp_style_unused_value_assignment_preference = discard_variable -csharp_style_unused_value_expression_statement_preference = discard_variable +csharp_prefer_simple_default_expression = true:suggestion +csharp_style_deconstructed_variable_declaration = true:suggestion +csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion +csharp_style_prefer_index_operator = true:suggestion +csharp_style_prefer_local_over_anonymous_function = true:suggestion +csharp_style_prefer_null_check_over_type_check = true:suggestion +csharp_style_prefer_range_operator = true:suggestion +csharp_style_prefer_tuple_swap = true:suggestion +csharp_style_prefer_utf8_string_literals = 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 = outside_namespace - -# New line preferences -csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true -csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true -csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true -csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true -csharp_style_allow_embedded_statements_on_same_line_experimental = true +csharp_using_directive_placement = outside_namespace:silent #### C# Formatting Rules #### @@ -198,89 +197,195 @@ csharp_preserve_single_line_blocks = true csharp_preserve_single_line_statements = true #### Naming styles #### +[*.{cs,vb}] # 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_and_namespaces_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.symbols = types_and_namespaces +dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.interfaces_should_be_ipascalcase.severity = suggestion +dotnet_naming_rule.interfaces_should_be_ipascalcase.symbols = interfaces +dotnet_naming_rule.interfaces_should_be_ipascalcase.style = ipascalcase + +dotnet_naming_rule.type_parameters_should_be_tpascalcase.severity = suggestion +dotnet_naming_rule.type_parameters_should_be_tpascalcase.symbols = type_parameters +dotnet_naming_rule.type_parameters_should_be_tpascalcase.style = tpascalcase + +dotnet_naming_rule.methods_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.methods_should_be_pascalcase.symbols = methods +dotnet_naming_rule.methods_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.properties_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.properties_should_be_pascalcase.symbols = properties +dotnet_naming_rule.properties_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.events_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.events_should_be_pascalcase.symbols = events +dotnet_naming_rule.events_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.local_variables_should_be_camelcase.severity = suggestion +dotnet_naming_rule.local_variables_should_be_camelcase.symbols = local_variables +dotnet_naming_rule.local_variables_should_be_camelcase.style = camelcase + +dotnet_naming_rule.local_constants_should_be_camelcase.severity = suggestion +dotnet_naming_rule.local_constants_should_be_camelcase.symbols = local_constants +dotnet_naming_rule.local_constants_should_be_camelcase.style = camelcase + +dotnet_naming_rule.parameters_should_be_camelcase.severity = suggestion +dotnet_naming_rule.parameters_should_be_camelcase.symbols = parameters +dotnet_naming_rule.parameters_should_be_camelcase.style = camelcase + +dotnet_naming_rule.public_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.public_fields_should_be_pascalcase.symbols = public_fields +dotnet_naming_rule.public_fields_should_be_pascalcase.style = pascalcase -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.private_fields_should_be__camelcase.severity = suggestion +dotnet_naming_rule.private_fields_should_be__camelcase.symbols = private_fields +dotnet_naming_rule.private_fields_should_be__camelcase.style = _camelcase -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 +dotnet_naming_rule.private_static_fields_should_be_s_camelcase.severity = suggestion +dotnet_naming_rule.private_static_fields_should_be_s_camelcase.symbols = private_static_fields +dotnet_naming_rule.private_static_fields_should_be_s_camelcase.style = s_camelcase -## Define the 'private_fields_should_be_underscored' naming rule -dotnet_naming_rule.private_fields_should_be_underscored.severity = suggestion -dotnet_naming_rule.private_fields_should_be_underscored.symbols = private_fields -dotnet_naming_rule.private_fields_should_be_underscored.style = underscored +dotnet_naming_rule.public_constant_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.public_constant_fields_should_be_pascalcase.symbols = public_constant_fields +dotnet_naming_rule.public_constant_fields_should_be_pascalcase.style = pascalcase -## Define the 'private_static_fields_should_be_underscored' naming rule -dotnet_naming_rule.private_static_fields_should_be_underscored.severity = suggestion -dotnet_naming_rule.private_static_fields_should_be_underscored.symbols = private_static_fields -dotnet_naming_rule.private_static_fields_should_be_underscored.style = underscored +dotnet_naming_rule.private_constant_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.private_constant_fields_should_be_pascalcase.symbols = private_constant_fields +dotnet_naming_rule.private_constant_fields_should_be_pascalcase.style = pascalcase -## Define the 'private_constants_should_be_underscored' naming rule -dotnet_naming_rule.private_constants_should_be_underscored.severity = suggestion -dotnet_naming_rule.private_constants_should_be_underscored.symbols = private_constants -dotnet_naming_rule.private_constants_should_be_underscored.style = underscored +dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.symbols = public_static_readonly_fields +dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.style = pascalcase -## Define the 'public_constants_should_be_pascal_case' naming rule -dotnet_naming_rule.public_constants_should_be_pascal_case.severity = suggestion -dotnet_naming_rule.public_constants_should_be_pascal_case.symbols = public_constants -dotnet_naming_rule.public_constants_should_be_pascal_case.style = pascal_case +dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.symbols = private_static_readonly_fields +dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.enums_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.enums_should_be_pascalcase.symbols = enums +dotnet_naming_rule.enums_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.local_functions_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.local_functions_should_be_pascalcase.symbols = local_functions +dotnet_naming_rule.local_functions_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.non_field_members_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascalcase.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascalcase.style = pascalcase # 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.interfaces.applicable_kinds = interface +dotnet_naming_symbols.interfaces.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interfaces.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.enums.applicable_kinds = enum +dotnet_naming_symbols.enums.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.enums.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 = +dotnet_naming_symbols.events.applicable_kinds = event +dotnet_naming_symbols.events.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.events.required_modifiers = + +dotnet_naming_symbols.methods.applicable_kinds = method +dotnet_naming_symbols.methods.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.methods.required_modifiers = + +dotnet_naming_symbols.properties.applicable_kinds = property +dotnet_naming_symbols.properties.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.properties.required_modifiers = + +dotnet_naming_symbols.public_fields.applicable_kinds = field +dotnet_naming_symbols.public_fields.applicable_accessibilities = public, internal +dotnet_naming_symbols.public_fields.required_modifiers = -## Define the 'private_fields' symbol group dotnet_naming_symbols.private_fields.applicable_kinds = field -dotnet_naming_symbols.private_fields.applicable_accessibilities = private +dotnet_naming_symbols.private_fields.applicable_accessibilities = private, protected, protected_internal, private_protected +dotnet_naming_symbols.private_fields.required_modifiers = -## Define the 'private_static_fields' symbol group dotnet_naming_symbols.private_static_fields.applicable_kinds = field -dotnet_naming_symbols.private_static_fields.applicable_accessibilities = private +dotnet_naming_symbols.private_static_fields.applicable_accessibilities = private, protected, protected_internal, private_protected dotnet_naming_symbols.private_static_fields.required_modifiers = static -## Define the 'private_constants' symbol group -dotnet_naming_symbols.private_constants.applicable_kinds = field -dotnet_naming_symbols.private_constants.applicable_accessibilities = private -dotnet_naming_symbols.private_constants.required_modifiers = const +dotnet_naming_symbols.types_and_namespaces.applicable_kinds = namespace, class, struct, interface, enum +dotnet_naming_symbols.types_and_namespaces.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types_and_namespaces.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 = + +dotnet_naming_symbols.type_parameters.applicable_kinds = namespace +dotnet_naming_symbols.type_parameters.applicable_accessibilities = * +dotnet_naming_symbols.type_parameters.required_modifiers = + +dotnet_naming_symbols.private_constant_fields.applicable_kinds = field +dotnet_naming_symbols.private_constant_fields.applicable_accessibilities = private, protected, protected_internal, private_protected +dotnet_naming_symbols.private_constant_fields.required_modifiers = const + +dotnet_naming_symbols.local_variables.applicable_kinds = local +dotnet_naming_symbols.local_variables.applicable_accessibilities = local +dotnet_naming_symbols.local_variables.required_modifiers = + +dotnet_naming_symbols.local_constants.applicable_kinds = local +dotnet_naming_symbols.local_constants.applicable_accessibilities = local +dotnet_naming_symbols.local_constants.required_modifiers = const + +dotnet_naming_symbols.parameters.applicable_kinds = parameter +dotnet_naming_symbols.parameters.applicable_accessibilities = * +dotnet_naming_symbols.parameters.required_modifiers = -## Define the 'public_constants' symbol group -dotnet_naming_symbols.public_constants.applicable_kinds = field -dotnet_naming_symbols.public_constants.applicable_accessibilities = public -dotnet_naming_symbols.public_constants.required_modifiers = const +dotnet_naming_symbols.public_constant_fields.applicable_kinds = field +dotnet_naming_symbols.public_constant_fields.applicable_accessibilities = public, internal +dotnet_naming_symbols.public_constant_fields.required_modifiers = const + +dotnet_naming_symbols.public_static_readonly_fields.applicable_kinds = field +dotnet_naming_symbols.public_static_readonly_fields.applicable_accessibilities = public, internal +dotnet_naming_symbols.public_static_readonly_fields.required_modifiers = readonly, static + +dotnet_naming_symbols.private_static_readonly_fields.applicable_kinds = field +dotnet_naming_symbols.private_static_readonly_fields.applicable_accessibilities = private, protected, protected_internal, private_protected +dotnet_naming_symbols.private_static_readonly_fields.required_modifiers = readonly, static + +dotnet_naming_symbols.local_functions.applicable_kinds = local_function +dotnet_naming_symbols.local_functions.applicable_accessibilities = * +dotnet_naming_symbols.local_functions.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.pascalcase.required_prefix = +dotnet_naming_style.pascalcase.required_suffix = +dotnet_naming_style.pascalcase.word_separator = +dotnet_naming_style.pascalcase.capitalization = pascal_case + +dotnet_naming_style.ipascalcase.required_prefix = I +dotnet_naming_style.ipascalcase.required_suffix = +dotnet_naming_style.ipascalcase.word_separator = +dotnet_naming_style.ipascalcase.capitalization = pascal_case + +dotnet_naming_style.tpascalcase.required_prefix = T +dotnet_naming_style.tpascalcase.required_suffix = +dotnet_naming_style.tpascalcase.word_separator = +dotnet_naming_style.tpascalcase.capitalization = pascal_case + +dotnet_naming_style._camelcase.required_prefix = _ +dotnet_naming_style._camelcase.required_suffix = +dotnet_naming_style._camelcase.word_separator = +dotnet_naming_style._camelcase.capitalization = camel_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 +dotnet_naming_style.camelcase.required_prefix = +dotnet_naming_style.camelcase.required_suffix = +dotnet_naming_style.camelcase.word_separator = +dotnet_naming_style.camelcase.capitalization = camel_case -## Define the 'underscored' naming style -dotnet_naming_style.underscored.capitalization = camel_case -dotnet_naming_style.underscored.required_prefix = _ +dotnet_naming_style.s_camelcase.required_prefix = s_ +dotnet_naming_style.s_camelcase.required_suffix = +dotnet_naming_style.s_camelcase.word_separator = +dotnet_naming_style.s_camelcase.capitalization = camel_case # ReSharper resharper_arrange_object_creation_when_type_not_evident_highlighting = none @@ -304,4 +409,4 @@ resharper_csharp_wrap_chained_method_calls = chop_if_long resharper_csharp_wrap_before_first_method_call = true resharper_csharp_wrap_after_property_in_chained_method_calls = true resharper_csharp_indent_raw_literal_string = do_not_change -resharper_csharp_max_line_length = 200 \ No newline at end of file +resharper_csharp_max_line_length = 240 \ No newline at end of file diff --git a/GraphHealthChecks.Tests/GraphHealthChecks.Tests.csproj b/GraphHealthChecks.Tests/GraphHealthChecks.Tests.csproj index 73596ac..e892205 100644 --- a/GraphHealthChecks.Tests/GraphHealthChecks.Tests.csproj +++ b/GraphHealthChecks.Tests/GraphHealthChecks.Tests.csproj @@ -9,26 +9,26 @@ - - - - - - - + + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + diff --git a/GraphHealthChecks.Tests/GraphHealthChecksFactoriesTests.cs b/GraphHealthChecks.Tests/GraphHealthChecksFactoriesTests.cs index bad9bcb..63bc470 100644 --- a/GraphHealthChecks.Tests/GraphHealthChecksFactoriesTests.cs +++ b/GraphHealthChecks.Tests/GraphHealthChecksFactoriesTests.cs @@ -15,7 +15,7 @@ public void GraphHealthCheckFactoryWithNoLoggerCustomSchema() .BuildServiceProvider() ); - Assert.IsAssignableFrom(result); + Assert.IsType(result, exactMatch: false); Assert.Equal("schema", (result as GraphHealthCheck)?.Schema); } @@ -30,7 +30,7 @@ public void GraphHealthCheckFactoryWithNoLoggerDefaultSchema() .BuildServiceProvider() ); - Assert.IsAssignableFrom(result); + Assert.IsType(result, exactMatch: false); Assert.Null((result as GraphHealthCheck)?.Schema); } @@ -46,7 +46,7 @@ public void GraphHealthCheckFactoryWithILoggerCustomSchema() .BuildServiceProvider() ); - Assert.IsAssignableFrom(result); + Assert.IsType(result, exactMatch: false); Assert.Equal("schema", (result as GraphHealthCheck)?.Schema); } @@ -62,7 +62,7 @@ public void GraphHealthCheckFactoryWithILoggerDefaultSchema() .BuildServiceProvider() ); - Assert.IsAssignableFrom(result); + Assert.IsType(result, exactMatch: false); Assert.Null((result as GraphHealthCheck)?.Schema); } @@ -78,7 +78,7 @@ public void GraphHealthCheckFactoryWithLoggerFnCustomSchema() .BuildServiceProvider() ); - Assert.IsAssignableFrom(result); + Assert.IsType(result, exactMatch: false); Assert.Equal("schema", (result as GraphHealthCheck)?.Schema); } @@ -94,7 +94,7 @@ public void GraphHealthCheckFactoryWithLoggerFnDefaultSchema() .BuildServiceProvider() ); - Assert.IsAssignableFrom(result); + Assert.IsType(result, exactMatch: false); Assert.Null((result as GraphHealthCheck)?.Schema); } @@ -102,4 +102,4 @@ public class Query { public string Name => "Hello"; } -} +} \ No newline at end of file diff --git a/GraphHealthChecks.Tests/GraphHealthExtensionsTests.cs b/GraphHealthChecks.Tests/GraphHealthExtensionsTests.cs index 56d3078..9bbc093 100644 --- a/GraphHealthChecks.Tests/GraphHealthExtensionsTests.cs +++ b/GraphHealthChecks.Tests/GraphHealthExtensionsTests.cs @@ -6,6 +6,16 @@ namespace GraphHealthChecks.Tests; public class GraphHealthExtensionsTests { + private static readonly string[] _schemas = + [ + "health1", + "health2", + "health3", + "health4", + "health5", + "health6" + ]; + [Fact(DisplayName = "AddGraphHealth - Multiple Instances - Separate Names and Schemas")] public void MultipleInstancesSeparateNamesAndSchemas() { @@ -26,15 +36,7 @@ public void MultipleInstancesSeparateNamesAndSchemas() Assert.Equal( options.Registrations.Count, - new[] - { - "health1", - "health2", - "health3", - "health4", - "health5", - "health6" - } + _schemas .Intersect(options.Registrations.Select(x => x.Name)) .Distinct() .Count() @@ -61,15 +63,7 @@ public void MultipleInstancesSeparateNamesAndSameSchema() Assert.Equal( options.Registrations.Count, - new[] - { - "health1", - "health2", - "health3", - "health4", - "health5", - "health6" - } + _schemas .Intersect(options.Registrations.Select(x => x.Name)) .Distinct() .Count() @@ -96,15 +90,7 @@ public void MultipleInstancesSeparateNamesAndSameSchemaDefault() Assert.Equal( options.Registrations.Count, - new[] - { - "health1", - "health2", - "health3", - "health4", - "health5", - "health6" - } + _schemas .Intersect(options.Registrations.Select(x => x.Name)) .Distinct() .Count() @@ -294,4 +280,4 @@ public void AddGraphHealthWithILoggerFactoryCustomHealthName() .Count() ); } -} +} \ No newline at end of file diff --git a/GraphHealthChecks.Tests/GraphQLHealthCheckTests.cs b/GraphHealthChecks.Tests/GraphQLHealthCheckTests.cs index a302c5a..ddb4bae 100644 --- a/GraphHealthChecks.Tests/GraphQLHealthCheckTests.cs +++ b/GraphHealthChecks.Tests/GraphQLHealthCheckTests.cs @@ -4,7 +4,6 @@ using Microsoft.Extensions.Diagnostics.HealthChecks; using Microsoft.Extensions.Logging; using NSubstitute.ExceptionExtensions; -using Snapshooter.Xunit; namespace GraphHealthChecks.Tests; @@ -25,16 +24,16 @@ private static object GetErrorResult(HealthCheckResult result) => [Fact(DisplayName = "GraphQLHealthCheck - No Logger - Unhealthy Schema")] public async Task NoLoggerUnhealthySchema() { - var mockRequestExecutorResolver = Substitute.For(); + var mockRequestExecutorResolver = Substitute.For(); mockRequestExecutorResolver - .GetRequestExecutorAsync(Arg.Any(), Arg.Any()) + .GetExecutorAsync(Arg.Any(), Arg.Any()) .Throws(new SchemaException()); var result = await new GraphHealthCheck(mockRequestExecutorResolver) .CheckHealthAsync(null!); Assert.Equal(HealthStatus.Unhealthy, result.Status); - Assert.IsAssignableFrom(result.Exception); + Assert.IsType(result.Exception, exactMatch: false); GetErrorResult(result).MatchSnapshot(); } @@ -42,15 +41,15 @@ public async Task NoLoggerUnhealthySchema() [Fact(DisplayName = "GraphQLHealthCheck - No Logger - General Error")] public async Task NoLoggerGeneralError() { - var mockRequestExecutorResolver = Substitute.For(); + var mockRequestExecutorResolver = Substitute.For(); mockRequestExecutorResolver - .GetRequestExecutorAsync(Arg.Any(), Arg.Any()) + .GetExecutorAsync(Arg.Any(), Arg.Any()) .Throws(new Exception("Splash!")); var result = await new GraphHealthCheck(mockRequestExecutorResolver).CheckHealthAsync(null!); Assert.Equal(HealthStatus.Unhealthy, result.Status); - Assert.IsAssignableFrom(result.Exception); + Assert.IsType(result.Exception, exactMatch: false); GetErrorResult(result).MatchSnapshot(); } @@ -64,7 +63,7 @@ public async Task NoLoggerHealthy() .AddQueryType() .Services .BuildServiceProvider() - .GetRequiredService() + .GetRequiredService() ) .CheckHealthAsync(null!); @@ -78,9 +77,9 @@ public async Task NoLoggerHealthy() public async Task ILoggerGeneralError() { var mockLogger = Substitute.For>(); - var mockResolver = Substitute.For(); + var mockResolver = Substitute.For(); mockResolver - .GetRequestExecutorAsync(Arg.Any(), Arg.Any()) + .GetExecutorAsync(Arg.Any(), Arg.Any()) .Throws(new Exception("Splash!")); var result = await new GraphHealthCheck( @@ -90,17 +89,19 @@ public async Task ILoggerGeneralError() .CheckHealthAsync(null!); Assert.Equal(HealthStatus.Unhealthy, result.Status); - Assert.IsAssignableFrom(result.Exception); + Assert.IsType(result.Exception, exactMatch: false); Assert.NotNull(result.Description); Assert.Contains("general", result.Description); - mockLogger.Received(1).Log( - LogLevel.Error, - Arg.Any(), - Arg.Any(), - Arg.Is(x => x.Message == "Splash!"), - Arg.Any>() - ); + mockLogger + .Received(1) + .Log( + LogLevel.Error, + Arg.Any(), + Arg.Any(), + Arg.Is(x => x.Message == "Splash!"), + Arg.Any>() + ); GetErrorResult(result).MatchSnapshot(); } @@ -116,23 +117,25 @@ public async Task ILoggerUnhealthySchema() .AddQueryType() .Services .BuildServiceProvider() - .GetRequiredService(), + .GetRequiredService(), mockLogger ) .CheckHealthAsync(null!); Assert.Equal(HealthStatus.Unhealthy, result.Status); - Assert.IsAssignableFrom(result.Exception); + Assert.IsType(result.Exception, exactMatch: false); Assert.NotNull(result.Description); Assert.Contains("schema", result.Description); - mockLogger.Received(1).Log( - LogLevel.Error, - Arg.Any(), - Arg.Any(), - Arg.Any(), - Arg.Any>() - ); + mockLogger + .Received(1) + .Log( + LogLevel.Error, + Arg.Any(), + Arg.Any(), + Arg.Any(), + Arg.Any>() + ); GetErrorResult(result).MatchSnapshot(); } @@ -148,23 +151,25 @@ public async Task ILoggerUnhealthySchemaNoAuth() .AddQueryType() .Services .BuildServiceProvider() - .GetRequiredService(), + .GetRequiredService(), mockLogger ) .CheckHealthAsync(null!); Assert.Equal(HealthStatus.Unhealthy, result.Status); - Assert.IsAssignableFrom(result.Exception); + Assert.IsType(result.Exception, exactMatch: false); Assert.NotNull(result.Description); Assert.Contains("schema", result.Description); - mockLogger.Received(1).Log( - LogLevel.Error, - Arg.Any(), - Arg.Any(), - Arg.Any(), - Arg.Any>() - ); + mockLogger + .Received(1) + .Log( + LogLevel.Error, + Arg.Any(), + Arg.Any(), + Arg.Any(), + Arg.Any>() + ); GetErrorResult(result).MatchSnapshot(); } @@ -173,24 +178,26 @@ public async Task ILoggerUnhealthySchemaNoAuth() public async Task ILoggerUnhealthySchemaNoAuthGeneralError() { var mockLogger = Substitute.For>(); - var mockRequestExecutorResolver = Substitute.For(); + var mockRequestExecutorResolver = Substitute.For(); mockRequestExecutorResolver - .GetRequestExecutorAsync(Arg.Any(), Arg.Any()) + .GetExecutorAsync(Arg.Any(), Arg.Any()) .Throws(new Exception("Splash!")); var result = await new GraphHealthCheck(mockRequestExecutorResolver, mockLogger) .CheckHealthAsync(null!); Assert.Equal(HealthStatus.Unhealthy, result.Status); - Assert.IsAssignableFrom(result.Exception); - - mockLogger.Received(1).Log( - LogLevel.Error, - Arg.Any(), - Arg.Any(), - Arg.Is(x => x.Message == "Splash!"), - Arg.Any>() - ); + Assert.IsType(result.Exception, exactMatch: false); + + mockLogger + .Received(1) + .Log( + LogLevel.Error, + Arg.Any(), + Arg.Any(), + Arg.Is(x => x.Message == "Splash!"), + Arg.Any>() + ); GetErrorResult(result).MatchSnapshot(); } @@ -207,7 +214,7 @@ public async Task ILoggerHealthyAuth() .AddQueryType() .Services .BuildServiceProvider() - .GetRequiredService(), + .GetRequiredService(), mockLogger ) .CheckHealthAsync(null!); @@ -215,13 +222,15 @@ public async Task ILoggerHealthyAuth() Assert.Equal(HealthStatus.Healthy, result.Status); Assert.Null(result.Description); - mockLogger.Received(0).Log( - LogLevel.Error, - Arg.Any(), - Arg.Any(), - Arg.Any(), - Arg.Any>() - ); + mockLogger + .Received(0) + .Log( + LogLevel.Error, + Arg.Any(), + Arg.Any(), + Arg.Any(), + Arg.Any>() + ); result.MatchSnapshot(); } @@ -237,7 +246,7 @@ public async Task ILoggerHealthy() .AddQueryType() .Services .BuildServiceProvider() - .GetRequiredService(), + .GetRequiredService(), mockLogger ) .CheckHealthAsync(null!); @@ -245,13 +254,15 @@ public async Task ILoggerHealthy() Assert.Equal(HealthStatus.Healthy, result.Status); Assert.Null(result.Description); - mockLogger.Received(0).Log( - LogLevel.Error, - Arg.Any(), - Arg.Any(), - Arg.Any(), - Arg.Any>() - ); + mockLogger + .Received(0) + .Log( + LogLevel.Error, + Arg.Any(), + Arg.Any(), + Arg.Any(), + Arg.Any>() + ); result.MatchSnapshot(); } @@ -266,4 +277,4 @@ public class QueryAuth [Authorize] public string Name => "Hello"; } -} +} \ No newline at end of file diff --git a/GraphHealthChecks.Tests/Usings.cs b/GraphHealthChecks.Tests/Usings.cs index 22997d3..cc65c31 100644 --- a/GraphHealthChecks.Tests/Usings.cs +++ b/GraphHealthChecks.Tests/Usings.cs @@ -1,2 +1,3 @@ -global using Xunit; -global using NSubstitute; +global using NSubstitute; +global using Snapshooter.Xunit; +global using Xunit; diff --git a/GraphHealthChecks/GraphHealthCheck.cs b/GraphHealthChecks/GraphHealthCheck.cs index 1507633..31bf07d 100644 --- a/GraphHealthChecks/GraphHealthCheck.cs +++ b/GraphHealthChecks/GraphHealthCheck.cs @@ -7,14 +7,15 @@ public record GraphHealthCheck : IHealthCheck private const string _generalError = "A general error has occurred."; private readonly ILogger? _logger; - private readonly IRequestExecutorResolver _requestExecutorResolver; + private readonly IRequestExecutorManager _requestExecutorResolver; - public GraphHealthCheck(IRequestExecutorResolver requestExecutorResolver, ILogger logger) + public GraphHealthCheck(IRequestExecutorManager requestExecutorResolver, ILogger logger) { - (_requestExecutorResolver, _logger) = (requestExecutorResolver, logger); + _requestExecutorResolver = requestExecutorResolver; + _logger = logger; } - public GraphHealthCheck(IRequestExecutorResolver requestExecutorResolver) + public GraphHealthCheck(IRequestExecutorManager requestExecutorResolver) { _requestExecutorResolver = requestExecutorResolver; } @@ -25,12 +26,11 @@ public async Task CheckHealthAsync(HealthCheckContext context { try { - _ = ( - await _requestExecutorResolver.GetRequestExecutorAsync( - Schema, - cancellationToken - ) - ).Schema.ToDocument(); + var executor = await _requestExecutorResolver.GetExecutorAsync( + Schema, + cancellationToken + ); + _ = executor.Schema.ToString(); return new HealthCheckResult(HealthStatus.Healthy); } @@ -47,4 +47,4 @@ await _requestExecutorResolver.GetRequestExecutorAsync( return new HealthCheckResult(HealthStatus.Unhealthy, _generalError, ex); } } -} +} \ No newline at end of file diff --git a/GraphHealthChecks/GraphHealthChecks.csproj b/GraphHealthChecks/GraphHealthChecks.csproj index 105d132..3564f48 100644 --- a/GraphHealthChecks/GraphHealthChecks.csproj +++ b/GraphHealthChecks/GraphHealthChecks.csproj @@ -6,7 +6,7 @@ true true $(MSBuildProjectName) - 5.0.0 + 6.0.0 Adamos Fiakkas Graph Health Checks for HotChocolate Adamos Fiakkas @@ -22,12 +22,12 @@ - - + + - + \ No newline at end of file diff --git a/GraphHealthChecks/GraphHealthChecksFactories.cs b/GraphHealthChecks/GraphHealthChecksFactories.cs index 1138002..019bd5c 100644 --- a/GraphHealthChecks/GraphHealthChecksFactories.cs +++ b/GraphHealthChecks/GraphHealthChecksFactories.cs @@ -3,14 +3,14 @@ public static class GraphHealthChecksFactories { public static Func GraphHealthCheckFactoryWithNoLogger(string? schemaName = default) => sp => - new GraphHealthCheck(sp.GetRequiredService()) + new GraphHealthCheck(sp.GetRequiredService()) { Schema = schemaName }; public static Func GraphHealthCheckFactoryWithILogger(string? schemaName = default) => sp => new GraphHealthCheck( - sp.GetRequiredService(), + sp.GetRequiredService(), sp.GetRequiredService>() ) { @@ -19,10 +19,10 @@ public static Func GraphHealthCheckFactoryWithIL public static Func GraphHealthCheckFactoryWithILoggerFactory(string? schemaName = default) => sp => new GraphHealthCheck( - sp.GetRequiredService(), + sp.GetRequiredService(), sp.GetRequiredService().CreateLogger() ) { Schema = schemaName }; -} +} \ No newline at end of file diff --git a/GraphHealthChecks/GraphHealthExtensions.cs b/GraphHealthChecks/GraphHealthExtensions.cs index 670916a..a655276 100644 --- a/GraphHealthChecks/GraphHealthExtensions.cs +++ b/GraphHealthChecks/GraphHealthExtensions.cs @@ -57,4 +57,4 @@ public static IHealthChecksBuilder AddGraphHealthWithILoggerFactory( timeout ) ); -} +} \ No newline at end of file diff --git a/GraphHealthChecks/README.md b/GraphHealthChecks/README.md index f1d3f94..a781d96 100644 --- a/GraphHealthChecks/README.md +++ b/GraphHealthChecks/README.md @@ -11,7 +11,8 @@ The purpose of this middleware is to provide feedback regarding the health of th ### Current Releases | HotChocolate Version | GraphHealthChecks Version | .NET Version | -| -------------------- | ------------------------- | ------------- | +|----------------------|---------------------------|---------------| +| 16.0.0 or higher | 6.0.0 | .NET 8, 9, 10 | | 15.1.11 or higher | 5.0.0 | .NET 8, 9, 10 | | 15.0.3 or higher | 4.0.1 | .NET 8, 9 | | 15.0.3 or higher | 4.0.0 | .NET 8, 9 | @@ -23,7 +24,7 @@ The purpose of this middleware is to provide feedback regarding the health of th ### Past Releases | HotChocolate Version | Last GraphHealthChecks Version | .NET Version | -| -------------------- | ------------------------------ | ------------ | +|----------------------|--------------------------------|--------------| | 13.7.0 or higher | 2.0.1 | .NET 6, 8 | | 13.3.3 or higher | 1.0.2 | .NET 6, 7 | diff --git a/GraphHealthChecks/Usings.cs b/GraphHealthChecks/Usings.cs index b8fd346..ad6d4fd 100644 --- a/GraphHealthChecks/Usings.cs +++ b/GraphHealthChecks/Usings.cs @@ -6,4 +6,4 @@ global using System.Collections.Generic; global using System.Threading.Tasks; global using System.Threading; -global using System; +global using System; \ No newline at end of file diff --git a/README.md b/README.md index c000e1e..c0b2eca 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ The purpose of this middleware is to provide feedback regarding the health of th ### Current Releases | HotChocolate Version | GraphHealthChecks Version | .NET Version | -| -------------------- | ------------------------- | ------------- | +|----------------------|---------------------------|---------------| +| 16.0.0 or higher | 6.0.0 | .NET 8, 9, 10 | | 15.1.11 or higher | 5.0.0 | .NET 8, 9, 10 | | 15.0.3 or higher | 4.0.1 | .NET 8, 9 | | 15.0.3 or higher | 4.0.0 | .NET 8, 9 | @@ -27,7 +28,7 @@ The purpose of this middleware is to provide feedback regarding the health of th ### Past Releases | HotChocolate Version | Last GraphHealthChecks Version | .NET Version | -| -------------------- | ------------------------------ | ------------ | +|----------------------|--------------------------------|--------------| | 13.7.0 or higher | 2.0.1 | .NET 6, 8 | | 13.3.3 or higher | 1.0.2 | .NET 6, 7 |