Details
Description
Issue SONARPLUGINS-1417 added code to GallioCommandBuilder to exclude any assemblies specified via the comma-separated config property 'sonar.gallio.coverage.excludes' from the NCover command call using the //ias command line argument.
This is great, but the way this property is retrieved in org.sonar.plugins.csharp.gallio.GallioSensor.analyse() means that only the first assembly specified via the property will actually be considered in the NCover excludes:
builder.setCoverageExcludes(configuration
.getString(GallioConstants.COVERAGE_EXCLUDES_KEY, GallioConstants.COVERAGE_EXCLUDES_DEFVALUE));
(I suspect that the same applies to PartCover, and in 1.2 also OpenCover, but I haven't tested it.)
The problem is that getString() returns only the first token in the comma-separated list. In the following scenario:
sonar.gallio.coverage.excludes=Assembly1,Assembly3,Assembly3
only Assembly1 would be actually excluded.
One possible solution would be to read and concatenate all tokens using getStringArray(), for example:
String[] coverageExcludesArray = configuration.getStringArray(GallioConstants.COVERAGE_EXCLUDES_KEY);
String coverageExcludesString = "";
for (String exclude : coverageExcludesArray) {
if (!coverageExcludesString.isEmpty())
coverageExcludesString += exclude;
}
builder.setCoverageExcludes(coverageExcludesString);
It would probably be cleaner though to change the interface of GallioCommandBuilder.setCoverageExcludes() to take an array of excludes instead of a single String, but that would require more extensive code changes.
Fixed
Also files from excluded assemblies do not have any coverage data anymore