Skip to content
This repository has been archived by the owner on Dec 3, 2019. It is now read-only.

Adding functionality to handle the user profile folder #16

Merged
merged 3 commits into from
Dec 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/BCC.MSBuildLog.Tests/BCC.MSBuildLog.Tests.csproj
Original file line number Diff line number Diff line change
@@ -52,6 +52,9 @@
<None Update="Resources\testconsoleapp1-codeanalysis.binlog">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Resources\visualstudio-recent.binlog">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Resources\visualstudio.binlog">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Binary file not shown.
15 changes: 15 additions & 0 deletions src/BCC.MSBuildLog.Tests/Services/BinaryLogProcessorTests.cs
Original file line number Diff line number Diff line change
@@ -353,6 +353,21 @@ public void Should_Parse_GitHubVisualStudio()
reportKbytes.Should().BeLessThan(128.0);
}

[Fact]
public void Should_Parse_GitHubVisualStudio_Recent()
{
var cloneRoot = @"c:\users\spade\projects\github\visualstudio\";
var logData = ProcessLog("visualstudio-recent.binlog", cloneRoot, Faker.Internet.UserName(), Faker.Random.Word(), Faker.Random.String(10));

logData.ErrorCount.Should().Be(0);
logData.WarningCount.Should().Be(1304);

logData.Report.Should().NotBeNullOrWhiteSpace();

var reportKbytes = Encoding.Unicode.GetByteCount(logData.Report) / 1024.0;
reportKbytes.Should().BeLessThan(128.0);
}

[Fact]
public void Should_Parse_DBATools()
{
12 changes: 9 additions & 3 deletions src/BCC.MSBuildLog/Services/BinaryLogProcessor.cs
Original file line number Diff line number Diff line change
@@ -209,12 +209,18 @@ private string GetFilePath(string cloneRoot, string projectFile, string file)
}

var filePath = Path.Combine(Path.GetDirectoryName(projectFile), file);
if (!filePath.IsSubPathOf(cloneRoot))
if (filePath.IsSubPathOf(cloneRoot))
{
throw new InvalidOperationException($"FilePath `{filePath}` is not a child of `{cloneRoot}`");
return GetRelativePath(filePath, cloneRoot).Replace("\\", "/");
}

return GetRelativePath(filePath, cloneRoot).Replace("\\", "/");
var dotNugetPosition = filePath.IndexOf(".nuget");
if (dotNugetPosition != -1)
{
return filePath.Substring(dotNugetPosition).Replace("\\", "/");
}

throw new InvalidOperationException($"FilePath `{filePath}` is not a child of `{cloneRoot}`");
}

private string GetRelativePath(string filespec, string folder)