SonarCommunity/sonar-dotnet — pull request #6 by donald-slagle (2013-03-01 18:48:03+00:00)
Title: Added Exclude by attribute functionality for open cover.

Exclude a class or method by filter(s) that match attributes that have been applied that have been applied. An * can be used as a wildcard. Example: *.ExcludeFromCoverage*.

This would be great to have in the main repository so I don't have to modify newer versions as I upgrade. I have tested this on the sonar server in my development environment and it does work at excluding methods/classes/properties that have the attribute defined under sonar.opencover.attributeExcludes applied to them. I did also modify how sonar.gallio.coverage.excludes works for open cover. Not sure if it was intended to only allow exclusions at the assembly level but I modified it so I can exclude freely just as you can by calling command line.

Pulled from opencover wiki for how their filtering works. I also verified that my changes are working on our sonar server.

-filter: - filters to employ to limit the scope of the coverage. Using PartCover syntax, where (+|-)[Assembly-Filter]Type-Filter
i.e.
+[Open*]* include all types in assemblies starting with Open,
-[*]Core.* exclude all types in the Core namespace regardless of the assembly. If no filters are supplied then the default inclusive filter +[*]* is applied automatically.
NOTE: Multiple filters can be applied by separating them with spaces and enclosing them with quotes i.e. -filter:"+[*]* -[A*]Name.*" .
NOTE: Exclusion filters take precedence over inclusion filters.

If it was intended to only allow assembly filtering then it would still be nice to have the attribute exclusion at the very least added. This seems more helpful in sonar because it does effect the code coverage where filtering entire namespaces does not - would could be the reason for the original design.