Skip to content

Conversation

@jaybarden1
Copy link
Contributor

No description provided.

…rator

- Updated tests for ServiceRegistrationGenerator to improve readability and maintainability.
- Ensured generated source code matches expected output for various scenarios including default scoped registration, singleton lifetime, and self-registration.
- Added tests to verify behavior for classes without interfaces and those with multiple interfaces without specified registration.
- Refactored StrongIdGenerator tests to ensure correct generation of partial structs with ID properties for specified types.
- Improved CompilationHelpers for better attribute handling in tests.
- Cleaned up formatting and organization of test files for consistency.
@jaybarden1 jaybarden1 requested a review from jbarden January 31, 2026 09:50
Comment on lines +12 to +62
name: Build and analyze
runs-on: windows-latest
env:
SONAR_PROJECT: 'astar-dev-source-generators'
ProjectName: 'AStar.Dev.Source.Generators'
RepositoryName: 'astar-dev-source-generators'
steps:
- name: Set up JDK
uses: actions/[email protected]
with:
java-version: 17
distribution: 'zulu'
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0
- name: 🛠 Cache SonarQube Cloud packages
uses: actions/[email protected]
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: 🛠 Cache SonarQube Cloud scanner
id: cache-sonar-scanner
uses: actions/[email protected]
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: 🛠 Install SonarQube Cloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
- name: 🔍 Restore, 🛠 Build and 🧪 Test with ☁️ SonarCloud / Qube
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell
run: |
dotnet tool install --global dotnet-coverage
.\.sonar\scanner\dotnet-sonarscanner begin /k:"astar-development_${{ env.SONAR_PROJECT }}" /o:"astar-development" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml /d:sonar.scanner.scanAll=false /d:sonar.scanner.skipJreProvisioning=true
dotnet build --configuration Release
dotnet-coverage collect 'dotnet test --filter "FullyQualifiedName!~Tests.EndToEnd"' -f xml -o 'coverage.xml'
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 12 days ago

To fix the problem, explicitly declare minimal GITHUB_TOKEN permissions for the workflow or the build job. Since the job only checks out and reads code and uses GITHUB_TOKEN for Sonar/SonarCloud integration (not to write to the repo), we can safely limit permissions to contents: read. Declaring permissions at the workflow root applies to all jobs, and there is only one job here, so adding a root-level block is the simplest and least invasive fix.

The best fix is:

  • Add a permissions: block near the top of .github/workflows/dotnet.yml, at the root level (same indentation as on: and jobs:).
  • Set contents: read as a minimal baseline. If later you discover this workflow must update PRs or commit statuses, you can extend this block accordingly.

Concretely:

  • In .github/workflows/dotnet.yml, between name: .NET (line 1) and on: (line 3), insert:
permissions:
  contents: read

No additional imports, methods, or definitions are needed, as this is purely a YAML configuration change.

Suggested changeset 1
.github/workflows/dotnet.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml
--- a/.github/workflows/dotnet.yml
+++ b/.github/workflows/dotnet.yml
@@ -1,5 +1,8 @@
 name: .NET
 
+permissions:
+  contents: read
+
 on:
   workflow_dispatch:
   push:
EOF
@@ -1,5 +1,8 @@
name: .NET

permissions:
contents: read

on:
workflow_dispatch:
push:
Copilot is powered by AI and may make mistakes. Always verify output.
@sonarqubecloud
Copy link

@jaybarden1 jaybarden1 merged commit e952963 into main Jan 31, 2026
6 checks passed
@jaybarden1 jaybarden1 deleted the features/fix-bug-in-autoregisterserviceattribute-detection-code-generation branch January 31, 2026 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants