diff --git a/.editorconfig b/.editorconfig index 43df899..0e13eaa 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,15 +1,375 @@ root = true [*] -indent_style = space +charset = utf-8 +end_of_line = lf indent_size = 2 -trim_trailing_whitespace = true +indent_style = space insert_final_newline = true -end_of_line = lf +trim_trailing_whitespace = true -[*.{cs,cake}] -indent_style = tab -indent_size = 4 +[*.json] +resharper_comment_typo_highlighting = none +resharper_identifier_typo_highlighting = none +resharper_string_literal_typo_highlighting = none + +[Directory.Packages.props] +insert_final_newline = false -[*.csproj] +[dotnet-tools.json] insert_final_newline = false + +[*.cs] +indent_size = tab +indent_style = tab +tab_width = 4 +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = false +csharp_indent_labels = one_less_than_current +csharp_indent_switch_labels = true +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 +csharp_prefer_braces = when_multiline : suggestion +csharp_prefer_simple_default_expression = true : suggestion +csharp_prefer_simple_using_statement = true : suggestion +csharp_prefer_static_local_function = true : suggestion +csharp_preferred_modifier_order = public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async : warning +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true +csharp_space_after_cast = true +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_style_conditional_delegate_call = true : suggestion +csharp_style_deconstructed_variable_declaration = true : suggestion +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 : suggestion +csharp_style_expression_bodied_local_functions = true : suggestion +csharp_style_expression_bodied_methods = true : suggestion +csharp_style_expression_bodied_operators = true : suggestion +csharp_style_expression_bodied_properties = true : suggestion +csharp_style_implicit_object_creation_when_type_is_apparent = true : suggestion +csharp_style_inlined_variable_declaration = true : suggestion +csharp_style_namespace_declarations = file_scoped : suggestion +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_index_operator = true : suggestion +csharp_style_prefer_local_over_anonymous_function = true : suggestion +csharp_style_prefer_not_pattern = true : suggestion +csharp_style_prefer_null_check_over_type_check = true : suggestion +csharp_style_prefer_pattern_matching = true : suggestion +csharp_style_prefer_primary_constructors = true : suggestion +csharp_style_prefer_range_operator = true : suggestion +csharp_style_prefer_switch_expression = true : suggestion +csharp_style_prefer_tuple_swap = true : warning +csharp_style_throw_expression = true : suggestion +csharp_style_unused_value_assignment_preference = discard_variable : warning +csharp_style_unused_value_expression_statement_preference = discard_variable : none +csharp_style_var_elsewhere = true : suggestion +csharp_style_var_for_built_in_types = true : suggestion +csharp_style_var_when_type_is_apparent = true : suggestion +csharp_using_directive_placement = outside_namespace : warning +dotnet_analyzer_diagnostic.severity = warning +dotnet_code_quality_unused_parameters = all : suggestion +dotnet_diagnostic.CA1014.severity = none +dotnet_diagnostic.CA1030.severity = none +dotnet_diagnostic.CA1031.severity = suggestion +dotnet_diagnostic.CA1032.severity = suggestion +dotnet_diagnostic.CA1054.severity = none +dotnet_diagnostic.CA1055.severity = none +dotnet_diagnostic.CA1056.severity = none +dotnet_diagnostic.CA1062.severity = suggestion +dotnet_diagnostic.CA1063.severity = none +dotnet_diagnostic.CA1303.severity = none +dotnet_diagnostic.CA1308.severity = suggestion +dotnet_diagnostic.CA1309.severity = suggestion +dotnet_diagnostic.CA1508.severity = suggestion +dotnet_diagnostic.CA1707.severity = none +dotnet_diagnostic.CA1716.severity = none +dotnet_diagnostic.CA1720.severity = suggestion +dotnet_diagnostic.CA1812.severity = none +dotnet_diagnostic.CA1815.severity = suggestion +dotnet_diagnostic.CA1816.severity = none +dotnet_diagnostic.CA1819.severity = suggestion +dotnet_diagnostic.CA1822.severity = suggestion +dotnet_diagnostic.CA1826.severity = suggestion +dotnet_diagnostic.CA1848.severity = suggestion +dotnet_diagnostic.CA2000.severity = none +dotnet_diagnostic.CA2227.severity = none +dotnet_diagnostic.CA2234.severity = none +dotnet_diagnostic.CA2237.severity = none +dotnet_diagnostic.CA2254.severity = none +dotnet_diagnostic.CA5351.severity = none +dotnet_diagnostic.IDE0001.severity = warning +dotnet_diagnostic.IDE0002.severity = warning +dotnet_diagnostic.IDE0003.severity = warning +dotnet_diagnostic.IDE0004.severity = warning +dotnet_diagnostic.IDE0005.severity = warning +dotnet_diagnostic.IDE0007.severity = suggestion +dotnet_diagnostic.IDE0008.severity = suggestion +dotnet_diagnostic.IDE0009.severity = warning +dotnet_diagnostic.IDE0010.severity = suggestion +dotnet_diagnostic.IDE0011.severity = suggestion +dotnet_diagnostic.IDE0016.severity = suggestion +dotnet_diagnostic.IDE0017.severity = suggestion +dotnet_diagnostic.IDE0018.severity = suggestion +dotnet_diagnostic.IDE0019.severity = suggestion +dotnet_diagnostic.IDE0020.severity = suggestion +dotnet_diagnostic.IDE0021.severity = suggestion +dotnet_diagnostic.IDE0022.severity = suggestion +dotnet_diagnostic.IDE0023.severity = suggestion +dotnet_diagnostic.IDE0024.severity = suggestion +dotnet_diagnostic.IDE0025.severity = suggestion +dotnet_diagnostic.IDE0026.severity = suggestion +dotnet_diagnostic.IDE0027.severity = suggestion +dotnet_diagnostic.IDE0028.severity = suggestion +dotnet_diagnostic.IDE0029.severity = warning +dotnet_diagnostic.IDE0030.severity = warning +dotnet_diagnostic.IDE0031.severity = suggestion +dotnet_diagnostic.IDE0032.severity = suggestion +dotnet_diagnostic.IDE0033.severity = warning +dotnet_diagnostic.IDE0034.severity = suggestion +dotnet_diagnostic.IDE0035.severity = warning +dotnet_diagnostic.IDE0036.severity = warning +dotnet_diagnostic.IDE0037.severity = suggestion +dotnet_diagnostic.IDE0038.severity = suggestion +dotnet_diagnostic.IDE0039.severity = suggestion +dotnet_diagnostic.IDE0040.severity = warning +dotnet_diagnostic.IDE0041.severity = suggestion +dotnet_diagnostic.IDE0042.severity = suggestion +dotnet_diagnostic.IDE0044.severity = warning +dotnet_diagnostic.IDE0045.severity = suggestion +dotnet_diagnostic.IDE0046.severity = none +dotnet_diagnostic.IDE0047.severity = suggestion +dotnet_diagnostic.IDE0048.severity = suggestion +dotnet_diagnostic.IDE0049.severity = warning +dotnet_diagnostic.IDE0051.severity = warning +dotnet_diagnostic.IDE0052.severity = warning +dotnet_diagnostic.IDE0053.severity = suggestion +dotnet_diagnostic.IDE0054.severity = suggestion +dotnet_diagnostic.IDE0056.severity = suggestion +dotnet_diagnostic.IDE0057.severity = suggestion +dotnet_diagnostic.IDE0058.severity = none +dotnet_diagnostic.IDE0059.severity = warning +dotnet_diagnostic.IDE0060.severity = suggestion +dotnet_diagnostic.IDE0061.severity = suggestion +dotnet_diagnostic.IDE0062.severity = suggestion +dotnet_diagnostic.IDE0063.severity = suggestion +dotnet_diagnostic.IDE0065.severity = warning +dotnet_diagnostic.IDE0066.severity = suggestion +dotnet_diagnostic.IDE0070.severity = suggestion +dotnet_diagnostic.IDE0071.severity = suggestion +dotnet_diagnostic.IDE0072.severity = suggestion +dotnet_diagnostic.IDE0074.severity = suggestion +dotnet_diagnostic.IDE0075.severity = warning +dotnet_diagnostic.IDE0078.severity = suggestion +dotnet_diagnostic.IDE0080.severity = suggestion +dotnet_diagnostic.IDE0082.severity = warning +dotnet_diagnostic.IDE0083.severity = suggestion +dotnet_diagnostic.IDE0090.severity = suggestion +dotnet_diagnostic.IDE0100.severity = warning +dotnet_diagnostic.IDE0110.severity = warning +dotnet_diagnostic.IDE0130.severity = warning +dotnet_diagnostic.IDE0150.severity = suggestion +dotnet_diagnostic.IDE0160.severity = suggestion +dotnet_diagnostic.IDE0161.severity = suggestion +dotnet_diagnostic.IDE0170.severity = suggestion +dotnet_diagnostic.IDE0180.severity = warning +dotnet_diagnostic.IDE0290.severity = suggestion +dotnet_diagnostic.IDE1005.severity = suggestion +dotnet_diagnostic.NUnit2045.severity = suggestion +dotnet_diagnostic.SA0001.severity = none +dotnet_diagnostic.SA1003.severity = none +dotnet_diagnostic.SA1008.severity = none +dotnet_diagnostic.SA1009.severity = none +dotnet_diagnostic.SA1011.severity = none +dotnet_diagnostic.SA1013.severity = none +dotnet_diagnostic.SA1027.severity = none +dotnet_diagnostic.SA1101.severity = none +dotnet_diagnostic.SA1116.severity = none +dotnet_diagnostic.SA1117.severity = none +dotnet_diagnostic.SA1118.severity = none +dotnet_diagnostic.SA1122.severity = none +dotnet_diagnostic.SA1133.severity = none +dotnet_diagnostic.SA1134.severity = none +dotnet_diagnostic.SA1200.severity = none +dotnet_diagnostic.SA1201.severity = none +dotnet_diagnostic.SA1202.severity = none +dotnet_diagnostic.SA1203.severity = none +dotnet_diagnostic.SA1204.severity = none +dotnet_diagnostic.SA1206.severity = none +dotnet_diagnostic.SA1214.severity = suggestion +dotnet_diagnostic.SA1300.severity = none +dotnet_diagnostic.SA1303.severity = none +dotnet_diagnostic.SA1308.severity = none +dotnet_diagnostic.SA1310.severity = none +dotnet_diagnostic.SA1311.severity = none +dotnet_diagnostic.SA1407.severity = none +dotnet_diagnostic.SA1408.severity = none +dotnet_diagnostic.SA1503.severity = none +dotnet_diagnostic.SA1504.severity = none +dotnet_diagnostic.SA1513.severity = none +dotnet_diagnostic.SA1516.severity = none +dotnet_diagnostic.SA1600.severity = none +dotnet_diagnostic.SA1601.severity = none +dotnet_diagnostic.SA1602.severity = none +dotnet_diagnostic.SA1604.severity = none +dotnet_diagnostic.SA1605.severity = none +dotnet_diagnostic.SA1611.severity = none +dotnet_diagnostic.SA1615.severity = none +dotnet_diagnostic.SA1618.severity = none +dotnet_diagnostic.SA1619.severity = none +dotnet_diagnostic.SA1623.severity = none +dotnet_diagnostic.SA1629.severity = none +dotnet_diagnostic.SA1633.severity = none +dotnet_diagnostic.SA1642.severity = none +dotnet_diagnostic.SA1643.severity = none +dotnet_diagnostic.SX1101.severity = warning +dotnet_diagnostic.SYSLIB1045.severity = suggestion +dotnet_diagnostic.SYSLIB1054.severity = none +dotnet_naming_rule.local_functions_rule.severity = warning +dotnet_naming_rule.local_functions_rule.style = upper_camel_case_style +dotnet_naming_rule.local_functions_rule.symbols = local_functions_symbols +dotnet_naming_rule.private_constants_rule.severity = warning +dotnet_naming_rule.private_constants_rule.style = c_lower_camel_case_style +dotnet_naming_rule.private_constants_rule.symbols = private_constants_symbols +dotnet_naming_rule.private_instance_fields_rule.severity = warning +dotnet_naming_rule.private_instance_fields_rule.style = m_lower_camel_case_style +dotnet_naming_rule.private_instance_fields_rule.symbols = private_instance_fields_symbols +dotnet_naming_rule.private_static_fields_rule.severity = warning +dotnet_naming_rule.private_static_fields_rule.style = s_lower_camel_case_style +dotnet_naming_rule.private_static_fields_rule.symbols = private_static_fields_symbols +dotnet_naming_rule.private_static_readonly_rule.severity = warning +dotnet_naming_rule.private_static_readonly_rule.style = s_lower_camel_case_style +dotnet_naming_rule.private_static_readonly_rule.symbols = private_static_readonly_symbols +dotnet_naming_style.c_lower_camel_case_style.capitalization = camel_case +dotnet_naming_style.c_lower_camel_case_style.required_prefix = c_ +dotnet_naming_style.m_lower_camel_case_style.capitalization = camel_case +dotnet_naming_style.m_lower_camel_case_style.required_prefix = m_ +dotnet_naming_style.s_lower_camel_case_style.capitalization = camel_case +dotnet_naming_style.s_lower_camel_case_style.required_prefix = s_ +dotnet_naming_style.upper_camel_case_style.capitalization = pascal_case +dotnet_naming_symbols.local_functions_symbols.applicable_accessibilities = * +dotnet_naming_symbols.local_functions_symbols.applicable_kinds = local_function +dotnet_naming_symbols.private_constants_symbols.applicable_accessibilities = private +dotnet_naming_symbols.private_constants_symbols.applicable_kinds = field +dotnet_naming_symbols.private_constants_symbols.required_modifiers = const +dotnet_naming_symbols.private_instance_fields_symbols.applicable_accessibilities = private +dotnet_naming_symbols.private_instance_fields_symbols.applicable_kinds = field +dotnet_naming_symbols.private_static_fields_symbols.applicable_accessibilities = private +dotnet_naming_symbols.private_static_fields_symbols.applicable_kinds = field +dotnet_naming_symbols.private_static_fields_symbols.required_modifiers = static +dotnet_naming_symbols.private_static_readonly_symbols.applicable_accessibilities = private +dotnet_naming_symbols.private_static_readonly_symbols.applicable_kinds = field +dotnet_naming_symbols.private_static_readonly_symbols.required_modifiers = static, readonly +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = true +dotnet_style_coalesce_expression = true : warning +dotnet_style_collection_initializer = true : suggestion +dotnet_style_explicit_tuple_names = true : warning +dotnet_style_namespace_match_folder = true : warning +dotnet_style_null_propagation = true : suggestion +dotnet_style_object_initializer = true : suggestion +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity : none +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity : none +dotnet_style_parentheses_in_other_operators = never_if_unnecessary : suggestion +dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary : suggestion +dotnet_style_predefined_type_for_locals_parameters_members = true : warning +dotnet_style_predefined_type_for_member_access = true : warning +dotnet_style_prefer_auto_properties = true : 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 : none +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 : warning +dotnet_style_prefer_simplified_interpolation = true : suggestion +dotnet_style_qualification_for_event = false : warning +dotnet_style_qualification_for_field = false : warning +dotnet_style_qualification_for_method = false : warning +dotnet_style_qualification_for_property = false : warning +dotnet_style_readonly_field = true : warning +dotnet_style_require_accessibility_modifiers = for_non_interface_members : warning +resharper_access_to_disposed_closure_highlighting = none +resharper_access_to_modified_closure_highlighting = none +resharper_apply_auto_detected_rules = false +resharper_arrange_constructor_or_destructor_body_highlighting = hint +resharper_arrange_method_or_operator_body_highlighting = hint +resharper_arrange_missing_parentheses_highlighting = hint +resharper_arrange_trailing_comma_in_multiline_lists_highlighting = warning +resharper_comment_typo_highlighting = none +resharper_compare_of_floats_by_equality_operator_highlighting = suggestion +resharper_convert_to_primary_constructor_highlighting = hint +resharper_csharp_align_first_arg_by_paren = false +resharper_csharp_align_linq_query = false +resharper_csharp_align_multiline_argument = false +resharper_csharp_align_multiline_array_and_object_initializer = false +resharper_csharp_align_multiline_binary_expressions_chain = false +resharper_csharp_align_multiline_calls_chain = false +resharper_csharp_align_multiline_expression = false +resharper_csharp_align_multiline_extends_list = false +resharper_csharp_align_multiline_for_stmt = false +resharper_csharp_align_multiline_parameter = false +resharper_csharp_align_multiline_statement_conditions = false +resharper_csharp_align_multiline_switch_expression = false +resharper_csharp_align_multiple_declaration = false +resharper_csharp_align_multline_type_parameter_constrains = false +resharper_csharp_align_multline_type_parameter_list = false +resharper_csharp_align_tuple_components = false +resharper_csharp_blank_lines_after_block_statements = 0 +resharper_csharp_indent_anonymous_method_block = false +resharper_csharp_indent_nested_for_stmt = true +resharper_csharp_indent_nested_foreach_stmt = true +resharper_csharp_indent_nested_while_stmt = true +resharper_csharp_indent_raw_literal_string = indent +resharper_csharp_int_align = false +resharper_csharp_keep_existing_arrangement = true +resharper_csharp_nested_ternary_style = simple_wrap +resharper_csharp_new_line_before_while = true +resharper_csharp_parentheses_group_non_obvious_operations = conditional +resharper_csharp_parentheses_non_obvious_operations = shift, bitwise +resharper_csharp_parentheses_redundancy_style = remove_if_not_clarifies_precedence +resharper_csharp_space_within_single_line_array_initializer_braces = true +resharper_csharp_trailing_comma_in_multiline_lists = true +resharper_csharp_wrap_before_ternary_opsigns = true +resharper_csharp_wrap_lines = false +resharper_csharp_wrap_ternary_expr_style = wrap_if_long +resharper_identifier_typo_highlighting = none +resharper_invert_if_highlighting = none +resharper_is_expression_always_true_highlighting = hint +resharper_localizable_element_highlighting = none +resharper_pattern_always_of_type_highlighting = none +resharper_string_literal_typo_highlighting = none +resharper_unused_auto_property_accessor_global_highlighting = none +resharper_unused_auto_property_accessor_local_highlighting = suggestion +resharper_unused_member_global_highlighting = none +resharper_unused_member_local_highlighting = suggestion diff --git a/.gitattributes b/.gitattributes index 6313b56..4092f8f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,5 @@ * text=auto eol=lf + +*.cs text diff=csharp +*.csproj text merge=union +*.sln text merge=union diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..5e1e243 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,40 @@ +name: Build + +on: + push: + branches: [master] + tags-ignore: ['**'] + pull_request: + workflow_dispatch: + +env: + DOTNET_NOLOGO: 1 + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + +defaults: + run: + shell: pwsh + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - name: Install .NET + uses: actions/setup-dotnet@v3 + - name: Check out code + uses: actions/checkout@v3 + - name: Restore + run: .\build.ps1 restore + - name: Build + run: .\build.ps1 build --skip restore + - name: Test + run: .\build.ps1 test --skip build + - name: Publish + if: runner.os == 'Windows' && github.repository_owner == 'Faithlife' && github.ref == 'refs/heads/master' + env: + BUILD_BOT_PASSWORD: ${{ secrets.BUILD_BOT_PASSWORD }} + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + run: .\build.ps1 publish --skip test diff --git a/.github/workflows/publish-docs.yaml b/.github/workflows/publish-docs.yaml new file mode 100644 index 0000000..f2e15ed --- /dev/null +++ b/.github/workflows/publish-docs.yaml @@ -0,0 +1,21 @@ +name: Publish Docs +on: + workflow_dispatch: +env: + DOTNET_NOLOGO: 1 + DOTNET_CLI_TELEMETRY_OPTOUT: 1 +defaults: + run: + shell: pwsh +jobs: + publish-docs: + runs-on: windows-latest + steps: + - name: Install .NET + uses: actions/setup-dotnet@v3 + - name: Check out code + uses: actions/checkout@v3 + - name: Publish Docs + env: + BUILD_BOT_PASSWORD: ${{ secrets.BUILD_BOT_PASSWORD }} + run: .\build.ps1 publish --no-test --trigger publish-docs diff --git a/.gitignore b/.gitignore index c355af8..a2ad192 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .vs/ +.idea/ +artifacts/ bin/ -cake/ obj/ release/ @@ -8,7 +9,8 @@ release/ *.log *.ncrunchproject *.ncrunchsolution -*.suo *.user - launchSettings.json +nCrunchTemp* +_ReSharper* +.DS_Store diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2d7db28..0000000 --- a/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -sudo: required -dist: trusty - -before_install: - - sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list' - - sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893 - - sudo apt-get update - - sudo apt-get install -y dotnet-dev-1.0.1 - -script: - - dotnet restore - - dotnet test tests/Faithlife.Utility.Dapper.Tests/Faithlife.Utility.Dapper.Tests.csproj -c Release -f netcoreapp1.1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..8ab1646 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,9 @@ +# Contributing + +## Publishing + +* To publish the library, update the `` in [`Directory.Build.props`](Directory.Build.props), add a corresponding section to the top of [`ReleaseNotes.md`](ReleaseNotes.md), commit, and push. + +## Template + +* This repository uses the [`faithlife-build`](https://github.com/Faithlife/CSharpTemplate/tree/faithlife-build) template of [`Faithlife/CSharpTemplate`](https://github.com/Faithlife/CSharpTemplate). diff --git a/DapperUtility.sln b/DapperUtility.sln index cec8170..ba12b9c 100644 --- a/DapperUtility.sln +++ b/DapperUtility.sln @@ -1,40 +1,59 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26403.7 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "root", "root", "{68EEB72A-6D49-4B06-87C1-B54D028F897F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Faithlife.Utility.Dapper", "src\Faithlife.Utility.Dapper\Faithlife.Utility.Dapper.csproj", "{1F75E8CE-F59A-4738-81EC-17B71C125A06}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Faithlife.Utility.Dapper.Tests", "tests\Faithlife.Utility.Dapper.Tests\Faithlife.Utility.Dapper.Tests.csproj", "{3506DA15-B470-42E7-B897-D436451CBC32}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Build", "tools\Build\Build.csproj", "{9BB3C85C-100E-4128-A9AF-8F697D753538}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XmlDocGen", "tools\XmlDocGen\XmlDocGen.csproj", "{0A5C4B36-610E-4451-BD56-86E5C8A52C42}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A21957E2-3EB8-4CA5-8537-04F60C9F98D5}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig .gitattributes = .gitattributes .gitignore = .gitignore - appveyor.yml = appveyor.yml - build.cake = build.cake build.ps1 = build.ps1 + CONTRIBUTING.md = CONTRIBUTING.md + Directory.Build.props = Directory.Build.props + Directory.Packages.props = Directory.Packages.props + global.json = global.json LICENSE = LICENSE + nuget.config = nuget.config README.md = README.md + ReleaseNotes.md = ReleaseNotes.md EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Faithlife.Utility.Dapper", "src\Faithlife.Utility.Dapper\Faithlife.Utility.Dapper.csproj", "{F8160721-2FE9-4516-8A6C-346D40DD06C4}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Faithlife.Utility.Dapper.Tests", "tests\Faithlife.Utility.Dapper.Tests\Faithlife.Utility.Dapper.Tests.csproj", "{037DA62C-FFCF-4C1B-B8DC-42B75107D1F7}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F8160721-2FE9-4516-8A6C-346D40DD06C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F8160721-2FE9-4516-8A6C-346D40DD06C4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F8160721-2FE9-4516-8A6C-346D40DD06C4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F8160721-2FE9-4516-8A6C-346D40DD06C4}.Release|Any CPU.Build.0 = Release|Any CPU - {037DA62C-FFCF-4C1B-B8DC-42B75107D1F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {037DA62C-FFCF-4C1B-B8DC-42B75107D1F7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {037DA62C-FFCF-4C1B-B8DC-42B75107D1F7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {037DA62C-FFCF-4C1B-B8DC-42B75107D1F7}.Release|Any CPU.Build.0 = Release|Any CPU + {1F75E8CE-F59A-4738-81EC-17B71C125A06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F75E8CE-F59A-4738-81EC-17B71C125A06}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F75E8CE-F59A-4738-81EC-17B71C125A06}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F75E8CE-F59A-4738-81EC-17B71C125A06}.Release|Any CPU.Build.0 = Release|Any CPU + {3506DA15-B470-42E7-B897-D436451CBC32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3506DA15-B470-42E7-B897-D436451CBC32}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3506DA15-B470-42E7-B897-D436451CBC32}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3506DA15-B470-42E7-B897-D436451CBC32}.Release|Any CPU.Build.0 = Release|Any CPU + {9BB3C85C-100E-4128-A9AF-8F697D753538}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9BB3C85C-100E-4128-A9AF-8F697D753538}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9BB3C85C-100E-4128-A9AF-8F697D753538}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9BB3C85C-100E-4128-A9AF-8F697D753538}.Release|Any CPU.Build.0 = Release|Any CPU + {0A5C4B36-610E-4451-BD56-86E5C8A52C42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0A5C4B36-610E-4451-BD56-86E5C8A52C42}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0A5C4B36-610E-4451-BD56-86E5C8A52C42}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0A5C4B36-610E-4451-BD56-86E5C8A52C42}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {28CD7BF1-0965-4088-8597-4C08C20C814C} + EndGlobalSection EndGlobal diff --git a/DapperUtility.sln.DotSettings b/DapperUtility.sln.DotSettings new file mode 100644 index 0000000..6f09a21 --- /dev/null +++ b/DapperUtility.sln.DotSettings @@ -0,0 +1,2 @@ + + <?xml version="1.0" encoding="utf-16"?><Profile name="Build"><XAMLCollapseEmptyTags>False</XAMLCollapseEmptyTags><CppClangTidyCleanupDescriptor /><CSCodeStyleAttributes ArrangeTypeAccessModifier="True" ArrangeTypeMemberAccessModifier="True" SortModifiers="True" RemoveRedundantParentheses="True" AddMissingParentheses="False" ArrangeBraces="False" ArrangeAttributes="False" ArrangeArgumentsStyle="False" ArrangeCodeBodyStyle="False" ArrangeVarStyle="True" ArrangeTrailingCommas="True" /><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSReformatCode>True</CSReformatCode><CSArrangeQualifiers>True</CSArrangeQualifiers><CSFixBuiltinTypeReferences>True</CSFixBuiltinTypeReferences><CSShortenReferences>True</CSShortenReferences><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSMakeAutoPropertyGetOnly>True</CSMakeAutoPropertyGetOnly></Profile> diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..bbf312a --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,41 @@ + + + + 2.0.0 + 2.0.0 + 12.0 + disable + enable + true + $(NoWarn);1591;1998;NU1507;NU5105 + en-US + embedded + Faithlife + DapperUtility + MIT + https://github.com/$(GitHubOrganization)/$(RepositoryName) + https://github.com/$(GitHubOrganization)/$(RepositoryName)/blob/master/ReleaseNotes.md + https://github.com/$(GitHubOrganization)/$(RepositoryName).git + Faithlife + Copyright $(Authors) + true + true + true + latest-all + true + true + false + false + false + true + true + true + true + + + + $(VersionPrefix).$(BuildNumber) + true + + + diff --git a/Directory.Packages.props b/Directory.Packages.props new file mode 100644 index 0000000..1bae07e --- /dev/null +++ b/Directory.Packages.props @@ -0,0 +1,18 @@ + + + true + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/LICENSE b/LICENSE index 40cccd6..5595acf 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2016-2017 Faithlife Corporation +Copyright 2024 Faithlife Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 2b2416d..17ed009 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,6 @@ **Faithlife.Utility.Dapper** is a utility library for [Dapper](https://github.com/StackExchange/dapper-dot-net). -Ubuntu | Windows | NuGet ---- | --- | --- -[![Travis CI](https://img.shields.io/travis/Faithlife/DapperUtility/master.svg)](https://travis-ci.org/Faithlife/DapperUtility) | [![AppVeyor](https://img.shields.io/appveyor/ci/ejball/dapperutility/master.svg)](https://ci.appveyor.com/project/ejball/dapperutility) | [![NuGet](https://img.shields.io/nuget/v/Faithlife.Utility.Dapper.svg)](https://www.nuget.org/packages/Faithlife.Utility.Dapper) +[![Build](https://github.com/Faithlife/DapperUtility/workflows/Build/badge.svg)](https://github.com/Faithlife/DapperUtility/actions?query=workflow%3ABuild) [![NuGet](https://img.shields.io/nuget/v/Faithlife.Utility.Dapper.svg)](https://www.nuget.org/packages/Faithlife.Utility.Dapper) -**Documentation:** https://faithlife.github.io/DapperUtility/ +[Documentation](https://faithlife.github.io/DapperUtility/) | [Release Notes](https://github.com/Faithlife/DapperUtility/blob/master/ReleaseNotes.md) | [Contributing](https://github.com/Faithlife/DapperUtility/blob/master/CONTRIBUTING.md) diff --git a/ReleaseNotes.md b/ReleaseNotes.md new file mode 100644 index 0000000..b4ad18b --- /dev/null +++ b/ReleaseNotes.md @@ -0,0 +1,5 @@ +# Release Notes + +## 0.1.0 + +* Initial release. diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 44a7837..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,8 +0,0 @@ -version: '{build}' -image: Visual Studio 2017 -environment: - NUGETAPIKEY: - secure: hPo98uWApLeubFt4LvY7wXpLKExUDaQbtzn4qCKXTq2C4wH2H9K3dFusJDLMTaff -build_script: -- ps: .\build.ps1 --target=NuGetPublish """--trigger=$env:APPVEYOR_REPO_TAG_NAME""" "--nugetApiKey=$env:NUGETAPIKEY" -test: off diff --git a/build.cake b/build.cake deleted file mode 100644 index 38101a8..0000000 --- a/build.cake +++ /dev/null @@ -1,110 +0,0 @@ -#tool "nuget:?package=XmlDocMarkdown&version=0.5.0" -#tool "nuget:?package=xunit.runner.console&version=2.2.0" - -using System.Text.RegularExpressions; - -var target = Argument("target", "Default"); -var configuration = Argument("configuration", "Release"); -var nugetApiKey = Argument("nugetApiKey", ""); -var trigger = Argument("trigger", ""); - -var solutionFileName = "DapperUtility.sln"; -var nugetSource = "https://api.nuget.org/v3/index.json"; -var docsAssembly = $@"src\Faithlife.Utility.Dapper\bin\{configuration}\net45\Faithlife.Utility.Dapper.dll"; -var docsSourceUri = "https://github.com/Faithlife/DapperUtility/tree/master/src/Faithlife.Utility.Dapper"; - -Task("Clean") - .Does(() => - { - CleanDirectories("src/**/bin"); - CleanDirectories("src/**/obj"); - CleanDirectories("tests/**/bin"); - CleanDirectories("tests/**/obj"); - CleanDirectories("release"); - }); - -Task("Build") - .IsDependentOn("Clean") - .Does(() => - { - DotNetCoreRestore(solutionFileName); - DotNetCoreBuild(solutionFileName, new DotNetCoreBuildSettings { Configuration = configuration, ArgumentCustomization = args => args.Append("--verbosity normal") }); - }); - -Task("GenerateDocs") - .IsDependentOn("Build") - .Does(() => GenerateDocs(verify: false)); - -Task("VerifyGenerateDocs") - .IsDependentOn("Build") - .Does(() => GenerateDocs(verify: true)); - -Task("Test") - .IsDependentOn("VerifyGenerateDocs") - .Does(() => - { - foreach (var projectPath in GetFiles("tests/**/*.csproj").Select(x => x.FullPath)) - DotNetCoreTest(projectPath, new DotNetCoreTestSettings { Configuration = configuration }); - }); - -Task("NuGetPackage") - .IsDependentOn("Test") - .Does(() => - { - foreach (var projectPath in GetFiles("src/**/*.csproj").Select(x => x.FullPath)) - DotNetCorePack(projectPath, new DotNetCorePackSettings { Configuration = configuration, OutputDirectory = "release" }); - }); - -Task("NuGetPublish") - .IsDependentOn("NuGetPackage") - .WithCriteria(() => !string.IsNullOrEmpty(nugetApiKey)) - .Does(() => - { - var nupkgPaths = GetFiles("release/*.nupkg").Select(x => x.FullPath).ToList(); - - string version = null; - foreach (var nupkgPath in nupkgPaths) - { - string nupkgVersion = Regex.Match(nupkgPath, @"\.([^\.]+\.[^\.]+\.[^\.]+)\.nupkg$").Groups[1].ToString(); - if (version == null) - version = nupkgVersion; - else if (version != nupkgVersion) - throw new InvalidOperationException($"Mismatched package versions '{version}' and '{nupkgVersion}'."); - } - - if (trigger == null || Regex.IsMatch(trigger, "^v[0-9]")) - { - if (trigger != null && trigger != $"v{version}") - throw new InvalidOperationException($"Trigger '{trigger}' doesn't match package version '{version}'."); - - var pushSettings = new NuGetPushSettings { ApiKey = nugetApiKey, Source = nugetSource }; - foreach (var nupkgPath in nupkgPaths) - NuGetPush(nupkgPath, pushSettings); - } - else - { - Information("To publish this package, push this git tag: v" + version); - } - }); - -Task("Default") - .IsDependentOn("Test"); - -void GenerateDocs(bool verify) -{ - int exitCode = StartProcess($@"cake\XmlDocMarkdown\tools\XmlDocMarkdown.exe", - $@"{docsAssembly} docs\ --source ""{docsSourceUri}"" --newline lf --clean" + (verify ? " --verify" : "")); - if (exitCode == 1 && verify) - throw new InvalidOperationException("Generated docs don't match; use -target=GenerateDocs to regenerate."); - else if (exitCode != 0) - throw new InvalidOperationException($"Docs generation failed with exit code {exitCode}."); -} - -void ExecuteProcess(string exePath, string arguments) -{ - int exitCode = StartProcess(exePath, arguments); - if (exitCode != 0) - throw new InvalidOperationException($"{exePath} failed with exit code {exitCode}."); -} - -RunTarget(target); diff --git a/build.ps1 b/build.ps1 index ac3073e..9b32821 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,55 +1,12 @@ -<# -.SYNOPSIS -This is a Powershell script to bootstrap a Cake build. -#> - -[CmdletBinding()] -Param( - [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] - [string[]]$ScriptArgs -) - -# delete cake directory if script changed -$CakeDirPath = Join-Path $PSScriptRoot "cake" -$PackagesConfigPath = Join-Path $CakeDirPath "packages.config" -If ((Test-Path $PackagesConfigPath) -and ((Get-Item(Join-Path $PSScriptRoot "build.cake")).LastWriteTime -gt (Get-Item($PackagesConfigPath)).LastWriteTime)) { - Write-Host "Cake script changed; rebuilding cake directory." - Remove-Item $CakeDirPath -Force -Recurse +#!/usr/bin/env pwsh +$ErrorActionPreference = 'Stop' +Push-Location $PSScriptRoot +try { + dotnet publish ./tools/Build/Build.csproj --artifacts-path ./artifacts --nologo --verbosity quiet + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + dotnet ./artifacts/publish/Build/release/Build.dll $args + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } +} +finally { + Pop-Location } - -# create cake directory -New-Item -Path $CakeDirPath -Type Directory -ErrorAction SilentlyContinue | Out-Null - -# create packages.config -If (!(Test-Path $PackagesConfigPath)) { - [System.IO.File]::WriteAllLines($PackagesConfigPath, @( - "", - "", - "`t", - "")) -} - -# download nuget.exe if not in path and not already downloaded -$NuGetExe = Get-Command "nuget.exe" -ErrorAction SilentlyContinue -If ($NuGetExe -ne $null) { - $NuGetExePath = $NuGetExe.Path -} -Else { - $NuGetExePath = Join-Path $CakeDirPath "nuget.exe" - If (!(Test-Path $NuGetExePath)) { - Invoke-WebRequest -Uri http://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile $NuGetExePath - } -} - -# use NuGet to download Cake -Push-Location $CakeDirPath -Invoke-Expression "&`"$NuGetExePath`" install -ExcludeVersion -OutputDirectory ." -If ($LASTEXITCODE -ne 0) { - Throw "An error occured while restoring NuGet tools." -} -Pop-Location - -# run Cake with specified arguments -$CakeExePath = Join-Path $CakeDirPath "Cake/Cake.exe" -Invoke-Expression "& `"$CakeExePath`" --paths_tools=cake --experimental $ScriptArgs" -Exit $LASTEXITCODE diff --git a/docs/BulkInsert.md b/docs/BulkInsert.md deleted file mode 100644 index 447bb99..0000000 --- a/docs/BulkInsert.md +++ /dev/null @@ -1,51 +0,0 @@ -# BulkInsert - -The [`BulkInsert`](Faithlife.Utility.Dapper/BulkInsertUtility/BulkInsert.md) (and [`BulkInsertAsync`](Faithlife.Utility.Dapper/BulkInsertUtility/BulkInsertAsync.md) extension methods allow efficient insertion of many rows into a database table with a familiar Dapper-like API. - -## Problem - -Dapper already has a mechanism for "bulk insert". Calling `Execute` with an `IEnumerable` will execute the specified `INSERT` command once for each item in the sequence. Unfortunately, this can be an extremely slow way to insert a large number of rows into a database. - -Each DBMS has its own preferred approaches for efficiently inserting many rows into a database, but the most portable way is to execute an `INSERT` command with multiple rows in the `VALUES` clause, like so: - -``` -INSERT INTO widgets (name, size) VALUES ('foo', 22), ('bar', 14), ('baz', 42) -``` - -Building a SQL statement for a large number of rows is straightforward, but runs the risk of SQL injection problems if the SQL isn't escaped propertly. - -Using command parameters is safer, but building and executing the SQL is more complex. Furthermore, databases often have a limit on the maximum number of command parameters that can be used, so it can be necessary to execute multiple SQL statements, one for each batch of rows to insert. - -## Solution - -`BulkInsert` is a simple Dapper-like extension method that builds the SQL commands for each batch and leverages Dapper to inject the command parameters. - -```csharp -var widgets = new[] { new { name = "foo", size = 22 }, new { name = "bar", size = 14 }, new { name = "baz", size = 42 } }; -connection.BulkInsert("INSERT INTO widgets (name, size) VALUES (@name, @size) ...", widgets); -``` - -The `...` after the `VALUES` clause must be included. It is used by `BulkInsert` to find the end of the `VALUES` clause that will be transformed. The call above will build a SQL statement like so: - -``` -INSERT INTO widgets (name, size) VALUES (@name_0, @size_0), (@name_1, @size_1) -``` - -The actual SQL statement will have as many parameters as needed to insert all of the specified rows. If the total number of command parameters exceeds 999 (the maximum number that [SQLite](https://www.sqlite.org/) supports and an efficient number for [MySql.Data](https://www.nuget.org/packages/MySql.Data/)), it will execute multiple SQL commands until all of the rows are inserted. - -All of the transformed SQL will be executed for each batch, so including additional statements before or after the `INSERT` statement is not recommended. - -Execute the method within a transaction if it is important to avoid inserting only some of the rows if there is an error. - -## Reference - -The `BulkInsert` and `BulkInsertAsync` methods of the `BulkInsertUtility` static class are extension methods on `IDbConnection`. They support these arguments: - -* `sql` – The SQL to execute, which must have a `VALUES` clause that is followed by `...`. -* `commonParam` – The values of any command parameters that are outside the `VALUES` clause, or are common to every row. (Optional.) -* `insertParams` – The values of the command parameters for each row to be inserted. -* `transaction` – The current transaction, if any (see `Dapper.Execute`). -* `batchSize` – If specified, indicates the number of rows to insert in each batch, even if doing so requires more than 999 command parameters. -* `cancellationToken` – The optional cancellation token (`BulkInsertAsync` only). - -The method returns the total number of rows affected (or, more specifically, the sum of the numbers returned when executing the SQL commands for each batch). diff --git a/docs/Faithlife.Utility.Dapper.md b/docs/Faithlife.Utility.Dapper.md deleted file mode 100644 index 1ea379a..0000000 --- a/docs/Faithlife.Utility.Dapper.md +++ /dev/null @@ -1,11 +0,0 @@ -# Faithlife.Utility.Dapper assembly - -The assembly `Faithlife.Utility.Dapper.dll` has 1 public type in 1 namespace. - -## Faithlife.Utility.Dapper namespace - -| public type | description | -| --- | --- | -| static class [BulkInsertUtility](Faithlife.Utility.Dapper/BulkInsertUtility.md) | Methods for bulk insert with Dapper. | - - diff --git a/docs/Faithlife.Utility.Dapper/BulkInsertUtility.md b/docs/Faithlife.Utility.Dapper/BulkInsertUtility.md deleted file mode 100644 index b843207..0000000 --- a/docs/Faithlife.Utility.Dapper/BulkInsertUtility.md +++ /dev/null @@ -1,25 +0,0 @@ -# BulkInsertUtility class - -Methods for bulk insert with Dapper. - -```csharp -public static class BulkInsertUtility -``` - -## Public Members - -| name | description | -| --- | --- | -| static [BulkInsert<TInsert>](BulkInsertUtility/BulkInsert.md)(…) | Efficiently inserts multiple rows, in batches as necessary. | -| static [BulkInsert<TCommon,TInsert>](BulkInsertUtility/BulkInsert.md)(…) | Efficiently inserts multiple rows, in batches as necessary. | -| static [BulkInsertAsync<TInsert>](BulkInsertUtility/BulkInsertAsync.md)(…) | Efficiently inserts multiple rows, in batches as necessary. | -| static [BulkInsertAsync<TCommon,TInsert>](BulkInsertUtility/BulkInsertAsync.md)(…) | Efficiently inserts multiple rows, in batches as necessary. | -| static [GetBulkInsertCommands<TInsert>](BulkInsertUtility/GetBulkInsertCommands.md)(…) | Gets the Dapper `CommandDefinition`s used by `BulkInsert` and `BulkInsertAsync`. | -| static [GetBulkInsertCommands<TCommon,TInsert>](BulkInsertUtility/GetBulkInsertCommands.md)(…) | Gets the Dapper `CommandDefinition`s used by `BulkInsert` and `BulkInsertAsync`. | - -## See Also - -* namespace [Faithlife.Utility.Dapper](../Faithlife.Utility.Dapper.md) -* [BulkInsertUtility.cs](https://github.com/Faithlife/DapperUtility/tree/master/src/Faithlife.Utility.Dapper/BulkInsertUtility.cs) - - diff --git a/docs/Faithlife.Utility.Dapper/BulkInsertUtility/BulkInsert.md b/docs/Faithlife.Utility.Dapper/BulkInsertUtility/BulkInsert.md deleted file mode 100644 index 9627cb3..0000000 --- a/docs/Faithlife.Utility.Dapper/BulkInsertUtility/BulkInsert.md +++ /dev/null @@ -1,31 +0,0 @@ -# BulkInsertUtility.BulkInsert<TInsert> method (1 of 2) - -Efficiently inserts multiple rows, in batches as necessary. - -```csharp -public static int BulkInsert(this IDbConnection connection, string sql, - IEnumerable insertParams, IDbTransaction transaction = null, int? batchSize = null) -``` - -## See Also - -* class [BulkInsertUtility](../BulkInsertUtility.md) -* namespace [Faithlife.Utility.Dapper](../../Faithlife.Utility.Dapper.md) - ---- - -# BulkInsertUtility.BulkInsert<TCommon,TInsert> method (2 of 2) - -Efficiently inserts multiple rows, in batches as necessary. - -```csharp -public static int BulkInsert(this IDbConnection connection, string sql, TCommon commonParam, - IEnumerable insertParams, IDbTransaction transaction = null, int? batchSize = null) -``` - -## See Also - -* class [BulkInsertUtility](../BulkInsertUtility.md) -* namespace [Faithlife.Utility.Dapper](../../Faithlife.Utility.Dapper.md) - - diff --git a/docs/Faithlife.Utility.Dapper/BulkInsertUtility/BulkInsertAsync.md b/docs/Faithlife.Utility.Dapper/BulkInsertUtility/BulkInsertAsync.md deleted file mode 100644 index 4259b0e..0000000 --- a/docs/Faithlife.Utility.Dapper/BulkInsertUtility/BulkInsertAsync.md +++ /dev/null @@ -1,32 +0,0 @@ -# BulkInsertUtility.BulkInsertAsync<TInsert> method (1 of 2) - -Efficiently inserts multiple rows, in batches as necessary. - -```csharp -public static Task BulkInsertAsync(this IDbConnection connection, string sql, - IEnumerable insertParams, IDbTransaction transaction = null, int? batchSize = null, CancellationToken cancellationToken = default(CancellationToken)) -``` - -## See Also - -* class [BulkInsertUtility](../BulkInsertUtility.md) -* namespace [Faithlife.Utility.Dapper](../../Faithlife.Utility.Dapper.md) - ---- - -# BulkInsertUtility.BulkInsertAsync<TCommon,TInsert> method (2 of 2) - -Efficiently inserts multiple rows, in batches as necessary. - -```csharp -public static Task BulkInsertAsync(this IDbConnection connection, string sql, - TCommon commonParam, IEnumerable insertParams, IDbTransaction transaction = null, - int? batchSize = null, CancellationToken cancellationToken = default(CancellationToken)) -``` - -## See Also - -* class [BulkInsertUtility](../BulkInsertUtility.md) -* namespace [Faithlife.Utility.Dapper](../../Faithlife.Utility.Dapper.md) - - diff --git a/docs/Faithlife.Utility.Dapper/BulkInsertUtility/GetBulkInsertCommands.md b/docs/Faithlife.Utility.Dapper/BulkInsertUtility/GetBulkInsertCommands.md deleted file mode 100644 index c3527ed..0000000 --- a/docs/Faithlife.Utility.Dapper/BulkInsertUtility/GetBulkInsertCommands.md +++ /dev/null @@ -1,32 +0,0 @@ -# BulkInsertUtility.GetBulkInsertCommands<TInsert> method (1 of 2) - -Gets the Dapper `CommandDefinition`s used by `BulkInsert` and `BulkInsertAsync`. - -```csharp -public static IEnumerable GetBulkInsertCommands(string sql, - IEnumerable insertParams, IDbTransaction transaction = null, int? batchSize = null, CancellationToken cancellationToken = default(CancellationToken)) -``` - -## See Also - -* class [BulkInsertUtility](../BulkInsertUtility.md) -* namespace [Faithlife.Utility.Dapper](../../Faithlife.Utility.Dapper.md) - ---- - -# BulkInsertUtility.GetBulkInsertCommands<TCommon,TInsert> method (2 of 2) - -Gets the Dapper `CommandDefinition`s used by `BulkInsert` and `BulkInsertAsync`. - -```csharp -public static IEnumerable GetBulkInsertCommands(string sql, - TCommon commonParam, IEnumerable insertParams, IDbTransaction transaction = null, - int? batchSize = null, CancellationToken cancellationToken = default(CancellationToken)) -``` - -## See Also - -* class [BulkInsertUtility](../BulkInsertUtility.md) -* namespace [Faithlife.Utility.Dapper](../../Faithlife.Utility.Dapper.md) - - diff --git a/docs/README.md b/docs/README.md deleted file mode 100644 index 05e6b94..0000000 --- a/docs/README.md +++ /dev/null @@ -1 +0,0 @@ -### https://faithlife.github.io/DapperUtility/ diff --git a/docs/_layouts/page.html b/docs/_layouts/page.html deleted file mode 100644 index ba95d08..0000000 --- a/docs/_layouts/page.html +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - {{ page.title | strip_html }} - - - - - - -
-
-
- {{ content }} -
-
- -
-
-
- - - - - - - diff --git a/docs/assets/github.png b/docs/assets/github.png deleted file mode 100644 index 192846a..0000000 Binary files a/docs/assets/github.png and /dev/null differ diff --git a/docs/assets/page.css b/docs/assets/page.css deleted file mode 100644 index f53166e..0000000 --- a/docs/assets/page.css +++ /dev/null @@ -1,185 +0,0 @@ -body { - font-variant: none; -} - -.navbar-static-top { - margin-bottom: 0; -} - -.navbar-inverse, -.navbar-inverse .navbar-nav > .active > a, -.navbar-inverse .navbar-nav > .active > a:hover, -.navbar-inverse .navbar-nav > .active > a:focus, -.navbar-inverse .navbar-nav > .open > a, -.navbar-inverse .navbar-nav > .open > a:hover, -.navbar-inverse .navbar-nav > .open > a:focus, -.navbar-inverse .navbar-nav .open .dropdown-menu > .active > a, -.navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:hover, -.navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:focus { - background-color: #429b1c; -} - -.large { - font-size: 125%; -} - -.github-logo { - height: 24px; -} - -.page-container { - margin-top: 21px; - margin-bottom: 21px; -} - -.content-column { - padding-left: 45px; -} - -h1, .h1, h2, .h2, h3, .h3 { - margin-top: 0; - padding-top: 21px; -} - -h4, .h4, h5, .h5, h6, .h6 { - margin-top: 14px; - margin-bottom: 7px; -} - -a, a:focus, a:hover, .btn-link, .btn-link:hover, .btn-link:focus { - color: #429b1c; -} - -.navbar-inverse .navbar-nav > li > a:hover, -.navbar-inverse .navbar-nav > li > a:focus, -.navbar-inverse .navbar-brand:hover, -.navbar-inverse .navbar-brand:focus { - color: #c1f992; -} - -a.anchorjs-link:active, a.anchorjs-link:hover { - text-decoration: none; -} - -nav.affix[data-toggle='toc'] { - margin-top: -60px; -} - -#toc { - width: 190px; -} - -pre { - color: inherit; -} - -code { - color: inherit; - background-color: #ecf0f1; -} - -@media (max-width: 767px) { - #toc { - display: none; - } -} - -@media (max-width: 479px) { - .content-column { - padding-left: 15px; - } - - .anchorjs-link { - display: none; - } -} - -/* apply .table, .table-striped, and .table-hover from Flatly to all tables */ -@media print { - table { - border-collapse: collapse !important; - } - table td, - table th { - background-color: #fff !important; - } -} -table { - width: 100%; - max-width: 100%; - margin-bottom: 21px; -} -table > thead > tr > th, -table > tbody > tr > th, -table > tfoot > tr > th, -table > thead > tr > td, -table > tbody > tr > td, -table > tfoot > tr > td { - padding: 8px; - line-height: 1.42857143; - vertical-align: top; - border-top: 1px solid #ecf0f1; -} -table > thead > tr > th { - vertical-align: bottom; - border-bottom: 2px solid #ecf0f1; -} -table > caption + thead > tr:first-child > th, -table > colgroup + thead > tr:first-child > th, -table > thead:first-child > tr:first-child > th, -table > caption + thead > tr:first-child > td, -table > colgroup + thead > tr:first-child > td, -table > thead:first-child > tr:first-child > td { - border-top: 0; -} -table > tbody + tbody { - border-top: 2px solid #ecf0f1; -} -table table { - background-color: #ffffff; -} -table > tbody > tr:nth-of-type(odd) { - background-color: #f9f9f9; -} -table > tbody > tr:hover { - background-color: #ecf0f1; -} - -/* undo underlined links in tables */ -table a:not(.btn), .table a:not(.btn) { - text-decoration: none; -} - -.highlight .hll { background-color: #ffffcc } -.highlight .c { color: #008000 } /* Comment */ -.highlight .err { border: 1px solid #FF0000 } /* Error */ -.highlight .k { color: #0000ff } /* Keyword */ -.highlight .cm { color: #008000 } /* Comment.Multiline */ -.highlight .cp { color: #0000ff } /* Comment.Preproc */ -.highlight .c1 { color: #008000 } /* Comment.Single */ -.highlight .cs { color: #008000 } /* Comment.Special */ -.highlight .ge { font-style: italic } /* Generic.Emph */ -.highlight .gh { font-weight: bold } /* Generic.Heading */ -.highlight .gp { font-weight: bold } /* Generic.Prompt */ -.highlight .gs { font-weight: bold } /* Generic.Strong */ -.highlight .gu { font-weight: bold } /* Generic.Subheading */ -.highlight .kc { color: #0000ff } /* Keyword.Constant */ -.highlight .kd { color: #0000ff } /* Keyword.Declaration */ -.highlight .kn { color: #0000ff } /* Keyword.Namespace */ -.highlight .kp { color: #0000ff } /* Keyword.Pseudo */ -.highlight .kr { color: #0000ff } /* Keyword.Reserved */ -.highlight .kt { color: #2b91af } /* Keyword.Type */ -.highlight .s { color: #a31515 } /* Literal.String */ -.highlight .nc { color: #2b91af } /* Name.Class */ -.highlight .ow { color: #0000ff } /* Operator.Word */ -.highlight .sb { color: #a31515 } /* Literal.String.Backtick */ -.highlight .sc { color: #a31515 } /* Literal.String.Char */ -.highlight .sd { color: #a31515 } /* Literal.String.Doc */ -.highlight .s2 { color: #a31515 } /* Literal.String.Double */ -.highlight .se { color: #a31515 } /* Literal.String.Escape */ -.highlight .sh { color: #a31515 } /* Literal.String.Heredoc */ -.highlight .si { color: #a31515 } /* Literal.String.Interpol */ -.highlight .sx { color: #a31515 } /* Literal.String.Other */ -.highlight .sr { color: #a31515 } /* Literal.String.Regex */ -.highlight .s1 { color: #a31515 } /* Literal.String.Single */ -.highlight .ss { color: #a31515 } /* Literal.String.Symbol */ diff --git a/docs/index.md b/docs/index.md deleted file mode 100644 index 1f17cb6..0000000 --- a/docs/index.md +++ /dev/null @@ -1,11 +0,0 @@ -# Faithlife.Utility.Dapper - -**Faithlife.Utility.Dapper** is a utility library for Dapper. - -## Features - -* [BulkInsert](BulkInsert.md) - -## Installation - -Faithlife.Utility.Dapper should be installed [via NuGet](https://www.nuget.org/packages/Faithlife.Utility.Dapper). diff --git a/global.json b/global.json new file mode 100644 index 0000000..391ba3c --- /dev/null +++ b/global.json @@ -0,0 +1,6 @@ +{ + "sdk": { + "version": "8.0.100", + "rollForward": "latestFeature" + } +} diff --git a/nuget.config b/nuget.config new file mode 100644 index 0000000..6873eb9 --- /dev/null +++ b/nuget.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/Faithlife.Utility.Dapper/BulkInsertUtility.cs b/src/Faithlife.Utility.Dapper/BulkInsertUtility.cs index f720c4b..42c215c 100644 --- a/src/Faithlife.Utility.Dapper/BulkInsertUtility.cs +++ b/src/Faithlife.Utility.Dapper/BulkInsertUtility.cs @@ -1,14 +1,9 @@ -using System; -using System.Collections.Generic; using System.Data; using System.Globalization; -using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Text; using System.Text.RegularExpressions; -using System.Threading; -using System.Threading.Tasks; using Dapper; namespace Faithlife.Utility.Dapper @@ -183,7 +178,9 @@ public static object[] GetValues(T param) return values; } +#pragma warning disable CA1810 static ParamExtractor() +#pragma warning restore CA1810 { var names = new List(); var getters = new List>(); @@ -196,8 +193,8 @@ static ParamExtractor() getters.Add(getter); } } - s_names = names.ToArray(); - s_getters = getters.ToArray(); + s_names = [.. names]; + s_getters = [.. getters]; } private static Func TryCreateGetter(PropertyInfo property) @@ -208,7 +205,7 @@ private static Func TryCreateGetter(PropertyInfo property) return null; var dynamicGetMethod = new DynamicMethod(name: $"_Get{property.Name}_", - returnType: typeof(T), parameterTypes: new[] { typeof(object) }, owner: ownerType); + returnType: typeof(T), parameterTypes: [typeof(object)], owner: ownerType); var generator = dynamicGetMethod.GetILGenerator(); generator.DeclareLocal(typeof(object)); generator.Emit(OpCodes.Ldarg_0); @@ -221,8 +218,8 @@ private static Func TryCreateGetter(PropertyInfo property) return (Func) dynamicGetMethod.CreateDelegate(typeof(Func)); } - static readonly string[] s_names; - static readonly Func[] s_getters; + private static readonly string[] s_names; + private static readonly Func[] s_getters; } private static IEnumerable> EnumerateBatches(IEnumerable items, int batchSize) @@ -232,7 +229,7 @@ private static IEnumerable> EnumerateBatches(IEnumerable { int count = itemsAsList.Count; if (count <= batchSize) - return count != 0 ? new[] { itemsAsList } : Enumerable.Empty>(); + return count != 0 ? [itemsAsList] : []; } return YieldBatches(items, batchSize); @@ -257,9 +254,9 @@ private static IEnumerable> YieldBatches(IEnumerable item yield return batch; } - static readonly Regex s_valuesClauseRegex = new Regex( + private static readonly Regex s_valuesClauseRegex = new Regex( @"\b[vV][aA][lL][uU][eE][sS]\s*(\(.*?\))\s*\.\.\.", RegexOptions.CultureInvariant | RegexOptions.Singleline | RegexOptions.RightToLeft); - static readonly Regex s_parameterRegex = new Regex(@"[@:?]\w+\b", RegexOptions.CultureInvariant); + private static readonly Regex s_parameterRegex = new Regex(@"[@:?]\w+\b", RegexOptions.CultureInvariant); } } diff --git a/src/Faithlife.Utility.Dapper/Faithlife.Utility.Dapper.csproj b/src/Faithlife.Utility.Dapper/Faithlife.Utility.Dapper.csproj index 63bb148..0e80ac7 100644 --- a/src/Faithlife.Utility.Dapper/Faithlife.Utility.Dapper.csproj +++ b/src/Faithlife.Utility.Dapper/Faithlife.Utility.Dapper.csproj @@ -1,32 +1,20 @@  - netstandard1.3;net45 - False - 1.1.0 - Faithlife Corporation - - + netstandard2.0 A utility library for Dapper. - Copyright 2016-2017 Faithlife Corporation - https://raw.githubusercontent.com/Faithlife/Parsing/master/LICENSE - https://faithlife.github.io/DapperUtility/ - git - https://github.com/Faithlife/DapperUtility.git Dapper - True - - embedded - True - bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml + true + true + README.md - - - - - + - \ No newline at end of file + + + + + diff --git a/tests/Faithlife.Utility.Dapper.Tests/BulkInsertUtilityTests.cs b/tests/Faithlife.Utility.Dapper.Tests/BulkInsertUtilityTests.cs index 8fc1082..443df4a 100644 --- a/tests/Faithlife.Utility.Dapper.Tests/BulkInsertUtilityTests.cs +++ b/tests/Faithlife.Utility.Dapper.Tests/BulkInsertUtilityTests.cs @@ -1,5 +1,3 @@ -using System; -using System.Linq; using Dapper; using FluentAssertions; using Xunit; @@ -169,7 +167,7 @@ public void WhitespaceEverywhere() [Fact] public void NothingToInsert() { - var commands = BulkInsertUtility.GetBulkInsertCommands("VALUES(@foo)...", new object[0]).ToList(); + var commands = BulkInsertUtility.GetBulkInsertCommands("VALUES(@foo)...", Array.Empty()).ToList(); commands.Count.Should().Be(0); } diff --git a/tests/Faithlife.Utility.Dapper.Tests/Faithlife.Utility.Dapper.Tests.csproj b/tests/Faithlife.Utility.Dapper.Tests/Faithlife.Utility.Dapper.Tests.csproj index fe888ab..f0463cf 100644 --- a/tests/Faithlife.Utility.Dapper.Tests/Faithlife.Utility.Dapper.Tests.csproj +++ b/tests/Faithlife.Utility.Dapper.Tests/Faithlife.Utility.Dapper.Tests.csproj @@ -1,14 +1,14 @@  - netcoreapp1.1 + net8.0 - - - - + + + + diff --git a/tools/Build/Build.cs b/tools/Build/Build.cs new file mode 100644 index 0000000..20f3186 --- /dev/null +++ b/tools/Build/Build.cs @@ -0,0 +1,23 @@ +return BuildRunner.Execute(args, build => +{ + var gitLogin = new GitLoginInfo("faithlifebuildbot", Environment.GetEnvironmentVariable("BUILD_BOT_PASSWORD") ?? ""); + + build.AddDotNetTargets( + new DotNetBuildSettings + { + NuGetApiKey = Environment.GetEnvironmentVariable("NUGET_API_KEY"), + DocsSettings = new DotNetDocsSettings + { + GitLogin = gitLogin, + GitAuthor = new GitAuthorInfo("Faithlife Build Bot", "faithlifebuildbot@users.noreply.github.com"), + SourceCodeUrl = "https://github.com/Faithlife/DapperUtility/tree/master/src", + GitBranchName = "docs", + TargetDirectory = "", + }, + PackageSettings = new DotNetPackageSettings + { + GitLogin = gitLogin, + PushTagOnPublish = x => $"v{x.Version}", + }, + }); +}); diff --git a/tools/Build/Build.csproj b/tools/Build/Build.csproj new file mode 100644 index 0000000..94c9978 --- /dev/null +++ b/tools/Build/Build.csproj @@ -0,0 +1,12 @@ + + + + Exe + net8.0 + + + + + + + diff --git a/tools/XmlDocGen/XmlDocGen.csproj b/tools/XmlDocGen/XmlDocGen.csproj new file mode 100644 index 0000000..79518b0 --- /dev/null +++ b/tools/XmlDocGen/XmlDocGen.csproj @@ -0,0 +1,16 @@ + + + + Exe + net8.0 + + + + + + + + + + + diff --git a/tools/XmlDocGen/XmlDocGenApp.cs b/tools/XmlDocGen/XmlDocGenApp.cs new file mode 100644 index 0000000..893a7df --- /dev/null +++ b/tools/XmlDocGen/XmlDocGenApp.cs @@ -0,0 +1,3 @@ +using XmlDocMarkdown.Core; + +return XmlDocMarkdownApp.Run(args);