Error with Visual Studio Code Coverage Import.

669 views
Skip to first unread message

Jared Holgate

unread,
Apr 25, 2016, 3:21:59 PM4/25/16
to SonarQube
Hi

I am consistently seeing errors when importing Coverage results from one specific solution. Others seem to work fine. I have been using version 5.1 of the C# plug in and I have just tried 5.2 RC, but am still seeing the same issue.

The error seems to be related to the source file having less lines than the coverage file seems to indicate. I've seen a similar issue referenced here, which looks like it was resolved, but not for me...;


Any help or guidance you could offer would be much appreciate as this is the final step to me getting useful info out of SonarQube.

Thanks

Jared

________________________________________________________________________________



The error is;

java.lang.IllegalStateException: Can't create measure for line 12 for file 'E:/b/3/_work/25/s/Maples.eServices.UI/Maples.eServices.UI.Services/TodayNotification/AggregatedEmailModels/ContactWithChanges.cs' with 9 lines

  1. 2016-04-25T18:42:08.8051671Z 19:42:08.617 INFO  - Sensor org.sonar.plugins.csharp.CSharpSensor (done) | time=3703ms
  2. 2016-04-25T18:42:08.8051671Z 19:42:08.617 INFO  - Sensor org.sonar.plugins.csharp.CSharpCodeCoverageProvider$CSharpCoverageReportImportSensor
  3. 2016-04-25T18:42:08.8051671Z 19:42:08.617 INFO  - Parsing the Visual Studio coverage XML report E:\b\3\_work\25\TestResults\svctfsbuild_KYTFS15BLD02 2016-04-25 19_38_27\In\KYTFS15BLD02\svctfsbuild_KYTFS15BLD02 2016-04-25 19_37_19.coveragexml
  4. 2016-04-25T18:42:08.9145352Z 19:42:08.773 INFO  - Adding this code coverage report to the cache for later reuse: E:\b\3\_work\25\TestResults\svctfsbuild_KYTFS15BLD02 2016-04-25 19_38_27\In\KYTFS15BLD02\svctfsbuild_KYTFS15BLD02 2016-04-25 19_37_19.coveragexml
  5. 2016-04-25T18:42:09.5707468Z INFO: ------------------------------------------------------------------------
  6. 2016-04-25T18:42:09.5707468Z INFO: EXECUTION FAILURE
  7. 2016-04-25T18:42:09.5707468Z INFO: ------------------------------------------------------------------------
  8. 2016-04-25T18:42:09.5707468Z Total time: 1:30.185s
  9. 2016-04-25T18:42:09.6801267Z Final Memory: 10M/235M
  10. 2016-04-25T18:42:09.6801267Z INFO: ------------------------------------------------------------------------
  11. 2016-04-25T18:42:09.6801267Z ##[error]ERROR: Error during Sonar runner execution
  12. 2016-04-25T18:42:09.6801267Z ##[error]org.sonar.runner.impl.RunnerException: Unable to execute Sonar
  13. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
  14. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
  15. 2016-04-25T18:42:09.6801267Z ##[error]at java.security.AccessController.doPrivileged(Native Method)
  16. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
  17. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
  18. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
  19. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.runner.api.Runner.execute(Runner.java:100)
  20. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.runner.Main.executeTask(Main.java:70)
  21. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.runner.Main.execute(Main.java:59)
  22. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.runner.Main.main(Main.java:53)
  23. 2016-04-25T18:42:09.6801267Z ##[error]Caused by: java.lang.IllegalStateException: Can't create measure for line 12 for file 'E:/b/3/_work/25/s/Maples.eServices.UI/Maples.eServices.UI.Services/TodayNotification/AggregatedEmailModels/ContactWithChanges.cs' with 9 lines
  24. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.batch.sensor.coverage.CoverageExclusions.validateMaxLine(CoverageExclusions.java:158)
  25. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.batch.sensor.coverage.CoverageExclusions.validate(CoverageExclusions.java:129)
  26. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.batch.deprecated.DeprecatedSensorContext.saveMeasure(DeprecatedSensorContext.java:204)
  27. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.plugins.dotnet.tests.CoverageReportImportSensor.analyze(CoverageReportImportSensor.java:103)
  28. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.plugins.dotnet.tests.CoverageReportImportSensor.analyse(CoverageReportImportSensor.java:74)
  29. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58)
  30. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50)
  31. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:102)
  32. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:185)
  33. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
  34. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:120)
  35. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:264)
  36. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:259)
  37. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:257)
  38. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:249)
  39. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
  40. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.batch.scan.ProjectScanContainer.startComponents(ProjectScanContainer.java:127)
  41. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:120)
  42. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.batch.task.ScanTask.execute(ScanTask.java:55)
  43. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.batch.task.TaskContainer.doAfterStart(TaskContainer.java:86)
  44. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
  45. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:120)
  46. 2016-04-25T18:42:09.6801267Z ##[error]at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:122)
  47. 2016-04-25T18:42:09.6957435Z ##[error]at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:119)
  48. 2016-04-25T18:42:09.6957435Z ##[error]at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:79)
  49. 2016-04-25T18:42:09.6957435Z ##[error]at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
  50. 2016-04-25T18:42:09.6957435Z ##[error]at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  51. 2016-04-25T18:42:09.6957435Z ##[error]at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  52. 2016-04-25T18:42:09.6957435Z ##[error]at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  53. 2016-04-25T18:42:09.6957435Z ##[error]at java.lang.reflect.Method.invoke(Unknown Source)
  54. 2016-04-25T18:42:09.6957435Z ##[error]at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
  55. 2016-04-25T18:42:09.6957435Z ##[error]... 9 more
  56. 2016-04-25T18:42:09.6957435Z ##[error]ERROR:
  57. 2016-04-25T18:42:09.6957435Z ##[error]ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
  58. 2016-04-25T18:42:09.6957435Z ##[error]The SonarQube Scanner did not complete successfully
  59. 2016-04-25T18:42:09.6957435Z 19:42:09.617  Creating a summary markdown file...
  60. 2016-04-25T18:42:09.6957435Z ##[error]Post-processing failed. Exit code: 1
  61. 2016-04-25T18:42:09.8207681Z ##[error]Unexpected exit code received from batch file: 1


