Skip to content

Commit 15dfa17

Browse files
committed
Put list of attribute names in array
1 parent 2a2f75a commit 15dfa17

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/coverlet.core/Instrumentation/Instrumenter.cs

+9-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ internal class Instrumenter
2424
private readonly static Lazy<MethodInfo> _markExecutedMethodLoader = new Lazy<MethodInfo>(GetMarkExecutedMethod);
2525
private InstrumenterResult _result;
2626

27+
private static readonly string[] _excludeAttributeNames = new[]
28+
{
29+
nameof(ExcludeFromCoverageAttribute),
30+
"ExcludeFromCoverage",
31+
nameof(ExcludeFromCodeCoverageAttribute),
32+
"ExcludeFromCodeCoverage"
33+
};
34+
2735
public Instrumenter(string module, string identifier, string[] filters, string[] excludedFiles)
2836
{
2937
_module = module;
@@ -271,9 +279,7 @@ private static void ReplaceExceptionHandlerBoundary(ExceptionHandler handler, In
271279
private static bool IsExcludeAttribute(CustomAttribute customAttribute)
272280
{
273281
var attributeName = customAttribute.AttributeType.Name;
274-
275-
return attributeName == nameof(ExcludeFromCoverageAttribute) || attributeName == "ExcludeFromCoverage"
276-
|| attributeName == nameof(ExcludeFromCodeCoverageAttribute) || attributeName == "ExcludeFromCodeCoverage";
282+
return _excludeAttributeNames.Any(a => a.Equals(attributeName));
277283
}
278284

279285
private static Mono.Cecil.Cil.MethodBody GetMethodBody(MethodDefinition method)

0 commit comments

Comments
 (0)