Single c# class file not listed in project's code tab

System Info:
SonarQube version - 7.9.1.27448
SonarScanner for MSBuild - 4.7.1

Hi all! I’m running into an issue and I know I’m just missing something, but Google is not my friend at the moment -

Problem
One of our devs noticed that a class he modified was not being picked up as having new code. After doing some digging, I’m finding that the c# class is not listed at all under “SonarqubeProjectName”->Code. The c# project in question is listed along with all the other files…except the file he modified. Every other file being modified seems to be behaving coverage wise etc. fine.

What I’ve Tried

  • Double checked that the c# file location is, in fact, under that project.
  • Looked at Scanner context and Sonarqube UI to make sure it’s not being excluded on the global, sonarqube project, or scanner scopes.
  • Cleared old code coverage reports…Just in case really.
  • Checked that there isn’t any special property setting in Visual Studio on that file compared to the ones that are working.
  • Verified that the code is just standard c# code

Other Related Details…?

  • The file is a big one - 10192 lines
  • In the Scanner context under one of the “Scanner Properties of module” sections it lists the class file under “sonar.sources” for the correct project so it sees the file at least…?

Is there anything else I should be checking?
Thanks!

Solved it. Going to post here for anyone who needs it:

There’s a warning in the output for the Run Code Analysis build step (so I guess the Scanner logs maybe?) -
Invalid character encountered in file [MISSING FILENAME] at line 91 for encoding UTF-8. Please fix file content or configure the encoding to be used using property ‘sonar.sourceEncoding’.
WARN: Encoding detected by Roslyn and encoding used by SonarQube do not match for file [MISSING FILENAME]. SonarQube encoding is ‘UTF-8’, Roslyn encoding is ‘windows-1252’. File will be skipped.

2 Likes