The relevant part(s) of the coveragexml file are;

         <function id="215992" token="0x6000cce" name="get_ContactId()" type_name="ContactWithChanges" block_coverage="0.00" line_coverage="0.00" blocks_covered="0" blocks_not_covered="3" lines_covered="0" lines_partially_covered="0" lines_not_covered="1">
          <ranges>
            <range source_id="213" covered="no" start_line="5" start_column="26" end_line="5" end_column="27" />
            <range source_id="213" covered="no" start_line="5" start_column="28" end_line="5" end_column="32" />
          </ranges>
        </function>
        <function id="216018" token="0x6000ccf" name="set_ContactId(int)" type_name="ContactWithChanges" block_coverage="0.00" line_coverage="0.00" blocks_covered="0" blocks_not_covered="3" lines_covered="0" lines_partially_covered="0" lines_not_covered="1">
          <ranges>
            <range source_id="213" covered="no" start_line="5" start_column="31" end_line="5" end_column="32" />
            <range source_id="213" covered="no" start_line="5" start_column="33" end_line="5" end_column="37" />
          </ranges>
        </function>
        <function id="216032" token="0x6000cd0" name="get_DisplayName()" type_name="ContactWithChanges" block_coverage="0.00" line_coverage="0.00" blocks_covered="0" blocks_not_covered="3" lines_covered="0" lines_partially_covered="0" lines_not_covered="1">
          <ranges>
            <range source_id="213" covered="no" start_line="5" start_column="33" end_line="5" end_column="37" />
          </ranges>
        </function>
        <function id="216058" token="0x6000cd1" name="set_DisplayName(string)" type_name="ContactWithChanges" block_coverage="0.00" line_coverage="0.00" blocks_covered="0" blocks_not_covered="3" lines_covered="0" lines_partially_covered="0" lines_not_covered="14">
          <ranges>
            <range source_id="213" covered="no" start_line="6" start_column="36" end_line="6" end_column="37" />
            <range source_id="213" covered="no" start_line="6" start_column="38" end_line="6" end_column="42" />
            <range source_id="213" covered="no" start_line="14" start_column="7" end_line="20" end_column="10" />
          </ranges>
        </function>
        <function id="216072" token="0x6000cd2" name="ContactWithChanges()" type_name="ContactWithChanges" block_coverage="0.00" line_coverage="0.00" blocks_covered="0" blocks_not_covered="4" lines_covered="0" lines_partially_covered="0" lines_not_covered="15">
          <ranges>
            <range source_id="213" covered="no" start_line="6" start_column="38" end_line="6" end_column="42" />
            <range source_id="213" covered="no" start_line="12" start_column="5" end_line="12" end_column="41" />
            <range source_id="213" covered="no" start_line="14" start_column="7" end_line="20" end_column="10" />
          </ranges>
        </function>
        <source_file id="213" path="E:\b\3\_work\25\s\Maples.eServices.UI\Maples.eServices.UI.Services\TodayNotification\AggregatedEmailModels\ContactWithChanges.cs">
        </source_file>

