Skip to content

Commit

Permalink
Merge pull request #147 from latop2604/feature/ctor-coverage
Browse files Browse the repository at this point in the history
Instrument class constructors
  • Loading branch information
tonerdo committed Jul 14, 2018
2 parents a189fc2 + 0cd2da0 commit abd4ae0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/coverlet.core/Instrumentation/Instrumenter.cs
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -91,6 +90,13 @@ private void InstrumentType(TypeDefinition type)
if (!actualMethod.CustomAttributes.Any(IsExcludeAttribute))
InstrumentMethod(method);
}

var ctors = type.GetConstructors();
foreach (var ctor in ctors)
{
if (!ctor.CustomAttributes.Any(IsExcludeAttribute))
InstrumentMethod(ctor);
}
}

private void InstrumentMethod(MethodDefinition method)
Expand Down Expand Up @@ -167,7 +173,7 @@ private void InstrumentIL(MethodDefinition method)
private Instruction AddInstrumentationCode(MethodDefinition method, ILProcessor processor, Instruction instruction, SequencePoint sequencePoint)
{
if (!_result.Documents.TryGetValue(sequencePoint.Document.Url, out var document))
{
{
document = new Document { Path = sequencePoint.Document.Url };
_result.Documents.Add(document.Path, document);
}
Expand All @@ -194,7 +200,7 @@ private Instruction AddInstrumentationCode(MethodDefinition method, ILProcessor
private Instruction AddInstrumentationCode(MethodDefinition method, ILProcessor processor, Instruction instruction, BranchPoint branchPoint)
{
if (!_result.Documents.TryGetValue(branchPoint.Document, out var document))
{
{
document = new Document { Path = branchPoint.Document };
_result.Documents.Add(document.Path, document);
}
Expand Down

0 comments on commit abd4ae0

Please sign in to comment.