Analysis Error "Line x out of range" with Partial Classes CSharp


(Lukas Tomalla) #1

Hey SonarQube Team,

At first, we like to use Sonarqube for our Projects and the new Pull Request feature is awesome.

We are using the Sonarqube 7.2.1 Developer Edition with the C# Plugin and TFS 2017 with the Sonarqube Extension 4.3.2

In our legacy code we used a lot of Partial Classes (2 - 3 files for a Class).
They are in different Folders, but they use the same physical filename.


The “Run Code Analysis” Task failed with an
“Line x is out of range in the xy.cs (lines: 237)”

I think the Problem is, that all filenames are stored in a List.

Exluding the Folder “Wrapper” and “Generator” fix this Problem.

Steps to reproduce

  1. Create an CSharp Project
  2. Create two Subfolder ( A and B)
  3. Add Class “MyClass” in Subfolder “A”
  4. Add Class “MyClass” in Subolfder “B”
  5. Make both classes Partial
  6. Set both classes in the same Namespace
  7. Add a Methode to the “MyClass” in Subfolder “B”
  8. Run Analysis