From c191876b5459c6c0f7a3829edf8dc7aef4aaf0eb Mon Sep 17 00:00:00 2001 From: Oluwatoni Solarin-Sodara Date: Mon, 19 Mar 2018 12:16:18 +0100 Subject: [PATCH] allow excluding entire types from coverage tracking --- src/coverlet.core/Instrumentation/Instrumenter.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/coverlet.core/Instrumentation/Instrumenter.cs b/src/coverlet.core/Instrumentation/Instrumenter.cs index 62dc251..0a0d53a 100644 --- a/src/coverlet.core/Instrumentation/Instrumenter.cs +++ b/src/coverlet.core/Instrumentation/Instrumenter.cs @@ -55,9 +55,12 @@ namespace Coverlet.Core.Instrumentation foreach (var type in module.GetTypes()) { + if (type.CustomAttributes.Any(a => a.AttributeType.Name == "ExcludeFromCoverageAttribute" || a.AttributeType.Name == "ExcludeFromCoverage")) + continue; + foreach (var method in type.Methods) { - if (!method.CustomAttributes.Any(a => a.AttributeType.Name == "ExcludeFromCoverageAttribute")) + if (!method.CustomAttributes.Any(a => a.AttributeType.Name == "ExcludeFromCoverageAttribute" || a.AttributeType.Name == "ExcludeFromCoverage")) InstrumentMethod(method); } }