name: "CodeQL"

permissions:
  actions: read
  contents: read
  security-events: write

on:
  push:
    branches: [ master ]
  pull_request:
    # The branches below must be a subset of the branches above
    branches: [ master ]
  schedule:
    - cron: '15 23 * * 1'

jobs:
  analyze:
    name: Analyze
    runs-on: windows-2022

    strategy:
      fail-fast: false
      matrix:
        language: [ 'csharp' ]

    steps:
    - name: Checkout repository
      uses: actions/checkout@v5
      with:
          fetch-depth: 0

    - name: Setup dotnet
      uses: actions/setup-dotnet@v5
      with:
        dotnet-version: |
          8.0.x
          9.0.x

    # Initializes the CodeQL tools for scanning.
    - name: Initialize CodeQL
      uses: github/codeql-action/init@v4
      with:
        languages: ${{ matrix.language }}
        # If you wish to specify custom queries, you can do so here or in a config file.
        # By default, queries listed here will override any specified in a config file.
        # Prefix the list here with "+" to use these queries and those in the config file.
        # queries: ./path/to/local/query, your-org/your-repo/queries@main

    # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
    # If this step fails, then you should remove it and run the build manually (see below)
    # Currently .NET8.0 isn't supported
    # - name: Autobuild
    #   uses: github/codeql-action/autobuild@v2

    - name: Restore dependencies
      run: dotnet restore
    - name: Build
      run: dotnet build --configuration Debug --no-restore

    - name: Perform CodeQL Analysis
      uses: github/codeql-action/analyze@v4
