diff --git a/.clangformat b/.clangformat new file mode 100644 index 0000000..47ce480 --- /dev/null +++ b/.clangformat @@ -0,0 +1,66 @@ +# Generated from CLion C/C++ Code Style settings +BasedOnStyle: LLVM +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: None +AlignOperands: Align +AllowAllArgumentsOnNextLine: false +AllowAllConstructorInitializersOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: None +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterReturnType: None +AlwaysBreakTemplateDeclarations: Yes +BreakBeforeBraces: Custom +BraceWrapping: + AfterCaseLabel: true + AfterClass: true + AfterControlStatement: Always + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterUnion: true + BeforeCatch: true + BeforeElse: true + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true +BreakBeforeBinaryOperators: None +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakInheritanceList: BeforeColon +ColumnLimit: 0 +CompactNamespaces: true +ContinuationIndentWidth: 4 +IndentCaseLabels: true +IndentPPDirectives: None +IndentWidth: 4 +KeepEmptyLinesAtTheStartOfBlocks: false +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: All +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PointerAlignment: Left +ReflowComments: false +SpaceAfterCStyleCast: true +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 0 +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInContainerLiterals: true +SpacesInParentheses: false +SpacesInSquareBrackets: false +TabWidth: 4 +UseTab: Never \ No newline at end of file diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..17221b3 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,243 @@ +# Удалите строку ниже, если вы хотите наследовать параметры .editorconfig из каталогов, расположенных выше в иерархии +root = true + +# Файлы C# +[*.cs] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 4 +tab_width = 4 + +# Предпочтения для this. и Me. +dotnet_style_qualification_for_event = false +dotnet_style_qualification_for_field = false +dotnet_style_qualification_for_method = false +dotnet_style_qualification_for_property = false + +# Упорядочение Using. +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = false +file_header_template = unset + +# Параметры использования ключевых слов языка и типов BCL. +dotnet_style_predefined_type_for_locals_parameters_members = true +dotnet_style_predefined_type_for_member_access = true + +# Предпочтения для скобок +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_operators = never_if_unnecessary +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity + +# Предпочтения модификатора +dotnet_style_require_accessibility_modifiers = for_non_interface_members + +# Выражения уровень предпочтения +dotnet_style_coalesce_expression = true +dotnet_style_collection_initializer = true +dotnet_style_explicit_tuple_names = true +dotnet_style_null_propagation = true +dotnet_style_object_initializer = true +dotnet_style_operator_placement_when_wrapping = beginning_of_line +dotnet_style_prefer_auto_properties = true +dotnet_style_prefer_compound_assignment = true +dotnet_style_prefer_conditional_expression_over_assignment = true +dotnet_style_prefer_conditional_expression_over_return = true +dotnet_style_prefer_inferred_anonymous_type_member_names = true +dotnet_style_prefer_inferred_tuple_names = true +dotnet_style_prefer_is_null_check_over_reference_equality_method = true +dotnet_style_prefer_simplified_boolean_expressions = true +dotnet_style_prefer_simplified_interpolation = true + +# Предпочтения для полей +dotnet_style_readonly_field = true + +# Настройки параметров +dotnet_code_quality_unused_parameters = all + +# Параметры подавления +dotnet_remove_unnecessary_suppression_exclusions = none + +#### Рекомендации по написанию кода C# #### + +# Предпочтения var +csharp_style_var_elsewhere = true +csharp_style_var_for_built_in_types = true +csharp_style_var_when_type_is_apparent = true + +# Члены, заданные выражениями +csharp_style_expression_bodied_accessors = true +csharp_style_expression_bodied_constructors = true +csharp_style_expression_bodied_indexers = true +csharp_style_expression_bodied_lambdas = true +csharp_style_expression_bodied_local_functions = false +csharp_style_expression_bodied_methods = true +csharp_style_expression_bodied_operators = true +csharp_style_expression_bodied_properties = true + +# Настройки соответствия шаблонов +csharp_style_pattern_matching_over_as_with_null_check = true +csharp_style_pattern_matching_over_is_with_cast_check = true +csharp_style_prefer_not_pattern = true +csharp_style_prefer_pattern_matching = true +csharp_style_prefer_switch_expression = true + +# Настройки проверки на null +csharp_style_conditional_delegate_call = true + +# Предпочтения модификатора +csharp_prefer_static_local_function = true +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async + +# Предпочтения для блоков кода +csharp_prefer_braces = true +csharp_prefer_simple_using_statement = true + +# Выражения уровень предпочтения +csharp_prefer_simple_default_expression = true +csharp_style_deconstructed_variable_declaration = true +csharp_style_implicit_object_creation_when_type_is_apparent = true +csharp_style_inlined_variable_declaration = true +csharp_style_pattern_local_over_anonymous_function = true +csharp_style_prefer_index_operator = true +csharp_style_prefer_range_operator = true +csharp_style_throw_expression = true +csharp_style_unused_value_assignment_preference = discard_variable +csharp_style_unused_value_expression_statement_preference = discard_variable + +# предпочтения для директивы using +csharp_using_directive_placement = outside_namespace + +#### Правила форматирования C# #### + +# Предпочтения для новых строк +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_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true +csharp_indent_labels = no_change +csharp_indent_switch_labels = true + +# Предпочтения для интервалов +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_name_and_open_parenthesis = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false + +# Предпочтения переноса +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +#### Стили именования #### + +# Правила именования + +dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i + +dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.types_should_be_pascal_case.symbols = types +dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case + +# Спецификации символов + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected + +# Стили именования + +dotnet_naming_style.pascal_case.capitalization = pascal_case + +dotnet_naming_style.begins_with_i.required_prefix = I +dotnet_naming_style.begins_with_i.capitalization = pascal_case + +# ReSharper properties +resharper_autodetect_indent_settings = true +resharper_blank_lines_around_local_method = 0 +resharper_braces_redundant = true +resharper_csharp_insert_final_newline = true +resharper_show_autodetect_configure_formatting_tip = false +resharper_use_indent_from_vs = false +resharper_csharp_wrap_lines = false +resharper_blank_lines_around_single_line_auto_property = 1 +resharper_blank_lines_around_single_line_property = 1 +resharper_csharp_blank_lines_around_single_line_property = 1 +resharper_blank_lines_after_block_statements = 0 +resharper_csharp_keep_blank_lines_in_code = 0 +resharper_wrap_chained_method_calls = chop_if_long + +# ReSharper inspection severities +resharper_arrange_redundant_parentheses_highlighting = hint +resharper_arrange_this_qualifier_highlighting = hint +resharper_arrange_type_member_modifiers_highlighting = hint +resharper_arrange_type_modifiers_highlighting = hint +resharper_built_in_type_reference_style_for_member_access_highlighting = hint +resharper_built_in_type_reference_style_highlighting = hint +resharper_enforce_do_while_statement_braces_highlighting = error +resharper_enforce_fixed_statement_braces_highlighting = error +resharper_enforce_foreach_statement_braces_highlighting = error +resharper_enforce_for_statement_braces_highlighting = error +resharper_enforce_if_statement_braces_highlighting = error +resharper_enforce_lock_statement_braces_highlighting = error +resharper_enforce_using_statement_braces_highlighting = error +resharper_enforce_while_statement_braces_highlighting = error +resharper_redundant_base_qualifier_highlighting = warning +resharper_suggest_var_or_type_built_in_types_highlighting = hint +resharper_suggest_var_or_type_elsewhere_highlighting = hint +resharper_suggest_var_or_type_simple_types_highlighting = hint +resharper_web_config_module_not_resolved_highlighting = warning +resharper_web_config_type_not_resolved_highlighting = warning +resharper_web_config_wrong_module_highlighting = warning + +# Named Arguments +resharper_arguments_anonymous_function = named +resharper_arguments_literal = named +resharper_arguments_named = named +resharper_arguments_other = named +resharper_arguments_string_literal = named + +# Line Breaks and Wrapping - Arrangement of Invocations +resharper_csharp_wrap_after_invocation_lpar = true +resharper_csharp_wrap_arguments_style = chop_if_long +resharper_csharp_wrap_before_invocation_rpar = true +resharper_max_invocation_arguments_on_line = 2 \ No newline at end of file diff --git a/.github/workflows/use-uniform-files.yml b/.github/workflows/use-uniform-files.yml new file mode 100644 index 0000000..183ac2e --- /dev/null +++ b/.github/workflows/use-uniform-files.yml @@ -0,0 +1,137 @@ +name: Use Uniform Files Workflow + +on: + schedule: + # Run every day at 00:00 UTC to check for updates + - cron: '0 0 * * *' + workflow_dispatch: + # Allow manual trigger + +jobs: + update-uniform-files: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + submodules: recursive + + - name: Check if Scripts submodule exists + id: check-submodule + run: | + if [ -d "Scripts" ] && [ -f "Scripts/.gitignore" ]; then + echo "submodule_exists=true" >> $GITHUB_OUTPUT + else + echo "submodule_exists=false" >> $GITHUB_OUTPUT + fi + + - name: Add Scripts submodule if not exists + if: steps.check-submodule.outputs.submodule_exists == 'false' + run: | + git submodule add https://github.com/linksplatform/Scripts.git Scripts + + - name: Update Scripts submodule + run: | + cd Scripts + git fetch origin + git checkout main + git pull origin main + cd .. + + - name: Check for uniform files updates + id: check-updates + run: | + files_updated=false + + # Check .gitignore + if [ -f "Scripts/.gitignore" ] && ( ! [ -f ".gitignore" ] || ! cmp -s "Scripts/.gitignore" ".gitignore" ); then + echo "Updating .gitignore" + cp "Scripts/.gitignore" ".gitignore" + files_updated=true + fi + + # Check .clangformat + if [ -f "Scripts/.clangformat" ] && ( ! [ -f ".clangformat" ] || ! cmp -s "Scripts/.clangformat" ".clangformat" ); then + echo "Updating .clangformat" + cp "Scripts/.clangformat" ".clangformat" + files_updated=true + fi + + # Check .editorconfig + if [ -f "Scripts/.editorconfig" ] && ( ! [ -f ".editorconfig" ] || ! cmp -s "Scripts/.editorconfig" ".editorconfig" ); then + echo "Updating .editorconfig" + cp "Scripts/.editorconfig" ".editorconfig" + files_updated=true + fi + + echo "files_updated=$files_updated" >> $GITHUB_OUTPUT + + - name: Create symlinks for uniform files (alternative approach) + if: steps.check-updates.outputs.files_updated == 'true' + run: | + # Remove existing files and create symlinks instead (optional approach) + # This ensures files stay in sync automatically + + # Uncomment the following lines if you prefer symlinks over copying: + # [ -f ".gitignore" ] && rm ".gitignore" && ln -s "Scripts/.gitignore" ".gitignore" + # [ -f ".clangformat" ] && rm ".clangformat" && ln -s "Scripts/.clangformat" ".clangformat" + # [ -f ".editorconfig" ] && rm ".editorconfig" && ln -s "Scripts/.editorconfig" ".editorconfig" + + echo "Files updated by copying. Consider using symlinks for automatic sync." + + - name: Commit and push changes + if: steps.check-updates.outputs.files_updated == 'true' + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + + # Add submodule changes + git add Scripts + + # Add uniform files changes + git add .gitignore .clangformat .editorconfig + + # Check if there are changes to commit + if git diff --staged --quiet; then + echo "No changes to commit" + exit 0 + fi + + git commit -m "Update uniform files from Scripts repository + + - Updated submodule Scripts to latest version + - Synchronized uniform files (.gitignore, .clangformat, .editorconfig) + + 🤖 Generated with [GitHub Actions]" + + git push + + - name: Check uniform files freshness + run: | + echo "Checking uniform files freshness..." + + # Check if uniform files are up to date with Scripts repository + files_fresh=true + + if [ -f "Scripts/.gitignore" ] && [ -f ".gitignore" ] && ! cmp -s "Scripts/.gitignore" ".gitignore"; then + echo "⚠️ .gitignore is not fresh" + files_fresh=false + fi + + if [ -f "Scripts/.clangformat" ] && [ -f ".clangformat" ] && ! cmp -s "Scripts/.clangformat" ".clangformat"; then + echo "⚠️ .clangformat is not fresh" + files_fresh=false + fi + + if [ -f "Scripts/.editorconfig" ] && [ -f ".editorconfig" ] && ! cmp -s "Scripts/.editorconfig" ".editorconfig"; then + echo "⚠️ .editorconfig is not fresh" + files_fresh=false + fi + + if [ "$files_fresh" = true ]; then + echo "✅ All uniform files are fresh" + else + echo "❌ Some uniform files are not fresh" + exit 1 + fi \ No newline at end of file