diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..00203be7 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +csharp_style_var_for_built_in_types = false:suggestion +csharp_style_var_when_type_is_apparent = false:suggestion +csharp_style_var_elsewhere = false:suggestion +dotnet_diagnostic.IDE0008.severity = error +dotnet_diagnostic.IDE0007.severity = silent + +csharp_preserve_single_line_statements = false +csharp_preserve_single_line_blocks = false +max_line_length = 999 diff --git a/.github/workflows/format.yaml b/.github/workflows/format.yaml index 02caeacf..c8b7ad39 100644 --- a/.github/workflows/format.yaml +++ b/.github/workflows/format.yaml @@ -1,81 +1,91 @@ -name: Format +name: format_check on: workflow_call: jobs: format_check: - name: Verify Rider formatting runs-on: ubuntu-latest + steps: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: '8.0.x' + dotnet-version: 8.0.x - name: Install JetBrains ReSharper Global Tools (jb) + shell: bash run: | + set -euo pipefail + cd /tmp dotnet tool install --global JetBrains.ReSharper.GlobalTools echo "$HOME/.dotnet/tools" >> "$GITHUB_PATH" - - name: Run Rider cleanup (dry-check via diff) + - name: Discover all solutions + id: discover + shell: bash run: | - jb cleanupcode \ - --profile="Built-in: Reformat Code" \ - --no-build \ - --verbosity=WARN \ - --include="**/*.cs" \ - --exclude="**/bin/**" \ - --exclude="**/obj/**" \ - --exclude="**/.idea/**" \ - . + set -euo pipefail + git ls-files '*.sln' > solutions.txt || true + echo "Found solution files:" + cat solutions.txt || true + count=$(wc -l < solutions.txt | tr -d ' ') + echo "solution_count=$count" >> "$GITHUB_OUTPUT" - - name: Detect formatting changes (code files only) - id: diff + - name: Check formatting + if: steps.discover.outputs.solution_count != '0' + shell: bash run: | - LIST_FILE="$RUNNER_TEMP/files_needing_format.txt" - CHANGED="$(git status --porcelain --untracked-files=no -- '*.cs' '*.csproj' '*.sln' | awk '{print $2}' | sort -u)" - if [[ -n "$CHANGED" ]]; then - echo "changed=true" >> "$GITHUB_OUTPUT" - echo "$CHANGED" | tee "$LIST_FILE" - echo "list_file=$LIST_FILE" >> "$GITHUB_OUTPUT" - else - echo "changed=false" >> "$GITHUB_OUTPUT" - echo "list_file=" >> "$GITHUB_OUTPUT" - fi + set -euo pipefail + while IFS= read -r sln; do + [ -z "$sln" ] && continue + echo "==> Restoring $sln" + dotnet restore "$sln" - - name: Summarize unformatted files - if: steps.diff.outputs.changed == 'true' - run: | - { - echo "### ❌ Formatting check failed" - echo - echo "The following code files are not formatted properly:" - echo - echo '```' - cat "${{ steps.diff.outputs.list_file }}" - echo '```' - echo - echo "➡️ Run Rider **Code Cleanup** (Built-in: *Reformat Code*) locally and commit." - } >> "$GITHUB_STEP_SUMMARY" + echo "==> Running jb cleanupcode" + jb cleanupcode "$sln" \ + --profile="Built-in: Reformat Code" \ + --no-build \ + --verbosity=WARN \ + --include="Assets/**/*.cs" \ + --exclude="**/bin/**" \ + --exclude="**/obj/**" \ + --exclude="**/.idea/**" \ + --exclude="**/Library/**" \ + --exclude="**/Logs/**" \ + --exclude="**/Temp/**" + done < solutions.txt - - name: Annotate files in Checks UI - if: steps.diff.outputs.changed == 'true' + - name: Diff & annotate unformatted files (fail if any) + if: steps.discover.outputs.solution_count != '0' + shell: bash run: | - while IFS= read -r f; do - echo "::error file=$f,title=Not formatted::Run Rider Code Cleanup (Built-in: Reformat Code) and commit." - done < "${{ steps.diff.outputs.list_file }}" + set -euo pipefail + DIFF_FILE=cleanup.diff + git --no-pager diff --unified=0 -- 'Assets/**/*.cs' > "$DIFF_FILE" || true - - name: Revert any changes (always clean workspace) - if: always() - run: | - git restore --staged . - git checkout -- . - git clean -fd + if [ -s "$DIFF_FILE" ]; then + echo "Unformatted changes detected in Assets/:" + awk ' + BEGIN { file="" } + /^\+\+\+ b\// { sub(/^\+\+\+ b\//, "", $0); file=$0; next } + /^@@ / { + match($0, /\+([0-9]+)(,([0-9]+))?/, m) + start = m[1] + printf("::error file=%s,line=%d,title=Formatting differs::Run Rider Code Cleanup (or jb cleanupcode) locally and commit.\n", file, start) + } + ' "$DIFF_FILE" + echo "::error title=Formatting check failed::Some files under Assets/ differ from the configured formatting." + exit 1 + else + echo "Formatting is clean in Assets/." + fi - - name: Fail job if formatting needed - if: steps.diff.outputs.changed == 'true' - run: exit 1 + - name: No solutions found (informative) + if: steps.discover.outputs.solution_count == '0' + run: echo "No .sln files found; skipping formatting check." diff --git a/.gitignore b/.gitignore index 16e1720e..7d75db7d 100644 --- a/.gitignore +++ b/.gitignore @@ -45,9 +45,7 @@ # Autogenerated VS/MD/Consulo solution and project files ExportedObj/ .consulo/ -*.csproj *.unityproj -*.sln *.suo *.tmp *.user diff --git a/.idea/.idea.yahalom/.idea/codeStyles/Project.xml b/.idea/.idea.yahalom/.idea/codeStyles/Project.xml index 78e228a7..5c693b5a 100644 --- a/.idea/.idea.yahalom/.idea/codeStyles/Project.xml +++ b/.idea/.idea.yahalom/.idea/codeStyles/Project.xml @@ -21,6 +21,9 @@