-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #138 from lucaslorentz/feature/instrumentation-con…
…text-interface Add IInstrumentationContext interface
- Loading branch information
Showing
13 changed files
with
81 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/MiniCover.Core/Instrumentation/FileBasedInstrumentationContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Collections.Generic; | ||
using System.IO.Abstractions; | ||
using System.Linq; | ||
using MiniCover.Core.Extensions; | ||
using Mono.Cecil; | ||
|
||
namespace MiniCover.Core.Instrumentation | ||
{ | ||
public class FileBasedInstrumentationContext : IInstrumentationContext | ||
{ | ||
private int _uniqueId; | ||
|
||
public virtual IList<IFileInfo> Assemblies { get; set; } | ||
public virtual IList<IFileInfo> Sources { get; set; } | ||
public virtual IList<IFileInfo> Tests { get; set; } | ||
public virtual string HitsPath { get; set; } | ||
public virtual IDirectoryInfo Workdir { get; set; } | ||
|
||
public virtual int NewInstructionId() | ||
{ | ||
return ++_uniqueId; | ||
} | ||
|
||
public virtual bool IsSource(MethodDefinition methodDefinition) | ||
{ | ||
return methodDefinition.GetAllDocuments() | ||
.Any(d => Sources.Any(s => s.FullName == d.Url)); | ||
} | ||
|
||
public virtual bool IsTest(MethodDefinition methodDefinition) | ||
{ | ||
return methodDefinition.GetAllDocuments() | ||
.Any(d => Tests.Any(s => s.FullName == d.Url)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/MiniCover.Core/Instrumentation/IInstrumentationContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.Collections.Generic; | ||
using System.IO.Abstractions; | ||
using Mono.Cecil; | ||
|
||
namespace MiniCover.Core.Instrumentation | ||
{ | ||
public interface IInstrumentationContext | ||
{ | ||
IList<IFileInfo> Assemblies { get; } | ||
string HitsPath { get; } | ||
IDirectoryInfo Workdir { get; } | ||
int NewInstructionId(); | ||
bool IsSource(MethodDefinition methodDefinition); | ||
bool IsTest(MethodDefinition methodDefinition); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
src/MiniCover.Core/Instrumentation/InstrumentationContext.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters