Skip to content
This repository has been archived by the owner on Apr 6, 2024. It is now read-only.

Commit

Permalink
(GH-37) Add extension for returning file name and path
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalberger committed Jun 26, 2018
1 parent e1bc183 commit 5e94212
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 12 deletions.
Expand Up @@ -73,6 +73,7 @@
<Compile Include="GenericIssueReportFormatAliases.cs" />
<Compile Include="GenericIssueReportGenerator.cs" />
<Compile Include="GenericIssueReportFormatSettings.cs" />
<Compile Include="IIssueExtension.cs" />
<Compile Include="RazorEngineReferenceResolver.cs" />
<Compile Include="GenericIssueReportTemplate.cs" />
<Compile Include="GenericIssueReportTemplateExtensions.cs" />
Expand Down
30 changes: 30 additions & 0 deletions src/Cake.Issues.Reporting.Generic/IIssueExtension.cs
@@ -0,0 +1,30 @@
namespace Cake.Issues.Reporting.Generic
{
using Cake.Core.IO;

/// <summary>
/// Extension for <see cref="IIssue"/>.
/// </summary>
public static class IIssueExtension
{
/// <summary>
/// Returns the path of the <see cref="IIssue.AffectedFileRelativePath"/>.
/// </summary>
/// <param name="issue">Issue for which the path should be returned.</param>
/// <returns>Path of the file affected by the issue.</returns>
public static string FilePath(this IIssue issue)
{
return issue.AffectedFileRelativePath?.GetDirectory().FullPath;
}

/// <summary>
/// Returns the name of the file of the <see cref="IIssue.AffectedFileRelativePath"/>.
/// </summary>
/// <param name="issue">Issue for which the file name should be returned.</param>
/// <returns>Name of the file affected by the issue.</returns>
public static string FileName(this IIssue issue)
{
return issue.AffectedFileRelativePath?.GetFilename().ToString();
}
}
}
Expand Up @@ -31,6 +31,7 @@ internal class RazorEngineReferenceResolver : IReferenceResolver
yield return CompilerReference.From(this.FindLoaded(loadedAssemblies, "Newtonsoft.Json.dll"));
yield return CompilerReference.From(this.FindLoaded(loadedAssemblies, "Cake.Core.dll"));
yield return CompilerReference.From(this.FindLoaded(loadedAssemblies, "Cake.Issues.dll"));
yield return CompilerReference.From(this.FindLoaded(loadedAssemblies, "Cake.Issues.Reporting.Generic.dll"));
yield return CompilerReference.From(typeof(RazorEngine.Engine).Assembly);
}

Expand Down
15 changes: 3 additions & 12 deletions src/Cake.Issues.Reporting.Generic/Templates/DataTable.cshtml
@@ -1,4 +1,5 @@
@model IEnumerable<Cake.Issues.IIssue>
@using Cake.Issues.Reporting.Generic

<!DOCTYPE html>

Expand Down Expand Up @@ -77,18 +78,8 @@
<tr>
<td>@issue.PriorityName</td>
<td>@issue.Project</td>
<td>
@if (issue.AffectedFileRelativePath != null)
{
@issue.AffectedFileRelativePath.GetDirectory()
}
</td>
<td>
@if (issue.AffectedFileRelativePath != null)
{
@issue.AffectedFileRelativePath.GetFilename()
}
</td>
<td>@issue.FilePath()</td>
<td>@issue.FileName()</td>
<td>@issue.Line</td>
<td>
@if (issue.RuleUrl != null)
Expand Down

0 comments on commit 5e94212

Please sign in to comment.