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

Commit

Permalink
Merge branch 'release/0.9.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalberger committed Aug 22, 2020
2 parents cb2ac22 + 4a29bba commit 60a849a
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 27 deletions.
1 change: 1 addition & 0 deletions docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ The [Cake.Issues.MsBuild addin] provides the following features.
| <span class="glyphicon glyphicon-remove" style="color:red"></span> | `IIssue.EndLine` | |
| <span class="glyphicon glyphicon-ok" style="color:orange"></span> | `IIssue.Column` | Only for [MsBuildXmlFileLoggerFormat] |
| <span class="glyphicon glyphicon-remove" style="color:red"></span> | `IIssue.EndColumn` | |
| <span class="glyphicon glyphicon-remove" style="color:red"></span> | `IIssue.FileLink` | Can be set while reading issues |
| <span class="glyphicon glyphicon-ok" style="color:green"></span> | `IIssue.MessageText` | |
| <span class="glyphicon glyphicon-remove" style="color:red"></span> | `IIssue.MessageHtml` | |
| <span class="glyphicon glyphicon-remove" style="color:red"></span> | `IIssue.MessageMarkdown` | |
Expand Down
2 changes: 1 addition & 1 deletion nuspec/nuget/Cake.Issues.MsBuild.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ See the Project Site for an overview of the whole ecosystem of addins for workin
<repository type="git" url="https://github.com/cake-contrib/Cake.Issues.MsBuild.git"/>
<copyright>Copyright © BBT Software AG and contributors</copyright>
<tags>Cake Script Cake-Issues Cake-IssueProvider CodeAnalysis Linting MsBuild</tags>
<releaseNotes>https://github.com/cake-contrib/Cake.Issues.MsBuild/releases/tag/0.8.0</releaseNotes>
<releaseNotes>https://github.com/cake-contrib/Cake.Issues.MsBuild/releases/tag/0.9.0</releaseNotes>
</metadata>
<files>
<file src="..\..\..\..\nuspec\nuget\icon.png" target="" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="Cake.Core" Version="0.33.0" />
<PackageReference Include="Cake.Testing" Version="0.33.0" />
<PackageReference Include="Cake.Issues" Version="0.9.0-beta0002" />
<PackageReference Include="Cake.Issues.Testing" Version="0.9.0-beta0002" />
<PackageReference Include="Cake.Issues" Version="0.9.0" />
<PackageReference Include="Cake.Issues.Testing" Version="0.9.0" />
<PackageReference Include="Shouldly" Version="3.0.2" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
<PackageReference Include="xunit" Version="2.4.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void Should_Read_Full_Log_Correct()
// Given
var fixture = new MsBuildIssuesProviderFixture<BinaryLogFileFormat>("FullLog.binlog")
{
RepositorySettings = new RepositorySettings(@"C:\projects\cake-issues-demo\"),
ReadIssuesSettings = new ReadIssuesSettings(@"C:\projects\cake-issues-demo\"),
};

// When
Expand All @@ -49,7 +49,7 @@ public void Should_Read_Full_Log_Correct()
"Cake.Issues.MsBuild.MsBuildIssuesProvider",
"MSBuild")
.InProject(@"src\ClassLibrary1\ClassLibrary1.csproj", "ClassLibrary1")
.InFile(@"src\ClassLibrary1\Class1.cs", 13)
.InFile(@"src\ClassLibrary1\Class1.cs", 13, 17)
.OfRule("CS0219")
.WithPriority(IssuePriority.Warning));
IssueChecker.Check(
Expand All @@ -59,7 +59,7 @@ public void Should_Read_Full_Log_Correct()
"Cake.Issues.MsBuild.MsBuildIssuesProvider",
"MSBuild")
.InProject(@"src\ClassLibrary1\ClassLibrary1.csproj", "ClassLibrary1")
.InFile(@"src\ClassLibrary1\Class1.cs", 1)
.InFile(@"src\ClassLibrary1\Class1.cs", 1, 1)
.OfRule("SA1652", new Uri("https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1652.md"))
.WithPriority(IssuePriority.Warning));
IssueChecker.Check(
Expand All @@ -69,7 +69,7 @@ public void Should_Read_Full_Log_Correct()
"Cake.Issues.MsBuild.MsBuildIssuesProvider",
"MSBuild")
.InProject(@"src\ClassLibrary1\ClassLibrary1.csproj", "ClassLibrary1")
.InFile(@"src\ClassLibrary1\Class1.cs", 1)
.InFile(@"src\ClassLibrary1\Class1.cs", 1, 1)
.OfRule("SA1633", new Uri("https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1633.md"))
.WithPriority(IssuePriority.Warning));
IssueChecker.Check(
Expand All @@ -79,7 +79,7 @@ public void Should_Read_Full_Log_Correct()
"Cake.Issues.MsBuild.MsBuildIssuesProvider",
"MSBuild")
.InProject(@"src\ClassLibrary1\ClassLibrary1.csproj", "ClassLibrary1")
.InFile(@"src\ClassLibrary1\Properties\AssemblyInfo.cs", 1)
.InFile(@"src\ClassLibrary1\Properties\AssemblyInfo.cs", 1, 1)
.OfRule("SA1652", new Uri("https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1652.md"))
.WithPriority(IssuePriority.Warning));
IssueChecker.Check(
Expand All @@ -89,7 +89,7 @@ public void Should_Read_Full_Log_Correct()
"Cake.Issues.MsBuild.MsBuildIssuesProvider",
"MSBuild")
.InProject(@"src\ClassLibrary1\ClassLibrary1.csproj", "ClassLibrary1")
.InFile(@"src\ClassLibrary1\Properties\AssemblyInfo.cs", 1)
.InFile(@"src\ClassLibrary1\Properties\AssemblyInfo.cs", 1, 1)
.OfRule("SA1633", new Uri("https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1633.md"))
.WithPriority(IssuePriority.Warning));
IssueChecker.Check(
Expand All @@ -99,7 +99,7 @@ public void Should_Read_Full_Log_Correct()
"Cake.Issues.MsBuild.MsBuildIssuesProvider",
"MSBuild")
.InProject(@"src\ClassLibrary1\ClassLibrary1.csproj", "ClassLibrary1")
.InFile(@"src\ClassLibrary1\Properties\AssemblyInfo.cs", 5)
.InFile(@"src\ClassLibrary1\Properties\AssemblyInfo.cs", 5, 77)
.OfRule("SA1028", new Uri("https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md"))
.WithPriority(IssuePriority.Warning));
IssueChecker.Check(
Expand All @@ -109,7 +109,7 @@ public void Should_Read_Full_Log_Correct()
"Cake.Issues.MsBuild.MsBuildIssuesProvider",
"MSBuild")
.InProject(@"src\ClassLibrary1\ClassLibrary1.csproj", "ClassLibrary1")
.InFile(@"src\ClassLibrary1\Properties\AssemblyInfo.cs", 17)
.InFile(@"src\ClassLibrary1\Properties\AssemblyInfo.cs", 17, 76)
.OfRule("SA1028", new Uri("https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md"))
.WithPriority(IssuePriority.Warning));
IssueChecker.Check(
Expand All @@ -119,7 +119,7 @@ public void Should_Read_Full_Log_Correct()
"Cake.Issues.MsBuild.MsBuildIssuesProvider",
"MSBuild")
.InProject(@"src\ClassLibrary1\ClassLibrary1.csproj", "ClassLibrary1")
.InFile(@"src\ClassLibrary1\Properties\AssemblyInfo.cs", 18)
.InFile(@"src\ClassLibrary1\Properties\AssemblyInfo.cs", 18, 74)
.OfRule("SA1028", new Uri("https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md"))
.WithPriority(IssuePriority.Warning));
IssueChecker.Check(
Expand All @@ -129,7 +129,7 @@ public void Should_Read_Full_Log_Correct()
"Cake.Issues.MsBuild.MsBuildIssuesProvider",
"MSBuild")
.InProject(@"src\ClassLibrary1\ClassLibrary1.csproj", "ClassLibrary1")
.InFile(@"src\ClassLibrary1\Properties\AssemblyInfo.cs", 28)
.InFile(@"src\ClassLibrary1\Properties\AssemblyInfo.cs", 28, 22)
.OfRule("SA1028", new Uri("https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md"))
.WithPriority(IssuePriority.Warning));
IssueChecker.Check(
Expand All @@ -139,7 +139,7 @@ public void Should_Read_Full_Log_Correct()
"Cake.Issues.MsBuild.MsBuildIssuesProvider",
"MSBuild")
.InProject(@"src\ClassLibrary1\ClassLibrary1.csproj", "ClassLibrary1")
.InFile(@"src\ClassLibrary1\Properties\AssemblyInfo.cs", 32)
.InFile(@"src\ClassLibrary1\Properties\AssemblyInfo.cs", 32, 84)
.OfRule("SA1028", new Uri("https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md"))
.WithPriority(IssuePriority.Warning));
IssueChecker.Check(
Expand All @@ -149,7 +149,7 @@ public void Should_Read_Full_Log_Correct()
"Cake.Issues.MsBuild.MsBuildIssuesProvider",
"MSBuild")
.InProject(@"src\ClassLibrary1\ClassLibrary1.csproj", "ClassLibrary1")
.InFile(@"src\ClassLibrary1\Class1.cs", 1)
.InFile(@"src\ClassLibrary1\Class1.cs", 1, 1)
.OfRule("SA1200", new Uri("https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1200.md"))
.WithPriority(IssuePriority.Warning));
IssueChecker.Check(
Expand All @@ -159,7 +159,7 @@ public void Should_Read_Full_Log_Correct()
"Cake.Issues.MsBuild.MsBuildIssuesProvider",
"MSBuild")
.InProject(@"src\ClassLibrary1\ClassLibrary1.csproj", "ClassLibrary1")
.InFile(@"src\ClassLibrary1\Class1.cs", 2)
.InFile(@"src\ClassLibrary1\Class1.cs", 2, 1)
.OfRule("SA1200", new Uri("https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1200.md"))
.WithPriority(IssuePriority.Warning));
IssueChecker.Check(
Expand All @@ -169,7 +169,7 @@ public void Should_Read_Full_Log_Correct()
"Cake.Issues.MsBuild.MsBuildIssuesProvider",
"MSBuild")
.InProject(@"src\ClassLibrary1\ClassLibrary1.csproj", "ClassLibrary1")
.InFile(@"src\ClassLibrary1\Class1.cs", 3)
.InFile(@"src\ClassLibrary1\Class1.cs", 3, 1)
.OfRule("SA1200", new Uri("https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1200.md"))
.WithPriority(IssuePriority.Warning));
IssueChecker.Check(
Expand All @@ -179,7 +179,7 @@ public void Should_Read_Full_Log_Correct()
"Cake.Issues.MsBuild.MsBuildIssuesProvider",
"MSBuild")
.InProject(@"src\ClassLibrary1\ClassLibrary1.csproj", "ClassLibrary1")
.InFile(@"src\ClassLibrary1\Class1.cs", 4)
.InFile(@"src\ClassLibrary1\Class1.cs", 4, 1)
.OfRule("SA1200", new Uri("https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1200.md"))
.WithPriority(IssuePriority.Warning));
IssueChecker.Check(
Expand All @@ -189,7 +189,7 @@ public void Should_Read_Full_Log_Correct()
"Cake.Issues.MsBuild.MsBuildIssuesProvider",
"MSBuild")
.InProject(@"src\ClassLibrary1\ClassLibrary1.csproj", "ClassLibrary1")
.InFile(@"src\ClassLibrary1\Class1.cs", 5)
.InFile(@"src\ClassLibrary1\Class1.cs", 5, 1)
.OfRule("SA1200", new Uri("https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1200.md"))
.WithPriority(IssuePriority.Warning));
IssueChecker.Check(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,14 @@ 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);
var repoRootCreated = !Directory.Exists(fixture.ReadIssuesSettings.RepositoryRoot.FullPath);
Directory.CreateDirectory(fixture.ReadIssuesSettings.RepositoryRoot.FullPath);
try
{
var oldWorkingDirectory = Directory.GetCurrentDirectory();
try
{
Directory.SetCurrentDirectory(fixture.RepositorySettings.RepositoryRoot.FullPath);
Directory.SetCurrentDirectory(fixture.ReadIssuesSettings.RepositoryRoot.FullPath);

// When
var issues = fixture.ReadIssues().ToList();
Expand All @@ -398,7 +398,7 @@ public void Should_Read_Issue_With_Absolute_FileName_And_Without_Task()
{
if (repoRootCreated)
{
Directory.Delete(fixture.RepositorySettings.RepositoryRoot.FullPath);
Directory.Delete(fixture.ReadIssuesSettings.RepositoryRoot.FullPath);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal class MsBuildIssuesProviderFixture<T>
public MsBuildIssuesProviderFixture(string fileResourceName)
: base(fileResourceName)
{
this.RepositorySettings = new RepositorySettings(@"c:\Source\Cake.Issues.MsBuild");
this.ReadIssuesSettings = new ReadIssuesSettings(@"c:\Source\Cake.Issues.MsBuild");
}

protected override string FileResourceNamespace => "Cake.Issues.MsBuild.Tests.Testfiles." + typeof(T).Name + ".";
Expand Down
4 changes: 2 additions & 2 deletions src/Cake.Issues.MsBuild/Cake.Issues.MsBuild.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

<ItemGroup>
<PackageReference Include="Cake.Core" Version="0.33.0" />
<PackageReference Include="Cake.Issues" Version="0.9.0-beta0002" />
<PackageReference Include="Cake.Issues" Version="0.9.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0" />
<PackageReference Include="MSBuild.StructuredLogger" Version="2.1.133" />
<PackageReference Include="MSBuild.StructuredLogger" Version="2.0.174" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
</ItemGroup>

Expand Down
59 changes: 58 additions & 1 deletion src/Cake.Issues.MsBuild/LogFileFormat/BinaryLogFileFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public override IEnumerable<IIssue> ReadIssues(
}

var line = GetLine(buildWarning);
var endLine = GetEndLine(buildWarning);
var column = GetColumn(buildWarning);
var endColumn = GetEndColumn(buildWarning);
var rule = buildWarning.Code;

// Determine rule URL.
Expand All @@ -75,7 +78,7 @@ public override IEnumerable<IIssue> ReadIssues(
.NewIssue(buildWarning.Message, issueProvider)
.WithPriority(IssuePriority.Warning)
.InProject(projectFileRelativePath, System.IO.Path.GetFileNameWithoutExtension(projectFileRelativePath))
.InFile(fileName, line)
.InFile(fileName, line, endLine, column, endColumn)
.OfRule(rule, ruleUrl)
.Create());
}
Expand All @@ -102,6 +105,60 @@ public override IEnumerable<IIssue> ReadIssues(
return line;
}

/// <summary>
/// Reads the end of line range from a warning logged in a MsBuild log.
/// </summary>
/// <param name="warning">Warning element from MsBuild log.</param>
/// <returns>End of line range or null if warning is not related to a file.</returns>
private static int? GetEndLine(BuildWarningEventArgs warning)
{
var endLine = warning.EndLineNumber;

// Convert negative line numbers or line number 0 to null
if (endLine <= 0)
{
return null;
}

return endLine;
}

/// <summary>
/// Reads the affected column from a warning logged in a MsBuild log.
/// </summary>
/// <param name="warning">Warning element from MsBuild log.</param>
/// <returns>Column number or null if warning is not related to a file.</returns>
private static int? GetColumn(BuildWarningEventArgs warning)
{
var column = warning.ColumnNumber;

// Convert negative column numbers or column number 0 to null
if (column <= 0)
{
return null;
}

return column;
}

/// <summary>
/// Reads the end of column range from a warning logged in a MsBuild log.
/// </summary>
/// <param name="warning">Warning element from MsBuild log.</param>
/// <returns>End of column range or null if warning is not related to a file.</returns>
private static int? GetEndColumn(BuildWarningEventArgs warning)
{
var endColumn = warning.EndColumnNumber;

// Convert negative column numbers or column number 0 to null
if (endColumn <= 0)
{
return null;
}

return endColumn;
}

/// <summary>
/// Determines the project for a warning logged in a MsBuild log.
/// </summary>
Expand Down

0 comments on commit 60a849a

Please sign in to comment.