### Setup .NET SDK Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/action-yml-reference.md Installs the specified .NET SDK version using the actions/setup-dotnet action. ```yaml - name: Setup .NET uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5 with: dotnet-version: ${{ inputs.dotnet-version }} ``` -------------------------------- ### Basic Workflow Example Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/DOCUMENTATION_INDEX.md A simple example demonstrating the basic setup for a workflow. This is a good starting point for creating your own workflows. ```yaml name: Basic Inspect Code Workflow on: [push] jobs: inspect: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Run ReSharper Inspect Code uses: jetbrains/resharper-inspectcode@v1 with: solution: '**/*.sln' output_path: 'inspect_results' report_type: 'sarif' ``` -------------------------------- ### Minimal Workflow Setup Example Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/permissions-and-setup.md Example of a GitHub Actions workflow with minimal permissions for standard analysis. ```yaml name: Analysis on: [push] permissions: contents: read jobs: analyze: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./MySolution.sln upload-sarif: false format: Text ``` -------------------------------- ### Basic Code Analysis Setup Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/usage-examples.md This snippet shows the simplest way to set up InspectCode to analyze a solution with default settings. It installs the necessary SDK and action, analyzes the solution, and generates a SARIF report for GitHub code scanning. ```yaml name: Code Analysis on: [push, pull_request] jobs: inspect: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Run InspectCode uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./MySolution.sln ``` -------------------------------- ### Full Workflow Setup for Code Scanning Integration Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/permissions-and-setup.md Example of a GitHub Actions workflow configured for full code scanning integration with SARIF upload. ```yaml name: Analysis with Code Scanning on: [push, pull_request] permissions: contents: read security-events: write jobs: analyze: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./MySolution.sln upload-sarif: true format: Sarif ``` -------------------------------- ### Setup .NET SDK in GitHub Actions Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/execution-details.md Configures the .NET SDK version for the GitHub Actions runner. Use this to ensure the correct .NET environment for subsequent build or tool installation steps. ```yaml - name: Setup .NET uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 with: dotnet-version: 10.x # or 8.0.100, 9.x, etc. ``` -------------------------------- ### Multiple Workflows Example Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/DOCUMENTATION_INDEX.md This example shows how to set up multiple workflows: a fast pull request analysis and a more comprehensive daily analysis. This balances quick feedback with thorough code inspection. ```yaml name: Multiple Workflows on: push: branches: [ main ] pull_request: branches: [ main ] jobs: fast_pr_inspect: if: github.event_name == 'pull_request' runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 with: fetch-depth: 0 - name: Run ReSharper Inspect Code (Fast PR) uses: jetbrains/resharper-inspectcode@v1 with: solution: '**/*.sln' output_path: 'inspect_results_pr' report_type: 'sarif' severity_threshold: 'suggestion' daily_comprehensive_inspect: if: github.event_name == 'push' && github.ref == 'refs/heads/main' runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 with: fetch-depth: 0 - name: Run ReSharper Inspect Code (Daily) uses: jetbrains/resharper-inspectcode@v1 with: solution: '**/*.sln' output_path: 'inspect_results_daily' report_type: 'sarif' severity_threshold: 'hint' ``` -------------------------------- ### Install ReSharper Global Tools Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/permissions-and-setup.md Installs the ReSharper Global Tools via the .NET CLI. ```bash dotnet tool install JetBrains.ReSharper.GlobalTools --global --version 2026.1.0.1 ``` -------------------------------- ### Example inspectCode Command Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/execution-details.md This example demonstrates a typical `jb inspectcode` command with common options for analysis and output configuration. It shows how to specify the solution file, output format, severity level, number of jobs, and build/target parameters. ```bash jb inspectcode ./MySolution.sln \ --output=results.sarif.json \ --format=Sarif \ --severity=SUGGESTION \ --jobs=4 \ --build=True \ --target=Build ``` -------------------------------- ### Automatic .NET SDK Setup Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/permissions-and-setup.md Configures the .NET SDK version using the 'actions/setup-dotnet' action. ```yaml - uses: JetBrains/ReSharper-InspectCode@v0.13 with: dotnet-version: 10.x ``` -------------------------------- ### Enterprise Setup Workflow Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/DOCUMENTATION_INDEX.md This workflow provides a template for an enterprise-level setup, including comprehensive analysis and integration with existing CI/CD pipelines. It assumes a more complex environment. ```yaml name: Enterprise Setup on: schedule: - cron: '0 0 * * *' # Run daily at midnight workflow_dispatch: # Allow manual triggering jobs: enterprise_inspect: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 with: fetch-depth: 0 - name: Setup .NET uses: actions/setup-dotnet@v3 with: dotnet-version: '6.0.x' - name: Run ReSharper Inspect Code uses: jetbrains/resharper-inspectcode@v1 with: solution: '**/*.sln' output_path: 'inspect_results_enterprise' report_type: 'sarif' severity_threshold: 'error' vs_version: '2022' fail_on_error: true ``` -------------------------------- ### Action YAML Reference - Runs Schema (Composite Action) Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/DOCUMENTATION_INDEX.md Details the steps involved in the composite action's execution, including setup, tool installation, code inspection, and SARIF upload. ```yaml runs: using: 'composite' steps: - name: Setup .NET uses: actions/setup-dotnet@v3 with: dotnet-version: '6.0.x' # Example version, adjust as needed - name: Install ReSharper Tools shell: pwsh run: | # Commands to install ReSharper Command Line Tools # Example: Invoke-WebRequest -Uri 'https://download.jetbrains.com/resharper/ReSharperCommandlineTools.2023.1.3.zip' -OutFile ReSharperCommandlineTools.zip # Expand-Archive ReSharperCommandlineTools.zip -DestinationPath . echo "Installing ReSharper Tools..." - name: Inspect Code shell: pwsh run: | # Command to execute ReSharper InspectCode # Example: . ools\InspectCode.exe --ப்படுத்தி --output=inspect_results --reportType=sarif **/*.sln echo "Running Inspect Code..." - name: Upload SARIF Report if: steps.inspect.outputs.sarif_file_path uses: github/codeql-action/upload-sarif@v2 with: sarif_file: ${{ steps.inspect.outputs.sarif_file_path }} ``` -------------------------------- ### Install ReSharper Command-Line Tools Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/action-yml-reference.md Installs the ReSharper command-line tools globally using the 'dotnet tool install' command. ```yaml - name: Install ReSharper command line tools shell: bash run: dotnet tool install JetBrains.ReSharper.GlobalTools --global --version ${{ inputs.tool-version }} ``` -------------------------------- ### Troubleshooting - Diagnostic Workflow Example Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/DOCUMENTATION_INDEX.md A complete workflow example designed for troubleshooting. It enables detailed logging and verbosity to help diagnose issues during execution. ```yaml name: Diagnostic Workflow on: [push] jobs: diagnostic_inspect: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Run ReSharper Inspect Code (Diagnostic) uses: jetbrains/resharper-inspectcode@v1 with: solution: '**/*.sln' output_path: 'diagnostic_results' report_type: 'sarif' verbosity: 'trace' log_file: 'resharper_inspect.log' ``` -------------------------------- ### Install ReSharper Extensions Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/configuration.md Installs specified ReSharper extensions before running the analysis. Extensions are comma-separated. ```yaml with: solution: ./MySolution.sln eXtensions: "ReSharper.NUnit,ReSharper.Rider" ``` -------------------------------- ### Debug Configuration Example Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/configuration.md Example configuration for running InspectCode in debug mode with detailed logging and performance measurement. ```yaml - name: Run InspectCode uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./src/MyProject.sln output: ./debug/analysis.xml format: Xml upload-sarif: "false" verbosity: "TRACE" debug: "true" measure: "TIMELINE" ``` -------------------------------- ### Custom Self-Hosted Runner Configuration Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/permissions-and-setup.md Example configuration for using a custom self-hosted runner. ```yaml runs-on: [self-hosted, linux, x64] ``` -------------------------------- ### Output and Reporting Workflow Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/DOCUMENTATION_INDEX.md This example focuses on configuring the output and reporting of the code inspection. It shows how to generate different report types and manage the output location. ```yaml name: Output and Reporting on: [push] jobs: inspect: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Run ReSharper Inspect Code (SARIF) uses: jetbrains/resharper-inspectcode@v1 with: solution: '**/*.sln' output_path: 'sarif_output' report_type: 'sarif' - name: Run ReSharper Inspect Code (HTML) uses: jetbrains/resharper-inspectcode@v1 with: solution: '**/*.sln' output_path: 'html_output' report_type: 'html' ``` -------------------------------- ### Minimal Permissions Setup Workflow Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/DOCUMENTATION_INDEX.md This workflow demonstrates how to configure the action with the minimum required permissions. This is useful for enhancing security by adhering to the principle of least privilege. ```yaml name: Minimal Permissions Setup on: [push] jobs: inspect: runs-on: ubuntu-latest permissions: contents: read # Read access to repository contents # No other permissions are strictly required for basic inspection steps: - name: Checkout code uses: actions/checkout@v3 - name: Run ReSharper Inspect Code uses: jetbrains/resharper-inspectcode@v1 with: solution: '**/*.sln' output_path: 'inspect_results' report_type: 'sarif' ``` -------------------------------- ### Caching .NET Installation and NuGet Packages Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/permissions-and-setup.md Speeds up workflow runs by caching .NET installations and NuGet packages. ```yaml - name: Setup .NET uses: actions/setup-dotnet@v5 with: dotnet-version: 10.x - name: Cache NuGet packages uses: actions/cache@v3 with: path: ~/.nuget/packages key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} restore-keys: | ${{ runner.os }}-nuget- ``` -------------------------------- ### Install ReSharper Global Tools via Bash Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/execution-details.md Installs the ReSharper command-line tools globally using the dotnet CLI. This makes the 'jb' command available for code inspections. ```bash dotnet tool install JetBrains.ReSharper.GlobalTools --global --version ${{ inputs.tool-version }} ``` -------------------------------- ### Combined Filtering Example Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/configuration.md Demonstrates combining project, include, and exclude filters for precise analysis targeting. ```yaml with: solution: ./MySolution.sln project: "**/*.csproj" include: "**/*.cs" exclude: "**/Generated/**" ``` -------------------------------- ### Install Extensions from Custom NuGet Feed Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/configuration.md Installs extensions from a specified custom NuGet feed. Multiple sources can be provided, separated by semicolons. ```yaml with: solution: ./MySolution.sln eXtensions: "MyCompanyExtension" source: "https://my-nuget-feed.com/v3/index.json" ``` -------------------------------- ### Matrix Testing Workflow Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/DOCUMENTATION_INDEX.md This example demonstrates how to use matrix testing to run code inspections across different configurations, such as various .NET versions or operating systems. ```yaml name: Matrix Testing on: [push] jobs: inspect: runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, windows-latest] dotnet-version: ['3.1.x', '6.0.x', '7.0.x'] steps: - name: Checkout code uses: actions/checkout@v3 - name: Setup .NET uses: actions/setup-dotnet@v3 with: dotnet-version: ${{ matrix.dotnet-version }} - name: Run ReSharper Inspect Code uses: jetbrains/resharper-inspectcode@v1 with: solution: '**/*.sln' output_path: 'inspect_results' report_type: 'sarif' ``` -------------------------------- ### Verify PowerShell Installation Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/troubleshooting-and-diagnostics.md Check if PowerShell Core is installed and accessible on Linux/macOS runners. ```yaml - name: Check PowerShell run: which pwsh && pwsh --version - uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./MySolution.sln ``` -------------------------------- ### Troubleshooting - Version and Help Information Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/DOCUMENTATION_INDEX.md Shows how to retrieve version and help information for the ReSharper Inspect Code tool, useful for verifying installation and understanding available options. ```bash # Example commands to get version and help info # Navigate to the tools directory (adjust path if necessary) cd ./tools # Display version information ./InspectCode.exe --version # Display help information ./InspectCode.exe --help ``` -------------------------------- ### Specify Custom .NET Core Runtime Path Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/configuration.md Use this to point to a specific .NET Core runtime installation. Ensure the provided path is valid. ```yaml with: solution: ./MySolution.sln dotnetcore: "/usr/local/share/dotnet/dotnet" ``` -------------------------------- ### Enterprise CI Pipeline Configuration Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/configuration.md Example configuration for a comprehensive CI pipeline, including solution-wide analysis, filtering, and output settings. ```yaml - name: Run InspectCode uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./src/Enterprise.sln settings: ./.editorconfig.resharper output: ./build/reports/analysis.sarif format: Sarif upload-sarif: "true" exclude: "**/Generated/**,**/Migrations/**" include: "**/*.cs" sEverity: "WARNING" jobs: 8 verbosity: "INFO" build: "true" target: "Build" properties: "Configuration=Release;Platform=x64" tool-version: "2026.1.0.1" dotnet-version: "8.0.x" ``` -------------------------------- ### Example InspectCode Action Usage Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/inputs-reference.md Demonstrates how to use the InspectCode action in a GitHub Actions workflow, specifying solution path, output format, and severity level. ```yaml - name: Run InspectCode uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./src/MyProject.sln format: Sarif output: ./reports/analysis.sarif sEverity: WARNING jobs: 4 upload-sarif: true ``` -------------------------------- ### Analyze Specific Projects with Filtering Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/usage-examples.md Focus analysis on specific projects within a solution using glob patterns. This example analyzes core projects, includes all C# files, and excludes test directories. ```yaml - name: Analyze Core Projects uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./src/MySolution.sln project: "**/Core/**/*.csproj" include: "**/*.cs" exclude: "**/Tests/**" ``` -------------------------------- ### Configure ReSharper Tool Version Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/permissions-and-setup.md Examples of specifying the ReSharper tool version using semantic versioning. ```yaml tool-version: "2026.1.0.1" # Specific version tool-version: "2026.1" # Latest 2026.1.x tool-version: "2026" # Latest 2026.x.x ``` -------------------------------- ### GitHub Actions Workflow for Performance Optimization Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/MANIFEST.txt This example illustrates how to configure the ReSharper InspectCode GitHub Action for performance optimization during analysis. ```yaml name: ReSharper InspectCode Performance on: [push] jobs: inspectcode: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Run ReSharper InspectCode with performance options uses: jetbrains/resharper-inspectcode-action@v0.13 with: solution: "YourSolution.sln" performance-level: "high" # Additional performance-related configurations ``` -------------------------------- ### .NET SDK Version Configuration Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/configuration.md Specify the .NET SDK version to install for the analysis environment. Supports exact versions, minor/major ranges, and the latest available version. ```yaml with: dotnet-version: "8.0.100" ``` -------------------------------- ### Local Debugging with ReSharper Tools Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/troubleshooting-and-diagnostics.md Test analysis locally using the ReSharper command-line tools with equivalent setup to the GitHub Action. ```bash # Install .NET dotnet --version # Install ReSharper donet tool install JetBrains.ReSharper.GlobalTools --global --version 2026.1.0.1 # Run analysis jb inspectcode ./MySolution.sln --output=analysis.sarif --format=Sarif --verbosity=TRACE ``` -------------------------------- ### Basic GitHub Actions Workflow for ReSharper InspectCode Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/MANIFEST.txt A minimal example demonstrating how to integrate the ReSharper InspectCode GitHub Action into a workflow for a complete code analysis. ```yaml name: ReSharper InspectCode CI on: [push] jobs: inspectcode: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Run ReSharper InspectCode uses: jetbrains/resharper-inspectcode-action@v0.13 with: solution: "YourSolution.sln" ``` -------------------------------- ### GitHub Actions Workflow with Debug and Logging Options Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/MANIFEST.txt Example demonstrating how to enable debug and logging options for the ReSharper InspectCode GitHub Action to aid in troubleshooting. ```yaml name: ReSharper InspectCode Debugging on: [push] jobs: inspectcode: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Run ReSharper InspectCode with debug enabled uses: jetbrains/resharper-inspectcode-action@v0.13 with: solution: "YourSolution.sln" debug: "true" verbosity: "detailed" ``` -------------------------------- ### Standard CI/CD Configuration Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/configuration.md Configure for a standard CI/CD pipeline. This setup includes SARIF output, uploading to GitHub code scanning, and filtering results by severity. ```yaml - uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./src/MySolution.sln output: inspectcode.sarif format: Sarif upload-sarif: true sEverity: WARNING jobs: 4 ``` -------------------------------- ### Pull Request Analysis Configuration Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/configuration.md Example configuration for analyzing code changes in a pull request, focusing on specific severity and disabling SWEA. ```yaml - name: Run InspectCode uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./src/MyProject.sln output: inspectcode.sarif format: Sarif upload-sarif: "true" sEverity: "SUGGESTION" jobs: 0 no-swea: "true" verbosity: "WARN" ``` -------------------------------- ### Minimal Permissions Setup for Analysis Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/usage-examples.md This workflow performs code analysis with minimal permissions, suitable for pull requests where code scanning upload is not required. It uses HTML format for output and uploads the report as an artifact. Requires only 'contents: read' permission. ```yaml name: Analysis without Code Scanning Upload on: [pull_request] jobs: analyze: runs-on: ubuntu-latest permissions: contents: read steps: - uses: actions/checkout@v4 - name: Run InspectCode uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./src/MySolution.sln format: Html output: analysis.html upload-sarif: "false" - name: Upload Analysis uses: actions/upload-artifact@v3 with: name: analysis-report path: analysis.html ``` -------------------------------- ### Parsing SARIF Reports with jq Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/report-formats.md Command-line examples using 'jq' to extract specific information from SARIF files. Useful for counting issues, listing rule IDs, filtering by severity, and extracting file locations. ```bash # Count total issues jq '.runs[0].results | length' analysis.sarif.json # List all rule IDs jq -r '.runs[0].results[].ruleId' analysis.sarif.json | sort | uniq # Extract issues by severity jq '.runs[0].results[] | select(.level == "error")' analysis.sarif.json # Get file paths and line numbers jq -r '.runs[0].results[] | "\(.locations[0].physicalLocation.artifactLocation.uri):\(.locations[0].physicalLocation.region.startLine)"' \ analysis.sarif.json ``` -------------------------------- ### GitHub Actions Workflow with Custom Settings and Filtering Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/MANIFEST.txt An example showcasing advanced configuration of the ReSharper InspectCode GitHub Action, including custom analysis settings and file filtering. ```yaml name: ReSharper InspectCode Custom Config on: [push] jobs: inspectcode: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Run ReSharper InspectCode with custom settings uses: jetbrains/resharper-inspectcode-action@v0.13 with: solution: "YourSolution.sln" severity: "suggestion" include-files: "**/src/**.cs" exclude-files: "**/Migrations/**" # Other custom settings can be applied here ``` -------------------------------- ### Generate SARIF and HTML Reports Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/usage-examples.md This example shows how to generate both SARIF and HTML reports for code analysis. It runs InspectCode twice with different formats and outputs, then uploads both reports as artifacts. ```yaml name: Multi-Format Analysis on: [push] jobs: analyze: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: SARIF Report uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./src/MySolution.sln output: ./reports/analysis.sarif format: Sarif upload-sarif: "true" - name: HTML Report uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./src/MySolution.sln output: ./reports/analysis.html format: Html upload-sarif: "false" - name: Upload Artifacts uses: actions/upload-artifact@v3 with: name: analysis-reports path: ./reports/ ``` -------------------------------- ### Test NuGet Source Access Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/troubleshooting-and-diagnostics.md Test network connectivity to NuGet sources by listing available sources. This helps diagnose 'Tool Installation Fails' errors related to network issues. ```yaml - name: Test NuGet Access run: dotnet nuget list source - uses: JetBrains/ReSharper-InspectCode@v0.13 with: tool-version: "2026.1.0.1" ``` -------------------------------- ### Mono Runtime Configuration Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/configuration.md Configure the Mono runtime for macOS/Linux environments. Specify a custom Mono installation path or disable Mono detection by setting it to an empty string. ```yaml with: solution: ./MySolution.sln mono: "/Library/Frameworks/Mono.framework/Versions/Current/bin/mono" ``` ```yaml with: solution: ./MySolution.sln mono: "" ``` -------------------------------- ### GitHub Actions Workflow with Multiple Output Formats Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/MANIFEST.txt Example of using the ReSharper InspectCode GitHub Action to generate analysis reports in multiple formats, including SARIF, XML, and HTML. ```yaml name: ReSharper InspectCode Multi-Format Report on: [push] jobs: inspectcode: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Run ReSharper InspectCode with multiple formats uses: jetbrains/resharper-inspectcode-action@v0.13 with: solution: "YourSolution.sln" output-formats: "sarif,xml,html" ``` -------------------------------- ### Composite Action Runs Structure Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/action-yml-reference.md Defines the structure for a composite action, outlining the sequence of steps executed, including setup, tool installation, inspection, and conditional SARIF upload. ```yaml runs: using: composite steps: - step1: Setup .NET - step2: Install ReSharper tools - step3: Execute inspection - step4: Upload SARIF (conditional) ``` -------------------------------- ### Analyze Pre-built Solution Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/permissions-and-setup.md Skip the build step if the solution is already built. Use this to save time and resources. ```yaml - name: Build Solution run: dotnet build ./src/MySolution.sln --configuration Release - name: Analyze uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./src/MySolution.sln no-build: true ``` -------------------------------- ### Display Tool Version and Help Information Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/troubleshooting-and-diagnostics.md Display the tool version and configuration information. Note that using 'version: true' or 'help: true' will exit the tool without performing analysis. ```yaml - uses: JetBrains/ReSharper-InspectCode@v0.13 with: version: "true" help: "true" upload-sarif: "false" ``` -------------------------------- ### Recommended Runner Configuration Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/permissions-and-setup.md Specifies 'ubuntu-latest' as the recommended runner for optimal analysis performance. ```yaml jobs: analyze: runs-on: ubuntu-latest # Recommended for most scenarios ``` -------------------------------- ### Basic Usage of ReSharper Inspect Code Action Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/README.md Demonstrates the minimal configuration required to run the ReSharper Inspect Code action, specifying the solution file to analyze. ```yaml uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./MySolution.sln ``` -------------------------------- ### Build Solution Before Analysis Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/permissions-and-setup.md Configure the action to build the solution automatically before running the analysis. Ensures the code is up-to-date. ```yaml - uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./src/MySolution.sln build: true target: Build properties: "Configuration=Release" ``` -------------------------------- ### Cache ReSharper Tool Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/permissions-and-setup.md Cache the ReSharper tool installation to speed up subsequent runs. Reduces download time and improves workflow efficiency. ```yaml - name: Cache ReSharper Tool uses: actions/cache@v3 with: path: ~/.dotnet/tools key: ${{ runner.os }}-resharper-${{ inputs.tool-version }} restore-keys: | ${{ runner.os }}-resharper- - uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./MySolution.sln ``` -------------------------------- ### Action YAML Reference - Execution Script Sections Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/DOCUMENTATION_INDEX.md Illustrates the different sections within the execution script, covering argument initialization, environment variable parsing, command invocation, and output handling. ```powershell # Example PowerShell script sections # Argument Initialization param( [string]$SolutionPath = "**/*.sln", [string]$OutputPath = "inspect_results", [string]$ReportType = "sarif" ) # Environment Variable Parsing $env:PATH = ".\tools;" + $env:PATH # Command Invocation $inspectArgs = @( "--ப்படுத்தி", "--output=$OutputPath", "--reportType=$ReportType", "$SolutionPath" ) . # Exit Code Handling if ($LASTEXITCODE -ne 0) { Write-Error "InspectCode failed with exit code $LASTEXITCODE" exit $LASTEXITCODE } # Output Emission Write-Host "Inspection complete. Report saved to $OutputPath.$ReportType" ``` -------------------------------- ### Parsing XML Reports with xmllint Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/report-formats.md Command-line example using 'xmllint' with XPath to count all 'Issue' elements within an XML report file. ```bash # Count all issues xmllint --xpath "count(//Issue)" analysis.xml ``` -------------------------------- ### Get Issues in Specific File Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/report-formats.md Retrieves all issues located within a specific file ('MyFile.cs') from an analysis XML file. Requires `xmllint`. ```bash xmllint --xpath "//File[@Name='MyFile.cs']/Issue" analysis.xml ``` -------------------------------- ### Prepare Output Directory Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/permissions-and-setup.md Create the output directory for analysis results if it does not exist. Ensures the action has a place to save reports. ```yaml - name: Prepare Output Directory run: mkdir -p ./build/reports - uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./MySolution.sln output: ./build/reports/analysis.sarif ``` -------------------------------- ### Analyze Pre-built Solution Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/usage-examples.md Skips the build process and directly analyzes an already built solution. This is useful when build artifacts are available from a previous step or job. ```yaml - name: Analyze (Pre-built) uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./src/MySolution.sln no-build: "true" ``` -------------------------------- ### Multiple Output Formats (SARIF and HTML) Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/README.md Demonstrates using the action to generate analysis reports in both SARIF and HTML formats, with conditional SARIF upload. ```yaml - uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./MySolution.sln format: Sarif output: analysis.sarif upload-sarif: true - uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./MySolution.sln format: Html output: analysis.html upload-sarif: false ``` -------------------------------- ### Comprehensive Daily Build Workflow Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/usage-examples.md A daily build workflow that performs a comprehensive analysis, including solution-wide analysis and reporting all issue levels down to HINT. It runs on a schedule and uses all available CPU cores. ```yaml name: Comprehensive Daily Analysis on: schedule: - cron: '0 2 * * *' # 2 AM UTC daily workflow_dispatch: jobs: full-analysis: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Full InspectCode uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./src/MyApp.sln swea: "true" sEverity: HINT jobs: 0 output: ./reports/daily-analysis.sarif format: Sarif upload-sarif: "true" verbosity: INFO ``` -------------------------------- ### Build Before Analysis Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/configuration.md Configure whether to build the solution before analysis. The 'build' parameter defaults to 'true', and a custom MSBuild target can be specified. ```yaml with: solution: ./MySolution.sln build: "true" target: Build ``` -------------------------------- ### Minimal Configuration Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/configuration.md Use the minimal configuration to analyze a solution with default ReSharper settings. This is useful for quick checks or when no specific overrides are needed. ```yaml - uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./YourSolution.sln ``` -------------------------------- ### Check ReSharper Tool Version Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/usage-examples.md Retrieves and displays the version information of the ReSharper InspectCode tool without performing any code analysis. Useful for verifying tool installation and availability. ```yaml - name: Check Tool Version uses: JetBrains/ReSharper-InspectCode@v0.13 with: version: "true" upload-sarif: "false" ``` -------------------------------- ### Build Configuration Workflow Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/DOCUMENTATION_INDEX.md This workflow demonstrates how to integrate code inspection with your build process. It ensures that code quality is checked as part of the build. ```yaml name: Build Configuration Integration on: [push] jobs: build_and_inspect: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Setup .NET uses: actions/setup-dotnet@v3 with: dotnet-version: '6.0.x' - name: Build Solution run: dotnet build '**/*.sln' - name: Run ReSharper Inspect Code uses: jetbrains/resharper-inspectcode@v1 with: solution: '**/*.sln' output_path: 'inspect_results' report_type: 'sarif' ``` -------------------------------- ### Comprehensive Daily Analysis Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/README.md A detailed daily analysis configuration including solution-wide analysis, automatic build, and SARIF upload. ```yaml - uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./MySolution.sln swea: true sEverity: HINT jobs: 0 format: Sarif upload-sarif: true ``` -------------------------------- ### Generate and Parse XML Report Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/report-formats.md Example of configuring ReSharper InspectCode to output results in XML format. Includes a command to count the total number of issues found using 'xmllint'. ```yaml - uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./MySolution.sln format: Xml output: ./analysis.xml - name: Parse XML Results run: | xmllint --xpath "count(//Issue)" analysis.xml ``` -------------------------------- ### Primary Configuration Method Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/configuration.md Configure the InspectCode action using the 'with:' block in your workflow YAML file. Specify essential parameters like solution path, output format, and analysis jobs. ```yaml - name: Run InspectCode uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./MySolution.sln format: Sarif output: ./reports/analysis.sarif jobs: 4 sEverity: WARNING ``` -------------------------------- ### Cache Global Tools for ReSharper InspectCode Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/troubleshooting-and-diagnostics.md Implement caching for global tools to speed up subsequent runs and mitigate 'Tool Installation Fails' errors. This involves caching the dotnet tools directory. ```yaml - name: Cache Global Tools uses: actions/cache@v3 with: path: ~/.dotnet/tools key: resharper-${{ inputs.tool-version }} - uses: JetBrains/ReSharper-InspectCode@v0.13 with: tool-version: "2026.1.0.1" ``` -------------------------------- ### Create Minimal Reproduction Workflow Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/troubleshooting-and-diagnostics.md Set up a minimal GitHub Actions workflow to reproduce an issue. This includes checking out code, running ReSharper InspectCode with debug options, and uploading the report as an artifact. ```yaml name: Minimal Repro on: [workflow_dispatch] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./MySolution.sln format: Sarif output: analysis.sarif verbosity: VERBOSE debug: "true" - name: Upload Report for Analysis if: always() uses: actions/upload-artifact@v3 with: name: debug-report path: analysis.sarif ``` -------------------------------- ### Complete Diagnostic Workflow Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/troubleshooting-and-diagnostics.md A comprehensive workflow to gather system, .NET, and solution information, run analysis with full diagnostics, and validate the report. ```yaml name: Diagnostics on: [workflow_dispatch] jobs: diagnose: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: System Information run: | echo "=== OS ===" uname -a echo "=== Disk Space ===" df -h echo "=== Memory ===" free -h - name: .NET Information run: | dotnet --version dotnet --list-sdks dotnet --list-runtimes - name: Check Solution File run: | echo "=== Solution Files ===" find . -name "*.sln" -type f echo "=== Project Files ===" find . -name "*.csproj" -type f | head -10 - name: Version Check uses: JetBrains/ReSharper-InspectCode@v0.13 with: version: "true" upload-sarif: "false" - name: Run with Full Diagnostics id: analysis uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./MySolution.sln format: Sarif output: ./analysis.sarif upload-sarif: false verbosity: TRACE debug: "true" measure: TIMELINE dumpIssuesTypes: "true" - name: Validate Report if: always() run: | if [ -f analysis.sarif ]; then echo "Report generated successfully" ls -lh analysis.sarif jq '.runs[0].results | length' analysis.sarif else echo "Report not found" exit 1 fi - name: Upload Diagnostics if: always() uses: actions/upload-artifact@v3 with: name: diagnostics path: analysis.sarif ``` -------------------------------- ### GitHub Code Scanning Integration with SARIF Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/report-formats.md Example of configuring ReSharper InspectCode to generate and upload SARIF reports for GitHub code scanning. This enables security tab visibility and pull request annotations. ```yaml - uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./MySolution.sln format: Sarif output: ./analysis.sarif.json upload-sarif: true - name: View SARIF Structure run: jq '.runs[0].results | length' analysis.sarif.json ``` -------------------------------- ### Capture and Upload Full Log Output Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/troubleshooting-and-diagnostics.md Save detailed run logs, including step ID and exit code, and upload them as an artifact for analysis. ```yaml - uses: JetBrains/ReSharper-InspectCode@v0.13 id: analysis with: solution: ./MySolution.sln verbosity: VERBOSE - name: Save Logs if: always() run: | cat > run-log.txt << 'EOF' Step ID: ${{ steps.analysis.id }} Exit Code: ${{ job.status }} EOF - name: Upload Logs if: always() uses: actions/upload-artifact@v3 with: name: action-logs path: run-log.txt ``` -------------------------------- ### Run InspectCode and Access Outputs Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/usage-examples.md This snippet shows how to run InspectCode, save the output to a SARIF file, and then access the report file and format from the step's outputs for further processing. ```yaml - name: Run InspectCode id: analysis uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./src/MySolution.sln output: inspectcode.sarif format: Sarif - name: Check Report run: | echo "Report file: ${{ steps.analysis.outputs.report-file }}" echo "Report format: ${{ steps.analysis.outputs.report-format }}" ls -lh "${{ steps.analysis.outputs.report-file }}" ``` -------------------------------- ### Validating InspectCode Results in a Bash Script Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/outputs-reference.md Provides a bash script example for validating the generated InspectCode report file. It checks for the existence of the report file and verifies its format, optionally processing SARIF output with 'jq'. ```bash - name: Validate InspectCode Results shell: bash run: | REPORT_FILE="${{ steps.inspectcode.outputs.report-file }}" REPORT_FORMAT="${{ steps.inspectcode.outputs.report-format }}" if [ ! -f "$REPORT_FILE" ]; then echo "Error: Report file not found: $REPORT_FILE" exit 1 fi if [ "$REPORT_FORMAT" != "Sarif" ]; then echo "Warning: Report format is $REPORT_FORMAT, not Sarif" fi echo "Report generated successfully:" ls -lh "$REPORT_FILE" if [ "$REPORT_FORMAT" = "Sarif" ]; then jq '.runs[0].results | length' "$REPORT_FILE" fi ``` -------------------------------- ### Pull Request Analysis Configuration Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/usage-examples.md Configure InspectCode to analyze only the changes introduced in a pull request. This example specifies the solution path, output file, format, and severity level for the analysis, enabling SARIF upload for PR review. ```yaml name: PR Code Analysis on: pull_request: branches: [main] jobs: inspect: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Run InspectCode uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./src/MyApp.sln output: pr-analysis.sarif format: Sarif upload-sarif: "true" sEverity: SUGGESTION ``` -------------------------------- ### Force Enable Solution-Wide Analysis (SWEA) Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/configuration.md Enables solution-wide analysis for a more thorough inspection of the entire solution. ```yaml with: solution: ./MySolution.sln swea: "true" ``` -------------------------------- ### Troubleshooting - Verbosity Levels Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/DOCUMENTATION_INDEX.md Demonstrates setting different verbosity levels for the inspection tool to control the amount of diagnostic output. ```yaml steps: - name: Run Inspect Code (Quiet) uses: jetbrains/resharper-inspectcode@v1 with: solution: '**/*.sln' verbosity: 'quiet' - name: Run Inspect Code (Detailed) uses: jetbrains/resharper-inspectcode@v1 with: solution: '**/*.sln' verbosity: 'detailed' ``` -------------------------------- ### Checkout Repository with Submodules Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/permissions-and-setup.md Checkout the repository and its submodules. Ensures all necessary code is available for analysis. ```yaml - uses: actions/checkout@v4 with: fetch-depth: 0 # Full history if needed submodules: recursive # If using git submodules ``` -------------------------------- ### Custom Settings and Filtering Workflow Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/DOCUMENTATION_INDEX.md This workflow demonstrates how to apply custom settings and filtering to the code inspection process. Use this to tailor the analysis to specific project needs. ```yaml name: Custom Settings and Filtering on: [push] jobs: inspect: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Run ReSharper Inspect Code uses: jetbrains/resharper-inspectcode@v1 with: solution: '**/*.sln' output_path: 'inspect_results' report_type: 'sarif' filters: | - '**/Migrations/**' - '**/Tests/**' severity_threshold: 'warning' save_sarif_analysis_results: true ``` -------------------------------- ### Specify Solution File Path Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/troubleshooting-and-diagnostics.md Correct the solution file path when the error 'Could not find solution file at specified path' occurs. Ensure the path is correct relative to the working directory. ```yaml - uses: JetBrains/ReSharper-InspectCode@v0.13 with: solution: ./src/MySolution.sln # Use correct relative path ``` -------------------------------- ### Debugging and Troubleshooting Workflow Source: https://github.com/jetbrains/resharper-inspectcode/blob/main/_autodocs/DOCUMENTATION_INDEX.md This workflow is designed for debugging and troubleshooting. It enables verbose logging and specific diagnostic options to help identify issues. ```yaml name: Debugging and Troubleshooting on: [push] jobs: inspect: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Run ReSharper Inspect Code (Debug Mode) uses: jetbrains/resharper-inspectcode@v1 with: solution: '**/*.sln' output_path: 'inspect_results' report_type: 'sarif' verbosity: 'detailed' log_file: 'inspect.log' ```