restore original uninstrumented modules after coverage is run
This commit is contained in:
@@ -53,6 +53,8 @@ namespace Coverlet.Core
|
||||
data.Add(instrumenterResult.Module, documents);
|
||||
}
|
||||
|
||||
InstrumentationHelper.RestoreOriginalModules(_results);
|
||||
|
||||
return new CoverageResult
|
||||
{
|
||||
Identifier = _identifier,
|
||||
|
||||
@@ -3,6 +3,8 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection.PortableExecutable;
|
||||
|
||||
using Coverlet.Core.Instrumentation;
|
||||
|
||||
namespace Coverlet.Core.Helpers
|
||||
{
|
||||
internal static class InstrumentationHelper
|
||||
@@ -32,5 +34,14 @@ namespace Coverlet.Core.Helpers
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void RestoreOriginalModules(IEnumerable<InstrumenterResult> results)
|
||||
{
|
||||
foreach (var result in results)
|
||||
{
|
||||
File.Copy(result.OriginalModuleTempPath, result.OriginalModulePath, true);
|
||||
File.Delete(result.OriginalModuleTempPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,10 +27,19 @@ namespace Coverlet.Core.Instrumentation
|
||||
Path.GetFileNameWithoutExtension(_module) + "_" + _identifier
|
||||
);
|
||||
|
||||
string originalModuleTempPath = Path.Combine(
|
||||
Path.GetTempPath(),
|
||||
Path.GetFileNameWithoutExtension(_module) + "_" + _identifier + ".dll"
|
||||
);
|
||||
|
||||
File.Copy(_module, originalModuleTempPath);
|
||||
|
||||
_result = new InstrumenterResult
|
||||
{
|
||||
Module = Path.GetFileNameWithoutExtension(_module),
|
||||
ReportPath = reportPath
|
||||
ReportPath = reportPath,
|
||||
OriginalModulePath = _module,
|
||||
OriginalModuleTempPath = originalModuleTempPath
|
||||
};
|
||||
|
||||
InstrumentModule();
|
||||
|
||||
@@ -21,6 +21,8 @@ namespace Coverlet.Core.Instrumentation
|
||||
public InstrumenterResult() => Documents = new List<Document>();
|
||||
public string Module;
|
||||
public string ReportPath;
|
||||
public string OriginalModulePath;
|
||||
public string OriginalModuleTempPath;
|
||||
public List<Document> Documents { get; private set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user