From 30d61e61a62f71913065d3eb79fe150114725ed2 Mon Sep 17 00:00:00 2001 From: BEN ABT Date: Sat, 1 Mar 2025 16:43:36 +0100 Subject: [PATCH] add easy ci --- .editorconfig | 492 +++++++++++++----- .github/workflows/ci.yml | 53 +- .../HttpClientHintsRegistrationTests.cs | 1 - 3 files changed, 388 insertions(+), 158 deletions(-) diff --git a/.editorconfig b/.editorconfig index cbf76fc..9636fb7 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,167 +1,300 @@ -# Remove the line below if you want to inherit .editorconfig settings from higher directories -root = true +############################### +# Core EditorConfig Options # +############################### -# all files -[*] +root = true # stop .editorconfig files search on current file. +# All files +[*] charset = utf-8 - -# Indentation and spacing indent_style = space indent_size = 4 +trim_trailing_whitespace = true # Remove trailing whitespace +insert_final_newline = true # Ensure file ends with a newline +max_line_length = 120 # Maximum line length for readability +end_of_line = lf tab_width = 4 -# New line preferences -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true +############################### +# Markdown # +############################### + +[*.md] +trim_trailing_whitespace = false +max_line_length = off + +############################### +# Bicep # +############################### + +[*.bicep] +indent_size = 2 +max_line_length = off + +############################### +# XML # +############################### + +[*.xml] +indent_size = 2 +max_line_length = off + +############################### +# TypeScript # +############################### + +[*.ts] +indent_size = 2 + +############################### +# JavaScript # +############################### + +[*.js] +indent_size = 2 -# C# files -[*.cs] +############################### +# HTML # +############################### -file_header_template = Copyright © myCSharp.de - all rights reserved +[*.html] +indent_size = 2 -#### .NET Coding Conventions #### +############################### +# CSS/SCSS # +############################### +[*.{css,scss}] +indent_size = 2 + +############################### +# YAML # +############################### + +[*.{yml,yaml}] +indent_size = 2 +max_line_length = off + +############################### +# JSON # +############################### + +[*.json] +indent_size = 2 +max_line_length = off + +############################### +# C# / VB # +############################### + +[*.{cs,vb}] # 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 = false:suggestion -dotnet_style_qualification_for_method = true:suggestion -dotnet_style_qualification_for_property = true:suggestion +# this. preferences +dotnet_style_qualification_for_field = false:silent +dotnet_style_qualification_for_property = false:silent +dotnet_style_qualification_for_method = false:silent +dotnet_style_qualification_for_event = false:silent # Language keywords vs BCL types preferences -dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion -dotnet_style_predefined_type_for_member_access = true:suggestion +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 = never_if_unnecessary:silent +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_relational_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 +dotnet_style_readonly_field = true:warning # Expression-level preferences -csharp_style_deconstructed_variable_declaration = true:suggestion -csharp_style_inlined_variable_declaration = true:suggestion -csharp_style_throw_expression = true:suggestion -dotnet_style_coalesce_expression = true:suggestion +dotnet_style_object_initializer = 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_coalesce_expression = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning +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 -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 -# Field preferences -dotnet_style_readonly_field = true:suggestion +############################### +# Naming Conventions # +############################### +# Style Definitions -# Parameter preferences -dotnet_code_quality_unused_parameters = all:suggestion +dotnet_naming_rule.interface_should_be_begins_with_i.severity = warning +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i -#### C# Coding Conventions #### +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 -# var preferences -csharp_style_var_elsewhere = false:silent -csharp_style_var_for_built_in_types = false:silent -csharp_style_var_when_type_is_apparent = true:silent +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.constant_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.constant_should_be_pascal_case.symbols = constant +dotnet_naming_rule.constant_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.private_or_internal_static_field_should_be_static_field.severity = suggestion +dotnet_naming_rule.private_or_internal_static_field_should_be_static_field.symbols = private_or_internal_static_field +dotnet_naming_rule.private_or_internal_static_field_should_be_static_field.style = static_field + +dotnet_naming_rule.private_or_internal_field_should_be_instance_field.severity = suggestion +dotnet_naming_rule.private_or_internal_field_should_be_instance_field.symbols = private_or_internal_field +dotnet_naming_rule.private_or_internal_field_should_be_instance_field.style = instance_field + +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 + +dotnet_naming_style.static_field.required_prefix = s_ +dotnet_naming_style.static_field.required_suffix = +dotnet_naming_style.static_field.word_separator = +dotnet_naming_style.static_field.capitalization = camel_case + +dotnet_naming_style.instance_field.required_prefix = _ +dotnet_naming_style.instance_field.required_suffix = +dotnet_naming_style.instance_field.word_separator = +dotnet_naming_style.instance_field.capitalization = camel_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.private_or_internal_field.applicable_kinds = field +dotnet_naming_symbols.private_or_internal_field.applicable_accessibilities = internal, private, private_protected +dotnet_naming_symbols.private_or_internal_field.required_modifiers = + +dotnet_naming_symbols.private_or_internal_static_field.applicable_kinds = field +dotnet_naming_symbols.private_or_internal_static_field.applicable_accessibilities = internal, private, private_protected +dotnet_naming_symbols.private_or_internal_static_field.required_modifiers = static + +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 = + +dotnet_naming_symbols.constant.applicable_kinds = field +dotnet_naming_symbols.constant.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.constant.required_modifiers = const +dotnet_style_operator_placement_when_wrapping = beginning_of_line +dotnet_style_prefer_simplified_boolean_expressions = true:suggestion +dotnet_style_prefer_compound_assignment = true:suggestion +dotnet_style_prefer_simplified_interpolation = true:suggestion +dotnet_style_namespace_match_folder = true:suggestion +dotnet_style_allow_multiple_blank_lines_experimental = true:silent +dotnet_style_allow_statement_immediately_after_block_experimental = true:silent +dotnet_code_quality_unused_parameters = all:suggestion + +# var preferences +csharp_style_var_for_built_in_types = false:warning +csharp_style_var_when_type_is_apparent = false:warning +csharp_style_var_elsewhere = false:warning # Expression-bodied members -csharp_style_expression_bodied_accessors = true:silent -csharp_style_expression_bodied_constructors = true:silent -csharp_style_expression_bodied_indexers = true:silent -csharp_style_expression_bodied_lambdas = true:silent -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_methods = false:silent +csharp_style_expression_bodied_constructors = false:silent +csharp_style_expression_bodied_operators = false:silent csharp_style_expression_bodied_properties = true:silent - +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_accessors = true:silent # 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 - +csharp_style_pattern_matching_over_is_with_cast_check = true:warning +csharp_style_pattern_matching_over_as_with_null_check = true:warning # Null-checking preferences +csharp_style_throw_expression = true:suggestion 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 - -# Code-block preferences -csharp_prefer_braces = false:silent -csharp_prefer_simple_using_statement = true:suggestion - +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion # Expression-level preferences +csharp_prefer_braces = true:suggestion +csharp_style_deconstructed_variable_declaration = true:suggestion csharp_prefer_simple_default_expression = 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_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:silent - -#### C# Formatting Rules #### +csharp_style_prefer_local_over_anonymous_function = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion +# ------------------------------------------------------ # New line preferences -csharp_new_line_before_catch = true +csharp_new_line_before_open_brace = all csharp_new_line_before_else = true +csharp_new_line_before_catch = 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_before_members_in_anonymous_types = true 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 +csharp_indent_labels = one_less_than_current +# ------------------------------------------------------ # 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 +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_around_binary_operators = before_and_after +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +# ------------------------------------------------------ # Wrapping preferences -csharp_preserve_single_line_blocks = true csharp_preserve_single_line_statements = true +csharp_preserve_single_line_blocks = true +csharp_using_directive_placement = outside_namespace:silent +csharp_prefer_simple_using_statement = true:warning +csharp_style_namespace_declarations = file_scoped:suggestion +csharp_style_prefer_method_group_conversion = true:silent +csharp_style_prefer_top_level_statements = false:silent +csharp_style_expression_bodied_lambdas = true:silent +csharp_style_expression_bodied_local_functions = false:silent +csharp_style_prefer_null_check_over_type_check = true:suggestion +csharp_style_prefer_index_operator = true:suggestion +csharp_style_prefer_range_operator = true:silent +csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion +csharp_style_prefer_tuple_swap = true:suggestion +csharp_style_prefer_utf8_string_literals = true:suggestion +csharp_style_unused_value_assignment_preference = discard_variable:suggestion +csharp_style_unused_value_expression_statement_preference = discard_variable:silent +csharp_prefer_static_local_function = true:suggestion +csharp_style_prefer_readonly_struct = true:warning +csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:silent +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent +csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true:silent +csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent +csharp_style_prefer_switch_expression = true:suggestion +csharp_style_prefer_pattern_matching = true:silent +csharp_style_prefer_not_pattern = true:suggestion +csharp_style_prefer_extended_property_pattern = true:suggestion -#### Naming styles #### - +# ------------------------------------------------------ # Naming rules dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion @@ -176,32 +309,13 @@ 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.constant_should_be_pascal_case.severity = suggestion -dotnet_naming_rule.constant_should_be_pascal_case.symbols = constant -dotnet_naming_rule.constant_should_be_pascal_case.style = pascal_case - -dotnet_naming_rule.private_or_internal_static_field_should_be_static_field.severity = suggestion -dotnet_naming_rule.private_or_internal_static_field_should_be_static_field.symbols = private_or_internal_static_field -dotnet_naming_rule.private_or_internal_static_field_should_be_static_field.style = static_field - -dotnet_naming_rule.private_or_internal_field_should_be_instance_field.severity = suggestion -dotnet_naming_rule.private_or_internal_field_should_be_instance_field.symbols = private_or_internal_field -dotnet_naming_rule.private_or_internal_field_should_be_instance_field.style = instance_field - +# ------------------------------------------------------ # 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.private_or_internal_field.applicable_kinds = field -dotnet_naming_symbols.private_or_internal_field.applicable_accessibilities = internal, private, private_protected -dotnet_naming_symbols.private_or_internal_field.required_modifiers = - -dotnet_naming_symbols.private_or_internal_static_field.applicable_kinds = field -dotnet_naming_symbols.private_or_internal_static_field.applicable_accessibilities = internal, private, private_protected -dotnet_naming_symbols.private_or_internal_static_field.required_modifiers = static - 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 = @@ -210,31 +324,133 @@ dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, meth 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.constant.applicable_kinds = field -dotnet_naming_symbols.constant.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected -dotnet_naming_symbols.constant.required_modifiers = const - +# ------------------------------------------------------ # Naming styles +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.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 +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.static_field.required_prefix = s_ -dotnet_naming_style.static_field.required_suffix = -dotnet_naming_style.static_field.word_separator = -dotnet_naming_style.static_field.capitalization = camel_case +# ------------------------------------------------------ +# CA Style -dotnet_naming_style.instance_field.required_prefix = _ -dotnet_naming_style.instance_field.required_suffix = -dotnet_naming_style.instance_field.word_separator = -dotnet_naming_style.instance_field.capitalization = camel_case +# CA1050: Types are declared in namespaces to prevent name collisions and as a way to organize related types in an object hierarchy. +dotnet_diagnostic.CA1050.severity = warning + +# CA1507: Use nameof in place of string +dotnet_diagnostic.CA1507.severity = warning + +# CA1825: Avoid unnecessary zero-length array allocations. Use Array.Empty() instead. +dotnet_diagnostic.CA1825.severity = warning + +# CA1850: It is more efficient to use the static 'HashData' method over creating and managing a HashAlgorithm instance to call 'ComputeHash'. +dotnet_diagnostic.CA1850.severity = warning + +# CA1860: Prefer using 'IsEmpty', 'Count' or 'Length' properties whichever available, rather than calling 'Enumerable.Any()'. +# The intent is clearer and it is more performant than using 'Enumerable.Any()' extension method. +dotnet_diagnostic.CA1860.severity = warning + +# CA1860: Prefer using 'IsEmpty', 'Count' or 'Length' properties whichever available, rather than calling 'Enumerable.Any()'. +# The intent is clearer and it is more performant than using 'Enumerable.Any()' extension method. +dotnet_diagnostic.CA1860.severity = warning + +# CS1998: This async method lacks 'await' operators and will run synchronously. +# Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. +dotnet_diagnostic.CS1998.severity = error + +# CA2016: Forward the CancellationToken parameter to methods that take one +dotnet_diagnostic.CA2016.severity = error + + +# CA2211: Static fields that are neither constants nor read-only are not thread-safe. +# Access to such a field must be carefully controlled and requires advanced programming techniques to synchronize access to the class object. +dotnet_diagnostic.CA2211.severity = silent + +# ------------------------------------------------------ +# IDE + +# IDE0060: Avoid unused parameters in your code. +# If the parameter cannot be removed, then change its name so it starts with an underscore and is optionally followed by an +# integer, such as '_', '_1', '_2', etc. These are treated as special discard symbol names. +dotnet_diagnostic.IDE0060.severity = silent + +# IDE0130: Namespace does not match folder structure +dotnet_diagnostic.IDE0130.severity = warning + +# IDE0290: Use primary constructor +dotnet_diagnostic.IDE0290.severity = none +csharp_style_prefer_primary_constructors = false:suggestion + +# IDE1006: Naming rule violation: These words must begin with upper case characters: accessToken +dotnet_diagnostic.IDE1006.severity = warning + +# ------------------------------------------------------ +# Roslyn + +# RCS1021: Use expression-bodied lambda. +dotnet_diagnostic.RCS1021.severity = silent + +# RCS1036: Remove unnecessary blank line +dotnet_diagnostic.RCS1036.severity = warning + +# RCS1049: Simplify boolean comparison +# we usually prefer is vs ! +dotnet_diagnostic.RCS1049.severity = silent + +# RCS1123: Add parentheses when necessary +dotnet_diagnostic.RCS1123.severity = warning + +# RCS1163: Unused parameter +# Often this warning comes also from parameters we want to have for readability +dotnet_diagnostic.RCS1163.severity = silent + +# RCS1194: Implement exception constructors +dotnet_diagnostic.RCS1194.severity = silent + +# ------------------------------------------------------ +# Meziantou.Analyzer + +# MA0016: Prefer using collection abstraction instead of implementation +dotnet_diagnostic.MA0016.severity = none + +# MA0017: Abstract types should not have public or internal constructors +dotnet_diagnostic.MA0017.severity = none + +# MA0018: Do not declare static members on generic types (deprecated; use CA1000 instead) +dotnet_diagnostic.MA0018.severity = none + +# MA0029: Combine LINQ methods +# Often these recommendations have a performance impact, so it is recommended to review them before applying them. +dotnet_diagnostic.MA0029.severity = none + +# MA0040: Forward the CancellationToken parameter to methods that take one +dotnet_diagnostic.MA0040.severity = warning + +# MA0048: File name must match type name +dotnet_diagnostic.MA0048.severity = silent + +# MA0051: Method is too long (80 lines; maximum allowed: 60) +dotnet_diagnostic.MA0051.severity = suggestion + +# MA0154: Use langword in XML comment +dotnet_diagnostic.MA0154.severity = none + +# ------------------------------------------------------ +# Xunit + +# xUnit1006: Theory methods should have parameters +dotnet_diagnostic.xUnit1006.severity = silent -# RCS1096: Convert 'HasFlag' call to bitwise operation (or vice versa). -dotnet_diagnostic.RCS1096.severity = none +# xUnit1048: Support for 'async void' unit tests is being removed from xUnit.net v3. To simplify upgrading, convert the test to 'async Task' instead. +dotnet_diagnostic.xUnit1048.severity = error diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d56fc9..1e7129e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,8 @@ on: pull_request: branches: - main + release: + types: [published] env: BuildConfig: Release @@ -17,11 +19,6 @@ jobs: runs-on: ubuntu-latest steps: - - name: Cancel previous builds in PR - uses: styfle/cancel-workflow-action@0.12.1 - with: - access_token: ${{ github.token }} - - name: Checkout code uses: actions/checkout@v4 with: @@ -51,27 +48,45 @@ jobs: - name: Test with dotnet run: dotnet test --no-build --configuration ${{ env.BuildConfig }} - --logger "trx;LogFileName=test-results.trx" --results-directory ./artifacts/testResults + --logger "trx;LogFileName=test-results.trx" --results-directory ./artifacts/test-results continue-on-error: true - - name: Test Report - uses: dorny/test-reporter@v1 - if: always() - with: - name: DotNET Tests - path: "./artifacts/testResults/test-results.trx" - reporter: dotnet-trx - fail-on-error: true - - name: Pack NuGet run: dotnet pack --configuration ${{ env.BuildConfig }} + --output ./artifacts/nuget-packages /p:ContinuousIntegrationBuild=true /p:Version=${{ steps.nbgv.outputs.NuGetPackageVersion }} - - name: Push to NuGet - run: dotnet nuget push **/*.nupkg - --api-key ${{ secrets.NUGET_DEPLOY_KEY }} + - name: Upload Artifacts + uses: actions/upload-artifact@v4 + with: + name: artifacts + path: ./artifacts/**/* + + # the deploy job runs only when the build job is successful and the event is a release + deploy: + if: github.event_name == 'release' + name: Publish Package + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 # avoid shallow clone so nbgv can do its work. + + - name: Download build artifacts + uses: actions/download-artifact@v4 + + - name: Upload release asset + run: gh release upload ${{ github.event.release.tag_name }} + ${{ github.workspace }}/artifacts/nuget-packages/*.*nupkg + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish package + run: dotnet nuget push ${{github.workspace}}/artifacts/nuget-packages/*.nupkg --source https://api.nuget.org/v3/index.json - --no-symbols + --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate diff --git a/tests/MyCSharp.HttpClientHints.AspNetCore.UnitTests/HttpClientHintsRegistrationTests.cs b/tests/MyCSharp.HttpClientHints.AspNetCore.UnitTests/HttpClientHintsRegistrationTests.cs index 5a323d0..362d63e 100644 --- a/tests/MyCSharp.HttpClientHints.AspNetCore.UnitTests/HttpClientHintsRegistrationTests.cs +++ b/tests/MyCSharp.HttpClientHints.AspNetCore.UnitTests/HttpClientHintsRegistrationTests.cs @@ -6,7 +6,6 @@ using NSubstitute; using Xunit; - namespace MyCSharp.HttpClientHints.AspNetCore.UnitTests; public class HttpClientHintsRegistrationTests