Skip to content

Commit

Permalink
Complete Xml documentation, fixes #4
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash Beeson committed Nov 19, 2016
1 parent 16924c0 commit b193bfc
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Cake.Stylecop/Cake.StyleCop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Cake.StyleCop.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -28,6 +29,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Cake.StyleCop.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Cake.Common, Version=0.17.0.0, Culture=neutral, processorArchitecture=MSIL">
Expand Down
3 changes: 2 additions & 1 deletion Cake.Stylecop/Cake.StyleCop.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
</metadata>
<files>
<file src="bin/Release/StyleCopStyleSheet.xslt" target="lib/net45" />
<file src="bin/Release/StyleCop.dll" target="lib/net45" />
<file src="bin/Release/StyleCop.dll" target="lib/net45" />
<file src="bin/Release/StyleCop.CSharp.dll" target="lib/net45" />
<file src="bin/Release/StyleCop.CSharp.Rules.dll" target="lib/net45" />
<file src="bin/Release/Cake.StyleCop.dll" target="lib/net45" />
<file src="bin/Release/Cake.StyleCop.XML" target="lib/net45" />
<file src="bin/Release/resources/error.png" target="lib/net45/resources" />
<file src="bin/Release/resources/minus.png" target="lib/net45/resources" />
<file src="bin/Release/resources/plus.png" target="lib/net45/resources" />
Expand Down
24 changes: 21 additions & 3 deletions Cake.Stylecop/StyleCopHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,28 @@
using Cake.Core;

using global::StyleCop;

using StyleCop;


/// <summary>
/// Stylecop utility class.
/// </summary>
public class StylecopHandlers
{
private readonly ICakeContext _context;

private int _totalViolations;

/// <summary>
/// Creates a new instance.
/// </summary>
/// <param name="context">The context.</param>
public StylecopHandlers(ICakeContext context)
{
_context = context;
}

/// <summary>
/// The total number of violations.
/// </summary>
public int TotalViolations
{
get
Expand All @@ -25,11 +33,21 @@ public int TotalViolations
}
}

/// <summary>
/// Called when Stylecop output has been generated.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="args">The event args.</param>
public void OnOutputGenerated(object sender, OutputEventArgs args)
{
Cake.Common.Diagnostics.LoggingAliases.Information(_context, args.Output);
}

/// <summary>
/// Called when Stylecop has encountered a rule violation.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="args">The event args.</param>
public void ViolationEncountered(object sender, ViolationEventArgs args)
{
_totalViolations++;
Expand Down
6 changes: 6 additions & 0 deletions Cake.Stylecop/StyleCopReportSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@
{
using Cake.Core.IO;

/// <summary>
/// A utility class for configuring stylecop output.
/// </summary>
public class StyleCopReportSettings
{
/// <summary>
/// Creates a new instance of the StyleCopReportSettings class.
/// </summary>
public StyleCopReportSettings()
{
ResultFiles = new FilePathCollection(new PathComparer(false));
Expand Down
38 changes: 37 additions & 1 deletion Cake.Stylecop/StyleCopRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,33 @@

using global::StyleCop;

/// <summary>
/// A proxy onto the StyleCopSettings type.
/// </summary>
/// <param name="settings">The settings.</param>
/// <returns>The settings.</returns>
public delegate StyleCopSettings SettingsDelegate(StyleCopSettings settings);

/// <summary>
/// A proxy onto the StyleCopReportSettings type.
/// </summary>
/// <param name="settings">The settings.</param>
/// <returns>The settings.</returns>
public delegate StyleCopReportSettings ReportSettingsDelegate(StyleCopReportSettings settings);

/// <summary>
/// The class that executes stylecop analysis.
/// </summary>
public static class StyleCopRunner
{
private static StyleCopSettings settings;
private const string FOLDER_PROJECT_TYPE_GUID = "{2150E333-8FDC-42A3-9474-1A3956D46DE8}";

/// <summary>
/// Starts an analysis run.
/// </summary>
/// <param name="context">The cake context.</param>
/// <param name="settingsDelegate">The stylecop setting to use during the analysis.</param>
public static void Execute(ICakeContext context, SettingsDelegate settingsDelegate)
{
settings = settingsDelegate(new StyleCopSettings());
Expand Down Expand Up @@ -112,11 +131,12 @@ public static void Execute(ICakeContext context, SettingsDelegate settingsDelega
/// <summary>
/// Transforms the outputted report using an XSL transform file.
/// </summary>
/// <param name="htmlFile">The fully qualified path of the output html file.</param>
/// <param name="outputXmlFile">
/// The fully-qualified path of the report to transform.
/// </param>
/// <param name="transformFile">The filePath for the xslt transform</param>
/// <param name="context"></param>
/// <param name="context">The cake context.</param>
private static void Transform(ICakeContext context, FilePath htmlFile, FilePath outputXmlFile, FilePath transformFile)
{
if (!context.FileExists(outputXmlFile))
Expand All @@ -141,13 +161,23 @@ private static void Transform(ICakeContext context, FilePath htmlFile, FilePath
context.Log.Debug($"Stylecop: Finished transform {outputXmlFile.FullPath} to {htmlFile}");
}

/// <summary>
/// The Assembly Directory.
/// </summary>
/// <param name="assembly">Assembly to return the directory path for.</param>
/// <returns>The assemblies directory path.</returns>
public static string AssemblyDirectory(Assembly assembly)
{
var codeBase = assembly.CodeBase;
var uri = new UriBuilder(codeBase);
return Uri.UnescapeDataString(uri.Path);
}

/// <summary>
/// Starts the report aggregation process.
/// </summary>
/// <param name="context">The cake context.</param>
/// <param name="settingsDelegate">The settings to use during report aggregation.</param>
public static void Report(ICakeContext context, ReportSettingsDelegate settingsDelegate)
{
try
Expand Down Expand Up @@ -178,6 +208,12 @@ public static void Report(ICakeContext context, ReportSettingsDelegate settingsD
}
}

/// <summary>
/// Merges two or more Stylecop report files into a single xml document.
/// </summary>
/// <param name="context">The cake context.</param>
/// <param name="resultFiles">A collection of report files to merge.</param>
/// <returns>The resultant Xml document.</returns>
public static XDocument MergeResultFile(ICakeContext context, FilePathCollection resultFiles)
{
context.Log.Information($"Stylecop: Loading result xml file {resultFiles.First().FullPath}");
Expand Down
6 changes: 6 additions & 0 deletions Cake.Stylecop/StyleCopSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@
{
using Cake.Core.IO;

/// <summary>
/// Contains configuration for a stylecop analysis execution.
/// </summary>
public class StyleCopSettings
{
/// <summary>
/// Creates a new instance of the StyleCopSettings class.
/// </summary>
public StyleCopSettings()
{
Addins = new DirectoryPathCollection(new PathComparer(false));
Expand Down
3 changes: 3 additions & 0 deletions Cake.Stylecop/StyleCopSettingsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ namespace Cake.Stylecop

using Cake.Core.IO;

/// <summary>
/// Extensions that enable a fluent interface onto the StyleCopSettings type.
/// </summary>
public static class StyleCopSettingsExtensions
{
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const string Configuration = "Release";
.Does(() => {

var nuGetPackSettings = new NuGetPackSettings {
Version = "1.1.1",
Version = "1.1.2",
BasePath = "./Cake.StyleCop",
OutputDirectory = nupkgDestDir
};
Expand Down
2 changes: 1 addition & 1 deletion tools/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Cake" version="0.13.0" />
<package id="Cake" version="0.17.0" />
</packages>

0 comments on commit b193bfc

Please # to comment.