Skip to content

Commit

Permalink
Change GetSourceRelativePath
Browse files Browse the repository at this point in the history
Change GetSourceRelativePath so that you can have a workspace outside the path to the source file
  • Loading branch information
bhugot authored Feb 26, 2018
1 parent 2f7fbd4 commit 990f3ea
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/MiniCover/Instrumentation/Instrumenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,15 +333,17 @@ private void InstrumentInstruction(int instructionId, Instruction instruction,

private string GetSourceRelativePath(string path)
{
if (!path.StartsWith(normalizedWorkDir))
return null;

if (!sourceFiles.Contains(path))
return null;

return path.Substring(normalizedWorkDir.Length);
Uri file = new Uri(path);
Uri folder = new Uri(normalizedWorkDir);
string relativePath =
Uri.UnescapeDataString(
folder.MakeRelativeUri(file)
.ToString()
.Replace('/', Path.DirectorySeparatorChar)
);
return relativePath;
}

private string GetPdbFile(string assemblyFile)
{
return Path.ChangeExtension(assemblyFile, "pdb");
Expand Down

0 comments on commit 990f3ea

Please sign in to comment.