Skip to content

Add C# and C++ combined analysis example - #227

Merged
andres-garciasolares-sonarsource merged 1 commit into
masterfrom
add-csharp-cpp-analysis-example
Jul 16, 2026
Merged

Add C# and C++ combined analysis example#227
andres-garciasolares-sonarsource merged 1 commit into
masterfrom
add-csharp-cpp-analysis-example

Conversation

@andres-garciasolares-sonarsource

Copy link
Copy Markdown
Contributor

Adds a sample project demonstrating Sonar analysis of a solution containing both C# and C++ code together.

Adds a sample project demonstrating Sonar analysis of a solution containing both C# and C++ code together.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@andres-garciasolares-sonarsource
andres-garciasolares-sonarsource merged commit 5ac745d into master Jul 16, 2026
1 of 5 checks passed
@andres-garciasolares-sonarsource
andres-garciasolares-sonarsource deleted the add-csharp-cpp-analysis-example branch July 16, 2026 13:35
@gitar-bot

gitar-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown
CI failed: The 'verify-sca' CI job failed because the repository is missing the required Vault role configuration needed to authenticate and retrieve SonarQube secrets.

Overview

All CI runs for this PR failed during the verify-sca step due to a configuration issue involving Vault authentication. The repository is not currently authorized to access the required secrets.

Failures

Vault Authentication Failure (confidence: high)

  • Type: configuration
  • Affected jobs: 84833245811, 84833823180, 84834958529
  • Related to change: no
  • Root cause: The repository lacks an authorized Vault role (github-SonarSource-sonar-scanning-examples), leading to an HTTP 400 Bad Request error when the CI pipeline attempts to fetch secrets.
  • Suggested fix: Access the 'Manage Vault Policy' SPEED action linked in the job summary of your failed CI run to onboard this repository and grant it access to the necessary SonarQube secrets.

Summary

  • Change-related failures: 0 (This is an infrastructure/onboarding configuration issue).
  • Infrastructure/flaky failures: 3 (All jobs failed due to missing Vault policy).
  • Recommended action: Follow the link provided in the CI job summary to the 'Manage Vault Policy' action to register the repository with Vault. Once completed, re-run the failed CI jobs.
Code Review ✅ Approved 1 resolved / 1 findings

Adds a sample project demonstrating combined C# and C++ analysis. Address the potential integer overflow in the C# IsPrime method to ensure consistency with the C++ implementation.

✅ 1 resolved
Edge Case: C# IsPrime can overflow int in i*i, unlike C++ version

📄 sonar-scanner-dotnet/CSharpWithCppProject/CSharpProject/Calculator.cs:30 📄 sonar-scanner-dotnet/CSharpWithCppProject/CppProject/src/mathutils.cpp:29
In Calculator.IsPrime, the loop condition for (int i = 2; i * i <= n; i++) computes i * i as a 32-bit int. For large n near int.MaxValue, i * i overflows and wraps to a negative value, making the condition i * i <= n behave incorrectly (potentially terminating early or looping unexpectedly), so primality results can be wrong for very large inputs.

Notably, the parallel C++ implementation in mathutils.cpp already guards against exactly this: for (int i = 2; static_cast<long long>(i) * i <= n; ++i). The C# version should mirror that widening to stay consistent and correct.

Suggested fix: widen the multiplication to long, e.g. for (int i = 2; (long)i * i <= n; i++).

Tip

Comment Gitar fix CI or enable auto-apply: gitar auto-apply:on

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

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