The source code is;

namespace Maples.eServices.UI.Services.TodayNotification.AggregatedEmailModels
{
  public class ContactWithChanges
  {
    public int ContactId { get; set; }
    public string DisplayName { get; set; }
  }
}





Jared Holgate

unread,
Apr 25, 2016, 3:30:29 PM4/25/16
to SonarQube
Sorry, I just realised I should have posted this on StackOverflow, not here. Please ignore or delete and I will post there instead.
...

duncanp

unread,
Apr 26, 2016, 9:03:01 AM4/26/16
to SonarQube
Hi Jared,

Does ContactWithChanges.cs contain a partial class where the other partial is in another file?

If so, it sounds like an bug that discovered recently in the Visual Studio Code Analysis tools - the data in the coverage xml file is wrong, causing an error when the file is processed by the C# plugin.
That bug will be fixed, but the fix won't ship until a later version of Visual Studio (e.g. VS2015 Update 3, or possibly not until VS2016).

I don't know of a workaround short of not uploading the code coverage for that project. One hacky workaround might be to add some blank lines to the AggregatedEmailModels/ContactWithChanges.cs file (assuming it isn't a generated file), which might be enough to make the upload succeed.

Regards,
Duncan

Jared Holgate

unread,
Apr 27, 2016, 2:11:52 PM4/27/16
to SonarQube
Hi Duncan

Thanks for the response. I've checked through the source code and could only find a few partial classes within some unit test projects. I removed the partial and it still doesn't work, so it doesn't sound like the problem you are referring to.

Do you think it might possible to handle the exception in the SonarQube analyser without skewing the Coverage results?

Also it seems to fail on different files on different occasions, all with the same type of error and in the same solution, so adding white space would be a significant task. I've tried excluding the offending files from the coverage report using runsettings, but each time I exclude one file another has the same issue.

Thanks again.

Jared

beaudry...@gmail.com

unread,
Apr 28, 2016, 6:14:58 AM4/28/16
to SonarQube
My story is identical to Jared:
  • I have the same error.
  • it is not a partial class
  • If I disable the analysis on the file, it will be another one that fails

duncanp

unread,
Apr 29, 2016, 5:47:01 AM4/29/16
to SonarQube, beaudry...@gmail.com
@Jared, the VS test team have looked at the output you posted and it looks like the same underlying issue as the one they having been working on.
They plan to ship the fix in Visual Studio 2015 Update 3 (and in the next preview of VS2016).

Regards,
Duncan

Jared Holgate

unread,
Apr 29, 2016, 9:51:44 PM4/29/16
to SonarQube
That's great feedback, thank you for taking the time to investigate and respond.

Jared Holgate

unread,
Jun 7, 2016, 6:45:08 PM6/7/16
to SonarQube, beaudry...@gmail.com
Hi

One of my team noted this same issue with another solution. I'm not sure if it's relevant, but it seems that for that particular solution, simply adding a reference to PostSharp causes the issue.

Removing the PostSharp reference makes it work again. No attributes were added to the code, etc. Just the addition of PostSharp to a project.

Any update on an expected release date for TFS Update 3 or another work around? 

Thanks

Jared
Reply all
Reply to author
Forward
0 new messages