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

Commit

Permalink
Merge pull request #81 from brianfeucht/stylecop-argument-out-of-range
Browse files Browse the repository at this point in the history
(GH-80) MSBuild log generated by StyleCop throws ArgumentOutOfRangeException
  • Loading branch information
pascalberger committed Mar 18, 2019
2 parents 1e088ed + 1253904 commit 39a0bc8
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
Expand Up @@ -22,6 +22,7 @@
<None Remove="Testfiles\IssueWithOnlyFileName.xml" />
<None Remove="Testfiles\IssueWithoutCode.xml" />
<None Remove="Testfiles\IssueWithoutFile.xml" />
<None Remove="Testfiles\XmlFileLoggerLogFileFormat\IssueWithAbsoluteFileNameAndWithoutTask.xml" />
<None Remove="Testfiles\XmlFileLoggerLogFileFormat\IssueWithoutMessage.xml" />
<None Remove="Testfiles\XmlFileLoggerLogFileFormat\LogWithControlChars.xml" />
</ItemGroup>
Expand Down Expand Up @@ -54,4 +55,8 @@
<ProjectReference Include="..\Cake.Issues.MsBuild\Cake.Issues.MsBuild.csproj" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Testfiles\XmlFileLoggerLogFileFormat\IssueWithAbsoluteFileNameAndWithoutTask.xml" />
</ItemGroup>

</Project>
@@ -1,5 +1,6 @@
namespace Cake.Issues.MsBuild.Tests.LogFileFormat
{
using System.IO;
using System.Linq;
using Cake.Core.Diagnostics;
using Cake.Core.IO;
Expand Down Expand Up @@ -364,7 +365,6 @@ public void Should_Ignore_Issue_Without_Message()
issues.Count.ShouldBe(0);
}


[Fact]
public void Should_Filter_Control_Chars_From_Log_Content()
{
Expand All @@ -378,6 +378,40 @@ public void Should_Filter_Control_Chars_From_Log_Content()
issues.Count.ShouldBe(0);
}

[Fact]
public void Should_Read_Issue_With_Absolute_FileName_And_Without_Task()
{
var fixture = new MsBuildIssuesProviderFixture<XmlFileLoggerLogFileFormat>("IssueWithAbsoluteFileNameAndWithoutTask.xml");

var repoRootCreated = !Directory.Exists(fixture.RepositorySettings.RepositoryRoot.FullPath);
Directory.CreateDirectory(fixture.RepositorySettings.RepositoryRoot.FullPath);
try
{
var oldWorkingDirectory = Directory.GetCurrentDirectory();
try
{
Directory.SetCurrentDirectory(fixture.RepositorySettings.RepositoryRoot.FullPath);

// When
var issues = fixture.ReadIssues().ToList();

// Then
issues.Count.ShouldBe(1);
}
finally
{
Directory.SetCurrentDirectory(oldWorkingDirectory);
}
}
finally
{
if (repoRootCreated)
{
Directory.Delete(fixture.RepositorySettings.RepositoryRoot.FullPath);
}
}
}

private static void CheckIssue(
IIssue issue,
string projectFileRelativePath,
Expand Down
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<build started="3/11/2019 22:29:45">
<warning code="SA1633" file="File.cs" line="1" column="1" started="3/11/2019 22:29:59"><![CDATA[The file header is missing or not located at the top of the file.]]></warning>
</build>
Expand Up @@ -222,6 +222,10 @@ private static bool TryGetRule(XElement warning, out string rule)
var compileTaskDirectory = System.IO.Path.GetDirectoryName(parentFileAttr.Value);
fileName = System.IO.Path.Combine(compileTaskDirectory, fileName);
}
else
{
fileName = System.IO.Path.Combine(repositorySettings.RepositoryRoot.FullPath, fileName);
}
}

// Validate file path and make relative to repository root.
Expand Down

0 comments on commit 39a0bc8

Please sign in to comment.