diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 0000000..10378fe --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,20 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "csharpier": { + "version": "1.0.0", + "commands": [ + "csharpier" + ], + "rollForward": false + }, + "nbgv": { + "version": "3.7.115", + "commands": [ + "nbgv" + ], + "rollForward": false + } + } + } \ No newline at end of file diff --git a/.csharpierrc.yaml b/.csharpierrc.yaml new file mode 100644 index 0000000..cb1839b --- /dev/null +++ b/.csharpierrc.yaml @@ -0,0 +1 @@ +printWidth: 160 \ No newline at end of file diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..2335e22 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,303 @@ +# To learn more about .editorconfig see https://aka.ms/editorconfigdocs +############################### +# Core EditorConfig Options # +############################### +# All files +# Indentation and spacing +[*.{c,c++,cc,cginc,compute,cp,cpp,cu,cuh,cxx,h,hh,hlsl,hlsli,hlslinc,hpp,hxx,inc,inl,ino,ipp,mpp,mq4,mq5,mqh,proto,tpp,usf,ush}] +indent_style = tab +indent_size = tab +tab_width = 4 + +[*.{asax,ascx,aspx,axaml,cs,cshtml,css,htm,html,js,jsx,master,paml,razor,skin,ts,tsx,vb,xaml,xamlx,xoml}] +indent_style = space +indent_size = 4 +tab_width = 4 + +[*.{appxmanifest,axml,build,config,csproj,dbml,discomap,dtd,json,jsproj,lsproj,njsproj,nuspec,proj,props,resjson,resw,resx,StyleCop,targets,tasks,vbproj,xml,xsd}] +indent_style = space +indent_size = 2 +tab_width = 2 + +[*.csproj] +ij_xml_space_inside_empty_tag = true # Rider differs from VS on this, and it messes up csprojs + +insert_final_newline = true +charset = utf-8 +############################### +# .NET Coding Conventions # +############################### +[*.{cs,vb}] +# Organize usings +dotnet_sort_system_directives_first = true +# this. preferences +dotnet_style_qualification_for_field = false:suggestion +dotnet_style_qualification_for_property = false:suggestion +dotnet_style_qualification_for_method = false:suggestion +dotnet_style_qualification_for_event = false:suggestion +# Language keywords vs BCL types preferences +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: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 +# Modifier preferences +dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent +dotnet_style_readonly_field = true:suggestion +# Expression-level preferences +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_coalesce_expression = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent +dotnet_style_prefer_inferred_tuple_names = true:suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_auto_properties = true:silent +dotnet_style_prefer_conditional_expression_over_assignment = true:silent +dotnet_style_prefer_conditional_expression_over_return = true:silent +############################### +# Naming Conventions # +############################### +# Style Definitions +dotnet_naming_style.pascal_case_style.capitalization = pascal_case +# Use PascalCase for constant fields +dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields +dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style +dotnet_naming_symbols.constant_fields.applicable_kinds = field +dotnet_naming_symbols.constant_fields.applicable_accessibilities = * +dotnet_naming_symbols.constant_fields.required_modifiers = const +############################### +# C# Coding Conventions # +############################### +[*.cs] +# var preferences +csharp_style_var_for_built_in_types = true:suggestion +csharp_style_var_when_type_is_apparent = true:suggestion +csharp_style_var_elsewhere = true:suggestion +# Expression-bodied members +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:suggestion +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_accessors = true:silent +# Pattern matching preferences +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +# Null-checking preferences +csharp_style_throw_expression = true:suggestion +csharp_style_conditional_delegate_call = true:suggestion +# Modifier preferences +csharp_preferred_modifier_order = public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion +# Expression-level preferences +csharp_prefer_braces = when_multiline: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_inlined_variable_declaration = true:suggestion +############################### +# C# Formatting Rules # +############################### +# New line preferences +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_object_initializers = false +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_between_query_expression_clauses = true +# Indentation preferences +csharp_indent_case_contents = true +csharp_indent_switch_labels = true +csharp_indent_labels = flush_left +# Space preferences +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = 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 +csharp_space_within_single_line_array_initializer_braces = true +# Wrapping preferences +csharp_preserve_single_line_statements = true +csharp_preserve_single_line_blocks = true + +# ReSharper properties +resharper_align_first_arg_by_paren = true +resharper_align_linq_query = true +resharper_align_multiline_argument = true +resharper_align_multiline_calls_chain = true +resharper_align_multiline_expression = true +resharper_align_multiline_extends_list = true +resharper_align_multiline_for_stmt = true +resharper_align_multline_type_parameter_constrains = true +resharper_align_multline_type_parameter_list = true +resharper_align_tuple_components = true +resharper_csharp_align_multiline_parameter = true +resharper_apply_auto_detected_rules = false +resharper_braces_for_dowhile = required_for_multiline +resharper_braces_for_fixed = required_for_multiline +resharper_braces_for_for = required_for_multiline +resharper_braces_for_foreach = required_for_multiline +resharper_braces_for_ifelse = required_for_multiline +resharper_braces_for_lock = required_for_multiline +resharper_braces_for_using = required_for_multiline +resharper_braces_for_while = required_for_multiline +resharper_braces_redundant = true +resharper_csharp_align_multiple_declaration = true +resharper_csharp_empty_block_style = together +resharper_csharp_keep_blank_lines_in_code = 1 +resharper_csharp_keep_blank_lines_in_declarations = 1 +resharper_csharp_max_line_length = 160 +resharper_csharp_naming_rule.constants = AA_BB +resharper_csharp_naming_rule.private_constants = AA_BB +resharper_csharp_wrap_parameters_style = chop_if_long +resharper_keep_existing_declaration_block_arrangement = false +resharper_keep_existing_declaration_parens_arrangement = false +resharper_keep_existing_embedded_block_arrangement = false +resharper_keep_existing_enum_arrangement = false +resharper_keep_existing_expr_member_arrangement = false +resharper_max_attribute_length_for_same_line = 20 +resharper_max_enum_members_on_line = 1 +resharper_max_formal_parameters_on_line = 4 +resharper_object_creation_when_type_evident = explicitly_typed +resharper_place_accessorholder_attribute_on_same_line = false +resharper_place_attribute_on_same_line = false +resharper_place_constructor_initializer_on_same_line = false +resharper_place_field_attribute_on_same_line = false +resharper_use_heuristics_for_body_style = true +resharper_wrap_before_extends_colon = true +csharp_place_simple_embedded_statement_on_same_line = never +resharper_xmldoc_indent_child_elements = ZeroIndent +resharper_xmldoc_indent_text = ZeroIndent + +# Microsoft .NET properties +dotnet_naming_rule.constants_rule.import_to_resharper = as_predefined +dotnet_naming_rule.constants_rule.severity = warning +dotnet_naming_rule.constants_rule.style = all_upper +dotnet_naming_rule.constants_rule.symbols = constants_symbols +dotnet_naming_rule.constants_rule_1.import_to_resharper = True +dotnet_naming_rule.constants_rule_1.resharper_description = Constants +dotnet_naming_rule.constants_rule_1.resharper_guid = affe5d15-4cf8-4c12-b469-bb63e1aae3f4 +dotnet_naming_rule.constants_rule_1.severity = warning +dotnet_naming_rule.constants_rule_1.style = all_upper_style +dotnet_naming_rule.constants_rule_1.symbols = constants_symbols_1 +dotnet_naming_rule.constants_rule_2.import_to_resharper = as_predefined +dotnet_naming_rule.constants_rule_2.severity = warning +dotnet_naming_rule.constants_rule_2.style = all_upper_style +dotnet_naming_rule.constants_rule_2.symbols = constants_symbols_2 +dotnet_naming_rule.constant_fields_should_be_pascal_case_rule.import_to_resharper = True +dotnet_naming_rule.constant_fields_should_be_pascal_case_rule.resharper_description = constant_fields_should_be_pascal_case +dotnet_naming_rule.constant_fields_should_be_pascal_case_rule.resharper_guid = 9fd20547-9bf8-4551-975c-b24a2185cedb +dotnet_naming_rule.constant_fields_should_be_pascal_case_rule.severity = warning +dotnet_naming_rule.constant_fields_should_be_pascal_case_rule.style = all_upper_style +dotnet_naming_rule.constant_fields_should_be_pascal_case_rule.symbols = constant_fields_should_be_pascal_case_symbols +dotnet_naming_rule.private_constants_rule.import_to_resharper = as_predefined +dotnet_naming_rule.private_constants_rule.severity = warning +dotnet_naming_rule.private_constants_rule.style = all_upper +dotnet_naming_rule.private_constants_rule.symbols = private_constants_symbols +dotnet_naming_rule.private_constants_rule_1.import_to_resharper = as_predefined +dotnet_naming_rule.private_constants_rule_1.severity = warning +dotnet_naming_rule.private_constants_rule_1.style = all_upper_style +dotnet_naming_rule.private_constants_rule_1.symbols = private_constants_symbols_1 +dotnet_naming_rule.private_constants_rule_2.import_to_resharper = True +dotnet_naming_rule.private_constants_rule_2.resharper_description = PrivateConstants +dotnet_naming_rule.private_constants_rule_2.resharper_guid = 972de550-6e40-4c7a-a585-f15cb09f4d7b +dotnet_naming_rule.private_constants_rule_2.severity = warning +dotnet_naming_rule.private_constants_rule_2.style = all_upper_style +dotnet_naming_rule.private_constants_rule_2.symbols = private_constants_symbols_2 +dotnet_naming_rule.private_static_readonly_rule.import_to_resharper = as_predefined +dotnet_naming_rule.private_static_readonly_rule.severity = warning +dotnet_naming_rule.private_static_readonly_rule.style = lower_camel_case_style_1 +dotnet_naming_rule.private_static_readonly_rule.symbols = private_static_readonly_symbols +dotnet_naming_style.lower_camel_case_style_1.capitalization = camel_case +dotnet_naming_style.lower_camel_case_style_1.required_prefix = _ +dotnet_naming_style.private_prefix_style.required_prefix = _ +dotnet_naming_style.all_upper_style.capitalization = all_upper +dotnet_naming_style.all_upper_style.word_separator = _ +dotnet_naming_style.lower_camel_case_style.capitalization = camel_case +dotnet_naming_style.upper_camel_case_style.capitalization = pascal_case +dotnet_naming_symbols.constants_symbols.applicable_accessibilities = public,internal,protected,protected_internal,private_protected +dotnet_naming_symbols.constants_symbols.applicable_kinds = field +dotnet_naming_symbols.constants_symbols.required_modifiers = const +dotnet_naming_symbols.constants_symbols_1.applicable_accessibilities = local,public,internal,protected,protected_internal,private_protected +dotnet_naming_symbols.constants_symbols_1.applicable_kinds = field +dotnet_naming_symbols.constants_symbols_1.required_modifiers = const +dotnet_naming_symbols.constants_symbols_1.resharper_applicable_kinds = constant_field +dotnet_naming_symbols.constants_symbols_1.resharper_required_modifiers = any +dotnet_naming_symbols.constants_symbols_2.applicable_accessibilities = public,internal,protected,protected_internal,private_protected +dotnet_naming_symbols.constants_symbols_2.applicable_kinds = field +dotnet_naming_symbols.constants_symbols_2.required_modifiers = const +dotnet_naming_symbols.constant_fields_should_be_pascal_case_symbols.applicable_accessibilities = local,public,internal,private,protected,protected_internal,private_protected +dotnet_naming_symbols.constant_fields_should_be_pascal_case_symbols.applicable_kinds = field +dotnet_naming_symbols.constant_fields_should_be_pascal_case_symbols.required_modifiers = static,const +dotnet_naming_symbols.constant_fields_should_be_pascal_case_symbols.resharper_applicable_kinds = constant_field +dotnet_naming_symbols.constant_fields_should_be_pascal_case_symbols.resharper_required_modifiers = static +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_constants_symbols_1.applicable_accessibilities = private +dotnet_naming_symbols.private_constants_symbols_1.applicable_kinds = field +dotnet_naming_symbols.private_constants_symbols_1.required_modifiers = const +dotnet_naming_symbols.private_constants_symbols_2.applicable_accessibilities = local,private +dotnet_naming_symbols.private_constants_symbols_2.applicable_kinds = field +dotnet_naming_symbols.private_constants_symbols_2.required_modifiers = const +dotnet_naming_symbols.private_constants_symbols_2.resharper_applicable_kinds = constant_field +dotnet_naming_symbols.private_constants_symbols_2.resharper_required_modifiers = any +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_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:none +dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:none +dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none +dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion +dotnet_style_predefined_type_for_member_access = true:suggestion +dotnet_style_qualification_for_event = false:suggestion +dotnet_style_qualification_for_field = false:suggestion +dotnet_style_qualification_for_method = false:suggestion +dotnet_style_qualification_for_property = false:suggestion +dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion + +# ReSharper inspection severities +resharper_arrange_accessor_owner_body_highlighting = suggestion +resharper_arrange_redundant_parentheses_highlighting = hint +resharper_arrange_this_qualifier_highlighting = hint +resharper_arrange_type_member_modifiers_highlighting = suggestion +resharper_arrange_type_modifiers_highlighting = suggestion +resharper_built_in_type_reference_style_for_member_access_highlighting = hint +resharper_built_in_type_reference_style_highlighting = hint +resharper_convert_to_using_declaration_highlighting = none +resharper_enforce_do_while_statement_braces_highlighting = none +resharper_enforce_fixed_statement_braces_highlighting = none +resharper_enforce_foreach_statement_braces_highlighting = none +resharper_enforce_for_statement_braces_highlighting = none +resharper_enforce_if_statement_braces_highlighting = none +resharper_enforce_lock_statement_braces_highlighting = none +resharper_enforce_using_statement_braces_highlighting = none +resharper_enforce_while_statement_braces_highlighting = none +resharper_redundant_base_qualifier_highlighting = warning +resharper_remove_redundant_braces_highlighting = none +resharper_suggest_discard_declaration_var_style_highlighting = suggestion +resharper_suggest_var_or_type_built_in_types_highlighting = suggestion +resharper_suggest_var_or_type_elsewhere_highlighting = suggestion +resharper_suggest_var_or_type_simple_types_highlighting = suggestion + +############################### +# VB Coding Conventions # +############################### +[*.vb] +# Modifier preferences +visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async:suggestion + +[*.proto] +indent_style = tab +indent_size = tab +tab_width = 4 diff --git a/.github/workflows/dotnet-publish.yml b/.github/workflows/dotnet-publish.yml index 17efcb3..4dbcfe3 100644 --- a/.github/workflows/dotnet-publish.yml +++ b/.github/workflows/dotnet-publish.yml @@ -4,144 +4,41 @@ on: push: branches: [ master ] pull_request: - branches: [ master ] + types: [opened, synchronize, reopened] jobs: - linux-mac: - runs-on: ubuntu-latest - outputs: - release_upload_url: ${{ steps.create_release.outputs.upload_url }} + build: + runs-on: windows-latest steps: - - uses: actions/checkout@v2 - - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 + - uses: actions/checkout@v4 with: - dotnet-version: 3.1.101 - - - name: Build - working-directory: ./src - run: dotnet build --configuration Release + fetch-depth: 0 # avoid shallow clone so nbgv can do its work. - - name: Build LinuxX64 EXE - working-directory: ./src - run: dotnet publish -p:PublishProfile=LinuxX64 --configuration Release - - - name: Build MacOsx64 EXE - working-directory: ./src - run: dotnet publish -p:PublishProfile=MacOsx64 --configuration Release - - - name: Zip LinuxX64 EXE - uses: thedoctor0/zip-release@master + - name: Setup .NET + uses: actions/setup-dotnet@v4 with: - filename: 'Coveo.Connectors.EasyFilePusher_LinuxX64.zip' - directory: './bin/Release/netcoreapp3.1/publish/LinuxX64' - exclusions: '*.pdb' - type: zip + dotnet-version: 8 - - name: Zip MacOsx64 EXE - uses: thedoctor0/zip-release@master - with: - filename: 'Coveo.Connectors.EasyFilePusher_MacOsx64.zip' - directory: './bin/Release/netcoreapp3.1/publish/MacOsx64' - exclusions: '*.pdb' - type: zip + - name: Restore tools + run: dotnet tool restore - - name: Delete existing release - if: ${{ github.event_name == 'push' }} - uses: ame-yu/action-delete-latest-release@v2 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - - - name: Create release - if: ${{ github.event_name == 'push' }} - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: latest - release_name: Latest Release - draft: false - prerelease: false + - name: Create variables for version + id: nbgv + shell: bash + run: echo "SemVer2=$(dotnet nbgv get-version --variable NuGetPackageVersion)" >> $GITHUB_OUTPUT - - name: Release Linux executable - if: ${{ github.event_name == 'push' }} - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./bin/Release/netcoreapp3.1/publish/LinuxX64/Coveo.Connectors.EasyFilePusher_LinuxX64.zip - asset_name: Coveo.Connectors.EasyFilePusher_LinuxX64.zip - asset_content_type: application/zip - - - name: Release Mac executable - if: ${{ github.event_name == 'push' }} - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./bin/Release/netcoreapp3.1/publish/MacOsx64/Coveo.Connectors.EasyFilePusher_MacOsx64.zip - asset_name: Coveo.Connectors.EasyFilePusher_MacOsx64.zip - asset_content_type: application/zip - - windows: - needs: linux-mac - runs-on: windows-latest - steps: - - - uses: actions/checkout@v2 - - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 3.1.101 + - name: Verify variable + run: echo "SemVer2=${{ steps.nbgv.outputs.SemVer2 }}" - name: Build working-directory: ./src run: dotnet build --configuration Release - - name: Build WinX86 EXE - working-directory: ./src - run: dotnet publish -p:PublishProfile=WinX86 --configuration Release - - - name: Prepare Windows certificate 1/2 - id: write_pem_file - uses: timheuer/base64-to-file@v1 - with: - fileName: 'cert.pem' - encodedString: ${{ secrets.WINDOWS_CERT }} - - - name: Prepare Windows certificate 2/2 - working-directory: . - run: 'CMD /r openssl pkcs12 -in ${{ steps.write_pem_file.outputs.filePath }} -export -out cert.pfx -passin pass:"${{ secrets.WINDOWS_CERT_PWD }}" -passout pass:"${{ secrets.WINDOWS_CERT_PWD }}"' - - - name: Sign Windows executable - working-directory: . - run: 'CMD /r "C:\Program Files (x86)\Windows Kits\10\bin\x86\signtool.exe" sign /f cert.pfx /p ${{ secrets.WINDOWS_CERT_PWD }} bin\Release\netcoreapp3.1\publish\WinX86\Coveo.Connectors.EasyFilePusher.exe' - - - name: Delete Windows temp certificate 1/2 - working-directory: . - run: 'DEL cert.pfx' - - - name: Delete Windows temp certificate 2/2 - working-directory: . - run: 'DEL ${{ steps.write_pem_file.outputs.filePath }}' - - - name: Zip WinX86 EXE - working-directory: . - run: 'Compress-Archive bin\Release\netcoreapp3.1\publish\WinX86\Coveo.Connectors.EasyFilePusher.exe bin\Release\netcoreapp3.1\publish\WinX86\Coveo.Connectors.EasyFilePusher_WinX86.zip' - - - name: Release Windows executable + # Publish Github Release + - name: Create release if: ${{ github.event_name == 'push' }} - uses: actions/upload-release-asset@v1 + working-directory: . + run: gh release create v${{ steps.nbgv.outputs.SemVer2 }} --generate-notes --target $GITHUB_SHA env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ needs.linux-mac.outputs.release_upload_url }} - asset_path: ./bin/Release/netcoreapp3.1/publish/WinX86/Coveo.Connectors.EasyFilePusher_WinX86.zip - asset_name: Coveo.Connectors.EasyFilePusher_WinX86.zip - asset_content_type: application/zip + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 47abbed..14ee9cc 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ [Bb]in/ .nuget/ .vs/ +.vscode/ _ReSharper.* packages/ artifacts/ diff --git a/Directory.Build.props b/Directory.Build.props index c018b23..4923967 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,32 +1,32 @@ - 0.0.1 - + 1.0.0 + Coveo Solutions Inc. Coveo Solutions Inc. Easy File Pusher - + icon.png - + icon.png - + true Apache-2.0 Copyright © Coveo Solutions Inc true - + - netcoreapp3.1 + net8.0 latest enable true $(MSBuildThisFileDirectory)obj\$(MSBuildProjectName)\ false - + ..\..\bin\Debug @@ -34,9 +34,9 @@ ..\..\bin\Release - + - + \ No newline at end of file diff --git a/README.md b/README.md index 782ad71..18e181c 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,19 @@ The Coveo Easy File Pusher is a command-line tool that pushes items stored in a local file system to a Coveo Push source. To use the Easy File Pusher, you must first [create a Push source using the Coveo Administration Console](https://docs.coveo.com/en/1546/). Then, run the tool to scan the specified local folder and push the files matching the specified filter. +## Compile the Easy File Pusher + +Having the .Net 8 SDK is necessary for compiling the tool. See here for downloads applicable to your operating system: [https://dotnet.microsoft.com/en-us/download/dotnet/8.0](https://dotnet.microsoft.com/en-us/download/dotnet/8.0). + +First navigate in your terminal to the `src` folder. + +- Run one of the following commands: + - Windows: `dotnet publish -p:PublishProfile=WinX86 --configuration Release` + - Linux: `dotnet publish -p:PublishProfile=LinuxX64 --configuration Release` + - Mac: `dotnet publish -p:PublishProfile=MacOsx64 --configuration Release` + +The compiled executable will be found in `src/publish`. + ## Configure the Easy File Pusher There are two ways to provide the configuration values to the tool: @@ -15,9 +28,9 @@ There are two ways to provide the configuration values to the tool: Running the tool with the `--help` argument displays the arguments that can be specified on the command line: ``` - -e, --environment Required. Cloud environment: Hipaa, Prod, QA or Dev. + -e, --environment Required. Cloud environment: Hipaa or Prod. - -r, --region Required. Cloud region: UsEast1 or EuWest1. + -r, --region Required. Cloud region: UsEast1, EuWest1, ApSouthEast2 or CaCentral1. -o, --organizationid Required. ID of the organization in which to push documents. @@ -54,9 +67,9 @@ Alternatively, if you choose to launch the tool without any argument, it will th ## Supported Operating Systems -Since the tool was developed using .NET Core, it can be executed on the operating systems supported by .NET Core, i.e., Windows, macOS, and Linux. An executable for each supported operating system is available for download. +Since the tool was developed using .NET 8, it can be executed on the operating systems supported by .NET 8, i.e., Windows, macOS, and Linux. -Note that the macOS executable has not been signed with a certificate. As a result, running it requires a minor adjustment to work around a security warning: +Note that the macOS executable has not been signed with a certificate. If you get a security warning when running it, you might have to do a minor adjustment: 1. Unzip the executable file. 2. Control-click (or right-click) the file > **Open**/**Open with** > **Utilities** > **Terminal**. If **Terminal** isn't available, change **Enable: Recommended Applications** to **Enable: All Applications**. diff --git a/src/Coveo.Connectors.EasyFilePusher.sln.DotSettings b/src/Coveo.Connectors.EasyFilePusher.sln.DotSettings index 9360815..bde0c60 100644 --- a/src/Coveo.Connectors.EasyFilePusher.sln.DotSettings +++ b/src/Coveo.Connectors.EasyFilePusher.sln.DotSettings @@ -1,1359 +1,26 @@  - Inherit - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - <?xml version="1.0" encoding="utf-16"?><Profile name="Connector's STD (File Layout + Code Format)"><CSUseVar><BehavourStyle>DISABLED</BehavourStyle><LocalVariableStyle>ALWAYS_EXPLICIT</LocalVariableStyle><ForeachVariableStyle>ALWAYS_EXPLICIT</ForeachVariableStyle></CSUseVar><CSOptimizeUsings><OptimizeUsings>False</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSReformatCode>True</CSReformatCode><CSReorderTypeMembers>True</CSReorderTypeMembers><XAMLCollapseEmptyTags>False</XAMLCollapseEmptyTags></Profile> - <?xml version="1.0" encoding="utf-16"?><Profile name="Connector's STD (Full cleanup)"><CSReorderTypeMembers>True</CSReorderTypeMembers><CppClangTidyCleanupDescriptor /><CSCodeStyleAttributes ArrangeTypeAccessModifier="True" ArrangeTypeMemberAccessModifier="True" SortModifiers="False" RemoveRedundantParentheses="True" AddMissingParentheses="False" ArrangeBraces="True" ArrangeAttributes="False" ArrangeArgumentsStyle="False" ArrangeCodeBodyStyle="False" ArrangeVarStyle="False" ArrangeTrailingCommas="False" /><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSReformatCode>True</CSReformatCode><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSMakeAutoPropertyGetOnly>True</CSMakeAutoPropertyGetOnly><XAMLCollapseEmptyTags>False</XAMLCollapseEmptyTags></Profile> - - - Connector's STD (with reordering) - Connector's STD (File Layout + Code Format) - Required - Required - Required - Required - ExpressionBody - Shift, Bitwise, Conditional - - False - - - - - - False - - - True - - - - END_OF_LINE - END_OF_LINE - ALWAYS_ADD - ALWAYS_ADD - ALWAYS_ADD - ALWAYS_ADD - ALWAYS_ADD - ALWAYS_ADD - - True - True - True - True - True - True - END_OF_LINE - False - False - False - False - False - 1 - 1 - 10 - - END_OF_LINE - NEVER - False - False - False - NEVER - False - False - - - True - False - False - CHOP_IF_LONG - CHOP_IF_LONG - True - CHOP_IF_LONG - CHOP_IF_LONG - 150 - - - CHOP_ALWAYS - RemoveIndent - False - 1 - <?xml version="1.0" encoding="utf-16"?> -<Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns"> - <TypePattern DisplayName="Non-reorderable types"> - <TypePattern.Match> - <Or> - <And> - <Kind Is="Interface" /> - <Or> - <HasAttribute Name="System.Runtime.InteropServices.InterfaceTypeAttribute" /> - <HasAttribute Name="System.Runtime.InteropServices.ComImport" /> - </Or> - </And> - <Kind Is="Struct" /> - <HasAttribute Name="JetBrains.Annotations.NoReorderAttribute" /> - <HasAttribute Name="JetBrains.Annotations.NoReorder" /> - </Or> - </TypePattern.Match> - </TypePattern> - <TypePattern DisplayName="Connectors Team Type layout"> - <TypePattern.Match> - <Or> - <Kind Is="Class" /> - <Kind Is="Struct" /> - <Kind Is="Interface" /> - </Or> - </TypePattern.Match> - <Entry DisplayName="Private Enums"> - <Entry.Match> - <And> - <Access Is="Private" /> - <Kind Is="Enum" /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Interfaces"> - <Entry.Match> - <Kind Is="Interface" /> - </Entry.Match> - <Entry.SortBy> - <Access /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Private Constants"> - <Entry.Match> - <And> - <Kind Is="Constant" /> - <Access Is="Private" /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Private Static Readonly Fields"> - <Entry.Match> - <And> - <Kind Is="Field" /> - <Static /> - <Access Is="Private" /> - <Readonly /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Private Static Fields"> - <Entry.Match> - <And> - <Kind Is="Field" /> - <Static /> - <Access Is="Private" /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Private Readonly Fields"> - <Entry.Match> - <And> - <Access Is="Private" /> - <Kind Is="Field" /> - <Readonly /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Private Fields"> - <Entry.Match> - <And> - <Access Is="Private" /> - <Kind Is="Field" /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Private Readonly Properties"> - <Entry.Match> - <And> - <Kind Is="Property" /> - <Access Is="Private" /> - <Readonly /> - </And> - </Entry.Match> - <Entry.SortBy> - <Static /> - <Access /> - <Abstract /> - <ImplementsInterface /> - <Virtual /> - <Override /> - <Sealed /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Private Properties"> - <Entry.Match> - <And> - <Kind Is="Property" /> - <Access Is="Private" /> - </And> - </Entry.Match> - <Entry.SortBy> - <Static /> - <Access /> - <Abstract /> - <ImplementsInterface /> - <Virtual /> - <Override /> - <Sealed /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Private Indexers"> - <Entry.Match> - <And> - <Kind Is="Indexer" /> - <Access Is="Private" /> - </And> - </Entry.Match> - <Entry.SortBy> - <Access /> - <Abstract /> - <ImplementsInterface /> - <Virtual /> - <Override /> - <Sealed /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Private Delegates"> - <Entry.Match> - <And> - <Kind Is="Delegate" /> - <Access Is="Private" /> - </And> - </Entry.Match> - <Entry.SortBy> - <Access /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Private Events"> - <Entry.Match> - <And> - <Kind Is="Event" /> - <Access Is="Private" /> - </And> - </Entry.Match> - <Entry.SortBy> - <Static /> - <Access /> - <Abstract /> - <ImplementsInterface /> - <Virtual /> - <Override /> - <Sealed /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Protected Internal Constants"> - <Entry.Match> - <And> - <Kind Is="Constant" /> - <Access Is="ProtectedInternal" /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Protected Internal Static Readonly Fields"> - <Entry.Match> - <And> - <Kind Is="Field" /> - <Static /> - <Access Is="ProtectedInternal" /> - <Readonly /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Protected Internal Static Fields"> - <Entry.Match> - <And> - <Kind Is="Field" /> - <Static /> - <Access Is="ProtectedInternal" /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Protected Internal Readonly Fields"> - <Entry.Match> - <And> - <Access Is="ProtectedInternal" /> - <Kind Is="Field" /> - <Readonly /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Protected Internal Fields"> - <Entry.Match> - <And> - <Access Is="ProtectedInternal" /> - <Kind Is="Field" /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Protected Internal Readonly Properties"> - <Entry.Match> - <And> - <Kind Is="Property" /> - <Access Is="ProtectedInternal" /> - <Readonly /> - </And> - </Entry.Match> - <Entry.SortBy> - <Static /> - <Access /> - <Abstract /> - <ImplementsInterface /> - <Virtual /> - <Override /> - <Sealed /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Protected Internal Properties"> - <Entry.Match> - <And> - <Kind Is="Property" /> - <Access Is="ProtectedInternal" /> - </And> - </Entry.Match> - <Entry.SortBy> - <Static /> - <Access /> - <Abstract /> - <ImplementsInterface /> - <Virtual /> - <Override /> - <Sealed /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Protected Internal Indexers"> - <Entry.Match> - <And> - <Kind Is="Indexer" /> - <Access Is="ProtectedInternal" /> - </And> - </Entry.Match> - <Entry.SortBy> - <Access /> - <Abstract /> - <ImplementsInterface /> - <Virtual /> - <Override /> - <Sealed /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Protected Internal Delegates"> - <Entry.Match> - <And> - <Kind Is="Delegate" /> - <Access Is="ProtectedInternal" /> - </And> - </Entry.Match> - <Entry.SortBy> - <Access /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Protected Internal Events"> - <Entry.Match> - <And> - <Kind Is="Event" /> - <Access Is="ProtectedInternal" /> - </And> - </Entry.Match> - <Entry.SortBy> - <Static /> - <Access /> - <Abstract /> - <ImplementsInterface /> - <Virtual /> - <Override /> - <Sealed /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Protected Constants"> - <Entry.Match> - <And> - <Kind Is="Constant" /> - <Access Is="Protected" /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Protected Static Readonly Fields"> - <Entry.Match> - <And> - <Kind Is="Field" /> - <Static /> - <Access Is="Protected" /> - <Readonly /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Protected Static Fields"> - <Entry.Match> - <And> - <Kind Is="Field" /> - <Static /> - <Access Is="Protected" /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Protected Readonly Fields"> - <Entry.Match> - <And> - <Access Is="Protected" /> - <Kind Is="Field" /> - <Readonly /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Protected Fields"> - <Entry.Match> - <And> - <Access Is="Protected" /> - <Kind Is="Field" /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Protected Readonly Properties"> - <Entry.Match> - <And> - <Kind Is="Property" /> - <Access Is="Protected" /> - <Readonly /> - </And> - </Entry.Match> - <Entry.SortBy> - <Static /> - <Access /> - <Abstract /> - <ImplementsInterface /> - <Virtual /> - <Override /> - <Sealed /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Protected Properties"> - <Entry.Match> - <And> - <Kind Is="Property" /> - <Access Is="Protected" /> - </And> - </Entry.Match> - <Entry.SortBy> - <Static /> - <Access /> - <Abstract /> - <ImplementsInterface /> - <Virtual /> - <Override /> - <Sealed /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Protected Indexers"> - <Entry.Match> - <And> - <Kind Is="Indexer" /> - <Access Is="Protected" /> - </And> - </Entry.Match> - <Entry.SortBy> - <Access /> - <Abstract /> - <ImplementsInterface /> - <Virtual /> - <Override /> - <Sealed /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Protected Delegates"> - <Entry.Match> - <And> - <Kind Is="Delegate" /> - <Access Is="Protected" /> - </And> - </Entry.Match> - <Entry.SortBy> - <Access /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Protected Events"> - <Entry.Match> - <And> - <Kind Is="Event" /> - <Access Is="Protected" /> - </And> - </Entry.Match> - <Entry.SortBy> - <Static /> - <Access /> - <Abstract /> - <ImplementsInterface /> - <Virtual /> - <Override /> - <Sealed /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Internal Constants"> - <Entry.Match> - <And> - <Kind Is="Constant" /> - <Access Is="Internal" /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Internal Static Readonly Fields"> - <Entry.Match> - <And> - <Kind Is="Field" /> - <Static /> - <Access Is="Internal" /> - <Readonly /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Internal Static Fields"> - <Entry.Match> - <And> - <Kind Is="Field" /> - <Static /> - <Access Is="Internal" /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Internal Readonly Fields"> - <Entry.Match> - <And> - <Access Is="Internal" /> - <Kind Is="Field" /> - <Readonly /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Internal Fields"> - <Entry.Match> - <And> - <Access Is="Internal" /> - <Kind Is="Field" /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Internal Readonly Properties"> - <Entry.Match> - <And> - <Kind Is="Property" /> - <Access Is="Internal" /> - <Readonly /> - </And> - </Entry.Match> - <Entry.SortBy> - <Static /> - <Access /> - <Abstract /> - <ImplementsInterface /> - <Virtual /> - <Override /> - <Sealed /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Internal Properties"> - <Entry.Match> - <And> - <Kind Is="Property" /> - <Access Is="Internal" /> - </And> - </Entry.Match> - <Entry.SortBy> - <Static /> - <Access /> - <Abstract /> - <ImplementsInterface /> - <Virtual /> - <Override /> - <Sealed /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Internal Indexers"> - <Entry.Match> - <And> - <Kind Is="Indexer" /> - <Access Is="Internal" /> - </And> - </Entry.Match> - <Entry.SortBy> - <Access /> - <Abstract /> - <ImplementsInterface /> - <Virtual /> - <Override /> - <Sealed /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Internal Delegates"> - <Entry.Match> - <And> - <Kind Is="Delegate" /> - <Access Is="Internal" /> - </And> - </Entry.Match> - <Entry.SortBy> - <Access /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Internal Events"> - <Entry.Match> - <And> - <Kind Is="Event" /> - <Access Is="Internal" /> - </And> - </Entry.Match> - <Entry.SortBy> - <Static /> - <Access /> - <Abstract /> - <ImplementsInterface /> - <Virtual /> - <Override /> - <Sealed /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Public Constants"> - <Entry.Match> - <And> - <Kind Is="Constant" /> - <Access Is="Public" /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Public Static Readonly Fields"> - <Entry.Match> - <And> - <Kind Is="Field" /> - <Static /> - <Access Is="Public" /> - <Readonly /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Public Static Fields"> - <Entry.Match> - <And> - <Kind Is="Field" /> - <Static /> - <Access Is="Public" /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Public Readonly Fields"> - <Entry.Match> - <And> - <Access Is="Public" /> - <Kind Is="Field" /> - <Readonly /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Public Fields"> - <Entry.Match> - <And> - <Access Is="Public" /> - <Kind Is="Field" /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Public Readonly Properties"> - <Entry.Match> - <And> - <Kind Is="Property" /> - <Access Is="Public" /> - <Readonly /> - </And> - </Entry.Match> - <Entry.SortBy> - <Static /> - <Access /> - <Abstract /> - <ImplementsInterface /> - <Virtual /> - <Override /> - <Sealed /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Public Properties"> - <Entry.Match> - <And> - <Kind Is="Property" /> - <Access Is="Public" /> - </And> - </Entry.Match> - <Entry.SortBy> - <Static /> - <Access /> - <Abstract /> - <ImplementsInterface /> - <Virtual /> - <Override /> - <Sealed /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Public Indexers"> - <Entry.Match> - <And> - <Kind Is="Indexer" /> - <Access Is="Public" /> - </And> - </Entry.Match> - <Entry.SortBy> - <Access /> - <Abstract /> - <ImplementsInterface /> - <Virtual /> - <Override /> - <Sealed /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Public Delegates"> - <Entry.Match> - <And> - <Kind Is="Delegate" /> - <Access Is="Public" /> - </And> - </Entry.Match> - <Entry.SortBy> - <Access /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Public Events"> - <Entry.Match> - <And> - <Kind Is="Event" /> - <Access Is="Public" /> - </And> - </Entry.Match> - <Entry.SortBy> - <Static /> - <Access /> - <Abstract /> - <ImplementsInterface /> - <Virtual /> - <Override /> - <Sealed /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Constants"> - <Entry.Match> - <Kind Is="Constant" /> - </Entry.Match> - </Entry> - <Entry DisplayName="Static Readonly Fields"> - <Entry.Match> - <And> - <Kind Is="Field" /> - <Static /> - <Readonly /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Static Fields"> - <Entry.Match> - <And> - <Kind Is="Field" /> - <Static /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Readonly Fields"> - <Entry.Match> - <And> - <Kind Is="Field" /> - <Readonly /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Fields"> - <Entry.Match> - <Kind Is="Field" /> - </Entry.Match> - </Entry> - <Entry DisplayName="Readonly Properties"> - <Entry.Match> - <And> - <Kind Is="Property" /> - <Readonly /> - </And> - </Entry.Match> - <Entry.SortBy> - <Static /> - <Access /> - <Abstract /> - <ImplementsInterface /> - <Virtual /> - <Override /> - <Sealed /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Properties"> - <Entry.Match> - <Kind Is="Property" /> - </Entry.Match> - <Entry.SortBy> - <Static /> - <Access /> - <Abstract /> - <ImplementsInterface /> - <Virtual /> - <Override /> - <Sealed /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Indexers"> - <Entry.Match> - <Kind Is="Indexer" /> - </Entry.Match> - <Entry.SortBy> - <Access /> - <Abstract /> - <ImplementsInterface /> - <Virtual /> - <Override /> - <Sealed /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Delegates"> - <Entry.Match> - <Kind Is="Delegate" /> - </Entry.Match> - <Entry.SortBy> - <Access /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Events"> - <Entry.Match> - <Kind Is="Event" /> - </Entry.Match> - <Entry.SortBy> - <Static /> - <Access /> - <Abstract /> - <ImplementsInterface /> - <Virtual /> - <Override /> - <Sealed /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Static Constructor"> - <Entry.Match> - <And> - <Kind Is="Constructor" /> - <Static /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Private Constructor"> - <Entry.Match> - <And> - <Kind Is="Constructor" /> - <Access Is="Private" /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Protected Constructor"> - <Entry.Match> - <And> - <Kind Is="Constructor" /> - <Access Is="Protected" /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Internal Constructor"> - <Entry.Match> - <And> - <Kind Is="Constructor" /> - <Access Is="Internal" /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Protected Internal Constructor"> - <Entry.Match> - <And> - <Kind Is="Constructor" /> - <Access Is="ProtectedInternal" /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Public Constructor"> - <Entry.Match> - <And> - <Kind Is="Constructor" /> - <Access Is="Public" /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Constructors"> - <Entry.Match> - <Kind Is="Constructor" /> - </Entry.Match> - </Entry> - <Entry DisplayName="Finalizers"> - <Entry.Match> - <Kind Is="Destructor" /> - </Entry.Match> - </Entry> - <Entry DisplayName="Dispose"> - <Entry.Match> - <And> - <Kind Is="Method" /> - <ImplementsInterface Name="IDisposable" /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Public Methods"> - <Entry.Match> - <And> - <Kind Is="Method" /> - <Access Is="Public" /> - <Not> - <Static /> - </Not> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Public Static Methods"> - <Entry.Match> - <And> - <Kind Is="Method" /> - <Access Is="Public" /> - <Static /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Internal Methods"> - <Entry.Match> - <And> - <Kind Is="Method" /> - <Access Is="Internal" /> - <Not> - <Static /> - </Not> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Internal Static Methods"> - <Entry.Match> - <And> - <Kind Is="Method" /> - <Access Is="Internal" /> - <Static /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Protected Methods"> - <Entry.Match> - <And> - <Kind Is="Method" /> - <Access Is="Protected" /> - <Not> - <Static /> - </Not> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Protected Static Methods"> - <Entry.Match> - <And> - <Kind Is="Method" /> - <Access Is="Protected" /> - <Static /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Protected Internal Methods"> - <Entry.Match> - <And> - <Kind Is="Method" /> - <Access Is="ProtectedInternal" /> - <Not> - <Static /> - </Not> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Protected Internal Static Methods"> - <Entry.Match> - <And> - <Kind Is="Method" /> - <Access Is="ProtectedInternal" /> - <Static /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Private Methods"> - <Entry.Match> - <And> - <Kind Is="Method" /> - <Access Is="Private" /> - <Not> - <Static /> - </Not> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Private Static Methods"> - <Entry.Match> - <And> - <Kind Is="Method" /> - <Access Is="Private" /> - <Static /> - </And> - </Entry.Match> - </Entry> - <Entry DisplayName="Methods"> - <Entry.Match> - <Kind Is="Method" /> - </Entry.Match> - </Entry> - <Entry DisplayName="Enums"> - <Entry.Match> - <Kind Is="Enum" /> - </Entry.Match> - </Entry> - <Entry DisplayName="Operators"> - <Entry.Match> - <Kind Is="Operator" /> - </Entry.Match> - </Entry> - <Entry DisplayName="Structs"> - <Entry.Match> - <Kind Is="Struct" /> - </Entry.Match> - </Entry> - <Entry DisplayName="Classes"> - <Entry.Match> - <Kind Is="Class" /> - </Entry.Match> - </Entry> - </TypePattern> - <FilePattern> - <Entry DisplayName="Extern alias directives"> - <Entry.Match> - <Extern /> - </Entry.Match> - </Entry> - <Entry DisplayName="Delegates"> - <Entry.Match> - <Kind Is="Delegate" /> - </Entry.Match> - <Entry.SortBy> - <Access /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Enums"> - <Entry.Match> - <Kind Is="Enum" /> - </Entry.Match> - <Entry.SortBy> - <Access /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Interfaces"> - <Entry.Match> - <Kind Is="Interface" /> - </Entry.Match> - <Entry.SortBy> - <Access /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Structs"> - <Entry.Match> - <Kind Is="Struct" /> - </Entry.Match> - <Entry.SortBy> - <Access /> - </Entry.SortBy> - </Entry> - <Entry DisplayName="Classes"> - <Entry.Match> - <Kind Is="Class" /> - </Entry.Match> - <Entry.SortBy> - <Access /> - </Entry.SortBy> - </Entry> - </FilePattern> -</Patterns> - <?xml version="1.0" encoding="utf-8" ?> - -<!-- -I. Overall - -I.1 Each pattern can have <Match>....</Match> element. For the given type declaration, the pattern with the match, evaluated to 'true' with the largest weight, will be used -I.2 Each pattern consists of the sequence of <Entry>...</Entry> elements. Type member declarations are distributed between entries -I.3 If pattern has RemoveAllRegions="true" attribute, then all regions will be cleared prior to reordering. Otherwise, only auto-generated regions will be cleared -I.4 The contents of each entry is sorted by given keys (First key is primary, next key is secondary, etc). Then the declarations are grouped and en-regioned by given property - -II. Available match operands - -Each operand may have Weight="..." attribute. This weight will be added to the match weight if the operand is evaluated to 'true'. -The default weight is 1 - -II.1 Boolean functions: -II.1.1 <And>....</And> -II.1.2 <Or>....</Or> -II.1.3 <Not>....</Not> - -II.2 Operands -II.2.1 <Kind Is="..."/>. Kinds are: class, struct, interface, enum, delegate, type, constructor, destructor, property, indexer, method, operator, field, constant, event, member -II.2.2 <Name Is="..." [IgnoreCase="true/false"] />. The 'Is' attribute contains regular expression -II.2.3 <HasAttribute CLRName="..." [Inherit="true/false"] />. The 'CLRName' attribute contains regular expression -II.2.4 <Access Is="..."/>. The 'Is' values are: public, protected, internal, protected internal, private -II.2.5 <Static/> -II.2.6 <Abstract/> -II.2.7 <Virtual/> -II.2.8 <Override/> -II.2.9 <Sealed/> -II.2.10 <Readonly/> -II.2.11 <ImplementsInterface CLRName="..."/>. The 'CLRName' attribute contains regular expression -II.2.12 <HandlesEvent /> ---> - -<Patterns xmlns="urn:shemas-jetbrains-com:member-reordering-patterns"> - - <!--Do not reorder COM interfaces and structs marked by StructLayout attribute--> - <Pattern> - <Match> - <Or Weight="100"> - <And> - <Kind Is="interface"/> - <Or> - <HasAttribute CLRName="System.Runtime.InteropServices.InterfaceTypeAttribute"/> - <HasAttribute CLRName="System.Runtime.InteropServices.ComImport"/> - </Or> - </And> - <HasAttribute CLRName="System.Runtime.InteropServices.StructLayoutAttribute"/> - </Or> - </Match> - </Pattern> - - <!--Special formatting of NUnit test fixture--> - <Pattern RemoveAllRegions="true"> - <Match> - <And Weight="100"> - <Kind Is="class"/> - <HasAttribute CLRName="NUnit.Framework.TestFixtureAttribute" Inherit="true"/> - </And> - </Match> - - <Entry> - <Match> - <Or> - <Kind Is="constant" /> - <Kind Is="enum" /> - <Kind Is="field" /> - <Kind Is="delegate" /> - <Kind Is="event" /> - <Kind Is="indexer" /> - <Kind Is="property" /> - </Or> - </Match> - <Sort> - <Access Order="private protected-internal internal protected public" /> - <Kind Order="constant enum field delegate event indexer property" /> - <Static/> - <Name/> - </Sort> - </Entry> - - <!--Setup/Teardow--> - <Entry> - <Match> - <And> - <Kind Is="method"/> - <Or> - <HasAttribute CLRName="NUnit.Framework.SetUpAttribute" Inherit="true"/> - <HasAttribute CLRName="NUnit.Framework.TearDownAttribute" Inherit="true"/> - <HasAttribute CLRName="NUnit.Framework.FixtureSetUpAttribute" Inherit="true"/> - <HasAttribute CLRName="NUnit.Framework.FixtureTearDownAttribute" Inherit="true"/> - <HasAttribute CLRName="NUnit.Framework.TestFixtureSetUpAttribute" Inherit="true"/> - <HasAttribute CLRName="NUnit.Framework.TestFixtureTearDownAttribute" Inherit="true"/> - </Or> - </And> - </Match> -<Sort> - <Kind Order="constructor operator method destructor" /> - <Access Order="public protected internal protected-internal private" /> - <Static Descending="true"/> - <Name/> - </Sort> - </Entry> - -<!--Test methods--> - <Entry> - <Match> - <And Weight="100"> - <Kind Is="method"/> - <HasAttribute CLRName="NUnit.Framework.TestAttribute" Inherit="false"/> - </And> - </Match> - <Sort> - <Kind Order="constructor operator method destructor" /> - <Access Order="public protected internal protected-internal private" /> - <Static Descending="true"/> - <Name/> - </Sort> - </Entry> - - <!--All other members--> - <Entry> - <Match> - <Or> - <Kind Is="constructor" /> - <Kind Is="operator" /> - <Kind Is="method" /> - <Kind Is="destructor" /> - </Or> - </Match> - <Sort> - <Kind Order="constructor operator method destructor" /> - <Access Order="public protected internal protected-internal private" /> - <Static Descending="true"/> - <Name/> - </Sort> - </Entry> - - <!--all other members--> - <Entry> - <Sort> - <Kind/> - <Access Order="public protected internal protected-internal private" /> - <Static Descending="true"/> - <Name/> - </Sort> - </Entry> - - </Pattern> - - <!--Default pattern--> - <Pattern> - - <Entry> - <Match> - <Or> - <Kind Is="constant" /> - <Kind Is="enum" /> - <Kind Is="field" /> - <Kind Is="delegate" /> - <Kind Is="event" /> - <Kind Is="indexer" /> - <Kind Is="property" /> - </Or> - </Match> - <Sort> - <Access Order="private protected-internal internal protected public" /> - <Kind Order="constant enum field delegate event indexer property" /> - <Static/> - <Name/> - </Sort> - </Entry> - - <Entry> - <Match> - <Or> - <Kind Is="constructor" /> - <Kind Is="operator" /> - <Kind Is="method" /> - <Kind Is="destructor" /> - </Or> - </Match> - <Sort> - <Kind Order="constructor operator method destructor" /> - <Access Order="public protected internal protected-internal private" /> - <Static Descending="true"/> - <Name/> - </Sort> - </Entry> - - <!--all other members--> - <Entry> - <Sort> - <Kind/> - <Access Order="public protected internal protected-internal private" /> - <Static Descending="true"/> - <Name/> - </Sort> - </Entry> - - </Pattern> - -</Patterns> - - CustomLayout - UseExplicitType - UseExplicitType - UseExplicitType - True - - ID - $object$_On$event$ - <Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="I" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="p_" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /> - <Policy Inspect="True" Prefix="m_" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="s_" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="s_" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="s_" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="T" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy><Descriptor Staticness="Static, Instance" AccessRightKinds="Public" Description="Lambda expression"><ElementKinds><Kind Name="LAMBDA_PARAMETER" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> - <Policy><Descriptor Staticness="Static, Instance" AccessRightKinds="Public" Description="Ignore naming style on test methods"><ElementKinds><Kind Name="TEST_TYPE" /><Kind Name="TEST_MEMBER" /></ElementKinds></Descriptor><Policy Inspect="False" Prefix="" Suffix="" Style="AaBb" /></Policy> - $object$_On$event$ - <Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="I" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="p_" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /> - <Policy Inspect="True" Prefix="m_" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="s_" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="s_" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="T" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - True - D:\Projects\Repositories\easy-file-pusher\Coveo.Connectors.EasyFilePusher.sln.DotSettings - - True - 1 - True - True - True - True - True - True - True \ No newline at end of file + QA + RSS + #nullable enable +$HEADER$namespace $NAMESPACE$ +{ + public class $CLASS$ {$END$} +} + #nullable enable +$HEADER$namespace $NAMESPACE$ +{ + public record $RECORD$($END$); +} + #nullable enable +$HEADER$namespace $NAMESPACE$ +{ + public interface $INTERFACE$ {$END$} +} + #nullable enable +$HEADER$namespace $NAMESPACE$ +{ + public struct $STRUCT$ {$END$} +} + True + True + \ No newline at end of file diff --git a/src/Coveo.Connectors.EasyFilePusher/Coveo.Connectors.EasyFilePusher.csproj b/src/Coveo.Connectors.EasyFilePusher/Coveo.Connectors.EasyFilePusher.csproj index 96b3f3f..f593120 100644 --- a/src/Coveo.Connectors.EasyFilePusher/Coveo.Connectors.EasyFilePusher.csproj +++ b/src/Coveo.Connectors.EasyFilePusher/Coveo.Connectors.EasyFilePusher.csproj @@ -2,13 +2,11 @@ Exe - netcoreapp3.1 - - - + + diff --git a/src/Coveo.Connectors.EasyFilePusher/Program.cs b/src/Coveo.Connectors.EasyFilePusher/Program.cs index 7cce2c1..5ea0b53 100644 --- a/src/Coveo.Connectors.EasyFilePusher/Program.cs +++ b/src/Coveo.Connectors.EasyFilePusher/Program.cs @@ -3,7 +3,7 @@ using System.ComponentModel; using System.Diagnostics; using System.IO; -using System.Reflection; +using System.Threading; using CommandLine; using Coveo.Connectors.Utilities.PlatformSdk; using Coveo.Connectors.Utilities.PlatformSdk.Config; @@ -25,20 +25,24 @@ public class Program /// /// Entry point of the program. /// - /// Command-line arguments. - private static void Main(string[] p_Args) + /// Command-line arguments. + private static void Main(string[] args) { - if (p_Args.Length == 0) { + if (args.Length == 0) + { // Read the values interactively. IndexFiles(GetProgramArgumentsInteractively()); - } else { + } + else + { // Use the values specified on the command line. - new Parser(settings => { + new Parser(settings => + { settings.CaseInsensitiveEnumValues = true; settings.HelpWriter = Console.Out; - }).ParseArguments(p_Args).WithParsed(parsedArgs => { - IndexFiles(parsedArgs); - }); + }) + .ParseArguments(args) + .WithParsed(IndexFiles); } } @@ -48,21 +52,26 @@ private static void Main(string[] p_Args) /// Input arguments read from the keyboard. private static ProgramArguments GetProgramArgumentsInteractively() { - ProgramArguments programArgs = new ProgramArguments(); + var programArgs = new ProgramArguments(); - foreach (PropertyInfo property in typeof(ProgramArguments).GetProperties()) { - string helpText = ""; - bool isRequired = false; + foreach (var property in typeof(ProgramArguments).GetProperties()) + { + var helpText = ""; + var isRequired = false; object? defaultValue = null; - foreach (CustomAttributeData attrData in property.CustomAttributes) { - if (attrData.AttributeType == typeof(OptionAttribute)) { - foreach (CustomAttributeNamedArgument namedArg in attrData.NamedArguments) { - switch (namedArg.MemberName) { + foreach (var attrData in property.CustomAttributes) + { + if (attrData.AttributeType == typeof(OptionAttribute)) + { + foreach (var namedArg in attrData.NamedArguments) + { + switch (namedArg.MemberName) + { case nameof(OptionAttribute.HelpText): - helpText = (string) (namedArg.TypedValue.Value ?? ""); + helpText = (string)(namedArg.TypedValue.Value ?? ""); break; case nameof(OptionAttribute.Required): - isRequired = (bool) (namedArg.TypedValue.Value ?? false); + isRequired = (bool)(namedArg.TypedValue.Value ?? false); break; case nameof(OptionAttribute.Default): defaultValue = namedArg.TypedValue.Value; @@ -75,49 +84,71 @@ private static ProgramArguments GetProgramArgumentsInteractively() } Console.WriteLine(helpText); - bool success = false; - while (!success) { + var success = false; + while (!success) + { Console.Write($"{property.Name}{(defaultValue == null ? "" : " [" + defaultValue + "]")}: "); - string valueStr = Console.ReadLine().Trim(); - if (property.PropertyType == typeof(CloudEnvironment)) { + var valueStr = Console.ReadLine()?.Trim() ?? string.Empty; + if (property.PropertyType == typeof(CloudEnvironment)) + { Debug.Assert(isRequired); success = Enum.TryParse(valueStr, true, out CloudEnvironment environment); property.SetValue(programArgs, environment); - } else if (property.PropertyType == typeof(CloudRegion)) { + } + else if (property.PropertyType == typeof(CloudRegion)) + { Debug.Assert(isRequired); success = Enum.TryParse(valueStr, true, out CloudRegion region); property.SetValue(programArgs, region); - } else if (property.PropertyType == typeof(string)) { - if (valueStr != "") { + } + else if (property.PropertyType == typeof(string)) + { + if (valueStr != "") + { property.SetValue(programArgs, valueStr); success = true; - } else if (defaultValue != null) { + } + else if (defaultValue != null) + { property.SetValue(programArgs, defaultValue); success = true; } - } else if (property.PropertyType == typeof(int)) { - if (valueStr != "") { - success = int.TryParse(valueStr, out int intValue); + } + else if (property.PropertyType == typeof(int)) + { + if (valueStr != "") + { + success = int.TryParse(valueStr, out var intValue); property.SetValue(programArgs, intValue); - } else if (defaultValue != null) { + } + else if (defaultValue != null) + { property.SetValue(programArgs, defaultValue); success = true; } - } else if (property.PropertyType == typeof(bool)) { - if (valueStr != "") { - success = bool.TryParse(valueStr, out bool boolValue); + } + else if (property.PropertyType == typeof(bool)) + { + if (valueStr != "") + { + success = bool.TryParse(valueStr, out var boolValue); property.SetValue(programArgs, boolValue); - } else if (defaultValue != null) { + } + else if (defaultValue != null) + { property.SetValue(programArgs, defaultValue); success = true; } - } else { + } + else + { Debug.Fail("Unsupported value type."); } - if (!success) { - ConsoleColor originalColor = Console.ForegroundColor; + if (!success) + { + var originalColor = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Invalid value."); Console.ForegroundColor = originalColor; @@ -133,69 +164,77 @@ private static ProgramArguments GetProgramArgumentsInteractively() /// /// Indexes the files located in the specified folder. /// - /// Parsed command-line arguments. - private static void IndexFiles(ProgramArguments p_Args) + /// Parsed command-line arguments. + private static void IndexFiles(ProgramArguments args) { - string folder = Path.GetFullPath(p_Args.folder); - if (!folder.EndsWith(Path.DirectorySeparatorChar)) { + var folder = Path.GetFullPath(args.folder); + if (!folder.EndsWith(Path.DirectorySeparatorChar.ToString())) + { folder += Path.DirectorySeparatorChar; } - Console.WriteLine($"Pushing files \"{p_Args.include}\" from folder \"{folder}\"..."); + Console.WriteLine($"Pushing files \"{args.include}\" from folder \"{folder}\"..."); - ulong orderingId = RequestOrderingUtilities.CreateOrderingId(); + var orderingId = RequestOrderingUtilities.CreateOrderingId(); - ICoveoPlatformConfig platformConfig = new CoveoPlatformConfig(GetPushApiUrl(p_Args), GetPlatformApiUrl(p_Args), p_Args.apikey, p_Args.organizationid); - using (ICoveoPlatformClient platformClient = new CoveoPlatformClient(platformConfig)) { + ICoveoPlatformConfig platformConfig = new CoveoPlatformConfig(GetPushApiUrl(args), GetPlatformApiUrl(args), args.apikey, args.organizationid); + + using (ICoveoPlatformClient platformClient = new CoveoPlatformClient(platformConfig, CancellationToken.None)) + { IList documentBatch = new List(); - foreach (FileInfo fileInfo in new DirectoryInfo(folder).EnumerateFiles(p_Args.include, p_Args.recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly)) { - if (!fileInfo.FullName.StartsWith(folder)) { + foreach ( + var fileInfo in new DirectoryInfo(folder).EnumerateFiles( + args.include, + args.recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly + ) + ) + { + if (!fileInfo.FullName.StartsWith(folder)) + { throw new Exception("Unexpected file gathered from outside the source folder."); } Console.WriteLine(fileInfo.FullName.Substring(folder.Length)); - PushDocument document = new PushDocument(new Uri(fileInfo.FullName).AbsoluteUri) { - ModifiedDate = fileInfo.LastWriteTimeUtc - }; + var document = new PushDocument(new Uri(fileInfo.FullName).AbsoluteUri) { ModifiedDate = fileInfo.LastWriteTimeUtc }; document.AddMetadata("title", fileInfo.Name); document.AddMetadata("fileextension", fileInfo.Extension); - if (fileInfo.Length > 0) { + if (fileInfo.Length > 0) + { PushDocumentHelper.SetBinaryContentFromFileAndCompress(document, fileInfo.FullName); } documentBatch.Add(document); - if (documentBatch.Count >= p_Args.batchSize) { + if (documentBatch.Count >= args.batchSize) + { // Push this batch of documents. - SendBatch(platformClient, documentBatch, p_Args.sourceid, orderingId); + SendBatch(platformClient, documentBatch, args.sourceid, orderingId); } } // Send the (partial) final batch of documents. - SendBatch(platformClient, documentBatch, p_Args.sourceid, orderingId); + SendBatch(platformClient, documentBatch, args.sourceid, orderingId); // Delete the already indexed files that no longer exist. - platformClient.DocumentManager.DeleteDocumentsOlderThan(p_Args.sourceid, orderingId, null); + platformClient.DocumentManager.DeleteDocumentsOlderThan(args.sourceid, orderingId, null, CancellationToken.None); } } /// /// Sends a batch of documents to the platform. /// - /// The instance of to use. - /// The batch of documents to send. - /// ID of the source in which to push documents. - /// The ordering identifier. - private static void SendBatch(ICoveoPlatformClient p_PlatformClient, - IList p_DocumentBatch, - string p_SourceId, - ulong p_OrderingId) + /// The instance of to use. + /// The batch of documents to send. + /// ID of the source in which to push documents. + /// The ordering identifier. + private static void SendBatch(ICoveoPlatformClient platformClient, IList documentBatch, string sourceId, ulong orderingId) { - if (p_DocumentBatch.Count == 0) { + if (documentBatch.Count == 0) + { return; } - p_PlatformClient.DocumentManager.AddOrUpdateDocuments(p_SourceId, p_DocumentBatch, p_OrderingId); + platformClient.DocumentManager.AddOrUpdateDocuments(sourceId, documentBatch, orderingId, CancellationToken.None); - p_DocumentBatch.Clear(); + documentBatch.Clear(); } /// @@ -205,40 +244,44 @@ private static void SendBatch(ICoveoPlatformClient p_PlatformClient, /// The push API endpoint URL to use. private static string GetPushApiUrl(ProgramArguments p_Args) { - switch (p_Args.region) { + switch (p_Args.region) + { case CloudRegion.UsEast1: - switch (p_Args.environment) { + switch (p_Args.environment) + { case CloudEnvironment.Hipaa: return Constants.Endpoint.UsEast1.HIPAA_PUSH_API_URL; case CloudEnvironment.Prod: return Constants.Endpoint.UsEast1.PROD_PUSH_API_URL; - case CloudEnvironment.QA: - return Constants.Endpoint.UsEast1.QA_PUSH_API_URL; - case CloudEnvironment.Dev: - return Constants.Endpoint.UsEast1.DEV_PUSH_API_URL; default: throw new InvalidEnumArgumentException(INVALID_CLOUD_ENVIRONMENT); } case CloudRegion.EuWest1: - switch (p_Args.environment) { + switch (p_Args.environment) + { case CloudEnvironment.Hipaa: throw new InvalidEnumArgumentException(string.Format(ENVIRONMENT_X_IS_INVALID_FOR_REGION_Y, p_Args.environment, p_Args.region)); case CloudEnvironment.Prod: return Constants.Endpoint.EuWest1.PROD_PUSH_API_URL; - case CloudEnvironment.QA: - return Constants.Endpoint.EuWest1.QA_PUSH_API_URL; - case CloudEnvironment.Dev: - return Constants.Endpoint.EuWest1.DEV_PUSH_API_URL; default: throw new InvalidEnumArgumentException(INVALID_CLOUD_ENVIRONMENT); } case CloudRegion.ApSouthEast2: - switch (p_Args.environment) { + switch (p_Args.environment) + { case CloudEnvironment.Prod: return Constants.Endpoint.ApSoutheast2.PROD_PUSH_API_URL; case CloudEnvironment.Hipaa: - case CloudEnvironment.QA: - case CloudEnvironment.Dev: + throw new InvalidEnumArgumentException(string.Format(ENVIRONMENT_X_IS_INVALID_FOR_REGION_Y, p_Args.environment, p_Args.region)); + default: + throw new InvalidEnumArgumentException(INVALID_CLOUD_ENVIRONMENT); + } + case CloudRegion.CaCentral1: + switch (p_Args.environment) + { + case CloudEnvironment.Prod: + return Constants.Endpoint.CaCentral1.PROD_PUSH_API_URL; + case CloudEnvironment.Hipaa: throw new InvalidEnumArgumentException(string.Format(ENVIRONMENT_X_IS_INVALID_FOR_REGION_Y, p_Args.environment, p_Args.region)); default: throw new InvalidEnumArgumentException(INVALID_CLOUD_ENVIRONMENT); @@ -251,45 +294,49 @@ private static string GetPushApiUrl(ProgramArguments p_Args) /// /// Gets the platform endpoint URL to use that matches the command-line arguments specified. /// - /// Parsed command-line arguments. + /// Parsed command-line arguments. /// The platform endpoint URL to use. - private static string GetPlatformApiUrl(ProgramArguments p_Args) + private static string GetPlatformApiUrl(ProgramArguments args) { - switch (p_Args.region) { + switch (args.region) + { case CloudRegion.UsEast1: - switch (p_Args.environment) { + switch (args.environment) + { case CloudEnvironment.Hipaa: return Constants.PlatformEndpoint.UsEast1.HIPAA_PLATFORM_API_URL; case CloudEnvironment.Prod: return Constants.PlatformEndpoint.UsEast1.PROD_PLATFORM_API_URL; - case CloudEnvironment.QA: - return Constants.PlatformEndpoint.UsEast1.QA_PLATFORM_API_URL; - case CloudEnvironment.Dev: - return Constants.PlatformEndpoint.UsEast1.DEV_PLATFORM_API_URL; default: throw new InvalidEnumArgumentException(INVALID_CLOUD_ENVIRONMENT); } case CloudRegion.EuWest1: - switch (p_Args.environment) { + switch (args.environment) + { case CloudEnvironment.Hipaa: - throw new InvalidEnumArgumentException(string.Format(ENVIRONMENT_X_IS_INVALID_FOR_REGION_Y, p_Args.environment, p_Args.region)); + throw new InvalidEnumArgumentException(string.Format(ENVIRONMENT_X_IS_INVALID_FOR_REGION_Y, args.environment, args.region)); case CloudEnvironment.Prod: return Constants.PlatformEndpoint.EuWest1.PROD_PLATFORM_API_URL; - case CloudEnvironment.QA: - return Constants.PlatformEndpoint.EuWest1.QA_PLATFORM_API_URL; - case CloudEnvironment.Dev: - return Constants.PlatformEndpoint.EuWest1.DEV_PLATFORM_API_URL; default: throw new InvalidEnumArgumentException(INVALID_CLOUD_ENVIRONMENT); } case CloudRegion.ApSouthEast2: - switch (p_Args.environment) { + switch (args.environment) + { case CloudEnvironment.Prod: return Constants.PlatformEndpoint.ApSoutheast2.PROD_PLATFORM_API_URL; case CloudEnvironment.Hipaa: - case CloudEnvironment.QA: - case CloudEnvironment.Dev: - throw new InvalidEnumArgumentException(string.Format(ENVIRONMENT_X_IS_INVALID_FOR_REGION_Y, p_Args.environment, p_Args.region)); + throw new InvalidEnumArgumentException(string.Format(ENVIRONMENT_X_IS_INVALID_FOR_REGION_Y, args.environment, args.region)); + default: + throw new InvalidEnumArgumentException(INVALID_CLOUD_ENVIRONMENT); + } + case CloudRegion.CaCentral1: + switch (args.environment) + { + case CloudEnvironment.Prod: + return Constants.PlatformEndpoint.CaCentral1.PROD_PLATFORM_API_URL; + case CloudEnvironment.Hipaa: + throw new InvalidEnumArgumentException(string.Format(ENVIRONMENT_X_IS_INVALID_FOR_REGION_Y, args.environment, args.region)); default: throw new InvalidEnumArgumentException(INVALID_CLOUD_ENVIRONMENT); } diff --git a/src/Coveo.Connectors.EasyFilePusher/ProgramArguments.cs b/src/Coveo.Connectors.EasyFilePusher/ProgramArguments.cs index 1cb8573..b93f267 100644 --- a/src/Coveo.Connectors.EasyFilePusher/ProgramArguments.cs +++ b/src/Coveo.Connectors.EasyFilePusher/ProgramArguments.cs @@ -7,49 +7,41 @@ namespace Coveo.Connectors.EasyFilePusher /// internal class ProgramArguments { - [Option('e', nameof(environment), + [Option( + 'e', + nameof(environment), Required = true, - HelpText = "Cloud environment: " + nameof(CloudEnvironment.Hipaa) + ", " + nameof(CloudEnvironment.Prod) + ", " + nameof(CloudEnvironment.QA) + " or " + nameof(CloudEnvironment.Dev) + ".")] + HelpText = $"Cloud environment: {nameof(CloudEnvironment.Hipaa)} or {nameof(CloudEnvironment.Prod)}." + )] public CloudEnvironment environment { get; set; } - [Option('r', nameof(region), + [Option( + 'r', + nameof(region), Required = true, - HelpText = "Cloud region: " + nameof(CloudRegion.UsEast1) + ", " + nameof(CloudRegion.EuWest1) + " or " + nameof(CloudRegion.ApSouthEast2) + ".")] + HelpText = $"Cloud region: {nameof(CloudRegion.UsEast1)}, {nameof(CloudRegion.EuWest1)}, {nameof(CloudRegion.ApSouthEast2)} or {nameof(CloudRegion.CaCentral1)}." + )] public CloudRegion region { get; set; } - [Option('o', nameof(organizationid), - Required = true, - HelpText = "ID of the organization in which to push documents.")] + [Option('o', nameof(organizationid), Required = true, HelpText = "ID of the organization in which to push documents.")] public string organizationid { get; set; } = ""; - [Option('s', nameof(sourceid), - Required = true, - HelpText = "ID of the source in which to push documents.")] + [Option('s', nameof(sourceid), Required = true, HelpText = "ID of the source in which to push documents.")] public string sourceid { get; set; } = ""; - [Option('k', nameof(apikey), - Required = true, - HelpText = "API key to use.")] + [Option('k', nameof(apikey), Required = true, HelpText = "API key to use.")] public string apikey { get; set; } = ""; - [Option('f', nameof(folder), - Required = true, - HelpText = "Path of the local folder that contains the documents to index.")] + [Option('f', nameof(folder), Required = true, HelpText = "Path of the local folder that contains the documents to index.")] public string folder { get; set; } = ""; - [Option( - Default = "*", - HelpText = "Wildcard expression for which matching files will be pushed. All files are pushed by default.")] + [Option(Default = "*", HelpText = "Wildcard expression for which matching files will be pushed. All files are pushed by default.")] public string include { get; set; } = ""; - [Option( - Default = true, - HelpText = "Whether to recursively search in sub-folders for files to push. Sub-folders are searched by default.")] + [Option(Default = true, HelpText = "Whether to recursively search in sub-folders for files to push. Sub-folders are searched by default.")] public bool recursive { get; set; } - [Option( - Default = 10, - HelpText = "How many files to push per batch.")] + [Option(Default = 10, HelpText = "How many files to push per batch.")] public int batchSize { get; set; } } @@ -60,8 +52,6 @@ internal enum CloudEnvironment { Hipaa, Prod, - QA, - Dev } /// @@ -71,6 +61,7 @@ internal enum CloudRegion { UsEast1, EuWest1, - ApSouthEast2 + ApSouthEast2, + CaCentral1, } } diff --git a/src/Coveo.Connectors.EasyFilePusher/Properties/PublishProfiles/LinuxX64.pubxml b/src/Coveo.Connectors.EasyFilePusher/Properties/PublishProfiles/LinuxX64.pubxml index 89776f4..99717b8 100644 --- a/src/Coveo.Connectors.EasyFilePusher/Properties/PublishProfiles/LinuxX64.pubxml +++ b/src/Coveo.Connectors.EasyFilePusher/Properties/PublishProfiles/LinuxX64.pubxml @@ -1,17 +1,17 @@  - + Release - Any CPU - ..\..\bin\Release\netcoreapp3.1\publish\LinuxX64 + AnyCPU + ..\publish\LinuxX64 FileSystem - netcoreapp3.1 + net8.0 linux-x64 true - True - True + true + true \ No newline at end of file diff --git a/src/Coveo.Connectors.EasyFilePusher/Properties/PublishProfiles/MacOsx64.pubxml b/src/Coveo.Connectors.EasyFilePusher/Properties/PublishProfiles/MacOsx64.pubxml index 6298bf8..8af474d 100644 --- a/src/Coveo.Connectors.EasyFilePusher/Properties/PublishProfiles/MacOsx64.pubxml +++ b/src/Coveo.Connectors.EasyFilePusher/Properties/PublishProfiles/MacOsx64.pubxml @@ -1,17 +1,17 @@  - + Release Any CPU - ..\..\bin\Release\netcoreapp3.1\publish\MacOsx64 + ..\publish\MacOsx64 FileSystem - netcoreapp3.1 + net8.0 osx-x64 true - True - True + true + true \ No newline at end of file diff --git a/src/Coveo.Connectors.EasyFilePusher/Properties/PublishProfiles/WinX86.pubxml b/src/Coveo.Connectors.EasyFilePusher/Properties/PublishProfiles/WinX86.pubxml index 117c553..b3a21f7 100644 --- a/src/Coveo.Connectors.EasyFilePusher/Properties/PublishProfiles/WinX86.pubxml +++ b/src/Coveo.Connectors.EasyFilePusher/Properties/PublishProfiles/WinX86.pubxml @@ -1,18 +1,17 @@  - + Release Any CPU - ..\..\bin\Release\netcoreapp3.1\publish\WinX86 + ..\publish\WinX86 FileSystem - netcoreapp3.1 + net8.0 win-x86 true - True - False - True + true + true \ No newline at end of file diff --git a/version.json b/version.json new file mode 100644 index 0000000..08923a1 --- /dev/null +++ b/version.json @@ -0,0 +1,20 @@ +{ + "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", + "version": "1.0", + "assemblyVersion": { + "precision": "build" + }, + "nugetPackageVersion": { + "semVer": 2, + "precision": "build" + }, + "publicReleaseRefSpec": [ + "^refs/heads/master$" + ], + "cloudBuild": { + "buildNumber": { + "setVersionVariables": true, + "enabled": true + } + } + } \ No newline at end of file