diff --git a/.appveyor.yml b/.appveyor.yml
new file mode 100644
index 0000000..afb3780
--- /dev/null
+++ b/.appveyor.yml
@@ -0,0 +1,26 @@
+#---------------------------------#
+# Build Script #
+#---------------------------------#
+build_script:
+ - ps: .\build.ps1 -Target AppVeyor
+
+# Tests
+test: off
+
+#---------------------------------#
+# Branches to build #
+#---------------------------------#
+branches:
+ # Whitelist
+ only:
+ - develop
+ - master
+ - /release/.*/
+ - /hotfix/.*/
+
+#---------------------------------#
+# Build Cache #
+#---------------------------------#
+cache:
+- Source\packages -> Source\**\packages.config
+- tools -> setup.cake
\ No newline at end of file
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..1ff0c42
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,63 @@
+###############################################################################
+# Set default behavior to automatically normalize line endings.
+###############################################################################
+* text=auto
+
+###############################################################################
+# Set default behavior for command prompt diff.
+#
+# This is need for earlier builds of msysgit that does not have it on by
+# default for csharp files.
+# Note: This is only used by command line
+###############################################################################
+#*.cs diff=csharp
+
+###############################################################################
+# Set the merge driver for project and solution files
+#
+# Merging from the command prompt will add diff markers to the files if there
+# are conflicts (Merging from VS is not affected by the settings below, in VS
+# the diff markers are never inserted). Diff markers may cause the following
+# file extensions to fail to load in VS. An alternative would be to treat
+# these files as binary and thus will always conflict and require user
+# intervention with every merge. To do so, just uncomment the entries below
+###############################################################################
+#*.sln merge=binary
+#*.csproj merge=binary
+#*.vbproj merge=binary
+#*.vcxproj merge=binary
+#*.vcproj merge=binary
+#*.dbproj merge=binary
+#*.fsproj merge=binary
+#*.lsproj merge=binary
+#*.wixproj merge=binary
+#*.modelproj merge=binary
+#*.sqlproj merge=binary
+#*.wwaproj merge=binary
+
+###############################################################################
+# behavior for image files
+#
+# image files are treated as binary by default.
+###############################################################################
+#*.jpg binary
+#*.png binary
+#*.gif binary
+
+###############################################################################
+# diff behavior for common document formats
+#
+# Convert binary document formats to text before diffing them. This feature
+# is only available from the command line. Turn it on by uncommenting the
+# entries below.
+###############################################################################
+#*.doc diff=astextplain
+#*.DOC diff=astextplain
+#*.docx diff=astextplain
+#*.DOCX diff=astextplain
+#*.dot diff=astextplain
+#*.DOT diff=astextplain
+#*.pdf diff=astextplain
+#*.PDF diff=astextplain
+#*.rtf diff=astextplain
+#*.RTF diff=astextplain
diff --git a/.gitignore b/.gitignore
index f1e3d20..a9e78cf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,7 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.suo
@@ -40,9 +42,11 @@ TestResult.xml
[Rr]eleasePS/
dlldata.c
-# DNX
+# .NET Core
project.lock.json
+project.fragment.lock.json
artifacts/
+**/Properties/launchSettings.json
*_i.c
*_p.c
@@ -109,6 +113,10 @@ _TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
# NCrunch
_NCrunch_*
.*crunch*.local.xml
@@ -188,9 +196,9 @@ ClientBin/
*~
*.dbmdl
*.dbproj.schemaview
+*.jfm
*.pfx
*.publishsettings
-node_modules/
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
@@ -225,6 +233,10 @@ FakesAssemblies/
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
+node_modules/
+
+# Typescript v1 declaration files
+typings/
# Visual Studio 6 build log
*.plg
@@ -232,6 +244,9 @@ FakesAssemblies/
# Visual Studio 6 workspace options file
*.opt
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
@@ -250,3 +265,15 @@ paket-files/
# JetBrains Rider
.idea/
*.sln.iml
+
+# CodeRush
+.cr/
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+tools/**
+!tools/packages.config
+BuildArtifacts/
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..eb79eee
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,10 @@
+language: csharp
+script:
+ - ./build.sh -v diagnostic
+os:
+ - linux
+ - osx
+cache:
+ directories:
+ - packages
+ - tools
diff --git a/GitReleaseManager.yaml b/GitReleaseManager.yaml
new file mode 100644
index 0000000..721c1ba
--- /dev/null
+++ b/GitReleaseManager.yaml
@@ -0,0 +1,12 @@
+issue-labels-include:
+- Breaking change
+- Feature
+- Bug
+- Improvement
+- Documentation
+issue-labels-exclude:
+- Build
+issue-labels-alias:
+ - name: Documentation
+ header: Documentation
+ plural: Documentation
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index e77621a..e052ef6 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2017 BBT Software AG
+Copyright (c) 2017 BBT Software AG and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 943396a..c553d5c 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,52 @@
-# Cake.Prca.Issues.InspectCode
-Addin for providing issues reported by JetBrains Inspect Code to Cake.Prca Addin
+# JetBrains Inspect Code Issue Provider for Cake Pull Request Code Analysis Addin
+
+This Addin for the Cake Build Automation System allows you to write issue logged by JetBrains Inspect Code as comments to pull requests
+using the [Cake Pull Request Code Analysis Addin].
+More about Cake at http://cakebuild.net
+
+[![License](http://img.shields.io/:license-mit-blue.svg)](https://github.com/cake-contrib/Cake.Prca.Issues.InspectCode/blob/feature/build/LICENSE)
+
+## Information
+
+| | Stable | Pre-release |
+|:--:|:--:|:--:|
+|GitHub Release|-|[![GitHub release](https://img.shields.io/github/release/cake-contrib/Cake.Prca.Issues.InspectCode.svg)](https://github.com/cake-contrib/Cake.Prca.Issues.InspectCode/releases/latest)|
+|NuGet|[![NuGet](https://img.shields.io/nuget/v/Cake.Prca.Issues.InspectCode.svg)](https://www.nuget.org/packages/Cake.Prca.Issues.InspectCode)|[![NuGet](https://img.shields.io/nuget/vpre/Cake.Prca.Issues.InspectCode.svg)](https://www.nuget.org/packages/Cake.Prca.Issues.InspectCode)|
+
+## Build Status
+
+|Develop|Master|
+|:--:|:--:|
+|[![Build status](https://ci.appveyor.com/api/projects/status/xxx/branch/develop?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-prca-issues-inspectcode/branch/develop)|[![Build status](https://ci.appveyor.com/api/projects/status/xxx/branch/develop?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-prca-issues-inspectcode/branch/master)|
+
+## Code Coverage
+
+[![Coverage Status](https://coveralls.io/repos/github/cake-contrib/Cake.Prca.Issues.InspectCode/badge.svg?branch=develop)](https://coveralls.io/github/cake-contrib/Cake.Prca.Issues.InspectCode?branch=develop)
+
+## Quick Links
+
+- [Documentation](https://cake-contrib.github.io/Cake.Prca.Website)
+
+## Chat Room
+
+Come join in the conversation about Cake Pull Request Code Analysis in our Gitter Chat Room
+
+[![Join the chat at https://gitter.im/cake-contrib/Lobby](https://badges.gitter.im/cake-contrib/Lobby.svg)](https://gitter.im/cake-contrib/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+
+## Build
+
+To build this package we are using Cake.
+
+On Windows PowerShell run:
+
+```powershell
+./build
+```
+
+On OSX/Linux run:
+
+```bash
+./build.sh
+```
+
+[Cake Pull Request Code Analysis Addin]: https://github.com/cake-contrib/Cake.Prca
\ No newline at end of file
diff --git a/build.ps1 b/build.ps1
new file mode 100644
index 0000000..bdfb32b
--- /dev/null
+++ b/build.ps1
@@ -0,0 +1,184 @@
+##########################################################################
+# This is the Cake bootstrapper script for PowerShell.
+# This file was downloaded from https://github.com/cake-build/resources
+# Feel free to change this file to fit your needs.
+##########################################################################
+
+<#
+.SYNOPSIS
+This is a Powershell script to bootstrap a Cake build.
+.DESCRIPTION
+This Powershell script will download NuGet if missing, restore NuGet tools (including Cake)
+and execute your Cake build script with the parameters you provide.
+.PARAMETER Script
+The build script to execute.
+.PARAMETER Target
+The build script target to run.
+.PARAMETER Configuration
+The build configuration to use.
+.PARAMETER Verbosity
+Specifies the amount of information to be displayed.
+.PARAMETER Experimental
+Tells Cake to use the latest Roslyn release.
+.PARAMETER WhatIf
+Performs a dry run of the build script.
+No tasks will be executed.
+.PARAMETER Mono
+Tells Cake to use the Mono scripting engine.
+.PARAMETER SkipToolPackageRestore
+Skips restoring of packages.
+.PARAMETER ScriptArgs
+Remaining arguments are added here.
+.LINK
+http://cakebuild.net
+#>
+
+[CmdletBinding()]
+Param(
+ [string]$Script = "setup.cake",
+ [string]$Target = "Default",
+ [ValidateSet("Release", "Debug")]
+ [string]$Configuration = "Release",
+ [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
+ [string]$Verbosity = "Verbose",
+ [switch]$Experimental,
+ [Alias("DryRun","Noop")]
+ [switch]$WhatIf,
+ [switch]$Mono,
+ [switch]$SkipToolPackageRestore,
+ [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
+ [string[]]$ScriptArgs
+)
+
+[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null
+function MD5HashFile([string] $filePath)
+{
+ if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf))
+ {
+ return $null
+ }
+
+ [System.IO.Stream] $file = $null;
+ [System.Security.Cryptography.MD5] $md5 = $null;
+ try
+ {
+ $md5 = [System.Security.Cryptography.MD5]::Create()
+ $file = [System.IO.File]::OpenRead($filePath)
+ return [System.BitConverter]::ToString($md5.ComputeHash($file))
+ }
+ finally
+ {
+ if ($file -ne $null)
+ {
+ $file.Dispose()
+ }
+ }
+}
+
+Write-Host "Preparing to run build script..."
+
+if(!$PSScriptRoot){
+ $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
+}
+
+$TOOLS_DIR = Join-Path $PSScriptRoot "tools"
+$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe"
+$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe"
+$NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
+$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config"
+$PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum"
+
+# Should we use mono?
+$UseMono = "";
+if($Mono.IsPresent) {
+ Write-Verbose -Message "Using the Mono based scripting engine."
+ $UseMono = "-mono"
+}
+
+# Should we use the new Roslyn?
+$UseExperimental = "";
+if($Experimental.IsPresent -and !($Mono.IsPresent)) {
+ Write-Verbose -Message "Using experimental version of Roslyn."
+ $UseExperimental = "-experimental"
+}
+
+# Is this a dry run?
+$UseDryRun = "";
+if($WhatIf.IsPresent) {
+ $UseDryRun = "-dryrun"
+}
+
+# Make sure tools folder exists
+if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
+ Write-Verbose -Message "Creating tools directory..."
+ New-Item -Path $TOOLS_DIR -Type directory | out-null
+}
+
+# Make sure that packages.config exist.
+if (!(Test-Path $PACKAGES_CONFIG)) {
+ Write-Verbose -Message "Downloading packages.config..."
+ try { (New-Object System.Net.WebClient).DownloadFile("http://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) } catch {
+ Throw "Could not download packages.config."
+ }
+}
+
+# Try find NuGet.exe in path if not exists
+if (!(Test-Path $NUGET_EXE)) {
+ Write-Verbose -Message "Trying to find nuget.exe in PATH..."
+ $existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_) }
+ $NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1
+ if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) {
+ Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)."
+ $NUGET_EXE = $NUGET_EXE_IN_PATH.FullName
+ }
+}
+
+# Try download NuGet.exe if not exists
+if (!(Test-Path $NUGET_EXE)) {
+ Write-Verbose -Message "Downloading NuGet.exe..."
+ try {
+ (New-Object System.Net.WebClient).DownloadFile($NUGET_URL, $NUGET_EXE)
+ } catch {
+ Throw "Could not download NuGet.exe."
+ }
+}
+
+# Save nuget.exe path to environment to be available to child processed
+$ENV:NUGET_EXE = $NUGET_EXE
+
+# Restore tools from NuGet?
+if(-Not $SkipToolPackageRestore.IsPresent) {
+ Push-Location
+ Set-Location $TOOLS_DIR
+
+ # Check for changes in packages.config and remove installed tools if true.
+ [string] $md5Hash = MD5HashFile($PACKAGES_CONFIG)
+ if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or
+ ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
+ Write-Verbose -Message "Missing or changed package.config hash..."
+ Remove-Item * -Recurse -Exclude packages.config,nuget.exe
+ }
+
+ Write-Verbose -Message "Restoring tools from NuGet..."
+ $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -PreRelease -OutputDirectory `"$TOOLS_DIR`" -Source https://www.myget.org/F/cake/api/v3/index.json"
+
+ if ($LASTEXITCODE -ne 0) {
+ Throw "An error occured while restoring NuGet tools."
+ }
+ else
+ {
+ $md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII"
+ }
+ Write-Verbose -Message ($NuGetOutput | out-string)
+ Pop-Location
+}
+
+# Make sure that Cake has been installed.
+if (!(Test-Path $CAKE_EXE)) {
+ Throw "Could not find Cake.exe at $CAKE_EXE"
+}
+
+# Start Cake
+Write-Host "Running build script..."
+Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" -target=`"$Target`" -configuration=`"$Configuration`" -verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs"
+exit $LASTEXITCODE
\ No newline at end of file
diff --git a/build.sh b/build.sh
new file mode 100644
index 0000000..a541ec1
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,82 @@
+#!/usr/bin/env bash
+###############################################################
+# This is the Cake bootstrapper script that is responsible for
+# downloading Cake and all specified tools from NuGet.
+###############################################################
+
+# Define directories.
+SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
+TOOLS_DIR=$SCRIPT_DIR/tools
+NUGET_EXE=$TOOLS_DIR/nuget.exe
+CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe
+
+# Define default arguments.
+SCRIPT="setup.cake"
+TARGET="Default"
+CONFIGURATION="Release"
+VERBOSITY="verbose"
+DRYRUN=
+SHOW_VERSION=false
+SCRIPT_ARGUMENTS=()
+
+# Parse arguments.
+for i in "$@"; do
+ case $1 in
+ -s|--script) SCRIPT="$2"; shift ;;
+ -t|--target) TARGET="$2"; shift ;;
+ -c|--configuration) CONFIGURATION="$2"; shift ;;
+ -v|--verbosity) VERBOSITY="$2"; shift ;;
+ -d|--dryrun) DRYRUN="-dryrun" ;;
+ --version) SHOW_VERSION=true ;;
+ --) shift; SCRIPT_ARGUMENTS+=("$@"); break ;;
+ *) SCRIPT_ARGUMENTS+=("$1") ;;
+ esac
+ shift
+done
+
+# Make sure the tools folder exist.
+if [ ! -d $TOOLS_DIR ]; then
+ mkdir $TOOLS_DIR
+fi
+
+# Make sure that packages.config exist.
+if [ ! -f $TOOLS_DIR/packages.config ]; then
+ echo "Downloading packages.config..."
+ curl -Lsfo $TOOLS_DIR/packages.config http://cakebuild.net/bootstrapper/packages
+ if [ $? -ne 0 ]; then
+ echo "An error occured while downloading packages.config."
+ exit 1
+ fi
+fi
+
+# Download NuGet if it does not exist.
+if [ ! -f $NUGET_EXE ]; then
+ echo "Downloading NuGet..."
+ curl -Lsfo $NUGET_EXE https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
+ if [ $? -ne 0 ]; then
+ echo "An error occured while downloading nuget.exe."
+ exit 1
+ fi
+fi
+
+# Restore tools from NuGet.
+pushd $TOOLS_DIR >/dev/null
+mono $NUGET_EXE install -ExcludeVersion -PreRelease -Source https://www.myget.org/F/cake/api/v3/index.json
+if [ $? -ne 0 ]; then
+ echo "Could not restore NuGet packages."
+ exit 1
+fi
+popd >/dev/null
+
+# Make sure that Cake has been installed.
+if [ ! -f $CAKE_EXE ]; then
+ echo "Could not find Cake.exe at '$CAKE_EXE'."
+ exit 1
+fi
+
+# Start Cake
+if $SHOW_VERSION; then
+ exec mono $CAKE_EXE -version
+else
+ exec mono $CAKE_EXE $SCRIPT -verbosity=$VERBOSITY -configuration=$CONFIGURATION -target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}"
+fi
diff --git a/nuspec/nuget/Cake.Prca.Issues.InspectCode.nuspec b/nuspec/nuget/Cake.Prca.Issues.InspectCode.nuspec
new file mode 100644
index 0000000..f6d44ed
--- /dev/null
+++ b/nuspec/nuget/Cake.Prca.Issues.InspectCode.nuspec
@@ -0,0 +1,26 @@
+
+
+
+ Cake.Prca.Issues.InspectCode
+ JetBrains Inspect Code support for Cake Pull Request Code Analysis
+ 0.0.0
+ BBT Software AG
+ bbtsoftware, pascalberger, cake-contrib
+ JetBrains Inspect Code support for the Pull Request Code Analysis Addin for Cake Build Automation System
+ The Inspect Code support for the Pull Request Code Analysis Addin for Cake allows you to write any issues logged by JetBrains Inspect Code to a pull request.
+ https://github.com/cake-contrib/Cake.Prca.Issues.InspectCode/blob/develop/LICENSE
+ https://github.com/cake-contrib/Cake.Prca.Issues.InspectCode
+ https://raw.githubusercontent.com/cake-build/graphics/aba74fb4cb5fe9454381af2cc70c870088229d5c/png/cake-medium.png
+ false
+ Copyright © 2017 BBT Software AG, Root/Zermatt, Switzerland
+ Cake Script PullRequest CodeAnalysis Cake-Prca-IssueProvider Linting InspectCode
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/setup.cake b/setup.cake
new file mode 100644
index 0000000..2a791bd
--- /dev/null
+++ b/setup.cake
@@ -0,0 +1,23 @@
+#load nuget:https://www.myget.org/F/cake-contrib/api/v2?package=Cake.Recipe&prerelease
+
+Environment.SetVariableNames();
+
+BuildParameters.SetParameters(
+ context: Context,
+ buildSystem: BuildSystem,
+ sourceDirectoryPath: "./src",
+ title: "Cake.Prca.Issues.InspectCode",
+ repositoryOwner: "cake-contrib",
+ repositoryName: "Cake.Prca.Issues.InspectCode",
+ appVeyorAccountName: "cakecontrib");
+
+BuildParameters.PrintParameters(Context);
+
+ToolSettings.SetToolSettings(
+ context: Context,
+ dupFinderExcludePattern: new string[] { BuildParameters.RootDirectoryPath + "/src/Cake.Prca.Issues.InspectCode.Tests/*.cs" },
+ testCoverageFilter: "+[*]* -[xunit.*]* -[Cake.Core]* -[Cake.Testing]* -[*.Tests]* -[Cake.Prca]*",
+ testCoverageExcludeByAttribute: "*.ExcludeFromCodeCoverage*",
+ testCoverageExcludeByFile: "*/*Designer.cs;*/*.g.cs;*/*.g.i.cs");
+
+Build.Run();
diff --git a/src/Cake.Prca.Issues.InspectCode.Tests/Cake.Prca.Issues.InspectCode.Tests.csproj b/src/Cake.Prca.Issues.InspectCode.Tests/Cake.Prca.Issues.InspectCode.Tests.csproj
new file mode 100644
index 0000000..17a1ffa
--- /dev/null
+++ b/src/Cake.Prca.Issues.InspectCode.Tests/Cake.Prca.Issues.InspectCode.Tests.csproj
@@ -0,0 +1,115 @@
+
+
+
+
+
+ Debug
+ AnyCPU
+ {4056E537-66AE-457C-A6E9-59DE00AE1E27}
+ Library
+ Properties
+ Cake.Prca.Issues.InspectCode.Tests
+ Cake.Prca.Issues.InspectCode.Tests
+ v4.5.2
+ 512
+
+
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+ ..\packages\Cake.Core.0.18.0\lib\net45\Cake.Core.dll
+ True
+
+
+ ..\packages\Cake.Prca.0.1.0-unstable0011\lib\net45\Cake.Prca.dll
+ True
+
+
+ ..\packages\Cake.Testing.0.18.0\lib\net45\Cake.Testing.dll
+ True
+
+
+ ..\packages\Shouldly.2.8.2\lib\net451\Shouldly.dll
+ True
+
+
+
+
+
+
+
+
+
+
+ ..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll
+ True
+
+
+ ..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll
+ True
+
+
+ ..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll
+ True
+
+
+ ..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll
+ True
+
+
+
+
+
+
+
+
+
+
+
+ {686f8b73-d231-4cbd-b465-b9700aab40f6}
+ Cake.Prca.Issues.InspectCode
+
+
+
+
+
+
+
+ Designer
+
+
+
+
+
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Cake.Prca.Issues.InspectCode.Tests/ExceptionAssertExtensions.cs b/src/Cake.Prca.Issues.InspectCode.Tests/ExceptionAssertExtensions.cs
new file mode 100644
index 0000000..cea7ee5
--- /dev/null
+++ b/src/Cake.Prca.Issues.InspectCode.Tests/ExceptionAssertExtensions.cs
@@ -0,0 +1,20 @@
+namespace Cake.Prca.Issues.InspectCode.Tests
+{
+ using System;
+ using Xunit;
+
+ public static class ExceptionAssertExtensions
+ {
+ public static void IsArgumentNullException(this Exception exception, string parameterName)
+ {
+ Assert.IsType(exception);
+ Assert.Equal(parameterName, ((ArgumentNullException)exception).ParamName);
+ }
+
+ public static void IsArgumentOutOfRangeException(this Exception exception, string parameterName)
+ {
+ Assert.IsType(exception);
+ Assert.Equal(parameterName, ((ArgumentOutOfRangeException)exception).ParamName);
+ }
+ }
+}
diff --git a/src/Cake.Prca.Issues.InspectCode.Tests/InspectCodeProviderFixture.cs b/src/Cake.Prca.Issues.InspectCode.Tests/InspectCodeProviderFixture.cs
new file mode 100644
index 0000000..6477751
--- /dev/null
+++ b/src/Cake.Prca.Issues.InspectCode.Tests/InspectCodeProviderFixture.cs
@@ -0,0 +1,43 @@
+namespace Cake.Prca.Issues.InspectCode.Tests
+{
+ using System.Collections.Generic;
+ using System.IO;
+ using Core.Diagnostics;
+ using Testing;
+
+ public class InspectCodeProviderFixture
+ {
+
+ public InspectCodeProviderFixture(string fileResourceName)
+ {
+ this.Log = new FakeLog();
+ Log.Verbosity = Verbosity.Normal;
+
+ using (var stream = this.GetType().Assembly.GetManifestResourceStream("Cake.Prca.Issues.InspectCode.Tests.Testfiles." + fileResourceName))
+ {
+ using (var sr = new StreamReader(stream))
+ {
+ this.Settings =
+ InspectCodeSettings.FromContent(
+ sr.ReadToEnd(),
+ new Core.IO.DirectoryPath(@"c:\Source\Cake.Prca"));
+ }
+ }
+ }
+
+ public FakeLog Log { get; set; }
+
+ public InspectCodeSettings Settings { get; set; }
+
+ public InspectCodeProvider Create()
+ {
+ return new InspectCodeProvider(this.Log, this.Settings);
+ }
+
+ public IEnumerable ReadIssues()
+ {
+ var codeAnalysisProvider = this.Create();
+ return codeAnalysisProvider.ReadIssues();
+ }
+ }
+}
diff --git a/src/Cake.Prca.Issues.InspectCode.Tests/InspectCodeProviderTests.cs b/src/Cake.Prca.Issues.InspectCode.Tests/InspectCodeProviderTests.cs
new file mode 100644
index 0000000..4b334de
--- /dev/null
+++ b/src/Cake.Prca.Issues.InspectCode.Tests/InspectCodeProviderTests.cs
@@ -0,0 +1,78 @@
+namespace Cake.Prca.Issues.InspectCode.Tests
+{
+ using Core.IO;
+ using Shouldly;
+ using System.Linq;
+ using Testing;
+ using Xunit;
+
+ public class InspectCodeProviderTests
+ {
+ public sealed class TheInspectCodeProviderCtor
+ {
+ [Fact]
+ public void Should_Throw_If_Log_Is_Null()
+ {
+ // Given / When
+ var result = Record.Exception(() =>
+ new InspectCodeProvider(
+ null,
+ InspectCodeSettings.FromContent(@"foo", @"c:\src")));
+
+ // Then
+ result.IsArgumentNullException("log");
+ }
+
+ [Fact]
+ public void Should_Throw_If_Settings_Are_Null()
+ {
+ // Given / When
+ var result = Record.Exception(() => new InspectCodeProvider(new FakeLog(), null));
+
+ // Then
+ result.IsArgumentNullException("settings");
+ }
+ }
+
+ public sealed class TheReadIssuesMethod
+ {
+ [Fact]
+ public void Should_Read_Issue_Correct()
+ {
+ // Given
+ var fixture = new InspectCodeProviderFixture("inspectcode.xml");
+
+ // When
+ var issues = fixture.ReadIssues();
+
+ // Then
+ issues.Count().ShouldBe(1);
+ var issue = issues.Single();
+ CheckIssue(
+ issue,
+ @"src\Cake.Prca\CakeAliasConstants.cs",
+ 16,
+ "UnusedMember.Global",
+ 0,
+ @"Constant 'PullRequestSystemCakeAliasCategory' is never used");
+ }
+
+ private static void CheckIssue(
+ ICodeAnalysisIssue issue,
+ string affectedFileRelativePath,
+ int? line,
+ string rule,
+ int priority,
+ string message)
+ {
+ issue.AffectedFileRelativePath.ToString().ShouldBe(new FilePath(affectedFileRelativePath).ToString());
+ issue.AffectedFileRelativePath.IsRelative.ShouldBe(true, "Issue path is not relative");
+ issue.Line.ShouldBe(line);
+ issue.Rule.ShouldBe(rule);
+ issue.Priority.ShouldBe(priority);
+ issue.Message.ShouldBe(message);
+ }
+
+ }
+ }
+}
diff --git a/src/Cake.Prca.Issues.InspectCode.Tests/InspectCodeSettingsTests.cs b/src/Cake.Prca.Issues.InspectCode.Tests/InspectCodeSettingsTests.cs
new file mode 100644
index 0000000..611dea7
--- /dev/null
+++ b/src/Cake.Prca.Issues.InspectCode.Tests/InspectCodeSettingsTests.cs
@@ -0,0 +1,147 @@
+namespace Cake.Prca.Issues.InspectCode.Tests
+{
+ using System.IO;
+ using System.Text;
+ using Core.IO;
+ using Shouldly;
+ using Xunit;
+
+ public class InspectCodeSettingsTests
+ {
+ public sealed class TheInspectCodeSettings
+ {
+ [Fact]
+ public void Should_Throw_If_LogFilePath_Is_Null()
+ {
+ // Given / When
+ var result = Record.Exception(() =>
+ InspectCodeSettings.FromFilePath(
+ null,
+ new DirectoryPath(@"C:\")));
+
+ // Then
+ result.IsArgumentNullException("logFilePath");
+ }
+
+ [Fact]
+ public void Should_Throw_If_RepositoryRoot_For_LogFilePath_Is_Null()
+ {
+ // Given / When
+ var result = Record.Exception(() =>
+ InspectCodeSettings.FromFilePath(
+ new FilePath(@"C:\foo.log"),
+ null));
+
+ // Then
+ result.IsArgumentNullException("repositoryRoot");
+ }
+
+ [Fact]
+ public void Should_Throw_If_LogFileContent_Is_Null()
+ {
+ // Given / When
+ var result = Record.Exception(() =>
+ InspectCodeSettings.FromContent(
+ null,
+ new DirectoryPath(@"C:\")));
+
+ // Then
+ result.IsArgumentNullException("logFileContent");
+ }
+
+ [Fact]
+ public void Should_Throw_If_LogFileContent_Is_Empty()
+ {
+ // Given / When
+ var result = Record.Exception(() =>
+ InspectCodeSettings.FromContent(
+ string.Empty,
+ new DirectoryPath(@"C:\")));
+
+ // Then
+ result.IsArgumentOutOfRangeException("logFileContent");
+ }
+
+ [Fact]
+ public void Should_Throw_If_LogFileContent_Is_WhiteSpace()
+ {
+ // Given / When
+ var result = Record.Exception(() =>
+ InspectCodeSettings.FromContent(
+ " ",
+ new DirectoryPath(@"C:\")));
+
+ // Then
+ result.IsArgumentOutOfRangeException("logFileContent");
+ }
+
+ [Fact]
+ public void Should_Throw_If_RepositoryRoot_For_LogFileContent_Is_Null()
+ {
+ // Given / When
+ var result = Record.Exception(() =>
+ InspectCodeSettings.FromContent(
+ "foo",
+ null));
+
+ // Then
+ result.IsArgumentNullException("repositoryRoot");
+ }
+
+ [Fact]
+ public void Should_Set_Property_Values_Passed_To_Constructor()
+ {
+ // Given
+ const string logFileContent = "foo";
+ var repoRoot = new DirectoryPath(@"C:\");
+
+ // When
+ var settings = InspectCodeSettings.FromContent(logFileContent, repoRoot);
+
+ // Then
+ settings.LogFileContent.ShouldBe(logFileContent);
+ settings.RepositoryRoot.ShouldBe(repoRoot);
+ }
+
+ [Fact]
+ public void Should_Read_File_From_Disk()
+ {
+ var fileName = System.IO.Path.GetTempFileName();
+ try
+ {
+ // Given
+ string expected;
+ using (var ms = new MemoryStream())
+ using (var stream = this.GetType().Assembly.GetManifestResourceStream("Cake.Prca.Issues.InspectCode.Tests.Testfiles.inspectcode.xml"))
+ {
+ stream.CopyTo(ms);
+ var data = ms.ToArray();
+
+ using (var file = new FileStream(fileName, FileMode.Create, FileAccess.Write))
+ {
+ file.Write(data, 0, data.Length);
+ }
+
+ expected = Encoding.UTF8.GetString(data, 0, data.Length);
+ }
+
+ // When
+ var settings =
+ InspectCodeSettings.FromFilePath(
+ new FilePath(fileName),
+ new DirectoryPath(@"C:\"));
+
+ // Then
+ settings.LogFileContent.ShouldBe(expected);
+ }
+ finally
+ {
+ if (File.Exists(fileName))
+ {
+ File.Delete(fileName);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/Cake.Prca.Issues.InspectCode.Tests/Properties/AssemblyInfo.cs b/src/Cake.Prca.Issues.InspectCode.Tests/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..3444697
--- /dev/null
+++ b/src/Cake.Prca.Issues.InspectCode.Tests/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Cake.Prca.Issues.InspectCode.Tests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Cake.Prca.Issues.InspectCode.Tests")]
+[assembly: AssemblyCopyright("Copyright © 2017")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("4056e537-66ae-457c-a6e9-59de00ae1e27")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/src/Cake.Prca.Issues.InspectCode.Tests/Testfiles/IssueWithFile.xml b/src/Cake.Prca.Issues.InspectCode.Tests/Testfiles/IssueWithFile.xml
new file mode 100644
index 0000000..39db2e3
--- /dev/null
+++ b/src/Cake.Prca.Issues.InspectCode.Tests/Testfiles/IssueWithFile.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/Cake.Prca.Issues.InspectCode.Tests/Testfiles/IssueWithOnlyFileName.xml b/src/Cake.Prca.Issues.InspectCode.Tests/Testfiles/IssueWithOnlyFileName.xml
new file mode 100644
index 0000000..b981c4b
--- /dev/null
+++ b/src/Cake.Prca.Issues.InspectCode.Tests/Testfiles/IssueWithOnlyFileName.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Cake.Prca.Issues.InspectCode.Tests/Testfiles/IssueWithoutFile.xml b/src/Cake.Prca.Issues.InspectCode.Tests/Testfiles/IssueWithoutFile.xml
new file mode 100644
index 0000000..fd20b4d
--- /dev/null
+++ b/src/Cake.Prca.Issues.InspectCode.Tests/Testfiles/IssueWithoutFile.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/Cake.Prca.Issues.InspectCode.Tests/Testfiles/inspectcode.xml b/src/Cake.Prca.Issues.InspectCode.Tests/Testfiles/inspectcode.xml
new file mode 100644
index 0000000..6515c5e
--- /dev/null
+++ b/src/Cake.Prca.Issues.InspectCode.Tests/Testfiles/inspectcode.xml
@@ -0,0 +1,18 @@
+
+
+
+
+ src\Cake.Prca.sln
+
+ Solution
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Cake.Prca.Issues.InspectCode.Tests/packages.config b/src/Cake.Prca.Issues.InspectCode.Tests/packages.config
new file mode 100644
index 0000000..939ce75
--- /dev/null
+++ b/src/Cake.Prca.Issues.InspectCode.Tests/packages.config
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Cake.Prca.Issues.InspectCode.sln b/src/Cake.Prca.Issues.InspectCode.sln
new file mode 100644
index 0000000..f92c00f
--- /dev/null
+++ b/src/Cake.Prca.Issues.InspectCode.sln
@@ -0,0 +1,43 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.25420.1
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.Prca.Issues.InspectCode", "Cake.Prca.Issues.InspectCode\Cake.Prca.Issues.InspectCode.csproj", "{686F8B73-D231-4CBD-B465-B9700AAB40F6}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.Prca.Issues.InspectCode.Tests", "Cake.Prca.Issues.InspectCode.Tests\Cake.Prca.Issues.InspectCode.Tests.csproj", "{4056E537-66AE-457C-A6E9-59DE00AE1E27}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{ED8349A0-24FE-4004-BFE6-C3133B910CCB}"
+ ProjectSection(SolutionItems) = preProject
+ ..\build.ps1 = ..\build.ps1
+ ..\build.sh = ..\build.sh
+ ..\setup.cake = ..\setup.cake
+ EndProjectSection
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "nuspec", "nuspec", "{41F94A0D-F38D-4B1B-8200-52A377BA884A}"
+ ProjectSection(SolutionItems) = preProject
+ ..\nuspec\nuget\Cake.Prca.Issues.InspectCode.nuspec = ..\nuspec\nuget\Cake.Prca.Issues.InspectCode.nuspec
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {686F8B73-D231-4CBD-B465-B9700AAB40F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {686F8B73-D231-4CBD-B465-B9700AAB40F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {686F8B73-D231-4CBD-B465-B9700AAB40F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {686F8B73-D231-4CBD-B465-B9700AAB40F6}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4056E537-66AE-457C-A6E9-59DE00AE1E27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4056E537-66AE-457C-A6E9-59DE00AE1E27}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4056E537-66AE-457C-A6E9-59DE00AE1E27}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4056E537-66AE-457C-A6E9-59DE00AE1E27}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {41F94A0D-F38D-4B1B-8200-52A377BA884A} = {ED8349A0-24FE-4004-BFE6-C3133B910CCB}
+ EndGlobalSection
+EndGlobal
diff --git a/src/Cake.Prca.Issues.InspectCode.sln.DotSettings b/src/Cake.Prca.Issues.InspectCode.sln.DotSettings
new file mode 100644
index 0000000..7cc51a4
--- /dev/null
+++ b/src/Cake.Prca.Issues.InspectCode.sln.DotSettings
@@ -0,0 +1,3 @@
+
+ DO_NOT_SHOW
+ <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
\ No newline at end of file
diff --git a/src/Cake.Prca.Issues.InspectCode/Cake.Prca.Issues.InspectCode.csproj b/src/Cake.Prca.Issues.InspectCode/Cake.Prca.Issues.InspectCode.csproj
new file mode 100644
index 0000000..25ec41b
--- /dev/null
+++ b/src/Cake.Prca.Issues.InspectCode/Cake.Prca.Issues.InspectCode.csproj
@@ -0,0 +1,69 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {686F8B73-D231-4CBD-B465-B9700AAB40F6}
+ Library
+ Properties
+ Cake.Prca.Issues.InspectCode
+ Cake.Prca.Issues.InspectCode
+ v4.5.2
+ 512
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ bin\Debug\Cake.Prca.Issues.InspectCode.XML
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+ bin\Release\Cake.Prca.Issues.InspectCode.XML
+
+
+
+ ..\packages\Cake.Core.0.18.0\lib\net45\Cake.Core.dll
+ True
+
+
+ ..\packages\Cake.Prca.0.1.0-unstable0011\lib\net45\Cake.Prca.dll
+ True
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Cake.Prca.Issues.InspectCode/InspectCodeProvider.cs b/src/Cake.Prca.Issues.InspectCode/InspectCodeProvider.cs
new file mode 100644
index 0000000..682ca61
--- /dev/null
+++ b/src/Cake.Prca.Issues.InspectCode/InspectCodeProvider.cs
@@ -0,0 +1,183 @@
+namespace Cake.Prca.Issues.InspectCode
+{
+ using System.Collections.Generic;
+ using System.Globalization;
+ using System.IO;
+ using System.Linq;
+ using System.Xml.Linq;
+ using Core.Diagnostics;
+
+ ///
+ /// Provider for code analysis issues reported by JetBrains Inspect Code.
+ ///
+ public class InspectCodeProvider : CodeAnalysisProvider
+ {
+ private readonly InspectCodeSettings settings;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The Cake log context.
+ /// Settings for reading the log file.
+ public InspectCodeProvider(ICakeLog log, InspectCodeSettings settings)
+ : base(log)
+ {
+ settings.NotNull(nameof(settings));
+
+ this.settings = settings;
+ }
+
+ ///
+ public override IEnumerable ReadIssues()
+ {
+ var result = new List();
+
+ var logDocument = XDocument.Parse(settings.LogFileContent);
+
+ var solutionPath = Path.GetDirectoryName(logDocument.Descendants("Solution").Single().Value);
+
+ // Loop through all issue tags.
+ foreach (var issue in logDocument.Descendants("Issue"))
+ {
+ // Read affected file from the issue.
+ string fileName;
+ if (!TryGetFile(issue, solutionPath, out fileName))
+ {
+ continue;
+ }
+
+ // Read affected line from the issue.
+ int line;
+ if (!TryGetLine(issue, out line))
+ {
+ continue;
+ }
+
+ // Read rule code from the issue.
+ string rule;
+ if (!TryGetRule(issue, out rule))
+ {
+ continue;
+ }
+
+ // Read message from the issue.
+ string message;
+ if (!TryGetMessage(issue, out message))
+ {
+ continue;
+ }
+
+ result.Add(new CodeAnalysisIssue(
+ fileName,
+ line,
+ message,
+ 0, // TODO Set based on severity of issueType
+ rule));
+ }
+
+ return result;
+ }
+
+ ///
+ /// Reads the affected file path from an issue logged in a Inspect Code log.
+ ///
+ /// Issue element from Inspect Code log.
+ /// Path to the solution file.
+ /// Returns the full path to the affected file.
+ /// True if the file path could be parsed.
+ private static bool TryGetFile(XElement issue, string solutionPath, out string fileName)
+ {
+ fileName = string.Empty;
+
+ var fileAttr = issue.Attribute("File");
+ if (fileAttr == null)
+ {
+ return false;
+ }
+
+ fileName = fileAttr.Value;
+ if (string.IsNullOrWhiteSpace(fileName))
+ {
+ return false;
+ }
+
+ // Combine with path to the solution file.
+ fileName = Path.Combine(solutionPath, fileName);
+
+ return true;
+ }
+
+ ///
+ /// Reads the affected line from an issue logged in a Inspect Code log.
+ ///
+ /// Issue element from Inspect Code log.
+ /// Returns line.
+ /// True if the line could be parsed.
+ private static bool TryGetLine(XElement issue, out int line)
+ {
+ line = -1;
+
+ var lineAttr = issue.Attribute("Line");
+
+ var lineValue = lineAttr?.Value;
+ if (string.IsNullOrWhiteSpace(lineValue))
+ {
+ return false;
+ }
+
+ line = int.Parse(lineValue, CultureInfo.InvariantCulture);
+
+ return true;
+ }
+
+ ///
+ /// Reads the rule code from an issue logged in a Inspect Code log.
+ ///
+ /// Issue element from Inspect Code log.
+ /// Returns the code of the rule.
+ /// True if the rule code could be parsed.
+ private static bool TryGetRule(XElement issue, out string rule)
+ {
+ rule = string.Empty;
+
+ var codeAttr = issue.Attribute("TypeId");
+ if (codeAttr == null)
+ {
+ return false;
+ }
+
+ rule = codeAttr.Value;
+ if (string.IsNullOrWhiteSpace(rule))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ ///
+ /// Reads the message from an issue logged in a Inspect Code log.
+ ///
+ /// Issue element from Inspect Code log.
+ /// Returns the message of the issue.
+ /// True if the message could be parsed.
+ private static bool TryGetMessage(XElement issue, out string message)
+ {
+ message = string.Empty;
+
+ var messageAttr = issue.Attribute("Message");
+ if (messageAttr == null)
+ {
+ return false;
+ }
+
+ message = messageAttr.Value;
+ if (string.IsNullOrWhiteSpace(message))
+ {
+ return false;
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/src/Cake.Prca.Issues.InspectCode/InspectCodeProviderAliases.cs b/src/Cake.Prca.Issues.InspectCode/InspectCodeProviderAliases.cs
new file mode 100644
index 0000000..1d4f0fb
--- /dev/null
+++ b/src/Cake.Prca.Issues.InspectCode/InspectCodeProviderAliases.cs
@@ -0,0 +1,120 @@
+namespace Cake.Prca.Issues.InspectCode
+{
+ using Core;
+ using Core.Annotations;
+ using Core.IO;
+
+ ///
+ /// Contains functionality related to importing code analysis issues from JetBrains Inspect Code
+ /// to write them to pull requests.
+ ///
+ [CakeAliasCategory(CakeAliasConstants.MainCakeAliasCategory)]
+ [CakeNamespaceImport("Cake.Prca.Issues.InspectCode")]
+ public static class InspectCodeProviderAliases
+ {
+ ///
+ /// Gets an instance of a provider for code analysis issues reported by JetBrains Inspect Code using a log file from disk.
+ ///
+ /// The context.
+ /// Path to the the InspectCode log file.
+ /// Root path of the repository.
+ /// Instance of a provider for code analysis issues reported by JetBrains Insepct Code.
+ ///
+ /// Report code analysis issues reported by JetBrains Inspect Code to a TFS pull request:
+ ///
+ ///
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory(CakeAliasConstants.CodeAnalysisProviderCakeAliasCategory)]
+ public static ICodeAnalysisProvider InspectCodeFromFilePath(
+ this ICakeContext context,
+ FilePath logFilePath,
+ DirectoryPath repositoryRoot)
+ {
+ context.NotNull(nameof(context));
+ logFilePath.NotNull(nameof(logFilePath));
+ repositoryRoot.NotNull(nameof(repositoryRoot));
+
+ return context.InspectCode(InspectCodeSettings.FromFilePath(logFilePath, repositoryRoot));
+ }
+
+ ///
+ /// Gets an instance of a provider for code analysis issues reported by JetBrains Inspect Code using log file content.
+ ///
+ /// The context.
+ /// Content of the the Inspect Code log file.
+ /// Root path of the repository.
+ /// Instance of a provider for code analysis issues reported by JetBrains Inspect Code.
+ ///
+ /// Report code analysis issues reported by JetBrains Inspect Code to a TFS pull request:
+ ///
+ ///
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory(CakeAliasConstants.CodeAnalysisProviderCakeAliasCategory)]
+ public static ICodeAnalysisProvider InspectCodeFromContent(
+ this ICakeContext context,
+ string logFileContent,
+ DirectoryPath repositoryRoot)
+ {
+ context.NotNull(nameof(context));
+ logFileContent.NotNullOrWhiteSpace(nameof(logFileContent));
+ repositoryRoot.NotNull(nameof(repositoryRoot));
+
+ return context.InspectCode(InspectCodeSettings.FromContent(logFileContent, repositoryRoot));
+ }
+
+ ///
+ /// Gets an instance of a provider for code analysis issues reported by JetBrains Inspect Code using specified settings.
+ ///
+ /// The context.
+ /// Settings for reading the Inspect Code log.
+ /// Instance of a provider for code analysis issues reported by JetBrains Inspect Code.
+ ///
+ /// Report code analysis issues reported by JetBrains Inspect Code to a TFS pull request:
+ ///
+ ///
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory(CakeAliasConstants.CodeAnalysisProviderCakeAliasCategory)]
+ public static ICodeAnalysisProvider InspectCode(
+ this ICakeContext context,
+ InspectCodeSettings settings)
+ {
+ context.NotNull(nameof(context));
+ settings.NotNull(nameof(settings));
+
+ return new InspectCodeProvider(context.Log, settings);
+ }
+ }
+}
diff --git a/src/Cake.Prca.Issues.InspectCode/InspectCodeSettings.cs b/src/Cake.Prca.Issues.InspectCode/InspectCodeSettings.cs
new file mode 100644
index 0000000..91e3105
--- /dev/null
+++ b/src/Cake.Prca.Issues.InspectCode/InspectCodeSettings.cs
@@ -0,0 +1,80 @@
+namespace Cake.Prca.Issues.InspectCode
+{
+ using System.IO;
+ using Core.IO;
+
+ ///
+ /// Settings for .
+ ///
+ public class InspectCodeSettings
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Path to the the Inspect Code log file.
+ /// Root path of the repository.
+ protected InspectCodeSettings(FilePath logFilePath, DirectoryPath repositoryRoot)
+ {
+ logFilePath.NotNull(nameof(logFilePath));
+ repositoryRoot.NotNull(nameof(repositoryRoot));
+
+ this.RepositoryRoot = repositoryRoot;
+
+ using (var stream = new FileStream(logFilePath.FullPath, FileMode.Open, FileAccess.Read))
+ {
+ using (var sr = new StreamReader(stream))
+ {
+ this.LogFileContent = sr.ReadToEnd();
+ }
+ }
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Content of the the Inspect Code log file.
+ /// Root path of the repository.
+ protected InspectCodeSettings(string logFileContent, DirectoryPath repositoryRoot)
+ {
+ logFileContent.NotNullOrWhiteSpace(nameof(logFileContent));
+ repositoryRoot.NotNull(nameof(repositoryRoot));
+
+ this.RepositoryRoot = repositoryRoot;
+
+ this.LogFileContent = logFileContent;
+ }
+
+ ///
+ /// Gets the content of the log file.
+ ///
+ public string LogFileContent { get; private set; }
+
+ ///
+ /// Gets the Root path of the repository.
+ ///
+ public DirectoryPath RepositoryRoot { get; private set; }
+
+ ///
+ /// Returns a new instance of the class from a log file on disk.
+ ///
+ /// Path to the JetBrains Inspect Code log file.
+ /// Root path of the repository.
+ /// Instance of the class.
+ public static InspectCodeSettings FromFilePath(FilePath logFilePath, DirectoryPath repositoryRoot)
+ {
+ return new InspectCodeSettings(logFilePath, repositoryRoot);
+ }
+
+ ///
+ /// Returns a new instance of the class from the content
+ /// of a JetBrains Inspect Code log file.
+ ///
+ /// Content of the JetBrains Inspect Code log file.
+ /// Root path of the repository.
+ /// Instance of the class.
+ public static InspectCodeSettings FromContent(string logFileContent, DirectoryPath repositoryRoot)
+ {
+ return new InspectCodeSettings(logFileContent, repositoryRoot);
+ }
+ }
+}
diff --git a/src/Cake.Prca.Issues.InspectCode/Properties/AssemblyInfo.cs b/src/Cake.Prca.Issues.InspectCode/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..b575c7e
--- /dev/null
+++ b/src/Cake.Prca.Issues.InspectCode/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Cake.Prca.Issues.InspectCode")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Cake.Prca.Issues.InspectCode")]
+[assembly: AssemblyCopyright("Copyright © 2017")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("686f8b73-d231-4cbd-b465-b9700aab40f6")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/src/Cake.Prca.Issues.InspectCode/packages.config b/src/Cake.Prca.Issues.InspectCode/packages.config
new file mode 100644
index 0000000..d893e07
--- /dev/null
+++ b/src/Cake.Prca.Issues.InspectCode/packages.config
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/tools/packages.config b/tools/packages.config
new file mode 100644
index 0000000..3b95cb1
--- /dev/null
+++ b/tools/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file