C# doesnt get recognized in Java project

  • Gradle with SonnarScanner 3.0, SonarQube 8.1
  • What are you trying to achieve?: I have a project with following project structure in a gradle project. When I analyse the project via a gradle task, the C# Code ist not recognized in the SonarQube project. I want that the C# aswell as Java files to be analysed in the project.
  • What have you tried so far to achieve this?: I included the sourcecode of C# in app-1.gradle with "sonar.sources=“src/c#code,src/javacode”

Project Structure

build.gradle
app-1

  • app-1.gradle
    – src
    — c#code
    — javacode

app-2

  • app-2.gradle
    – src
    — javacode

Hi,

Welcome to the community!

To analyze C# you must use the Sonar Scanner for MSBuild which, not coincidentally, requires you to build your C#.

And then you face the backward problem of making sure your C# analysis recognizes Java code.

For your particular situation, I’d recommend first making sure your *.java files are referenced in your sln. Then

  • Java build via Gradle
  • Build C# & analyze all via the Scanner for MSBuild.

Alternately, you can just analyze the project twice: once with Gradle to pick up the Java code & once with MSBuild to pick up the C#.

 
HTH,
Ann