From 4926061bc9783ded64182fd3e41af1e76a044c55 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sun, 12 Dec 2021 13:04:08 +0100 Subject: [PATCH 01/44] Update Depandabot configuration to ignore Cake updates < 3.0 (#275) --- .github/dependabot.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 39aed68a9..236560971 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,7 +9,7 @@ updates: ignore: - dependency-name: Cake.Core versions: - - "> 1.0.0, < 2" + - "(,3.0)" - dependency-name: Cake.Testing versions: - - "> 1.0.0, < 2" \ No newline at end of file + - "(,3.0)" \ No newline at end of file From e1f7a331bf481d6196f0ab69d24c66f4ede5f261 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 17 Feb 2022 13:21:51 +0100 Subject: [PATCH 02/44] Bump Microsoft.NET.Test.Sdk from 17.0.0 to 17.1.0 in /src (#276) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.0.0 to 17.1.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v17.0.0...v17.1.0) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../Cake.Issues.PullRequests.Tests.csproj | 2 +- .../Cake.Issues.Reporting.Tests.csproj | 2 +- src/Cake.Issues.Tests/Cake.Issues.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj index 3a0777938..922a08162 100644 --- a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj +++ b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj @@ -10,7 +10,7 @@ ..\Cake.Issues.Tests.ruleset - + diff --git a/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj b/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj index 77f507ab6..9cf072851 100644 --- a/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj +++ b/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj b/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj index 94090792d..5d99f16a2 100644 --- a/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj +++ b/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj @@ -25,7 +25,7 @@ - + From cae9624961bc238678c1b79472f14e938702a301 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 May 2022 09:27:34 +0200 Subject: [PATCH 03/44] Bump xunit.runner.visualstudio from 2.4.3 to 2.4.4 in /src (#277) Bumps [xunit.runner.visualstudio](https://github.com/xunit/visualstudio.xunit) from 2.4.3 to 2.4.4. - [Release notes](https://github.com/xunit/visualstudio.xunit/releases) - [Commits](https://github.com/xunit/visualstudio.xunit/commits) --- updated-dependencies: - dependency-name: xunit.runner.visualstudio dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../Cake.Issues.PullRequests.Tests.csproj | 2 +- .../Cake.Issues.Reporting.Tests.csproj | 2 +- src/Cake.Issues.Tests/Cake.Issues.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj index 922a08162..e613994d9 100644 --- a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj +++ b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj @@ -16,7 +16,7 @@ - + diff --git a/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj b/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj index 9cf072851..4d1469a23 100644 --- a/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj +++ b/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj @@ -20,7 +20,7 @@ - + diff --git a/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj b/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj index 5d99f16a2..d06f5e3dc 100644 --- a/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj +++ b/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj @@ -34,7 +34,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + From a00c880a135041ffc3b5b1b80626febe8843d87b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 May 2022 07:12:02 +0200 Subject: [PATCH 04/44] Bump xunit.runner.visualstudio from 2.4.4 to 2.4.5 in /src (#278) Bumps [xunit.runner.visualstudio](https://github.com/xunit/visualstudio.xunit) from 2.4.4 to 2.4.5. - [Release notes](https://github.com/xunit/visualstudio.xunit/releases) - [Commits](https://github.com/xunit/visualstudio.xunit/commits) --- updated-dependencies: - dependency-name: xunit.runner.visualstudio dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../Cake.Issues.PullRequests.Tests.csproj | 2 +- .../Cake.Issues.Reporting.Tests.csproj | 2 +- src/Cake.Issues.Tests/Cake.Issues.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj index e613994d9..188abc3f6 100644 --- a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj +++ b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj @@ -16,7 +16,7 @@ - + diff --git a/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj b/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj index 4d1469a23..7c7a08625 100644 --- a/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj +++ b/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj @@ -20,7 +20,7 @@ - + diff --git a/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj b/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj index d06f5e3dc..2ef3e92b0 100644 --- a/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj +++ b/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj @@ -34,7 +34,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + From a22f330fe6430c7c4dace0b4e3c8cd523cca9c47 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Jul 2022 00:08:19 +0200 Subject: [PATCH 05/44] Bump Microsoft.NET.Test.Sdk from 17.1.0 to 17.2.0 in /src (#279) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.1.0 to 17.2.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v17.1.0...v17.2.0) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../Cake.Issues.PullRequests.Tests.csproj | 2 +- .../Cake.Issues.Reporting.Tests.csproj | 2 +- src/Cake.Issues.Tests/Cake.Issues.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj index 188abc3f6..41706922c 100644 --- a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj +++ b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj @@ -10,7 +10,7 @@ ..\Cake.Issues.Tests.ruleset - + diff --git a/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj b/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj index 7c7a08625..8c1efe0e6 100644 --- a/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj +++ b/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj b/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj index 2ef3e92b0..df708c25f 100644 --- a/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj +++ b/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj @@ -25,7 +25,7 @@ - + From 1c1b9b0892888a736129a87b86fff86eb298f6bc Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Mon, 25 Jul 2022 22:12:31 +0200 Subject: [PATCH 06/44] Build using Cake .NET Tool (#280) --- .config/dotnet-tools.json | 12 ++ build.ps1 | 268 ++------------------------------------ build.sh | 121 ++--------------- tools/packages.config | 4 - 4 files changed, 31 insertions(+), 374 deletions(-) create mode 100644 .config/dotnet-tools.json delete mode 100644 tools/packages.config diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 000000000..727dfd760 --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "cake.tool": { + "version": "0.38.5", + "commands": [ + "dotnet-cake" + ] + } + } +} \ No newline at end of file diff --git a/build.ps1 b/build.ps1 index 285bb729a..0940a3114 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,261 +1,15 @@ -########################################################################## -# This is the Cake bootstrapper script for PowerShell. -# Based on boostrapper from https://github.com/cake-build/resources -########################################################################## +$ErrorActionPreference = 'Stop' -<# +$SCRIPT_NAME = "recipe.cake" -.SYNOPSIS -This is a Powershell script to bootstrap a Cake build. +Write-Host "Restoring .NET Core tools" +dotnet tool restore +if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } -.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. +Write-Host "Bootstrapping Cake" +dotnet cake $SCRIPT_NAME --bootstrap +if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } -.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 ShowDescription -Shows description about tasks. -.PARAMETER DryRun -Performs a dry run. -.PARAMETER SkipToolPackageRestore -Skips restoring of packages. -.PARAMETER ScriptArgs -Remaining arguments are added here. - -.LINK -https://cakebuild.net - -#> - -[CmdletBinding()] -Param( - [string]$Script = "recipe.cake", - [string]$Target, - [string]$Configuration, - [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")] - [string]$Verbosity, - [switch]$ShowDescription, - [Alias("WhatIf", "Noop")] - [switch]$DryRun, - [switch]$SkipToolPackageRestore, - [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] - [string[]]$ScriptArgs -) - -# Attempt to set highest encryption available for SecurityProtocol. -# PowerShell will not set this by default (until maybe .NET 4.6.x). This -# will typically produce a message for PowerShell v2 (just an info -# message though) -try { - # Set TLS 1.2 (3072), then TLS 1.1 (768), then TLS 1.0 (192), finally SSL 3.0 (48) - # Use integers because the enumeration values for TLS 1.2 and TLS 1.1 won't - # exist in .NET 4.0, even though they are addressable if .NET 4.5+ is - # installed (.NET 4.5 is an in-place upgrade). - # PowerShell Core already has support for TLS 1.2 so we can skip this if running in that. - if (-not $IsCoreCLR) { - [System.Net.ServicePointManager]::SecurityProtocol = 3072 -bor 768 -bor 192 -bor 48 - } - } catch { - Write-Output 'Unable to set PowerShell to use TLS 1.2 and TLS 1.1 due to old .NET Framework installed. If you see underlying connection closed or trust errors, you may need to upgrade to .NET Framework 4.5+ and PowerShell v3' - } - -[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() - } - } -} - -function GetProxyEnabledWebClient -{ - $wc = New-Object System.Net.WebClient - $proxy = [System.Net.WebRequest]::GetSystemWebProxy() - $proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials - $wc.Proxy = $proxy - return $wc -} - -Write-Host "Preparing to run build script..." - -if(!$PSScriptRoot){ - $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent -} - -$TOOLS_DIR = Join-Path $PSScriptRoot "tools" -$ADDINS_DIR = Join-Path $TOOLS_DIR "Addins" -$MODULES_DIR = Join-Path $TOOLS_DIR "Modules" -$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" -$ADDINS_PACKAGES_CONFIG = Join-Path $ADDINS_DIR "packages.config" -$MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config" - -# 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 { - $wc = GetProxyEnabledWebClient - $wc.DownloadFile("https://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 $_ -PathType Container) } - $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 { - $wc = GetProxyEnabledWebClient - $wc.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 -$env:NUGET_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) { - "mono `"$NUGET_EXE`"" -} else { - "`"$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..." - Get-ChildItem -Exclude packages.config,nuget.exe,Cake.Bakery | - Remove-Item -Recurse -Force - } - - Write-Verbose -Message "Restoring tools from NuGet..." - - $NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`"" - - if ($LASTEXITCODE -ne 0) { - Throw "An error occurred while restoring NuGet tools." - } - else - { - $md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII" - } - Write-Verbose -Message ($NuGetOutput | Out-String) - - Pop-Location -} - -# Restore addins from NuGet -if (Test-Path $ADDINS_PACKAGES_CONFIG) { - Push-Location - Set-Location $ADDINS_DIR - - Write-Verbose -Message "Restoring addins from NuGet..." - $NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`"" - - if ($LASTEXITCODE -ne 0) { - Throw "An error occurred while restoring NuGet addins." - } - - Write-Verbose -Message ($NuGetOutput | Out-String) - - Pop-Location -} - -# Restore modules from NuGet -if (Test-Path $MODULES_PACKAGES_CONFIG) { - Push-Location - Set-Location $MODULES_DIR - - Write-Verbose -Message "Restoring modules from NuGet..." - $NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`"" - - if ($LASTEXITCODE -ne 0) { - Throw "An error occurred while restoring NuGet modules." - } - - 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" -} - -$CAKE_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) { - "mono `"$CAKE_EXE`"" -} else { - "`"$CAKE_EXE`"" -} - - # Build an array (not a string) of Cake arguments to be joined later -$cakeArguments = @() -if ($Script) { $cakeArguments += "`"$Script`"" } -if ($Target) { $cakeArguments += "-target=`"$Target`"" } -if ($Configuration) { $cakeArguments += "-configuration=$Configuration" } -if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" } -if ($ShowDescription) { $cakeArguments += "-showdescription" } -if ($DryRun) { $cakeArguments += "-dryrun" } -$cakeArguments += $ScriptArgs - -# Bootstrap & start Cake -Write-Host "Bootstrapping Cake..." -Invoke-Expression "& $CAKE_EXE_INVOCATION $Script --bootstrap" -if ($LASTEXITCODE -eq 0) -{ - Write-Host "Running build script..." - Invoke-Expression "& $CAKE_EXE_INVOCATION $($cakeArguments -join " ")" -} - -exit $LASTEXITCODE \ No newline at end of file +Write-Host "Running Build" +dotnet cake $SCRIPT_NAME @args +if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } \ No newline at end of file diff --git a/build.sh b/build.sh index 878a2f241..ba5d0c95c 100755 --- a/build.sh +++ b/build.sh @@ -1,116 +1,11 @@ -#!/usr/bin/env bash +#!/bin/bash +SCRIPT_NAME="recipe.cake" -########################################################################## -# This is the Cake bootstrapper script for Linux and OS X. -# Based on bootstrapper from https://github.com/cake-build/resources -########################################################################## +echo "Restoring .NET Core tools" +dotnet tool restore -# Define directories. -SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -TOOLS_DIR=$SCRIPT_DIR/tools -ADDINS_DIR=$TOOLS_DIR/Addins -MODULES_DIR=$TOOLS_DIR/Modules -NUGET_EXE=$TOOLS_DIR/nuget.exe -CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe -PACKAGES_CONFIG=$TOOLS_DIR/packages.config -PACKAGES_CONFIG_MD5=$TOOLS_DIR/packages.config.md5sum -ADDINS_PACKAGES_CONFIG=$ADDINS_DIR/packages.config -MODULES_PACKAGES_CONFIG=$MODULES_DIR/packages.config +echo "Bootstrapping Cake" +dotnet cake $SCRIPT_NAME --bootstrap -# Define md5sum or md5 depending on Linux/OSX -MD5_EXE= -if [[ "$(uname -s)" == "Darwin" ]]; then - MD5_EXE="md5 -r" -else - MD5_EXE="md5sum" -fi - -# Define default arguments. -SCRIPT="recipe.cake" -CAKE_ARGUMENTS=() - -# Parse arguments. -for i in "$@"; do - case $1 in - -s|--script) SCRIPT="$2"; shift ;; - --) shift; CAKE_ARGUMENTS+=("$@"); break ;; - *) CAKE_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" https://cakebuild.net/download/bootstrapper/packages - if [ $? -ne 0 ]; then - echo "An error occurred 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 occurred while downloading nuget.exe." - exit 1 - fi -fi - -# Restore tools from NuGet. -pushd "$TOOLS_DIR" >/dev/null -if [ ! -f "$PACKAGES_CONFIG_MD5" ] || [ "$( cat "$PACKAGES_CONFIG_MD5" | sed 's/\r$//' )" != "$( $MD5_EXE "$PACKAGES_CONFIG" | awk '{ print $1 }' )" ]; then - find . -type d ! -name . ! -name 'Cake.Bakery' | xargs rm -rf -fi - -mono "$NUGET_EXE" install -ExcludeVersion -if [ $? -ne 0 ]; then - echo "Could not restore NuGet tools." - exit 1 -fi - -$MD5_EXE "$PACKAGES_CONFIG" | awk '{ print $1 }' >| "$PACKAGES_CONFIG_MD5" - -popd >/dev/null - -# Restore addins from NuGet. -if [ -f "$ADDINS_PACKAGES_CONFIG" ]; then - pushd "$ADDINS_DIR" >/dev/null - - mono "$NUGET_EXE" install -ExcludeVersion - if [ $? -ne 0 ]; then - echo "Could not restore NuGet addins." - exit 1 - fi - - popd >/dev/null -fi - -# Restore modules from NuGet. -if [ -f "$MODULES_PACKAGES_CONFIG" ]; then - pushd "$MODULES_DIR" >/dev/null - - mono "$NUGET_EXE" install -ExcludeVersion - if [ $? -ne 0 ]; then - echo "Could not restore NuGet modules." - exit 1 - fi - - popd >/dev/null -fi - -# Make sure that Cake has been installed. -if [ ! -f "$CAKE_EXE" ]; then - echo "Could not find Cake.exe at '$CAKE_EXE'." - exit 1 -fi - -# Bootstrap & start Cake -(exec mono "$CAKE_EXE" $SCRIPT --bootstrap) && (exec mono "$CAKE_EXE" $SCRIPT "${CAKE_ARGUMENTS[@]}") \ No newline at end of file +echo "Running Build" +dotnet cake $SCRIPT_NAME "$@" \ No newline at end of file diff --git a/tools/packages.config b/tools/packages.config deleted file mode 100644 index 2e2ecbda3..000000000 --- a/tools/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - From a6d7d1b20c92fa6a6e51dd5936843e6a45b89423 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Wed, 27 Jul 2022 23:50:37 +0200 Subject: [PATCH 07/44] Update to Cake Recipe 3.0 (#282) --- .appveyor.yml | 2 +- .config/dotnet-tools.json | 2 +- recipe.cake | 20 ++++++++------------ 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index c687c0ff6..da4485dc0 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -16,7 +16,7 @@ install: - ps: nuget update -self build_script: - - ps: .\build.ps1 -Target CI + - ps: .\build.ps1 --target=CI # Tests test: off diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 727dfd760..4903ba5f5 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "cake.tool": { - "version": "0.38.5", + "version": "1.3.0", "commands": [ "dotnet-cake" ] diff --git a/recipe.cake b/recipe.cake index e107e5d9c..94a1a916c 100644 --- a/recipe.cake +++ b/recipe.cake @@ -1,4 +1,8 @@ -#load nuget:?package=Cake.Recipe&version=2.2.1 +#load nuget:https://pkgs.dev.azure.com/cake-contrib/Home/_packaging/addins/nuget/v3/index.json?package=Cake.Recipe&version=3.0.0-beta0001-0007&prerelease + +//************************************************************************************************* +// Settings +//************************************************************************************************* Environment.SetVariableNames(); @@ -15,20 +19,12 @@ BuildParameters.PrintParameters(Context); ToolSettings.SetToolSettings( context: Context, - dupFinderExcludePattern: new string[] - { - BuildParameters.RootDirectoryPath + "/src/Cake.Issues*/**/*.AssemblyInfo.cs", - BuildParameters.RootDirectoryPath + "/src/Cake.Issues*/Serialization/LitJson/*.cs", - BuildParameters.RootDirectoryPath + "/src/Cake.Issues.Tests/**/*.cs", - BuildParameters.RootDirectoryPath + "/src/Cake.Issues.PullRequests.Tests/**/*.cs", - BuildParameters.RootDirectoryPath + "/src/Cake.Issues.Reporting.Tests/**/*.cs" - }, testCoverageFilter: "+[*]* -[xunit.*]* -[Cake.Core]* -[Cake.Testing]* -[*.Tests]* -[Cake.Issues]LitJson.* -[Shouldly]* -[DiffEngine]* -[EmptyFiles]*", testCoverageExcludeByAttribute: "*.ExcludeFromCodeCoverage*", testCoverageExcludeByFile: "*/*Designer.cs;*/*.g.cs;*/*.g.i.cs"); -// Workaround until https://github.com/cake-contrib/Cake.Recipe/issues/862 has been fixed in Cake.Recipe -ToolSettings.SetToolPreprocessorDirectives( - reSharperTools: "#tool nuget:?package=JetBrains.ReSharper.CommandLineTools&version=2021.2.0"); +//************************************************************************************************* +// Execution +//************************************************************************************************* Build.RunDotNetCore(); From 32fa0f0362865b8eaee6c0f7a1fd68aec0456a55 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Thu, 28 Jul 2022 17:36:06 +0200 Subject: [PATCH 08/44] Disable coveralls (#286) --- recipe.cake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recipe.cake b/recipe.cake index 94a1a916c..629cf5c54 100644 --- a/recipe.cake +++ b/recipe.cake @@ -13,7 +13,8 @@ BuildParameters.SetParameters( title: "Cake.Issues", repositoryOwner: "cake-contrib", repositoryName: "Cake.Issues", - appVeyorAccountName: "cakecontrib"); + appVeyorAccountName: "cakecontrib", + shouldRunCoveralls: false); // Disabled because it's currently failing BuildParameters.PrintParameters(Context); From 4f20753e0d49dc5cfaf1081f6a98f1f3f3457461 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Thu, 28 Jul 2022 17:36:22 +0200 Subject: [PATCH 09/44] Update solution file to Visual Studio 2022 (#285) --- src/Cake.Issues.sln | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Cake.Issues.sln b/src/Cake.Issues.sln index f694a27f8..3af713397 100644 --- a/src/Cake.Issues.sln +++ b/src/Cake.Issues.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30804.86 +# Visual Studio Version 17 +VisualStudioVersion = 17.2.32526.322 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cake.Issues", "Cake.Issues\Cake.Issues.csproj", "{956EE163-6E8B-44A9-AE58-50185DE4F878}" EndProject From ffc84a46f3bc6a9c2b1fbd4742b5a3d54538dfda Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Mon, 1 Aug 2022 22:44:13 +0200 Subject: [PATCH 10/44] Use specific assertions for testing for true / false (#290) --- .../ISupportCheckingCommitIdExtensionsTests.cs | 12 ++++++------ src/Cake.Issues.Tests/BaseIssueComponentTests.cs | 2 +- src/Cake.Issues.Tests/StringPathExtensionsTests.cs | 12 ++++++------ .../Testing/ResourceTempFileTests.cs | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Cake.Issues.PullRequests.Tests/ISupportCheckingCommitIdExtensionsTests.cs b/src/Cake.Issues.PullRequests.Tests/ISupportCheckingCommitIdExtensionsTests.cs index cb4b8af4c..d892e658b 100644 --- a/src/Cake.Issues.PullRequests.Tests/ISupportCheckingCommitIdExtensionsTests.cs +++ b/src/Cake.Issues.PullRequests.Tests/ISupportCheckingCommitIdExtensionsTests.cs @@ -101,7 +101,7 @@ public void Should_Return_True_If_Commit_Is_Current() var result = capability.IsCurrentCommitId(commitId); // Then - result.ShouldBe(true); + result.ShouldBeTrue(); } [Fact] @@ -121,7 +121,7 @@ public void Should_Ignore_Casing() var result = capability.IsCurrentCommitId(commitId.ToUpperInvariant()); // Then - result.ShouldBe(true); + result.ShouldBeTrue(); } [Fact] @@ -141,7 +141,7 @@ public void Should_Return_False_If_Commit_Is_Different() var result = capability.IsCurrentCommitId(commitId); // Then - result.ShouldBe(false); + result.ShouldBeFalse(); } [Fact] @@ -161,7 +161,7 @@ public void Should_Return_False_If_PullRequestSystems_Returns_Null() var result = capability.IsCurrentCommitId(commitId); // Then - result.ShouldBe(false); + result.ShouldBeFalse(); } [Fact] @@ -181,7 +181,7 @@ public void Should_Return_False_If_PullRequestSystems_Returns_Empty_String() var result = capability.IsCurrentCommitId(commitId); // Then - result.ShouldBe(false); + result.ShouldBeFalse(); } [Fact] @@ -201,7 +201,7 @@ public void Should_Return_False_If_PullRequestSystems_Returns_Whitespace() var result = capability.IsCurrentCommitId(commitId); // Then - result.ShouldBe(false); + result.ShouldBeFalse(); } } } diff --git a/src/Cake.Issues.Tests/BaseIssueComponentTests.cs b/src/Cake.Issues.Tests/BaseIssueComponentTests.cs index d17ed54a2..5dd236e16 100644 --- a/src/Cake.Issues.Tests/BaseIssueComponentTests.cs +++ b/src/Cake.Issues.Tests/BaseIssueComponentTests.cs @@ -73,7 +73,7 @@ public void Should_Return_True() var result = provider.Initialize(settings); // Then - result.ShouldBe(true); + result.ShouldBeTrue(); } } diff --git a/src/Cake.Issues.Tests/StringPathExtensionsTests.cs b/src/Cake.Issues.Tests/StringPathExtensionsTests.cs index d6e6aeb43..4df19bc84 100644 --- a/src/Cake.Issues.Tests/StringPathExtensionsTests.cs +++ b/src/Cake.Issues.Tests/StringPathExtensionsTests.cs @@ -57,7 +57,7 @@ public void Should_Return_True_If_Valid_Path(string path) var result = path.IsValidPath(); // Then - result.ShouldBe(true); + result.ShouldBeTrue(); } [Theory] @@ -68,7 +68,7 @@ public void Should_Return_False_If_Invalid_Path(string path) var result = path.IsValidPath(); // Then - result.ShouldBe(false); + result.ShouldBeFalse(); } } @@ -124,7 +124,7 @@ public void Should_Return_True_If_Full_Path(string path) var result = path.IsFullPath(); // Then - result.ShouldBe(true); + result.ShouldBeTrue(); } [Theory] @@ -143,7 +143,7 @@ public void Should_Return_False_If_Not_Full_Path(string path) var result = path.IsFullPath(); // Then - result.ShouldBe(false); + result.ShouldBeFalse(); } } @@ -242,7 +242,7 @@ public void Should_Return_True_If_SubPath(string path, string baseDir) var result = path.IsSubpathOf(baseDir); // Then - result.ShouldBe(true); + result.ShouldBeTrue(); } [Theory] @@ -257,7 +257,7 @@ public void Should_Return_False_If_Not_SubPath(string path, string baseDir) var result = path.IsSubpathOf(baseDir); // Then - result.ShouldBe(false); + result.ShouldBeFalse(); } [Theory] diff --git a/src/Cake.Issues.Tests/Testing/ResourceTempFileTests.cs b/src/Cake.Issues.Tests/Testing/ResourceTempFileTests.cs index ec8aeff29..012a2780f 100644 --- a/src/Cake.Issues.Tests/Testing/ResourceTempFileTests.cs +++ b/src/Cake.Issues.Tests/Testing/ResourceTempFileTests.cs @@ -71,7 +71,7 @@ public void Should_Create_Temp_File() using (var tempFile = new ResourceTempFile(resourceName)) { // Then - File.Exists(tempFile.FileName).ShouldBe(true); + File.Exists(tempFile.FileName).ShouldBeTrue(); } } @@ -106,7 +106,7 @@ public void Should_Remove_Temp_File() } // Then - File.Exists(tempFileName).ShouldBe(false); + File.Exists(tempFileName).ShouldBeFalse(); } } } From 9339ee43d8102507c2b1b8e8b23f9c7a3b0d3cff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Aug 2022 12:39:28 +0200 Subject: [PATCH 11/44] Bump xunit from 2.4.1 to 2.4.2 in /src (#291) Bumps [xunit](https://github.com/xunit/xunit) from 2.4.1 to 2.4.2. - [Release notes](https://github.com/xunit/xunit/releases) - [Commits](https://github.com/xunit/xunit/compare/2.4.1...2.4.2) --- updated-dependencies: - dependency-name: xunit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../Cake.Issues.PullRequests.Tests.csproj | 2 +- .../Cake.Issues.Reporting.Tests.csproj | 2 +- src/Cake.Issues.Tests/Cake.Issues.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj index 41706922c..bb6f764ee 100644 --- a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj +++ b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj b/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj index 8c1efe0e6..5b8ac1d4c 100644 --- a/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj +++ b/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj @@ -19,7 +19,7 @@ - + diff --git a/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj b/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj index df708c25f..5b65d1abe 100644 --- a/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj +++ b/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj @@ -33,7 +33,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + From d0d9e34dcfefdb58c1af2bb9124f94178aa52f30 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Tue, 9 Aug 2022 18:59:06 +0000 Subject: [PATCH 12/44] Update to Cake.Recipe 3.0 (#292) --- recipe.cake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe.cake b/recipe.cake index 629cf5c54..cd884e800 100644 --- a/recipe.cake +++ b/recipe.cake @@ -1,4 +1,4 @@ -#load nuget:https://pkgs.dev.azure.com/cake-contrib/Home/_packaging/addins/nuget/v3/index.json?package=Cake.Recipe&version=3.0.0-beta0001-0007&prerelease +#load nuget:?package=Cake.Recipe&version=3.0.0 //************************************************************************************************* // Settings From 73b769d569997ca0f9ffbeb684d297d614da2a91 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Aug 2022 08:32:47 +0200 Subject: [PATCH 13/44] Bump Microsoft.NET.Test.Sdk from 17.2.0 to 17.3.0 in /src (#293) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.2.0 to 17.3.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v17.2.0...v17.3.0) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../Cake.Issues.PullRequests.Tests.csproj | 2 +- .../Cake.Issues.Reporting.Tests.csproj | 2 +- src/Cake.Issues.Tests/Cake.Issues.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj index bb6f764ee..f24e72c0c 100644 --- a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj +++ b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj @@ -10,7 +10,7 @@ ..\Cake.Issues.Tests.ruleset - + diff --git a/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj b/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj index 5b8ac1d4c..4c5938e57 100644 --- a/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj +++ b/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj b/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj index 5b65d1abe..f88e0da3e 100644 --- a/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj +++ b/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj @@ -25,7 +25,7 @@ - + From 32fce354a560b2b3f69006928da9962a897694e0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Aug 2022 07:52:49 +0200 Subject: [PATCH 14/44] Bump Shouldly from 4.0.3 to 4.1.0 in /src (#294) Bumps [Shouldly](https://github.com/shouldly/shouldly) from 4.0.3 to 4.1.0. - [Release notes](https://github.com/shouldly/shouldly/releases) - [Changelog](https://github.com/shouldly/shouldly/blob/master/BREAKING%20CHANGES.txt) - [Commits](https://github.com/shouldly/shouldly/compare/v4.0.3...4.1.0) --- updated-dependencies: - dependency-name: Shouldly dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../Cake.Issues.PullRequests.Tests.csproj | 2 +- .../Cake.Issues.Reporting.Tests.csproj | 2 +- src/Cake.Issues.Tests/Cake.Issues.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj index f24e72c0c..eafc941e6 100644 --- a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj +++ b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj b/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj index 4c5938e57..1f81e2412 100644 --- a/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj +++ b/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj @@ -17,7 +17,7 @@ - + diff --git a/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj b/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj index f88e0da3e..2a9a14a04 100644 --- a/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj +++ b/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj @@ -28,7 +28,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive From d472662ebac535ca54d4e9383e5ed1fb2cd86256 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 31 Aug 2022 08:05:21 +0200 Subject: [PATCH 15/44] Bump Microsoft.NET.Test.Sdk from 17.3.0 to 17.3.1 in /src (#295) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.3.0 to 17.3.1. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v17.3.0...v17.3.1) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../Cake.Issues.PullRequests.Tests.csproj | 2 +- .../Cake.Issues.Reporting.Tests.csproj | 2 +- src/Cake.Issues.Tests/Cake.Issues.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj index eafc941e6..bba5c0b1e 100644 --- a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj +++ b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj @@ -10,7 +10,7 @@ ..\Cake.Issues.Tests.ruleset - + diff --git a/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj b/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj index 1f81e2412..0fc6c560f 100644 --- a/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj +++ b/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj b/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj index 2a9a14a04..e3b347897 100644 --- a/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj +++ b/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj @@ -25,7 +25,7 @@ - + From 83e1bc6588211743952426db119911956c2dc97b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 27 Sep 2022 09:54:13 +0200 Subject: [PATCH 16/44] Bump Microsoft.NET.Test.Sdk from 17.3.1 to 17.3.2 in /src (#296) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.3.1 to 17.3.2. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v17.3.1...v17.3.2) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../Cake.Issues.PullRequests.Tests.csproj | 2 +- .../Cake.Issues.Reporting.Tests.csproj | 2 +- src/Cake.Issues.Tests/Cake.Issues.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj index bba5c0b1e..e71fb1703 100644 --- a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj +++ b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj @@ -10,7 +10,7 @@ ..\Cake.Issues.Tests.ruleset - + diff --git a/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj b/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj index 0fc6c560f..e445e47ca 100644 --- a/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj +++ b/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj b/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj index e3b347897..15687ed23 100644 --- a/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj +++ b/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj @@ -25,7 +25,7 @@ - + From dd9e3de60bd46b48b4da3f274a2ba683cc611606 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 30 Nov 2022 22:10:30 +0100 Subject: [PATCH 17/44] Bump Microsoft.NET.Test.Sdk from 17.3.2 to 17.4.0 in /src (#299) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.3.2 to 17.4.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v17.3.2...v17.4.0) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../Cake.Issues.PullRequests.Tests.csproj | 2 +- .../Cake.Issues.Reporting.Tests.csproj | 2 +- src/Cake.Issues.Tests/Cake.Issues.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj index e71fb1703..c0ae41327 100644 --- a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj +++ b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj @@ -10,7 +10,7 @@ ..\Cake.Issues.Tests.ruleset - + diff --git a/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj b/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj index e445e47ca..1b43d1d08 100644 --- a/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj +++ b/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj b/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj index 15687ed23..670cc40d5 100644 --- a/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj +++ b/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj @@ -25,7 +25,7 @@ - + From 78ab2dabe51956d8924bf98c441cd2dcf3810134 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sun, 18 Dec 2022 12:31:29 +0000 Subject: [PATCH 18/44] (GH-303) Update target frameworks (#305) --- nuspec/nuget/Cake.Issues.PullRequests.nuspec | 9 +++------ nuspec/nuget/Cake.Issues.Reporting.nuspec | 9 +++------ nuspec/nuget/Cake.Issues.Testing.nuspec | 9 +++------ nuspec/nuget/Cake.Issues.nuspec | 9 +++------ .../Cake.Issues.PullRequests.Tests.csproj | 2 +- .../Cake.Issues.PullRequests.csproj | 2 +- .../Cake.Issues.Reporting.Tests.csproj | 2 +- src/Cake.Issues.Reporting/Cake.Issues.Reporting.csproj | 2 +- src/Cake.Issues.Testing/Cake.Issues.Testing.csproj | 2 +- src/Cake.Issues.Tests/Cake.Issues.Tests.csproj | 2 +- src/Cake.Issues/Cake.Issues.csproj | 2 +- 11 files changed, 19 insertions(+), 31 deletions(-) diff --git a/nuspec/nuget/Cake.Issues.PullRequests.nuspec b/nuspec/nuget/Cake.Issues.PullRequests.nuspec index 6b6820425..089a77a8c 100644 --- a/nuspec/nuget/Cake.Issues.PullRequests.nuspec +++ b/nuspec/nuget/Cake.Issues.PullRequests.nuspec @@ -26,14 +26,11 @@ See the Project Site for an overview of the whole ecosystem of addins for workin - - - - - - + + + \ No newline at end of file diff --git a/nuspec/nuget/Cake.Issues.Reporting.nuspec b/nuspec/nuget/Cake.Issues.Reporting.nuspec index c66820bed..137a8f7f8 100644 --- a/nuspec/nuget/Cake.Issues.Reporting.nuspec +++ b/nuspec/nuget/Cake.Issues.Reporting.nuspec @@ -26,14 +26,11 @@ See the Project Site for an overview of the whole ecosystem of addins for workin - - - - - - + + + \ No newline at end of file diff --git a/nuspec/nuget/Cake.Issues.Testing.nuspec b/nuspec/nuget/Cake.Issues.Testing.nuspec index b4adcc064..c2df48bb4 100644 --- a/nuspec/nuget/Cake.Issues.Testing.nuspec +++ b/nuspec/nuget/Cake.Issues.Testing.nuspec @@ -21,14 +21,11 @@ Common helpers for testing add-ins based on Cake.Issues - - - - - - + + + \ No newline at end of file diff --git a/nuspec/nuget/Cake.Issues.nuspec b/nuspec/nuget/Cake.Issues.nuspec index 9d107551d..06fecb3b6 100644 --- a/nuspec/nuget/Cake.Issues.nuspec +++ b/nuspec/nuget/Cake.Issues.nuspec @@ -28,14 +28,11 @@ See the Project Site for an overview of the whole ecosystem of addins for workin - - - - - - + + + \ No newline at end of file diff --git a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj index c0ae41327..a798e2808 100644 --- a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj +++ b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj @@ -1,6 +1,6 @@  - netcoreapp3.1 + net6.0 false Cake.Issues Copyright © BBT Software AG and contributors diff --git a/src/Cake.Issues.PullRequests/Cake.Issues.PullRequests.csproj b/src/Cake.Issues.PullRequests/Cake.Issues.PullRequests.csproj index 992b6027d..96b850bf5 100644 --- a/src/Cake.Issues.PullRequests/Cake.Issues.PullRequests.csproj +++ b/src/Cake.Issues.PullRequests/Cake.Issues.PullRequests.csproj @@ -1,6 +1,6 @@  - netcoreapp3.1;net5.0;net6.0 + net6.0;net7.0 false Cake.Issues Copyright © BBT Software AG and contributors diff --git a/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj b/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj index 1b43d1d08..96ee06117 100644 --- a/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj +++ b/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net6.0 false Copyright © BBT Software AG and contributors Tests for the Cake.Issues.Reporting addin diff --git a/src/Cake.Issues.Reporting/Cake.Issues.Reporting.csproj b/src/Cake.Issues.Reporting/Cake.Issues.Reporting.csproj index de1daf659..494eb1198 100644 --- a/src/Cake.Issues.Reporting/Cake.Issues.Reporting.csproj +++ b/src/Cake.Issues.Reporting/Cake.Issues.Reporting.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1;net5.0;net6.0 + net6.0;net7.0 Addin for the Cake build automation system for creating reports for issues from any code analyzer or linter BBT Software AG and contributors BBT Software AG and contributors diff --git a/src/Cake.Issues.Testing/Cake.Issues.Testing.csproj b/src/Cake.Issues.Testing/Cake.Issues.Testing.csproj index 1184f85d6..bdf1d6daf 100644 --- a/src/Cake.Issues.Testing/Cake.Issues.Testing.csproj +++ b/src/Cake.Issues.Testing/Cake.Issues.Testing.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1;net5.0;net6.0 + net6.0;net7.0 Common helpers for testing addins based on Cake.Issues BBT Software AG BBT Software AG diff --git a/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj b/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj index 670cc40d5..f7446f7d6 100644 --- a/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj +++ b/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net6.0 false Cake.Issues Copyright © BBT Software AG and contributors diff --git a/src/Cake.Issues/Cake.Issues.csproj b/src/Cake.Issues/Cake.Issues.csproj index 89607bb82..8c8225057 100644 --- a/src/Cake.Issues/Cake.Issues.csproj +++ b/src/Cake.Issues/Cake.Issues.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1;net5.0;net6.0 + net6.0;net7.0 Addin for reading code analyzer or linter issues for the Cake build automation system BBT Software AG BBT Software AG From 2b4db1c6a77fb11b59e26325fa62575c71449467 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sun, 18 Dec 2022 12:34:00 +0000 Subject: [PATCH 19/44] (GH-304) Build against Cake 3.0 (#306) --- .github/dependabot.yml | 4 ++-- .../Cake.Issues.PullRequests.Tests.csproj | 4 ++-- src/Cake.Issues.PullRequests/Cake.Issues.PullRequests.csproj | 2 +- .../Cake.Issues.Reporting.Tests.csproj | 4 ++-- src/Cake.Issues.Reporting/Cake.Issues.Reporting.csproj | 2 +- src/Cake.Issues.Testing/Cake.Issues.Testing.csproj | 4 ++-- src/Cake.Issues.Tests/Cake.Issues.Tests.csproj | 4 ++-- src/Cake.Issues/Cake.Issues.csproj | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 236560971..ea51e5cac 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,7 +9,7 @@ updates: ignore: - dependency-name: Cake.Core versions: - - "(,3.0)" + - "(,4.0)" - dependency-name: Cake.Testing versions: - - "(,3.0)" \ No newline at end of file + - "(,4.0)" \ No newline at end of file diff --git a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj index a798e2808..176c08a4c 100644 --- a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj +++ b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj @@ -11,8 +11,8 @@ - - + + diff --git a/src/Cake.Issues.PullRequests/Cake.Issues.PullRequests.csproj b/src/Cake.Issues.PullRequests/Cake.Issues.PullRequests.csproj index 96b850bf5..7e2da4238 100644 --- a/src/Cake.Issues.PullRequests/Cake.Issues.PullRequests.csproj +++ b/src/Cake.Issues.PullRequests/Cake.Issues.PullRequests.csproj @@ -18,7 +18,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj b/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj index 96ee06117..408e81bf6 100644 --- a/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj +++ b/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj @@ -15,8 +15,8 @@ - - + + diff --git a/src/Cake.Issues.Reporting/Cake.Issues.Reporting.csproj b/src/Cake.Issues.Reporting/Cake.Issues.Reporting.csproj index 494eb1198..8665ac719 100644 --- a/src/Cake.Issues.Reporting/Cake.Issues.Reporting.csproj +++ b/src/Cake.Issues.Reporting/Cake.Issues.Reporting.csproj @@ -19,7 +19,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Cake.Issues.Testing/Cake.Issues.Testing.csproj b/src/Cake.Issues.Testing/Cake.Issues.Testing.csproj index bdf1d6daf..ecfee1990 100644 --- a/src/Cake.Issues.Testing/Cake.Issues.Testing.csproj +++ b/src/Cake.Issues.Testing/Cake.Issues.Testing.csproj @@ -18,8 +18,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj b/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj index f7446f7d6..f08020d35 100644 --- a/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj +++ b/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj @@ -26,8 +26,8 @@ - - + + all diff --git a/src/Cake.Issues/Cake.Issues.csproj b/src/Cake.Issues/Cake.Issues.csproj index 8c8225057..7e69def11 100644 --- a/src/Cake.Issues/Cake.Issues.csproj +++ b/src/Cake.Issues/Cake.Issues.csproj @@ -17,7 +17,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive From ab2a1dc78c8b26704996d4970d8006f034ad11e7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 18 Dec 2022 12:40:55 +0000 Subject: [PATCH 20/44] Bump Microsoft.CodeAnalysis.NetAnalyzers from 6.0.0 to 7.0.0 in /src (#302) Bumps [Microsoft.CodeAnalysis.NetAnalyzers](https://github.com/dotnet/roslyn-analyzers) from 6.0.0 to 7.0.0. - [Release notes](https://github.com/dotnet/roslyn-analyzers/releases) - [Changelog](https://github.com/dotnet/roslyn-analyzers/blob/main/PostReleaseActivities.md) - [Commits](https://github.com/dotnet/roslyn-analyzers/compare/6.0.0...7.0.0) --- updated-dependencies: - dependency-name: Microsoft.CodeAnalysis.NetAnalyzers dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- src/Cake.Issues.PullRequests/Cake.Issues.PullRequests.csproj | 2 +- src/Cake.Issues.Reporting/Cake.Issues.Reporting.csproj | 2 +- src/Cake.Issues.Testing/Cake.Issues.Testing.csproj | 2 +- src/Cake.Issues/Cake.Issues.csproj | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Cake.Issues.PullRequests/Cake.Issues.PullRequests.csproj b/src/Cake.Issues.PullRequests/Cake.Issues.PullRequests.csproj index 7e2da4238..5125c9512 100644 --- a/src/Cake.Issues.PullRequests/Cake.Issues.PullRequests.csproj +++ b/src/Cake.Issues.PullRequests/Cake.Issues.PullRequests.csproj @@ -19,7 +19,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Cake.Issues.Reporting/Cake.Issues.Reporting.csproj b/src/Cake.Issues.Reporting/Cake.Issues.Reporting.csproj index 8665ac719..9edfe0edd 100644 --- a/src/Cake.Issues.Reporting/Cake.Issues.Reporting.csproj +++ b/src/Cake.Issues.Reporting/Cake.Issues.Reporting.csproj @@ -20,7 +20,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Cake.Issues.Testing/Cake.Issues.Testing.csproj b/src/Cake.Issues.Testing/Cake.Issues.Testing.csproj index ecfee1990..c022d9cf1 100644 --- a/src/Cake.Issues.Testing/Cake.Issues.Testing.csproj +++ b/src/Cake.Issues.Testing/Cake.Issues.Testing.csproj @@ -20,7 +20,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Cake.Issues/Cake.Issues.csproj b/src/Cake.Issues/Cake.Issues.csproj index 7e69def11..46f32b336 100644 --- a/src/Cake.Issues/Cake.Issues.csproj +++ b/src/Cake.Issues/Cake.Issues.csproj @@ -18,7 +18,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive From fe640e5bbf2606640fb2ee0ae084dfb278c35110 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 18 Dec 2022 12:48:18 +0000 Subject: [PATCH 21/44] Bump Microsoft.NET.Test.Sdk from 17.4.0 to 17.4.1 in /src (#315) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.4.0 to 17.4.1. - [Release notes](https://github.com/microsoft/vstest/releases) - [Changelog](https://github.com/microsoft/vstest/blob/main/docs/releases.md) - [Commits](https://github.com/microsoft/vstest/compare/v17.4.0...v17.4.1) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../Cake.Issues.PullRequests.Tests.csproj | 2 +- .../Cake.Issues.Reporting.Tests.csproj | 2 +- src/Cake.Issues.Tests/Cake.Issues.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj index 176c08a4c..ccced770f 100644 --- a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj +++ b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj @@ -10,7 +10,7 @@ ..\Cake.Issues.Tests.ruleset - + diff --git a/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj b/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj index 408e81bf6..23b0c762d 100644 --- a/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj +++ b/src/Cake.Issues.Reporting.Tests/Cake.Issues.Reporting.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj b/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj index f08020d35..a210d6997 100644 --- a/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj +++ b/src/Cake.Issues.Tests/Cake.Issues.Tests.csproj @@ -25,7 +25,7 @@ - + From 30b1e1e26d62c2ef5ecb0543269519bf8ff51499 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sun, 18 Dec 2022 12:50:43 +0000 Subject: [PATCH 22/44] Make constructors of abstract classes protected (#307) --- .../BaseCheckingCommitIdCapability.cs | 2 +- .../BaseDiscussionThreadsCapability.cs | 2 +- .../BaseFilteringByModifiedFilesCapability.cs | 2 +- .../BasePullRequestSystemCapability.cs | 2 +- .../BaseMultiFormatIssueProviderFixture.cs | 2 +- src/Cake.Issues/BaseMultiFormatIssueProviderSettings.cs | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Cake.Issues.PullRequests/BaseCheckingCommitIdCapability.cs b/src/Cake.Issues.PullRequests/BaseCheckingCommitIdCapability.cs index 073da6022..8f475ad35 100644 --- a/src/Cake.Issues.PullRequests/BaseCheckingCommitIdCapability.cs +++ b/src/Cake.Issues.PullRequests/BaseCheckingCommitIdCapability.cs @@ -15,7 +15,7 @@ public abstract class BaseCheckingCommitIdCapability /// /// The Cake log context. /// Pull request system to which this capability belongs. - public BaseCheckingCommitIdCapability(ICakeLog log, T pullRequestSystem) + protected BaseCheckingCommitIdCapability(ICakeLog log, T pullRequestSystem) : base(log, pullRequestSystem) { } diff --git a/src/Cake.Issues.PullRequests/BaseDiscussionThreadsCapability.cs b/src/Cake.Issues.PullRequests/BaseDiscussionThreadsCapability.cs index 0aa8607ae..ef347a9e3 100644 --- a/src/Cake.Issues.PullRequests/BaseDiscussionThreadsCapability.cs +++ b/src/Cake.Issues.PullRequests/BaseDiscussionThreadsCapability.cs @@ -16,7 +16,7 @@ public abstract class BaseDiscussionThreadsCapability /// /// The Cake log context. /// Pull request system to which this capability belongs. - public BaseDiscussionThreadsCapability(ICakeLog log, T pullRequestSystem) + protected BaseDiscussionThreadsCapability(ICakeLog log, T pullRequestSystem) : base(log, pullRequestSystem) { } diff --git a/src/Cake.Issues.PullRequests/BaseFilteringByModifiedFilesCapability.cs b/src/Cake.Issues.PullRequests/BaseFilteringByModifiedFilesCapability.cs index ca67bbc50..f2b24a4df 100644 --- a/src/Cake.Issues.PullRequests/BaseFilteringByModifiedFilesCapability.cs +++ b/src/Cake.Issues.PullRequests/BaseFilteringByModifiedFilesCapability.cs @@ -17,7 +17,7 @@ public abstract class BaseFilteringByModifiedFilesCapability /// /// The Cake log context. /// Pull request system to which this capability belongs. - public BaseFilteringByModifiedFilesCapability(ICakeLog log, T pullRequestSystem) + protected BaseFilteringByModifiedFilesCapability(ICakeLog log, T pullRequestSystem) : base(log, pullRequestSystem) { } diff --git a/src/Cake.Issues.PullRequests/BasePullRequestSystemCapability.cs b/src/Cake.Issues.PullRequests/BasePullRequestSystemCapability.cs index 1355274f7..38fedfb21 100644 --- a/src/Cake.Issues.PullRequests/BasePullRequestSystemCapability.cs +++ b/src/Cake.Issues.PullRequests/BasePullRequestSystemCapability.cs @@ -14,7 +14,7 @@ public abstract class BasePullRequestSystemCapability : IPullRequestSystemCap /// /// The Cake log context. /// Pull request system to which this capability belongs. - public BasePullRequestSystemCapability(ICakeLog log, T pullRequestSystem) + protected BasePullRequestSystemCapability(ICakeLog log, T pullRequestSystem) { log.NotNull(nameof(log)); pullRequestSystem.NotNull(nameof(pullRequestSystem)); diff --git a/src/Cake.Issues.Testing/BaseMultiFormatIssueProviderFixture.cs b/src/Cake.Issues.Testing/BaseMultiFormatIssueProviderFixture.cs index f23c1c4a4..eda982313 100644 --- a/src/Cake.Issues.Testing/BaseMultiFormatIssueProviderFixture.cs +++ b/src/Cake.Issues.Testing/BaseMultiFormatIssueProviderFixture.cs @@ -19,7 +19,7 @@ public abstract class BaseMultiFormatIssueProviderFixture class. /// /// Name of the resource to load. - public BaseMultiFormatIssueProviderFixture(string fileResourceName) + protected BaseMultiFormatIssueProviderFixture(string fileResourceName) : base(fileResourceName) { } diff --git a/src/Cake.Issues/BaseMultiFormatIssueProviderSettings.cs b/src/Cake.Issues/BaseMultiFormatIssueProviderSettings.cs index 2d490302a..1c0df2363 100644 --- a/src/Cake.Issues/BaseMultiFormatIssueProviderSettings.cs +++ b/src/Cake.Issues/BaseMultiFormatIssueProviderSettings.cs @@ -18,7 +18,7 @@ public abstract class BaseMultiFormatIssueProviderSettingsPath to the log file. /// The log file needs to be in the format as defined by the parameter. /// Format of the provided log file. - public BaseMultiFormatIssueProviderSettings(FilePath logFilePath, ILogFileFormat format) + protected BaseMultiFormatIssueProviderSettings(FilePath logFilePath, ILogFileFormat format) : base(logFilePath) { format.NotNull(nameof(format)); @@ -33,7 +33,7 @@ public BaseMultiFormatIssueProviderSettings(FilePath logFilePath, ILogFileFormat /// Content of the log file. /// The log file needs to be in the format as defined by the parameter. /// Format of the provided log file. - public BaseMultiFormatIssueProviderSettings(byte[] logFileContent, ILogFileFormat format) + protected BaseMultiFormatIssueProviderSettings(byte[] logFileContent, ILogFileFormat format) : base(logFileContent) { format.NotNull(nameof(format)); From 6a0f14a49f69542a5948b9888a450cf5e4ec6d59 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sun, 18 Dec 2022 12:51:14 +0000 Subject: [PATCH 23/44] Fixes formatting (#308) --- src/Cake.Issues.Tests/IssueBuilderTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Cake.Issues.Tests/IssueBuilderTests.cs b/src/Cake.Issues.Tests/IssueBuilderTests.cs index 03586055e..6e3967f89 100644 --- a/src/Cake.Issues.Tests/IssueBuilderTests.cs +++ b/src/Cake.Issues.Tests/IssueBuilderTests.cs @@ -1954,7 +1954,6 @@ public void Should_Handle_RuleNames_Which_Are_WhiteSpace() issue.RuleName.ShouldBe(ruleName); } - [Theory] [InlineData("ruleId")] public void Should_Set_Rule(string ruleId) From 39bd423ba601e5f19c8aeac63a08735d4cd0530d Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sun, 18 Dec 2022 13:05:42 +0000 Subject: [PATCH 24/44] Remove not required variable assignments (#310) --- src/Cake.Issues.PullRequests.Tests/OrchestratorTests.cs | 9 --------- src/Cake.Issues.Tests/ByteArrayExtensionsTests.cs | 1 - 2 files changed, 10 deletions(-) diff --git a/src/Cake.Issues.PullRequests.Tests/OrchestratorTests.cs b/src/Cake.Issues.PullRequests.Tests/OrchestratorTests.cs index 2873cfacc..3cba57eae 100644 --- a/src/Cake.Issues.PullRequests.Tests/OrchestratorTests.cs +++ b/src/Cake.Issues.PullRequests.Tests/OrchestratorTests.cs @@ -2128,9 +2128,6 @@ public void Should_Only_Resolve_Issues_From_Same_Comment_Source() }, })); - var threadToResolve = - fixture.PullRequestSystem.DiscussionThreadsCapability.DiscussionThreads.Single(); - fixture.IssueProviders.Clear(); fixture.IssueProviders.Add( new FakeIssueProvider( @@ -2235,9 +2232,6 @@ public void Should_Only_Reopen_Still_Active_Issues_From_Same_Comment_Source() }, })); - var threadToReopen = - fixture.PullRequestSystem.DiscussionThreadsCapability.DiscussionThreads.Single(); - fixture.IssueProviders.Clear(); fixture.IssueProviders.Add( new FakeIssueProvider( @@ -2318,9 +2312,6 @@ public void Should_Output_A_Warning_If_Unknown_Thread_Status() }, })); - var threadToReopen = - fixture.PullRequestSystem.DiscussionThreadsCapability.DiscussionThreads.Single(); - fixture.IssueProviders.Clear(); fixture.IssueProviders.Add( new FakeIssueProvider( diff --git a/src/Cake.Issues.Tests/ByteArrayExtensionsTests.cs b/src/Cake.Issues.Tests/ByteArrayExtensionsTests.cs index 8193deede..3a6223769 100644 --- a/src/Cake.Issues.Tests/ByteArrayExtensionsTests.cs +++ b/src/Cake.Issues.Tests/ByteArrayExtensionsTests.cs @@ -99,7 +99,6 @@ public void Should_Return_Correct_Value_If_Enconding_Has_Preamble_But_Value_Not( { // Given var encoding = Encoding.UTF32; - var preamble = encoding.GetPreamble(); var valueWithoutPreamble = value.ToByteArray(encoding); // When From 7acf31063fc066e14b80d1b0d013ccf182e9136d Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sun, 18 Dec 2022 13:14:06 +0000 Subject: [PATCH 25/44] Remove not required continue (#311) --- src/Cake.Issues.PullRequests/Orchestrator.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Cake.Issues.PullRequests/Orchestrator.cs b/src/Cake.Issues.PullRequests/Orchestrator.cs index a46cbd08f..b17592a77 100644 --- a/src/Cake.Issues.PullRequests/Orchestrator.cs +++ b/src/Cake.Issues.PullRequests/Orchestrator.cs @@ -355,7 +355,6 @@ private IDictionary GetCommentsForIssue( { this.log.Warning( "Thread has unknown status und matching comment(s) are ignored."); - continue; } } From 1e7628437de6dfcd614fc6a23252777aa006eeaf Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sun, 18 Dec 2022 13:27:12 +0000 Subject: [PATCH 26/44] Simplify new statements (#313) --- src/Cake.Issues/BaseRuleUrlResolver.cs | 2 +- src/Cake.Issues/IssueBuilder.cs | 2 +- src/Cake.Issues/IssuesReader.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cake.Issues/BaseRuleUrlResolver.cs b/src/Cake.Issues/BaseRuleUrlResolver.cs index 80c84e315..7c14bd08e 100644 --- a/src/Cake.Issues/BaseRuleUrlResolver.cs +++ b/src/Cake.Issues/BaseRuleUrlResolver.cs @@ -11,7 +11,7 @@ public abstract class BaseRuleUrlResolver where T : BaseRuleDescription, new() { - private readonly List, int>> registeredUrlResolver = new List, int>>(); + private readonly List, int>> registeredUrlResolver = new (); /// /// Registers a new resolver with default priority of 0. diff --git a/src/Cake.Issues/IssueBuilder.cs b/src/Cake.Issues/IssueBuilder.cs index a4ad60ae8..02bf49a17 100644 --- a/src/Cake.Issues/IssueBuilder.cs +++ b/src/Cake.Issues/IssueBuilder.cs @@ -29,7 +29,7 @@ public class IssueBuilder private Uri ruleUrl; private string run; private FileLinkSettings fileLinkSettings; - private Dictionary additionalInformation = new Dictionary(); + private Dictionary additionalInformation = new (); /// /// Initializes a new instance of the class. diff --git a/src/Cake.Issues/IssuesReader.cs b/src/Cake.Issues/IssuesReader.cs index d64e03af9..2983b931d 100644 --- a/src/Cake.Issues/IssuesReader.cs +++ b/src/Cake.Issues/IssuesReader.cs @@ -10,7 +10,7 @@ public class IssuesReader { private readonly ICakeLog log; - private readonly List issueProviders = new List(); + private readonly List issueProviders = new (); private readonly IReadIssuesSettings settings; /// From ff568622b80981943c37236b6a8b67957d269196 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sun, 18 Dec 2022 13:41:59 +0000 Subject: [PATCH 27/44] Use range operator instead of substring (#309) --- src/Cake.Issues/StringPathExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cake.Issues/StringPathExtensions.cs b/src/Cake.Issues/StringPathExtensions.cs index 142726f51..6322c3c18 100644 --- a/src/Cake.Issues/StringPathExtensions.cs +++ b/src/Cake.Issues/StringPathExtensions.cs @@ -212,7 +212,7 @@ internal static string Right(this string value, int length) throw new ArgumentOutOfRangeException(nameof(length), length, "Length is less than zero"); } - return (length < value.Length) ? value.Substring(value.Length - length) : value; + return (length < value.Length) ? value[^length..] : value; } } } From 50ae8d1c79c315f42e720b147a82bb390d9dfc4d Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sun, 18 Dec 2022 13:51:46 +0000 Subject: [PATCH 28/44] Check that no exception is thrown (#312) --- src/Cake.Issues.Reporting.Tests/IssueReportFormatTests.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Cake.Issues.Reporting.Tests/IssueReportFormatTests.cs b/src/Cake.Issues.Reporting.Tests/IssueReportFormatTests.cs index 4c9a8daa0..25c8f6c60 100644 --- a/src/Cake.Issues.Reporting.Tests/IssueReportFormatTests.cs +++ b/src/Cake.Issues.Reporting.Tests/IssueReportFormatTests.cs @@ -69,9 +69,10 @@ public void Should_Not_Throw_If_Issues_Is_Empty() var fixture = new IssueReportFormatFixture(); // When - var result = Record.Exception(() => fixture.CreateReport(new List())); + var result = fixture.CreateReport(new List()); // Then + result.ShouldNotBeNull(); } [Fact] From 531ec63edd90c70a28fa3bd94cb42f071cb8da69 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sun, 18 Dec 2022 14:01:28 +0000 Subject: [PATCH 29/44] Remove dupFinder exclusions (#314) --- src/Cake.Issues.PullRequests/IssueFilterer.cs | 6 ----- src/Cake.Issues.PullRequests/Orchestrator.cs | 6 ----- ...sToPullRequestFromIssueProviderSettings.cs | 4 ---- .../ReportIssuesToPullRequestSettings.cs | 4 ---- .../Testing/IssueCheckerTests.cs | 24 ------------------- src/Cake.Issues/Aliases.NewIssue.cs | 6 ----- src/Cake.Issues/IssueBuilder.cs | 12 ---------- .../SerializableIssueExtensions.cs | 6 ----- .../SerializableIssueV2Extensions.cs | 6 ----- .../SerializableIssueV3Extensions.cs | 6 ----- .../SerializableIssueV4Extensions.cs | 6 ----- .../SerializableIssueV5Extensions.cs | 6 ----- 12 files changed, 92 deletions(-) diff --git a/src/Cake.Issues.PullRequests/IssueFilterer.cs b/src/Cake.Issues.PullRequests/IssueFilterer.cs index 4e5121d2a..3b49090b8 100644 --- a/src/Cake.Issues.PullRequests/IssueFilterer.cs +++ b/src/Cake.Issues.PullRequests/IssueFilterer.cs @@ -27,10 +27,6 @@ public IssueFilterer( IPullRequestSystem pullRequestSystem, IReportIssuesToPullRequestSettings settings) { -#pragma warning disable SA1123 // Do not place regions within elements - #region DupFinder Exclusion -#pragma warning restore SA1123 // Do not place regions within elements - log.NotNull(nameof(log)); pullRequestSystem.NotNull(nameof(pullRequestSystem)); settings.NotNull(nameof(settings)); @@ -38,8 +34,6 @@ public IssueFilterer( this.log = log; this.pullRequestSystem = pullRequestSystem; this.settings = settings; - - #endregion } /// diff --git a/src/Cake.Issues.PullRequests/Orchestrator.cs b/src/Cake.Issues.PullRequests/Orchestrator.cs index b17592a77..e37417716 100644 --- a/src/Cake.Issues.PullRequests/Orchestrator.cs +++ b/src/Cake.Issues.PullRequests/Orchestrator.cs @@ -25,17 +25,11 @@ public Orchestrator( ICakeLog log, IPullRequestSystem pullRequestSystem) { -#pragma warning disable SA1123 // Do not place regions within elements - #region DupFinder Exclusion -#pragma warning restore SA1123 // Do not place regions within elements - log.NotNull(nameof(log)); pullRequestSystem.NotNull(nameof(pullRequestSystem)); this.log = log; this.pullRequestSystem = pullRequestSystem; - - #endregion } /// diff --git a/src/Cake.Issues.PullRequests/ReportIssuesToPullRequestFromIssueProviderSettings.cs b/src/Cake.Issues.PullRequests/ReportIssuesToPullRequestFromIssueProviderSettings.cs index 7142849c8..d5b348c27 100644 --- a/src/Cake.Issues.PullRequests/ReportIssuesToPullRequestFromIssueProviderSettings.cs +++ b/src/Cake.Issues.PullRequests/ReportIssuesToPullRequestFromIssueProviderSettings.cs @@ -9,11 +9,7 @@ /// public class ReportIssuesToPullRequestFromIssueProviderSettings : ReadIssuesSettings, IReportIssuesToPullRequestFromIssueProviderSettings { -#pragma warning disable SA1124 // Do not use regions - #region DupFinder Exclusion -#pragma warning restore SA1124 // Do not use regions private readonly List, IEnumerable>> issueFilters = new (); - #endregion /// /// Initializes a new instance of the class. diff --git a/src/Cake.Issues.PullRequests/ReportIssuesToPullRequestSettings.cs b/src/Cake.Issues.PullRequests/ReportIssuesToPullRequestSettings.cs index 89829cfe3..cf67046be 100644 --- a/src/Cake.Issues.PullRequests/ReportIssuesToPullRequestSettings.cs +++ b/src/Cake.Issues.PullRequests/ReportIssuesToPullRequestSettings.cs @@ -9,11 +9,7 @@ /// public class ReportIssuesToPullRequestSettings : RepositorySettings, IReportIssuesToPullRequestSettings { -#pragma warning disable SA1124 // Do not use regions - #region DupFinder Exclusion -#pragma warning restore SA1124 // Do not use regions private readonly List, IEnumerable>> issueFilters = new (); - #endregion /// /// Initializes a new instance of the class. diff --git a/src/Cake.Issues.Tests/Testing/IssueCheckerTests.cs b/src/Cake.Issues.Tests/Testing/IssueCheckerTests.cs index 02f273d17..0b32f6003 100644 --- a/src/Cake.Issues.Tests/Testing/IssueCheckerTests.cs +++ b/src/Cake.Issues.Tests/Testing/IssueCheckerTests.cs @@ -13,10 +13,6 @@ public sealed class TheCheckMethodWithIssueBuilder [Fact] public void Should_Throw_If_IssueToCheck_Is_Null() { -#pragma warning disable SA1123 // Do not place regions within elements - #region DupFinder Exclusion -#pragma warning restore SA1123 // Do not place regions within elements - // Given var fixture = new IssueBuilderFixture(); IIssue issueToCheck = null; @@ -28,17 +24,11 @@ public void Should_Throw_If_IssueToCheck_Is_Null() // Then result.IsArgumentNullException("issueToCheck"); - - #endregion } [Fact] public void Should_Throw_If_ExpectedIssue_Is_Null() { -#pragma warning disable SA1123 // Do not place regions within elements - #region DupFinder Exclusion -#pragma warning restore SA1123 // Do not place regions within elements - // Given var fixture = new IssueBuilderFixture(); var issueToCheck = fixture.IssueBuilder.Create(); @@ -50,8 +40,6 @@ public void Should_Throw_If_ExpectedIssue_Is_Null() // Then result.IsArgumentNullException("expectedIssue"); - - #endregion } [Fact] @@ -74,10 +62,6 @@ public sealed class TheCheckMethodComparingTwoIssues [Fact] public void Should_Throw_If_IssueToCheck_Is_Null() { -#pragma warning disable SA1123 // Do not place regions within elements - #region DupFinder Exclusion -#pragma warning restore SA1123 // Do not place regions within elements - // Given var fixture = new IssueBuilderFixture(); IIssue issueToCheck = null; @@ -89,17 +73,11 @@ public void Should_Throw_If_IssueToCheck_Is_Null() // Then result.IsArgumentNullException("issueToCheck"); - - #endregion } [Fact] public void Should_Throw_If_ExpectedIssue_Is_Null() { -#pragma warning disable SA1123 // Do not place regions within elements - #region DupFinder Exclusion -#pragma warning restore SA1123 // Do not place regions within elements - // Given var fixture = new IssueBuilderFixture(); var issueToCheck = fixture.IssueBuilder.Create(); @@ -111,8 +89,6 @@ public void Should_Throw_If_ExpectedIssue_Is_Null() // Then result.IsArgumentNullException("expectedIssue"); - - #endregion } [Fact] diff --git a/src/Cake.Issues/Aliases.NewIssue.cs b/src/Cake.Issues/Aliases.NewIssue.cs index 3e23ad827..671f1d6f5 100644 --- a/src/Cake.Issues/Aliases.NewIssue.cs +++ b/src/Cake.Issues/Aliases.NewIssue.cs @@ -81,18 +81,12 @@ public static IssueBuilder NewIssue( string providerType, string providerName) { -#pragma warning disable SA1123 // Do not place regions within elements - #region DupFinder Exclusion -#pragma warning restore SA1123 // Do not place regions within elements - context.NotNull(nameof(context)); identifier.NotNullOrWhiteSpace(nameof(identifier)); message.NotNullOrWhiteSpace(nameof(message)); providerType.NotNullOrWhiteSpace(nameof(providerType)); providerName.NotNullOrWhiteSpace(nameof(providerName)); - #endregion - return IssueBuilder.NewIssue(identifier, message, providerType, providerName); } } diff --git a/src/Cake.Issues/IssueBuilder.cs b/src/Cake.Issues/IssueBuilder.cs index 02bf49a17..f2bcac613 100644 --- a/src/Cake.Issues/IssueBuilder.cs +++ b/src/Cake.Issues/IssueBuilder.cs @@ -44,17 +44,11 @@ private IssueBuilder( string providerType, string providerName) { -#pragma warning disable SA1123 // Do not place regions within elements - #region DupFinder Exclusion -#pragma warning restore SA1123 // Do not place regions within elements - identifier.NotNullOrWhiteSpace(nameof(identifier)); message.NotNullOrWhiteSpace(nameof(message)); providerType.NotNullOrWhiteSpace(nameof(providerType)); providerName.NotNullOrWhiteSpace(nameof(providerName)); - #endregion - this.identifier = identifier; this.messageText = message; this.providerType = providerType; @@ -141,17 +135,11 @@ public static IssueBuilder NewIssue( string providerType, string providerName) { -#pragma warning disable SA1123 // Do not place regions within elements - #region DupFinder Exclusion -#pragma warning restore SA1123 // Do not place regions within elements - identifier.NotNullOrWhiteSpace(nameof(identifier)); message.NotNullOrWhiteSpace(nameof(message)); providerType.NotNullOrWhiteSpace(nameof(providerType)); providerName.NotNullOrWhiteSpace(nameof(providerName)); - #endregion - return new IssueBuilder(identifier, message, providerType, providerName); } diff --git a/src/Cake.Issues/Serialization/SerializableIssueExtensions.cs b/src/Cake.Issues/Serialization/SerializableIssueExtensions.cs index 5d31d46b7..79f7e1582 100644 --- a/src/Cake.Issues/Serialization/SerializableIssueExtensions.cs +++ b/src/Cake.Issues/Serialization/SerializableIssueExtensions.cs @@ -15,10 +15,6 @@ internal static class SerializableIssueExtensions /// Converted issue. internal static Issue ToIssue(this SerializableIssue serializableIssue) { -#pragma warning disable SA1123 // Do not place regions within elements - #region DupFinder Exclusion -#pragma warning restore SA1123 // Do not place regions within elements - serializableIssue.NotNull(nameof(serializableIssue)); Uri ruleUrl = null; @@ -49,8 +45,6 @@ internal static Issue ToIssue(this SerializableIssue serializableIssue) serializableIssue.ProviderType, serializableIssue.ProviderName, new Dictionary()); - - #endregion } } } diff --git a/src/Cake.Issues/Serialization/SerializableIssueV2Extensions.cs b/src/Cake.Issues/Serialization/SerializableIssueV2Extensions.cs index b8d90b746..100f3ccd4 100644 --- a/src/Cake.Issues/Serialization/SerializableIssueV2Extensions.cs +++ b/src/Cake.Issues/Serialization/SerializableIssueV2Extensions.cs @@ -15,10 +15,6 @@ internal static class SerializableIssueV2Extensions /// Converted issue. internal static Issue ToIssue(this SerializableIssueV2 serializableIssue) { -#pragma warning disable SA1123 // Do not place regions within elements - #region DupFinder Exclusion -#pragma warning restore SA1123 // Do not place regions within elements - serializableIssue.NotNull(nameof(serializableIssue)); Uri ruleUrl = null; @@ -49,8 +45,6 @@ internal static Issue ToIssue(this SerializableIssueV2 serializableIssue) serializableIssue.ProviderType, serializableIssue.ProviderName, new Dictionary()); - - #endregion } } } diff --git a/src/Cake.Issues/Serialization/SerializableIssueV3Extensions.cs b/src/Cake.Issues/Serialization/SerializableIssueV3Extensions.cs index 37cb78727..085438fb7 100644 --- a/src/Cake.Issues/Serialization/SerializableIssueV3Extensions.cs +++ b/src/Cake.Issues/Serialization/SerializableIssueV3Extensions.cs @@ -15,10 +15,6 @@ internal static class SerializableIssueV3Extensions /// Converted issue. internal static Issue ToIssue(this SerializableIssueV3 serializableIssue) { -#pragma warning disable SA1123 // Do not place regions within elements - #region DupFinder Exclusion -#pragma warning restore SA1123 // Do not place regions within elements - serializableIssue.NotNull(nameof(serializableIssue)); Uri ruleUrl = null; @@ -55,8 +51,6 @@ internal static Issue ToIssue(this SerializableIssueV3 serializableIssue) serializableIssue.ProviderType, serializableIssue.ProviderName, new Dictionary()); - - #endregion } } } diff --git a/src/Cake.Issues/Serialization/SerializableIssueV4Extensions.cs b/src/Cake.Issues/Serialization/SerializableIssueV4Extensions.cs index ac9408153..a54ec6f80 100644 --- a/src/Cake.Issues/Serialization/SerializableIssueV4Extensions.cs +++ b/src/Cake.Issues/Serialization/SerializableIssueV4Extensions.cs @@ -14,10 +14,6 @@ internal static class SerializableIssueV4Extensions /// Converted issue. internal static Issue ToIssue(this SerializableIssueV4 serializableIssue) { -#pragma warning disable SA1123 // Do not place regions within elements - #region DupFinder Exclusion -#pragma warning restore SA1123 // Do not place regions within elements - serializableIssue.NotNull(nameof(serializableIssue)); Uri ruleUrl = null; @@ -54,8 +50,6 @@ internal static Issue ToIssue(this SerializableIssueV4 serializableIssue) serializableIssue.ProviderType, serializableIssue.ProviderName, serializableIssue.AdditionalInformation); - - #endregion } } } diff --git a/src/Cake.Issues/Serialization/SerializableIssueV5Extensions.cs b/src/Cake.Issues/Serialization/SerializableIssueV5Extensions.cs index 11b68d4a3..7c11b0aed 100644 --- a/src/Cake.Issues/Serialization/SerializableIssueV5Extensions.cs +++ b/src/Cake.Issues/Serialization/SerializableIssueV5Extensions.cs @@ -14,10 +14,6 @@ internal static class SerializableIssueV5Extensions /// Converted issue. internal static Issue ToIssue(this SerializableIssueV5 serializableIssue) { -#pragma warning disable SA1123 // Do not place regions within elements - #region DupFinder Exclusion -#pragma warning restore SA1123 // Do not place regions within elements - serializableIssue.NotNull(nameof(serializableIssue)); Uri ruleUrl = null; @@ -54,8 +50,6 @@ internal static Issue ToIssue(this SerializableIssueV5 serializableIssue) serializableIssue.ProviderType, serializableIssue.ProviderName, serializableIssue.AdditionalInformation); - - #endregion } } } From 3c409038e6801f0472cfc9e213cefc8f076e2282 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sun, 18 Dec 2022 14:15:08 +0000 Subject: [PATCH 30/44] Update to LitJson 0.18 (#316) --- .../Serialization/LitJson/IJsonWrapper.cs | 40 +- .../Serialization/LitJson/JsonData.cs | 785 ++++++++------- .../Serialization/LitJson/JsonException.cs | 28 +- .../Serialization/LitJson/JsonMapper.cs | 796 ++++++++------- .../Serialization/LitJson/JsonMockWrapper.cs | 110 ++- .../Serialization/LitJson/JsonReader.cs | 383 ++++---- .../Serialization/LitJson/JsonWriter.cs | 428 +++++---- .../Serialization/LitJson/Lexer.cs | 903 ++++++++++-------- .../Serialization/LitJson/ParserToken.cs | 3 +- 9 files changed, 1902 insertions(+), 1574 deletions(-) diff --git a/src/Cake.Issues/Serialization/LitJson/IJsonWrapper.cs b/src/Cake.Issues/Serialization/LitJson/IJsonWrapper.cs index 34b2b820d..5d76dde91 100644 --- a/src/Cake.Issues/Serialization/LitJson/IJsonWrapper.cs +++ b/src/Cake.Issues/Serialization/LitJson/IJsonWrapper.cs @@ -38,29 +38,29 @@ internal enum JsonType internal interface IJsonWrapper : IList, IOrderedDictionary { - bool IsArray { get; } + bool IsArray { get; } bool IsBoolean { get; } - bool IsDouble { get; } - bool IsInt { get; } - bool IsLong { get; } - bool IsObject { get; } - bool IsString { get; } + bool IsDouble { get; } + bool IsInt { get; } + bool IsLong { get; } + bool IsObject { get; } + bool IsString { get; } - bool GetBoolean (); - double GetDouble (); - int GetInt (); - JsonType GetJsonType (); - long GetLong (); - string GetString (); + bool GetBoolean(); + double GetDouble(); + int GetInt(); + JsonType GetJsonType(); + long GetLong(); + string GetString(); - void SetBoolean (bool val); - void SetDouble (double val); - void SetInt (int val); - void SetJsonType (JsonType type); - void SetLong (long val); - void SetString (string val); + void SetBoolean(bool val); + void SetDouble(double val); + void SetInt(int val); + void SetJsonType(JsonType type); + void SetLong(long val); + void SetString(string val); - string ToJson (); - void ToJson (JsonWriter writer); + string ToJson(); + void ToJson(JsonWriter writer); } } diff --git a/src/Cake.Issues/Serialization/LitJson/JsonData.cs b/src/Cake.Issues/Serialization/LitJson/JsonData.cs index d595bfc2e..41f65cd11 100644 --- a/src/Cake.Issues/Serialization/LitJson/JsonData.cs +++ b/src/Cake.Issues/Serialization/LitJson/JsonData.cs @@ -28,15 +28,15 @@ namespace LitJson internal class JsonData : IJsonWrapper, IEquatable { #region Fields - private IList inst_array; - private bool inst_boolean; - private double inst_double; - private int inst_int; - private long inst_long; + private IList inst_array; + private bool inst_boolean; + private double inst_double; + private int inst_int; + private long inst_long; private IDictionary inst_object; - private string inst_string; - private string json; - private JsonType type; + private string inst_string; + private string json; + private JsonType type; // Used to implement the IOrderedDictionary interface private IList> object_list; @@ -44,48 +44,58 @@ internal class JsonData : IJsonWrapper, IEquatable #region Properties - public int Count { - get { return EnsureCollection ().Count; } + public int Count + { + get { return EnsureCollection().Count; } } - public bool IsArray { + public bool IsArray + { get { return type == JsonType.Array; } } - public bool IsBoolean { + public bool IsBoolean + { get { return type == JsonType.Boolean; } } - public bool IsDouble { + public bool IsDouble + { get { return type == JsonType.Double; } } - public bool IsInt { + public bool IsInt + { get { return type == JsonType.Int; } } - public bool IsLong { + public bool IsLong + { get { return type == JsonType.Long; } } - public bool IsObject { + public bool IsObject + { get { return type == JsonType.Object; } } - public bool IsString { + public bool IsString + { get { return type == JsonType.String; } } - public ICollection Keys { - get { EnsureDictionary (); return inst_object.Keys; } + public ICollection Keys + { + get { EnsureDictionary(); return inst_object.Keys; } } - + /// /// Determines whether the json contains an element that has the specified key. /// /// The key to locate in the json. /// true if the json contains an element that has the specified key; otherwise, false. - public Boolean ContainsKey(String key) { + public Boolean ContainsKey(String key) + { EnsureDictionary(); return this.inst_object.Keys.Contains(key); } @@ -93,64 +103,80 @@ public Boolean ContainsKey(String key) { #region ICollection Properties - int ICollection.Count { - get { + int ICollection.Count + { + get + { return Count; } } - bool ICollection.IsSynchronized { - get { - return EnsureCollection ().IsSynchronized; + bool ICollection.IsSynchronized + { + get + { + return EnsureCollection().IsSynchronized; } } - object ICollection.SyncRoot { - get { - return EnsureCollection ().SyncRoot; + object ICollection.SyncRoot + { + get + { + return EnsureCollection().SyncRoot; } } #endregion #region IDictionary Properties - bool IDictionary.IsFixedSize { - get { - return EnsureDictionary ().IsFixedSize; + bool IDictionary.IsFixedSize + { + get + { + return EnsureDictionary().IsFixedSize; } } - bool IDictionary.IsReadOnly { - get { - return EnsureDictionary ().IsReadOnly; + bool IDictionary.IsReadOnly + { + get + { + return EnsureDictionary().IsReadOnly; } } - ICollection IDictionary.Keys { - get { - EnsureDictionary (); - IList keys = new List (); + ICollection IDictionary.Keys + { + get + { + EnsureDictionary(); + IList keys = new List(); foreach (KeyValuePair entry in - object_list) { - keys.Add (entry.Key); + object_list) + { + keys.Add(entry.Key); } - return (ICollection) keys; + return (ICollection)keys; } } - ICollection IDictionary.Values { - get { - EnsureDictionary (); - IList values = new List (); + ICollection IDictionary.Values + { + get + { + EnsureDictionary(); + IList values = new List(); foreach (KeyValuePair entry in - object_list) { - values.Add (entry.Value); + object_list) + { + values.Add(entry.Value); } - return (ICollection) values; + return (ICollection)values; } } #endregion @@ -158,87 +184,104 @@ ICollection IDictionary.Values { #region IJsonWrapper Properties - bool IJsonWrapper.IsArray { + bool IJsonWrapper.IsArray + { get { return IsArray; } } - bool IJsonWrapper.IsBoolean { + bool IJsonWrapper.IsBoolean + { get { return IsBoolean; } } - bool IJsonWrapper.IsDouble { + bool IJsonWrapper.IsDouble + { get { return IsDouble; } } - bool IJsonWrapper.IsInt { + bool IJsonWrapper.IsInt + { get { return IsInt; } } - bool IJsonWrapper.IsLong { + bool IJsonWrapper.IsLong + { get { return IsLong; } } - bool IJsonWrapper.IsObject { + bool IJsonWrapper.IsObject + { get { return IsObject; } } - bool IJsonWrapper.IsString { + bool IJsonWrapper.IsString + { get { return IsString; } } #endregion #region IList Properties - bool IList.IsFixedSize { - get { - return EnsureList ().IsFixedSize; + bool IList.IsFixedSize + { + get + { + return EnsureList().IsFixedSize; } } - bool IList.IsReadOnly { - get { - return EnsureList ().IsReadOnly; + bool IList.IsReadOnly + { + get + { + return EnsureList().IsReadOnly; } } #endregion #region IDictionary Indexer - object IDictionary.this[object key] { - get { - return EnsureDictionary ()[key]; + object IDictionary.this[object key] + { + get + { + return EnsureDictionary()[key]; } - set { - if (! (key is String)) - throw new ArgumentException ( + set + { + if (!(key is String)) + throw new ArgumentException( "The key has to be a string"); - JsonData data = ToJsonData (value); + JsonData data = ToJsonData(value); - this[(string) key] = data; + this[(string)key] = data; } } #endregion #region IOrderedDictionary Indexer - object IOrderedDictionary.this[int idx] { - get { - EnsureDictionary (); + object IOrderedDictionary.this[int idx] + { + get + { + EnsureDictionary(); return object_list[idx].Value; } - set { - EnsureDictionary (); - JsonData data = ToJsonData (value); + set + { + EnsureDictionary(); + JsonData data = ToJsonData(value); KeyValuePair old_entry = object_list[idx]; inst_object[old_entry.Key] = data; KeyValuePair entry = - new KeyValuePair (old_entry.Key, data); + new KeyValuePair(old_entry.Key, data); object_list[idx] = entry; } @@ -247,14 +290,17 @@ object IOrderedDictionary.this[int idx] { #region IList Indexer - object IList.this[int index] { - get { - return EnsureList ()[index]; + object IList.this[int index] + { + get + { + return EnsureList()[index]; } - set { - EnsureList (); - JsonData data = ToJsonData (value); + set + { + EnsureList(); + JsonData data = ToJsonData(value); this[index] = data; } @@ -263,27 +309,34 @@ object IList.this[int index] { #region Public Indexers - public JsonData this[string prop_name] { - get { - EnsureDictionary (); + public JsonData this[string prop_name] + { + get + { + EnsureDictionary(); return inst_object[prop_name]; } - set { - EnsureDictionary (); + set + { + EnsureDictionary(); KeyValuePair entry = - new KeyValuePair (prop_name, value); + new KeyValuePair(prop_name, value); - if (inst_object.ContainsKey (prop_name)) { - for (int i = 0; i < object_list.Count; i++) { - if (object_list[i].Key == prop_name) { + if (inst_object.ContainsKey(prop_name)) + { + for (int i = 0; i < object_list.Count; i++) + { + if (object_list[i].Key == prop_name) + { object_list[i] = entry; break; } } - } else - object_list.Add (entry); + } + else + object_list.Add(entry); inst_object[prop_name] = value; @@ -291,9 +344,11 @@ public JsonData this[string prop_name] { } } - public JsonData this[int index] { - get { - EnsureCollection (); + public JsonData this[int index] + { + get + { + EnsureCollection(); if (type == JsonType.Array) return inst_array[index]; @@ -301,15 +356,17 @@ public JsonData this[int index] { return object_list[index].Value; } - set { - EnsureCollection (); + set + { + EnsureCollection(); if (type == JsonType.Array) inst_array[index] = value; - else { + else + { KeyValuePair entry = object_list[index]; KeyValuePair new_entry = - new KeyValuePair (entry.Key, value); + new KeyValuePair(entry.Key, value); object_list[index] = new_entry; inst_object[entry.Key] = value; @@ -322,71 +379,76 @@ public JsonData this[int index] { #region Constructors - public JsonData () + public JsonData() { } - public JsonData (bool boolean) + public JsonData(bool boolean) { type = JsonType.Boolean; inst_boolean = boolean; } - public JsonData (double number) + public JsonData(double number) { type = JsonType.Double; inst_double = number; } - public JsonData (int number) + public JsonData(int number) { type = JsonType.Int; inst_int = number; } - public JsonData (long number) + public JsonData(long number) { type = JsonType.Long; inst_long = number; } - public JsonData (object obj) + public JsonData(object obj) { - if (obj is Boolean) { + if (obj is Boolean) + { type = JsonType.Boolean; - inst_boolean = (bool) obj; + inst_boolean = (bool)obj; return; } - if (obj is Double) { + if (obj is Double) + { type = JsonType.Double; - inst_double = (double) obj; + inst_double = (double)obj; return; } - if (obj is Int32) { + if (obj is Int32) + { type = JsonType.Int; - inst_int = (int) obj; + inst_int = (int)obj; return; } - if (obj is Int64) { + if (obj is Int64) + { type = JsonType.Long; - inst_long = (long) obj; + inst_long = (long)obj; return; } - if (obj is String) { + if (obj is String) + { type = JsonType.String; - inst_string = (string) obj; + inst_string = (string)obj; return; } - throw new ArgumentException ( + throw new ArgumentException( "Unable to wrap the given object with JsonData"); } - public JsonData (string str) + public JsonData(string str) { type = JsonType.String; inst_string = str; @@ -395,53 +457,53 @@ public JsonData (string str) #region Implicit Conversions - public static implicit operator JsonData (Boolean data) + public static implicit operator JsonData(Boolean data) { - return new JsonData (data); + return new JsonData(data); } - public static implicit operator JsonData (Double data) + public static implicit operator JsonData(Double data) { - return new JsonData (data); + return new JsonData(data); } - public static implicit operator JsonData (Int32 data) + public static implicit operator JsonData(Int32 data) { - return new JsonData (data); + return new JsonData(data); } - public static implicit operator JsonData (Int64 data) + public static implicit operator JsonData(Int64 data) { - return new JsonData (data); + return new JsonData(data); } - public static implicit operator JsonData (String data) + public static implicit operator JsonData(String data) { - return new JsonData (data); + return new JsonData(data); } #endregion #region Explicit Conversions - public static explicit operator Boolean (JsonData data) + public static explicit operator Boolean(JsonData data) { if (data.type != JsonType.Boolean) - throw new InvalidCastException ( + throw new InvalidCastException( "Instance of JsonData doesn't hold a double"); return data.inst_boolean; } - public static explicit operator Double (JsonData data) + public static explicit operator Double(JsonData data) { if (data.type != JsonType.Double) - throw new InvalidCastException ( + throw new InvalidCastException( "Instance of JsonData doesn't hold a double"); return data.inst_double; } - public static explicit operator Int32(JsonData data) + public static explicit operator Int32(JsonData data) { if (data.type != JsonType.Int && data.type != JsonType.Long) { @@ -464,10 +526,10 @@ public static explicit operator Int64(JsonData data) return data.type == JsonType.Long ? data.inst_long : data.inst_int; } - public static explicit operator String (JsonData data) + public static explicit operator String(JsonData data) { if (data.type != JsonType.String) - throw new InvalidCastException ( + throw new InvalidCastException( "Instance of JsonData doesn't hold a string"); return data.inst_string; @@ -476,51 +538,53 @@ public static explicit operator String (JsonData data) #region ICollection Methods - void ICollection.CopyTo (Array array, int index) + void ICollection.CopyTo(Array array, int index) { - EnsureCollection ().CopyTo (array, index); + EnsureCollection().CopyTo(array, index); } #endregion #region IDictionary Methods - void IDictionary.Add (object key, object value) + void IDictionary.Add(object key, object value) { - JsonData data = ToJsonData (value); + JsonData data = ToJsonData(value); - EnsureDictionary ().Add (key, data); + EnsureDictionary().Add(key, data); KeyValuePair entry = - new KeyValuePair ((string) key, data); - object_list.Add (entry); + new KeyValuePair((string)key, data); + object_list.Add(entry); json = null; } - void IDictionary.Clear () + void IDictionary.Clear() { - EnsureDictionary ().Clear (); - object_list.Clear (); + EnsureDictionary().Clear(); + object_list.Clear(); json = null; } - bool IDictionary.Contains (object key) + bool IDictionary.Contains(object key) { - return EnsureDictionary ().Contains (key); + return EnsureDictionary().Contains(key); } - IDictionaryEnumerator IDictionary.GetEnumerator () + IDictionaryEnumerator IDictionary.GetEnumerator() { - return ((IOrderedDictionary) this).GetEnumerator (); + return ((IOrderedDictionary)this).GetEnumerator(); } - void IDictionary.Remove (object key) + void IDictionary.Remove(object key) { - EnsureDictionary ().Remove (key); + EnsureDictionary().Remove(key); - for (int i = 0; i < object_list.Count; i++) { - if (object_list[i].Key == (string) key) { - object_list.RemoveAt (i); + for (int i = 0; i < object_list.Count; i++) + { + if (object_list[i].Key == (string)key) + { + object_list.RemoveAt(i); break; } } @@ -531,284 +595,293 @@ void IDictionary.Remove (object key) #region IEnumerable Methods - IEnumerator IEnumerable.GetEnumerator () + IEnumerator IEnumerable.GetEnumerator() { - return EnsureCollection ().GetEnumerator (); + return EnsureCollection().GetEnumerator(); } #endregion #region IJsonWrapper Methods - bool IJsonWrapper.GetBoolean () + bool IJsonWrapper.GetBoolean() { if (type != JsonType.Boolean) - throw new InvalidOperationException ( + throw new InvalidOperationException( "JsonData instance doesn't hold a boolean"); return inst_boolean; } - double IJsonWrapper.GetDouble () + double IJsonWrapper.GetDouble() { if (type != JsonType.Double) - throw new InvalidOperationException ( + throw new InvalidOperationException( "JsonData instance doesn't hold a double"); return inst_double; } - int IJsonWrapper.GetInt () + int IJsonWrapper.GetInt() { if (type != JsonType.Int) - throw new InvalidOperationException ( + throw new InvalidOperationException( "JsonData instance doesn't hold an int"); return inst_int; } - long IJsonWrapper.GetLong () + long IJsonWrapper.GetLong() { if (type != JsonType.Long) - throw new InvalidOperationException ( + throw new InvalidOperationException( "JsonData instance doesn't hold a long"); return inst_long; } - string IJsonWrapper.GetString () + string IJsonWrapper.GetString() { if (type != JsonType.String) - throw new InvalidOperationException ( + throw new InvalidOperationException( "JsonData instance doesn't hold a string"); return inst_string; } - void IJsonWrapper.SetBoolean (bool val) + void IJsonWrapper.SetBoolean(bool val) { type = JsonType.Boolean; inst_boolean = val; json = null; } - void IJsonWrapper.SetDouble (double val) + void IJsonWrapper.SetDouble(double val) { type = JsonType.Double; inst_double = val; json = null; } - void IJsonWrapper.SetInt (int val) + void IJsonWrapper.SetInt(int val) { type = JsonType.Int; inst_int = val; json = null; } - void IJsonWrapper.SetLong (long val) + void IJsonWrapper.SetLong(long val) { type = JsonType.Long; inst_long = val; json = null; } - void IJsonWrapper.SetString (string val) + void IJsonWrapper.SetString(string val) { type = JsonType.String; inst_string = val; json = null; } - string IJsonWrapper.ToJson () + string IJsonWrapper.ToJson() { - return ToJson (); + return ToJson(); } - void IJsonWrapper.ToJson (JsonWriter writer) + void IJsonWrapper.ToJson(JsonWriter writer) { - ToJson (writer); + ToJson(writer); } #endregion #region IList Methods - int IList.Add (object value) + int IList.Add(object value) { - return Add (value); + return Add(value); } - void IList.Clear () + void IList.Clear() { - EnsureList ().Clear (); + EnsureList().Clear(); json = null; } - bool IList.Contains (object value) + bool IList.Contains(object value) { - return EnsureList ().Contains (value); + return EnsureList().Contains(value); } - int IList.IndexOf (object value) + int IList.IndexOf(object value) { - return EnsureList ().IndexOf (value); + return EnsureList().IndexOf(value); } - void IList.Insert (int index, object value) + void IList.Insert(int index, object value) { - EnsureList ().Insert (index, value); + EnsureList().Insert(index, value); json = null; } - void IList.Remove (object value) + void IList.Remove(object value) { - EnsureList ().Remove (value); + EnsureList().Remove(value); json = null; } - void IList.RemoveAt (int index) + void IList.RemoveAt(int index) { - EnsureList ().RemoveAt (index); + EnsureList().RemoveAt(index); json = null; } #endregion #region IOrderedDictionary Methods - IDictionaryEnumerator IOrderedDictionary.GetEnumerator () + IDictionaryEnumerator IOrderedDictionary.GetEnumerator() { - EnsureDictionary (); + EnsureDictionary(); - return new OrderedDictionaryEnumerator ( - object_list.GetEnumerator ()); + return new OrderedDictionaryEnumerator( + object_list.GetEnumerator()); } - void IOrderedDictionary.Insert (int idx, object key, object value) + void IOrderedDictionary.Insert(int idx, object key, object value) { - string property = (string) key; - JsonData data = ToJsonData (value); + string property = (string)key; + JsonData data = ToJsonData(value); this[property] = data; KeyValuePair entry = - new KeyValuePair (property, data); + new KeyValuePair(property, data); - object_list.Insert (idx, entry); + object_list.Insert(idx, entry); } - void IOrderedDictionary.RemoveAt (int idx) + void IOrderedDictionary.RemoveAt(int idx) { - EnsureDictionary (); + EnsureDictionary(); - inst_object.Remove (object_list[idx].Key); - object_list.RemoveAt (idx); + inst_object.Remove(object_list[idx].Key); + object_list.RemoveAt(idx); } #endregion #region Private Methods - private ICollection EnsureCollection () + private ICollection EnsureCollection() { if (type == JsonType.Array) - return (ICollection) inst_array; + return (ICollection)inst_array; if (type == JsonType.Object) - return (ICollection) inst_object; + return (ICollection)inst_object; - throw new InvalidOperationException ( + throw new InvalidOperationException( "The JsonData instance has to be initialized first"); } - private IDictionary EnsureDictionary () + private IDictionary EnsureDictionary() { if (type == JsonType.Object) - return (IDictionary) inst_object; + return (IDictionary)inst_object; if (type != JsonType.None) - throw new InvalidOperationException ( + throw new InvalidOperationException( "Instance of JsonData is not a dictionary"); type = JsonType.Object; - inst_object = new Dictionary (); - object_list = new List> (); + inst_object = new Dictionary(); + object_list = new List>(); - return (IDictionary) inst_object; + return (IDictionary)inst_object; } - private IList EnsureList () + private IList EnsureList() { if (type == JsonType.Array) - return (IList) inst_array; + return (IList)inst_array; if (type != JsonType.None) - throw new InvalidOperationException ( + throw new InvalidOperationException( "Instance of JsonData is not a list"); type = JsonType.Array; - inst_array = new List (); + inst_array = new List(); - return (IList) inst_array; + return (IList)inst_array; } - private JsonData ToJsonData (object obj) + private JsonData ToJsonData(object obj) { if (obj == null) return null; if (obj is JsonData) - return (JsonData) obj; + return (JsonData)obj; - return new JsonData (obj); + return new JsonData(obj); } - private static void WriteJson (IJsonWrapper obj, JsonWriter writer) + private static void WriteJson(IJsonWrapper obj, JsonWriter writer) { - if (obj == null) { - writer.Write (null); + if (obj == null) + { + writer.Write(null); return; } - if (obj.IsString) { - writer.Write (obj.GetString ()); + if (obj.IsString) + { + writer.Write(obj.GetString()); return; } - if (obj.IsBoolean) { - writer.Write (obj.GetBoolean ()); + if (obj.IsBoolean) + { + writer.Write(obj.GetBoolean()); return; } - if (obj.IsDouble) { - writer.Write (obj.GetDouble ()); + if (obj.IsDouble) + { + writer.Write(obj.GetDouble()); return; } - if (obj.IsInt) { - writer.Write (obj.GetInt ()); + if (obj.IsInt) + { + writer.Write(obj.GetInt()); return; } - if (obj.IsLong) { - writer.Write (obj.GetLong ()); + if (obj.IsLong) + { + writer.Write(obj.GetLong()); return; } - if (obj.IsArray) { - writer.WriteArrayStart (); - foreach (object elem in (IList) obj) - WriteJson ((JsonData) elem, writer); - writer.WriteArrayEnd (); + if (obj.IsArray) + { + writer.WriteArrayStart(); + foreach (object elem in (IList)obj) + WriteJson((JsonData)elem, writer); + writer.WriteArrayEnd(); return; } - if (obj.IsObject) { - writer.WriteObjectStart (); + if (obj.IsObject) + { + writer.WriteObjectStart(); - foreach (DictionaryEntry entry in ((IDictionary) obj)) { - writer.WritePropertyName ((string) entry.Key); - WriteJson ((JsonData) entry.Value, writer); + foreach (DictionaryEntry entry in ((IDictionary)obj)) + { + writer.WritePropertyName((string)entry.Key); + WriteJson((JsonData)entry.Value, writer); } - writer.WriteObjectEnd (); + writer.WriteObjectEnd(); return; } @@ -816,19 +889,19 @@ private static void WriteJson (IJsonWrapper obj, JsonWriter writer) #endregion - public int Add (object value) + public int Add(object value) { - JsonData data = ToJsonData (value); + JsonData data = ToJsonData(value); json = null; - return EnsureList ().Add (data); + return EnsureList().Add(data); } public bool Remove(object obj) { json = null; - if(IsObject) + if (IsObject) { JsonData value = null; if (inst_object.TryGetValue((string)obj, out value)) @@ -836,28 +909,30 @@ public bool Remove(object obj) else throw new KeyNotFoundException("The specified key was not found in the JsonData object."); } - if(IsArray) + if (IsArray) { return inst_array.Remove(ToJsonData(obj)); } - throw new InvalidOperationException ( + throw new InvalidOperationException( "Instance of JsonData is not an object or a list."); } - public void Clear () + public void Clear() { - if (IsObject) { - ((IDictionary) this).Clear (); + if (IsObject) + { + ((IDictionary)this).Clear(); return; } - if (IsArray) { - ((IList) this).Clear (); + if (IsArray) + { + ((IList)this).Clear(); return; } } - public bool Equals (JsonData x) + public bool Equals(JsonData x) { if (x == null) return false; @@ -872,147 +947,150 @@ public bool Equals (JsonData x) } } - switch (this.type) { - case JsonType.None: - return true; + switch (this.type) + { + case JsonType.None: + return true; - case JsonType.Object: - return this.inst_object.Equals (x.inst_object); + case JsonType.Object: + return this.inst_object.Equals(x.inst_object); - case JsonType.Array: - return this.inst_array.Equals (x.inst_array); + case JsonType.Array: + return this.inst_array.Equals(x.inst_array); - case JsonType.String: - return this.inst_string.Equals (x.inst_string); + case JsonType.String: + return this.inst_string.Equals(x.inst_string); - case JsonType.Int: - { - if (x.IsLong) - { - if (x.inst_long < Int32.MinValue || x.inst_long > Int32.MaxValue) - return false; - return this.inst_int.Equals((int)x.inst_long); - } - return this.inst_int.Equals(x.inst_int); - } + case JsonType.Int: + { + if (x.IsLong) + { + if (x.inst_long < Int32.MinValue || x.inst_long > Int32.MaxValue) + return false; + return this.inst_int.Equals((int)x.inst_long); + } + return this.inst_int.Equals(x.inst_int); + } - case JsonType.Long: - { - if (x.IsInt) - { - if (this.inst_long < Int32.MinValue || this.inst_long > Int32.MaxValue) - return false; - return x.inst_int.Equals((int)this.inst_long); - } - return this.inst_long.Equals(x.inst_long); - } + case JsonType.Long: + { + if (x.IsInt) + { + if (this.inst_long < Int32.MinValue || this.inst_long > Int32.MaxValue) + return false; + return x.inst_int.Equals((int)this.inst_long); + } + return this.inst_long.Equals(x.inst_long); + } - case JsonType.Double: - return this.inst_double.Equals (x.inst_double); + case JsonType.Double: + return this.inst_double.Equals(x.inst_double); - case JsonType.Boolean: - return this.inst_boolean.Equals (x.inst_boolean); + case JsonType.Boolean: + return this.inst_boolean.Equals(x.inst_boolean); } return false; } - public JsonType GetJsonType () + public JsonType GetJsonType() { return type; } - public void SetJsonType (JsonType type) + public void SetJsonType(JsonType type) { if (this.type == type) return; - switch (type) { - case JsonType.None: - break; + switch (type) + { + case JsonType.None: + break; - case JsonType.Object: - inst_object = new Dictionary (); - object_list = new List> (); - break; + case JsonType.Object: + inst_object = new Dictionary(); + object_list = new List>(); + break; - case JsonType.Array: - inst_array = new List (); - break; + case JsonType.Array: + inst_array = new List(); + break; - case JsonType.String: - inst_string = default (String); - break; + case JsonType.String: + inst_string = default(String); + break; - case JsonType.Int: - inst_int = default (Int32); - break; + case JsonType.Int: + inst_int = default(Int32); + break; - case JsonType.Long: - inst_long = default (Int64); - break; + case JsonType.Long: + inst_long = default(Int64); + break; - case JsonType.Double: - inst_double = default (Double); - break; + case JsonType.Double: + inst_double = default(Double); + break; - case JsonType.Boolean: - inst_boolean = default (Boolean); - break; + case JsonType.Boolean: + inst_boolean = default(Boolean); + break; } this.type = type; } - public string ToJson () + public string ToJson() { if (json != null) return json; - StringWriter sw = new StringWriter (); - JsonWriter writer = new JsonWriter (sw); + StringWriter sw = new StringWriter(); + JsonWriter writer = new JsonWriter(sw); writer.Validate = false; - WriteJson (this, writer); - json = sw.ToString (); + WriteJson(this, writer); + json = sw.ToString(); return json; } - public void ToJson (JsonWriter writer) + public void ToJson(JsonWriter writer) { bool old_validate = writer.Validate; writer.Validate = false; - WriteJson (this, writer); + WriteJson(this, writer); writer.Validate = old_validate; } - public override string ToString () + public override string ToString() { - switch (type) { - case JsonType.Array: - return "JsonData array"; + switch (type) + { + case JsonType.Array: + return "JsonData array"; - case JsonType.Boolean: - return inst_boolean.ToString (); + case JsonType.Boolean: + return inst_boolean.ToString(); - case JsonType.Double: - return inst_double.ToString (); + case JsonType.Double: + return inst_double.ToString(); - case JsonType.Int: - return inst_int.ToString (); + case JsonType.Int: + return inst_int.ToString(); - case JsonType.Long: - return inst_long.ToString (); + case JsonType.Long: + return inst_long.ToString(); - case JsonType.Object: - return "JsonData object"; + case JsonType.Object: + return "JsonData object"; - case JsonType.String: - return inst_string; + case JsonType.String: + return inst_string; } return "Uninitialized JsonData"; @@ -1025,41 +1103,46 @@ internal class OrderedDictionaryEnumerator : IDictionaryEnumerator IEnumerator> list_enumerator; - public object Current { + public object Current + { get { return Entry; } } - public DictionaryEntry Entry { - get { + public DictionaryEntry Entry + { + get + { KeyValuePair curr = list_enumerator.Current; - return new DictionaryEntry (curr.Key, curr.Value); + return new DictionaryEntry(curr.Key, curr.Value); } } - public object Key { + public object Key + { get { return list_enumerator.Current.Key; } } - public object Value { + public object Value + { get { return list_enumerator.Current.Value; } } - public OrderedDictionaryEnumerator ( + public OrderedDictionaryEnumerator( IEnumerator> enumerator) { list_enumerator = enumerator; } - public bool MoveNext () + public bool MoveNext() { - return list_enumerator.MoveNext (); + return list_enumerator.MoveNext(); } - public void Reset () + public void Reset() { - list_enumerator.Reset (); + list_enumerator.Reset(); } } } diff --git a/src/Cake.Issues/Serialization/LitJson/JsonException.cs b/src/Cake.Issues/Serialization/LitJson/JsonException.cs index 6353b6995..e3b612ed0 100644 --- a/src/Cake.Issues/Serialization/LitJson/JsonException.cs +++ b/src/Cake.Issues/Serialization/LitJson/JsonException.cs @@ -27,44 +27,44 @@ internal class JsonException : ApplicationException #endif { - public JsonException () : base () + public JsonException() : base() { } - internal JsonException (ParserToken token) : - base (String.Format ( + internal JsonException(ParserToken token) : + base(String.Format( "Invalid token '{0}' in input string", token)) { } - internal JsonException (ParserToken token, + internal JsonException(ParserToken token, Exception inner_exception) : - base (String.Format ( + base(String.Format( "Invalid token '{0}' in input string", token), inner_exception) { } - internal JsonException (int c) : - base (String.Format ( - "Invalid character '{0}' in input string", (char) c)) + internal JsonException(int c) : + base(String.Format( + "Invalid character '{0}' in input string", (char)c)) { } - internal JsonException (int c, Exception inner_exception) : - base (String.Format ( - "Invalid character '{0}' in input string", (char) c), + internal JsonException(int c, Exception inner_exception) : + base(String.Format( + "Invalid character '{0}' in input string", (char)c), inner_exception) { } - public JsonException (string message) : base (message) + public JsonException(string message) : base(message) { } - public JsonException (string message, Exception inner_exception) : - base (message, inner_exception) + public JsonException(string message, Exception inner_exception) : + base(message, inner_exception) { } } diff --git a/src/Cake.Issues/Serialization/LitJson/JsonMapper.cs b/src/Cake.Issues/Serialization/LitJson/JsonMapper.cs index d9dd42f3f..24873ab7a 100644 --- a/src/Cake.Issues/Serialization/LitJson/JsonMapper.cs +++ b/src/Cake.Issues/Serialization/LitJson/JsonMapper.cs @@ -28,8 +28,8 @@ namespace LitJson internal struct PropertyMetadata { public MemberInfo Info; - public bool IsField; - public Type Type; + public bool IsField; + public Type Type; } @@ -40,10 +40,12 @@ internal struct ArrayMetadata private bool is_list; - public Type ElementType { - get { + public Type ElementType + { + get + { if (element_type == null) - return typeof (JsonData); + return typeof(JsonData); return element_type; } @@ -51,12 +53,14 @@ public Type ElementType { set { element_type = value; } } - public bool IsArray { + public bool IsArray + { get { return is_array; } set { is_array = value; } } - public bool IsList { + public bool IsList + { get { return is_list; } set { is_list = value; } } @@ -71,10 +75,12 @@ internal struct ObjectMetadata private IDictionary properties; - public Type ElementType { - get { + public Type ElementType + { + get + { if (element_type == null) - return typeof (JsonData); + return typeof(JsonData); return element_type; } @@ -82,25 +88,27 @@ public Type ElementType { set { element_type = value; } } - public bool IsDictionary { + public bool IsDictionary + { get { return is_dictionary; } set { is_dictionary = value; } } - public IDictionary Properties { + public IDictionary Properties + { get { return properties; } set { properties = value; } } } - internal delegate void ExporterFunc (object obj, JsonWriter writer); - internal delegate void ExporterFunc (T obj, JsonWriter writer); + internal delegate void ExporterFunc(object obj, JsonWriter writer); + internal delegate void ExporterFunc(T obj, JsonWriter writer); - internal delegate object ImporterFunc (object input); - internal delegate TValue ImporterFunc (TJson input); + internal delegate object ImporterFunc(object input); + internal delegate TValue ImporterFunc(TJson input); - internal delegate IJsonWrapper WrapperFactory (); + internal delegate IJsonWrapper WrapperFactory(); internal class JsonMapper @@ -119,189 +127,212 @@ internal class JsonMapper IDictionary> custom_importers_table; private static readonly IDictionary array_metadata; - private static readonly object array_metadata_lock = new Object (); + private static readonly object array_metadata_lock = new Object(); private static readonly IDictionary> conv_ops; - private static readonly object conv_ops_lock = new Object (); + private static readonly object conv_ops_lock = new Object(); private static readonly IDictionary object_metadata; - private static readonly object object_metadata_lock = new Object (); + private static readonly object object_metadata_lock = new Object(); private static readonly IDictionary> type_properties; - private static readonly object type_properties_lock = new Object (); + private static readonly object type_properties_lock = new Object(); - private static readonly JsonWriter static_writer; - private static readonly object static_writer_lock = new Object (); + private static readonly JsonWriter static_writer; + private static readonly object static_writer_lock = new Object(); #endregion #region Constructors - static JsonMapper () + static JsonMapper() { max_nesting_depth = 100; - array_metadata = new Dictionary (); - conv_ops = new Dictionary> (); - object_metadata = new Dictionary (); + array_metadata = new Dictionary(); + conv_ops = new Dictionary>(); + object_metadata = new Dictionary(); type_properties = new Dictionary> (); + IList>(); - static_writer = new JsonWriter (); + static_writer = new JsonWriter(); datetime_format = DateTimeFormatInfo.InvariantInfo; - base_exporters_table = new Dictionary (); - custom_exporters_table = new Dictionary (); + base_exporters_table = new Dictionary(); + custom_exporters_table = new Dictionary(); base_importers_table = new Dictionary> (); + IDictionary>(); custom_importers_table = new Dictionary> (); + IDictionary>(); - RegisterBaseExporters (); - RegisterBaseImporters (); + RegisterBaseExporters(); + RegisterBaseImporters(); } #endregion #region Private Methods - private static void AddArrayMetadata (Type type) + private static void AddArrayMetadata(Type type) { - if (array_metadata.ContainsKey (type)) + if (array_metadata.ContainsKey(type)) return; - ArrayMetadata data = new ArrayMetadata (); + ArrayMetadata data = new ArrayMetadata(); data.IsArray = type.IsArray; - if (type.GetInterface ("System.Collections.IList") != null) + if (type.GetInterface("System.Collections.IList") != null) data.IsList = true; - foreach (PropertyInfo p_info in type.GetProperties ()) { + foreach (PropertyInfo p_info in type.GetProperties()) + { if (p_info.Name != "Item") continue; - ParameterInfo[] parameters = p_info.GetIndexParameters (); + ParameterInfo[] parameters = p_info.GetIndexParameters(); if (parameters.Length != 1) continue; - if (parameters[0].ParameterType == typeof (int)) + if (parameters[0].ParameterType == typeof(int)) data.ElementType = p_info.PropertyType; } - lock (array_metadata_lock) { - try { - array_metadata.Add (type, data); - } catch (ArgumentException) { + lock (array_metadata_lock) + { + try + { + array_metadata.Add(type, data); + } + catch (ArgumentException) + { return; } } } - private static void AddObjectMetadata (Type type) + private static void AddObjectMetadata(Type type) { - if (object_metadata.ContainsKey (type)) + if (object_metadata.ContainsKey(type)) return; - ObjectMetadata data = new ObjectMetadata (); + ObjectMetadata data = new ObjectMetadata(); - if (type.GetInterface ("System.Collections.IDictionary") != null) + if (type.GetInterface("System.Collections.IDictionary") != null) data.IsDictionary = true; - data.Properties = new Dictionary (); + data.Properties = new Dictionary(); - foreach (PropertyInfo p_info in type.GetProperties ()) { - if (p_info.Name == "Item") { - ParameterInfo[] parameters = p_info.GetIndexParameters (); + foreach (PropertyInfo p_info in type.GetProperties()) + { + if (p_info.Name == "Item") + { + ParameterInfo[] parameters = p_info.GetIndexParameters(); if (parameters.Length != 1) continue; - if (parameters[0].ParameterType == typeof (string)) + if (parameters[0].ParameterType == typeof(string)) data.ElementType = p_info.PropertyType; continue; } - PropertyMetadata p_data = new PropertyMetadata (); + PropertyMetadata p_data = new PropertyMetadata(); p_data.Info = p_info; p_data.Type = p_info.PropertyType; - data.Properties.Add (p_info.Name, p_data); + data.Properties.Add(p_info.Name, p_data); } - foreach (FieldInfo f_info in type.GetFields ()) { - PropertyMetadata p_data = new PropertyMetadata (); + foreach (FieldInfo f_info in type.GetFields()) + { + PropertyMetadata p_data = new PropertyMetadata(); p_data.Info = f_info; p_data.IsField = true; p_data.Type = f_info.FieldType; - data.Properties.Add (f_info.Name, p_data); + data.Properties.Add(f_info.Name, p_data); } - lock (object_metadata_lock) { - try { - object_metadata.Add (type, data); - } catch (ArgumentException) { + lock (object_metadata_lock) + { + try + { + object_metadata.Add(type, data); + } + catch (ArgumentException) + { return; } } } - private static void AddTypeProperties (Type type) + private static void AddTypeProperties(Type type) { - if (type_properties.ContainsKey (type)) + if (type_properties.ContainsKey(type)) return; - IList props = new List (); + IList props = new List(); - foreach (PropertyInfo p_info in type.GetProperties ()) { + foreach (PropertyInfo p_info in type.GetProperties()) + { if (p_info.Name == "Item") continue; - PropertyMetadata p_data = new PropertyMetadata (); + PropertyMetadata p_data = new PropertyMetadata(); p_data.Info = p_info; p_data.IsField = false; - props.Add (p_data); + props.Add(p_data); } - foreach (FieldInfo f_info in type.GetFields ()) { - PropertyMetadata p_data = new PropertyMetadata (); + foreach (FieldInfo f_info in type.GetFields()) + { + PropertyMetadata p_data = new PropertyMetadata(); p_data.Info = f_info; p_data.IsField = true; - props.Add (p_data); + props.Add(p_data); } - lock (type_properties_lock) { - try { - type_properties.Add (type, props); - } catch (ArgumentException) { + lock (type_properties_lock) + { + try + { + type_properties.Add(type, props); + } + catch (ArgumentException) + { return; } } } - private static MethodInfo GetConvOp (Type t1, Type t2) + private static MethodInfo GetConvOp(Type t1, Type t2) { - lock (conv_ops_lock) { - if (! conv_ops.ContainsKey (t1)) - conv_ops.Add (t1, new Dictionary ()); + lock (conv_ops_lock) + { + if (!conv_ops.ContainsKey(t1)) + conv_ops.Add(t1, new Dictionary()); } - if (conv_ops[t1].ContainsKey (t2)) + if (conv_ops[t1].ContainsKey(t2)) return conv_ops[t1][t2]; - MethodInfo op = t1.GetMethod ( + MethodInfo op = t1.GetMethod( "op_Implicit", new Type[] { t2 }); - lock (conv_ops_lock) { - try { - conv_ops[t1].Add (t2, op); - } catch (ArgumentException) { + lock (conv_ops_lock) + { + try + { + conv_ops[t1].Add(t2, op); + } + catch (ArgumentException) + { return conv_ops[t1][t2]; } } @@ -309,9 +340,9 @@ private static MethodInfo GetConvOp (Type t1, Type t2) return op; } - private static object ReadValue (Type inst_type, JsonReader reader) + private static object ReadValue(Type inst_type, JsonReader reader) { - reader.Read (); + reader.Read(); if (reader.Token == JsonToken.ArrayEnd) return null; @@ -319,18 +350,20 @@ private static object ReadValue (Type inst_type, JsonReader reader) Type underlying_type = Nullable.GetUnderlyingType(inst_type); Type value_type = underlying_type ?? inst_type; - if (reader.Token == JsonToken.Null) { - #if NETSTANDARD1_5 + if (reader.Token == JsonToken.Null) + { +#if NETSTANDARD1_5 if (inst_type.IsClass() || underlying_type != null) { return null; } - #else - if (inst_type.IsClass || underlying_type != null) { +#else + if (inst_type.IsClass || underlying_type != null) + { return null; } - #endif +#endif - throw new JsonException (String.Format ( + throw new JsonException(String.Format( "Can't assign null to an instance of type {0}", inst_type)); } @@ -339,146 +372,171 @@ private static object ReadValue (Type inst_type, JsonReader reader) reader.Token == JsonToken.Int || reader.Token == JsonToken.Long || reader.Token == JsonToken.String || - reader.Token == JsonToken.Boolean) { + reader.Token == JsonToken.Boolean) + { - Type json_type = reader.Value.GetType (); + Type json_type = reader.Value.GetType(); - if (value_type.IsAssignableFrom (json_type)) + if (value_type.IsAssignableFrom(json_type)) return reader.Value; // If there's a custom importer that fits, use it - if (custom_importers_table.ContainsKey (json_type) && - custom_importers_table[json_type].ContainsKey ( - value_type)) { + if (custom_importers_table.ContainsKey(json_type) && + custom_importers_table[json_type].ContainsKey( + value_type)) + { ImporterFunc importer = custom_importers_table[json_type][value_type]; - return importer (reader.Value); + return importer(reader.Value); } // Maybe there's a base importer that works - if (base_importers_table.ContainsKey (json_type) && - base_importers_table[json_type].ContainsKey ( - value_type)) { + if (base_importers_table.ContainsKey(json_type) && + base_importers_table[json_type].ContainsKey( + value_type)) + { ImporterFunc importer = base_importers_table[json_type][value_type]; - return importer (reader.Value); + return importer(reader.Value); } // Maybe it's an enum - #if NETSTANDARD1_5 +#if NETSTANDARD1_5 if (value_type.IsEnum()) return Enum.ToObject (value_type, reader.Value); - #else +#else if (value_type.IsEnum) - return Enum.ToObject (value_type, reader.Value); - #endif + return Enum.ToObject(value_type, reader.Value); +#endif // Try using an implicit conversion operator - MethodInfo conv_op = GetConvOp (value_type, json_type); + MethodInfo conv_op = GetConvOp(value_type, json_type); if (conv_op != null) - return conv_op.Invoke (null, + return conv_op.Invoke(null, new object[] { reader.Value }); // No luck - throw new JsonException (String.Format ( + throw new JsonException(String.Format( "Can't assign value '{0}' (type {1}) to type {2}", reader.Value, json_type, inst_type)); } object instance = null; - if (reader.Token == JsonToken.ArrayStart) { + if (reader.Token == JsonToken.ArrayStart) + { - AddArrayMetadata (inst_type); + AddArrayMetadata(inst_type); ArrayMetadata t_data = array_metadata[inst_type]; - if (! t_data.IsArray && ! t_data.IsList) - throw new JsonException (String.Format ( + if (!t_data.IsArray && !t_data.IsList) + throw new JsonException(String.Format( "Type {0} can't act as an array", inst_type)); IList list; Type elem_type; - if (! t_data.IsArray) { - list = (IList) Activator.CreateInstance (inst_type); + if (!t_data.IsArray) + { + list = (IList)Activator.CreateInstance(inst_type); elem_type = t_data.ElementType; - } else { - list = new ArrayList (); - elem_type = inst_type.GetElementType (); + } + else + { + list = new ArrayList(); + elem_type = inst_type.GetElementType(); } - while (true) { - object item = ReadValue (elem_type, reader); + list.Clear(); + + while (true) + { + object item = ReadValue(elem_type, reader); if (item == null && reader.Token == JsonToken.ArrayEnd) break; - list.Add (item); + list.Add(item); } - if (t_data.IsArray) { + if (t_data.IsArray) + { int n = list.Count; - instance = Array.CreateInstance (elem_type, n); + instance = Array.CreateInstance(elem_type, n); for (int i = 0; i < n; i++) - ((Array) instance).SetValue (list[i], i); - } else + ((Array)instance).SetValue(list[i], i); + } + else instance = list; - } else if (reader.Token == JsonToken.ObjectStart) { - AddObjectMetadata (value_type); + } + else if (reader.Token == JsonToken.ObjectStart) + { + AddObjectMetadata(value_type); ObjectMetadata t_data = object_metadata[value_type]; - instance = Activator.CreateInstance (value_type); + instance = Activator.CreateInstance(value_type); - while (true) { - reader.Read (); + while (true) + { + reader.Read(); if (reader.Token == JsonToken.ObjectEnd) break; - string property = (string) reader.Value; + string property = (string)reader.Value; - if (t_data.Properties.ContainsKey (property)) { + if (t_data.Properties.ContainsKey(property)) + { PropertyMetadata prop_data = t_data.Properties[property]; - if (prop_data.IsField) { - ((FieldInfo) prop_data.Info).SetValue ( - instance, ReadValue (prop_data.Type, reader)); - } else { + if (prop_data.IsField) + { + ((FieldInfo)prop_data.Info).SetValue( + instance, ReadValue(prop_data.Type, reader)); + } + else + { PropertyInfo p_info = - (PropertyInfo) prop_data.Info; + (PropertyInfo)prop_data.Info; if (p_info.CanWrite) - p_info.SetValue ( + p_info.SetValue( instance, - ReadValue (prop_data.Type, reader), + ReadValue(prop_data.Type, reader), null); else - ReadValue (prop_data.Type, reader); + ReadValue(prop_data.Type, reader); } - } else { - if (! t_data.IsDictionary) { - - if (! reader.SkipNonMembers) { - throw new JsonException (String.Format ( + } + else + { + if (!t_data.IsDictionary) + { + + if (!reader.SkipNonMembers) + { + throw new JsonException(String.Format( "The type {0} doesn't have the " + "property '{1}'", inst_type, property)); - } else { - ReadSkip (reader); + } + else + { + ReadSkip(reader); continue; } } - ((IDictionary) instance).Add ( - property, ReadValue ( + ((IDictionary)instance).Add( + property, ReadValue( t_data.ElementType, reader)); } @@ -489,65 +547,74 @@ private static object ReadValue (Type inst_type, JsonReader reader) return instance; } - private static IJsonWrapper ReadValue (WrapperFactory factory, + private static IJsonWrapper ReadValue(WrapperFactory factory, JsonReader reader) { - reader.Read (); + reader.Read(); if (reader.Token == JsonToken.ArrayEnd || reader.Token == JsonToken.Null) return null; - IJsonWrapper instance = factory (); + IJsonWrapper instance = factory(); - if (reader.Token == JsonToken.String) { - instance.SetString ((string) reader.Value); + if (reader.Token == JsonToken.String) + { + instance.SetString((string)reader.Value); return instance; } - if (reader.Token == JsonToken.Double) { - instance.SetDouble ((double) reader.Value); + if (reader.Token == JsonToken.Double) + { + instance.SetDouble((double)reader.Value); return instance; } - if (reader.Token == JsonToken.Int) { - instance.SetInt ((int) reader.Value); + if (reader.Token == JsonToken.Int) + { + instance.SetInt((int)reader.Value); return instance; } - if (reader.Token == JsonToken.Long) { - instance.SetLong ((long) reader.Value); + if (reader.Token == JsonToken.Long) + { + instance.SetLong((long)reader.Value); return instance; } - if (reader.Token == JsonToken.Boolean) { - instance.SetBoolean ((bool) reader.Value); + if (reader.Token == JsonToken.Boolean) + { + instance.SetBoolean((bool)reader.Value); return instance; } - if (reader.Token == JsonToken.ArrayStart) { - instance.SetJsonType (JsonType.Array); + if (reader.Token == JsonToken.ArrayStart) + { + instance.SetJsonType(JsonType.Array); - while (true) { - IJsonWrapper item = ReadValue (factory, reader); + while (true) + { + IJsonWrapper item = ReadValue(factory, reader); if (item == null && reader.Token == JsonToken.ArrayEnd) break; - ((IList) instance).Add (item); + ((IList)instance).Add(item); } } - else if (reader.Token == JsonToken.ObjectStart) { - instance.SetJsonType (JsonType.Object); + else if (reader.Token == JsonToken.ObjectStart) + { + instance.SetJsonType(JsonType.Object); - while (true) { - reader.Read (); + while (true) + { + reader.Read(); if (reader.Token == JsonToken.ObjectEnd) break; - string property = (string) reader.Value; + string property = (string)reader.Value; - ((IDictionary) instance)[property] = ReadValue ( + ((IDictionary)instance)[property] = ReadValue( factory, reader); } @@ -556,58 +623,58 @@ private static IJsonWrapper ReadValue (WrapperFactory factory, return instance; } - private static void ReadSkip (JsonReader reader) + private static void ReadSkip(JsonReader reader) { - ToWrapper ( - delegate { return new JsonMockWrapper (); }, reader); + ToWrapper( + delegate { return new JsonMockWrapper(); }, reader); } - private static void RegisterBaseExporters () + private static void RegisterBaseExporters() { - base_exporters_table[typeof (byte)] = + base_exporters_table[typeof(byte)] = delegate (object obj, JsonWriter writer) { - writer.Write (Convert.ToInt32 ((byte) obj)); + writer.Write(Convert.ToInt32((byte)obj)); }; - base_exporters_table[typeof (char)] = + base_exporters_table[typeof(char)] = delegate (object obj, JsonWriter writer) { - writer.Write (Convert.ToString ((char) obj)); + writer.Write(Convert.ToString((char)obj)); }; - base_exporters_table[typeof (DateTime)] = + base_exporters_table[typeof(DateTime)] = delegate (object obj, JsonWriter writer) { - writer.Write (Convert.ToString ((DateTime) obj, + writer.Write(Convert.ToString((DateTime)obj, datetime_format)); }; - base_exporters_table[typeof (decimal)] = + base_exporters_table[typeof(decimal)] = delegate (object obj, JsonWriter writer) { - writer.Write ((decimal) obj); + writer.Write((decimal)obj); }; - base_exporters_table[typeof (sbyte)] = + base_exporters_table[typeof(sbyte)] = delegate (object obj, JsonWriter writer) { - writer.Write (Convert.ToInt32 ((sbyte) obj)); + writer.Write(Convert.ToInt32((sbyte)obj)); }; - base_exporters_table[typeof (short)] = + base_exporters_table[typeof(short)] = delegate (object obj, JsonWriter writer) { - writer.Write (Convert.ToInt32 ((short) obj)); + writer.Write(Convert.ToInt32((short)obj)); }; - base_exporters_table[typeof (ushort)] = + base_exporters_table[typeof(ushort)] = delegate (object obj, JsonWriter writer) { - writer.Write (Convert.ToInt32 ((ushort) obj)); + writer.Write(Convert.ToInt32((ushort)obj)); }; - base_exporters_table[typeof (uint)] = + base_exporters_table[typeof(uint)] = delegate (object obj, JsonWriter writer) { - writer.Write (Convert.ToUInt64 ((uint) obj)); + writer.Write(Convert.ToUInt64((uint)obj)); }; - base_exporters_table[typeof (ulong)] = + base_exporters_table[typeof(ulong)] = delegate (object obj, JsonWriter writer) { - writer.Write ((ulong) obj); + writer.Write((ulong)obj); }; base_exporters_table[typeof(DateTimeOffset)] = @@ -616,21 +683,21 @@ private static void RegisterBaseExporters () }; } - private static void RegisterBaseImporters () + private static void RegisterBaseImporters() { ImporterFunc importer; importer = delegate (object input) { - return Convert.ToByte ((int) input); + return Convert.ToByte((int)input); }; - RegisterImporter (base_importers_table, typeof (int), - typeof (byte), importer); + RegisterImporter(base_importers_table, typeof(int), + typeof(byte), importer); importer = delegate (object input) { - return Convert.ToUInt64 ((int) input); + return Convert.ToUInt64((int)input); }; - RegisterImporter (base_importers_table, typeof (int), - typeof (ulong), importer); + RegisterImporter(base_importers_table, typeof(int), + typeof(ulong), importer); importer = delegate (object input) { return Convert.ToInt64((int)input); @@ -639,65 +706,70 @@ private static void RegisterBaseImporters () typeof(long), importer); importer = delegate (object input) { - return Convert.ToSByte ((int) input); + return Convert.ToSByte((int)input); }; - RegisterImporter (base_importers_table, typeof (int), - typeof (sbyte), importer); + RegisterImporter(base_importers_table, typeof(int), + typeof(sbyte), importer); importer = delegate (object input) { - return Convert.ToInt16 ((int) input); + return Convert.ToInt16((int)input); }; - RegisterImporter (base_importers_table, typeof (int), - typeof (short), importer); + RegisterImporter(base_importers_table, typeof(int), + typeof(short), importer); importer = delegate (object input) { - return Convert.ToUInt16 ((int) input); + return Convert.ToUInt16((int)input); }; - RegisterImporter (base_importers_table, typeof (int), - typeof (ushort), importer); + RegisterImporter(base_importers_table, typeof(int), + typeof(ushort), importer); importer = delegate (object input) { - return Convert.ToUInt32 ((int) input); + return Convert.ToUInt32((int)input); }; - RegisterImporter (base_importers_table, typeof (int), - typeof (uint), importer); + RegisterImporter(base_importers_table, typeof(int), + typeof(uint), importer); importer = delegate (object input) { - return Convert.ToSingle ((int) input); + return Convert.ToSingle((int)input); }; - RegisterImporter (base_importers_table, typeof (int), - typeof (float), importer); + RegisterImporter(base_importers_table, typeof(int), + typeof(float), importer); importer = delegate (object input) { - return Convert.ToDouble ((int) input); + return Convert.ToDouble((int)input); }; - RegisterImporter (base_importers_table, typeof (int), - typeof (double), importer); + RegisterImporter(base_importers_table, typeof(int), + typeof(double), importer); importer = delegate (object input) { - return Convert.ToDecimal ((double) input); + return Convert.ToDecimal((double)input); }; - RegisterImporter (base_importers_table, typeof (double), - typeof (decimal), importer); + RegisterImporter(base_importers_table, typeof(double), + typeof(decimal), importer); + importer = delegate (object input) { + return Convert.ToSingle((double)input); + }; + RegisterImporter(base_importers_table, typeof(double), + typeof(float), importer); importer = delegate (object input) { - return Convert.ToUInt32 ((long) input); + return Convert.ToUInt32((long)input); }; - RegisterImporter (base_importers_table, typeof (long), - typeof (uint), importer); + RegisterImporter(base_importers_table, typeof(long), + typeof(uint), importer); importer = delegate (object input) { - return Convert.ToChar ((string) input); + return Convert.ToChar((string)input); }; - RegisterImporter (base_importers_table, typeof (string), - typeof (char), importer); + RegisterImporter(base_importers_table, typeof(string), + typeof(char), importer); importer = delegate (object input) { - return Convert.ToDateTime ((string) input, datetime_format); + return Convert.ToDateTime((string)input, datetime_format); }; - RegisterImporter (base_importers_table, typeof (string), - typeof (DateTime), importer); + RegisterImporter(base_importers_table, typeof(string), + typeof(DateTime), importer); importer = delegate (object input) { return DateTimeOffset.Parse((string)input, datetime_format); @@ -706,262 +778,300 @@ private static void RegisterBaseImporters () typeof(DateTimeOffset), importer); } - private static void RegisterImporter ( + private static void RegisterImporter( IDictionary> table, Type json_type, Type value_type, ImporterFunc importer) { - if (! table.ContainsKey (json_type)) - table.Add (json_type, new Dictionary ()); + if (!table.ContainsKey(json_type)) + table.Add(json_type, new Dictionary()); table[json_type][value_type] = importer; } - private static void WriteValue (object obj, JsonWriter writer, + private static void WriteValue(object obj, JsonWriter writer, bool writer_is_private, int depth) { if (depth > max_nesting_depth) - throw new JsonException ( - String.Format ("Max allowed object depth reached while " + + throw new JsonException( + String.Format("Max allowed object depth reached while " + "trying to export from type {0}", - obj.GetType ())); + obj.GetType())); - if (obj == null) { - writer.Write (null); + if (obj == null) + { + writer.Write(null); return; } - if (obj is IJsonWrapper) { + if (obj is IJsonWrapper) + { if (writer_is_private) - writer.TextWriter.Write (((IJsonWrapper) obj).ToJson ()); + writer.TextWriter.Write(((IJsonWrapper)obj).ToJson()); else - ((IJsonWrapper) obj).ToJson (writer); + ((IJsonWrapper)obj).ToJson(writer); + + return; + } + if (obj is String) + { + writer.Write((string)obj); return; } - if (obj is String) { - writer.Write ((string) obj); + if (obj is Double) + { + writer.Write((double)obj); return; } - if (obj is Double) { - writer.Write ((double) obj); + if (obj is Single) + { + writer.Write((float)obj); return; } - if (obj is Int32) { - writer.Write ((int) obj); + if (obj is Int32) + { + writer.Write((int)obj); return; } - if (obj is Boolean) { - writer.Write ((bool) obj); + if (obj is Boolean) + { + writer.Write((bool)obj); return; } - if (obj is Int64) { - writer.Write ((long) obj); + if (obj is Int64) + { + writer.Write((long)obj); return; } - if (obj is Array) { - writer.WriteArrayStart (); + if (obj is Array) + { + writer.WriteArrayStart(); - foreach (object elem in (Array) obj) - WriteValue (elem, writer, writer_is_private, depth + 1); + foreach (object elem in (Array)obj) + WriteValue(elem, writer, writer_is_private, depth + 1); - writer.WriteArrayEnd (); + writer.WriteArrayEnd(); return; } - if (obj is IList) { - writer.WriteArrayStart (); - foreach (object elem in (IList) obj) - WriteValue (elem, writer, writer_is_private, depth + 1); - writer.WriteArrayEnd (); + if (obj is IList) + { + writer.WriteArrayStart(); + foreach (object elem in (IList)obj) + WriteValue(elem, writer, writer_is_private, depth + 1); + writer.WriteArrayEnd(); return; } - if (obj is IDictionary) { - writer.WriteObjectStart (); - foreach (DictionaryEntry entry in (IDictionary) obj) { - writer.WritePropertyName ((string) entry.Key); - WriteValue (entry.Value, writer, writer_is_private, + if (obj is IDictionary dictionary) + { + writer.WriteObjectStart(); + foreach (DictionaryEntry entry in dictionary) + { + var propertyName = entry.Key is string key ? + key + : Convert.ToString(entry.Key, CultureInfo.InvariantCulture); + writer.WritePropertyName(propertyName); + WriteValue(entry.Value, writer, writer_is_private, depth + 1); } - writer.WriteObjectEnd (); + writer.WriteObjectEnd(); return; } - Type obj_type = obj.GetType (); + Type obj_type = obj.GetType(); // See if there's a custom exporter for the object - if (custom_exporters_table.ContainsKey (obj_type)) { + if (custom_exporters_table.ContainsKey(obj_type)) + { ExporterFunc exporter = custom_exporters_table[obj_type]; - exporter (obj, writer); + exporter(obj, writer); return; } // If not, maybe there's a base exporter - if (base_exporters_table.ContainsKey (obj_type)) { + if (base_exporters_table.ContainsKey(obj_type)) + { ExporterFunc exporter = base_exporters_table[obj_type]; - exporter (obj, writer); + exporter(obj, writer); return; } // Last option, let's see if it's an enum - if (obj is Enum) { - Type e_type = Enum.GetUnderlyingType (obj_type); - - if (e_type == typeof (long) - || e_type == typeof (uint) - || e_type == typeof (ulong)) - writer.Write ((ulong) obj); + if (obj is Enum) + { + Type e_type = Enum.GetUnderlyingType(obj_type); + + if (e_type == typeof(long)) + writer.Write((long)obj); + else if (e_type == typeof(uint)) + writer.Write((uint)obj); + else if (e_type == typeof(ulong)) + writer.Write((ulong)obj); + else if (e_type == typeof(ushort)) + writer.Write((ushort)obj); + else if (e_type == typeof(short)) + writer.Write((short)obj); + else if (e_type == typeof(byte)) + writer.Write((byte)obj); + else if (e_type == typeof(sbyte)) + writer.Write((sbyte)obj); else - writer.Write ((int) obj); + writer.Write((int)obj); return; } // Okay, so it looks like the input should be exported as an // object - AddTypeProperties (obj_type); + AddTypeProperties(obj_type); IList props = type_properties[obj_type]; - writer.WriteObjectStart (); - foreach (PropertyMetadata p_data in props) { - if (p_data.IsField) { - writer.WritePropertyName (p_data.Info.Name); - WriteValue (((FieldInfo) p_data.Info).GetValue (obj), + writer.WriteObjectStart(); + foreach (PropertyMetadata p_data in props) + { + if (p_data.IsField) + { + writer.WritePropertyName(p_data.Info.Name); + WriteValue(((FieldInfo)p_data.Info).GetValue(obj), writer, writer_is_private, depth + 1); } - else { - PropertyInfo p_info = (PropertyInfo) p_data.Info; + else + { + PropertyInfo p_info = (PropertyInfo)p_data.Info; - if (p_info.CanRead) { - writer.WritePropertyName (p_data.Info.Name); - WriteValue (p_info.GetValue (obj, null), + if (p_info.CanRead) + { + writer.WritePropertyName(p_data.Info.Name); + WriteValue(p_info.GetValue(obj, null), writer, writer_is_private, depth + 1); } } } - writer.WriteObjectEnd (); + writer.WriteObjectEnd(); } #endregion - public static string ToJson (object obj) + public static string ToJson(object obj) { - lock (static_writer_lock) { - static_writer.Reset (); + lock (static_writer_lock) + { + static_writer.Reset(); - WriteValue (obj, static_writer, true, 0); + WriteValue(obj, static_writer, true, 0); - return static_writer.ToString (); + return static_writer.ToString(); } } - public static void ToJson (object obj, JsonWriter writer) + public static void ToJson(object obj, JsonWriter writer) { - WriteValue (obj, writer, false, 0); + WriteValue(obj, writer, false, 0); } - public static JsonData ToObject (JsonReader reader) + public static JsonData ToObject(JsonReader reader) { - return (JsonData) ToWrapper ( - delegate { return new JsonData (); }, reader); + return (JsonData)ToWrapper( + delegate { return new JsonData(); }, reader); } - public static JsonData ToObject (TextReader reader) + public static JsonData ToObject(TextReader reader) { - JsonReader json_reader = new JsonReader (reader); + JsonReader json_reader = new JsonReader(reader); - return (JsonData) ToWrapper ( - delegate { return new JsonData (); }, json_reader); + return (JsonData)ToWrapper( + delegate { return new JsonData(); }, json_reader); } - public static JsonData ToObject (string json) + public static JsonData ToObject(string json) { - return (JsonData) ToWrapper ( - delegate { return new JsonData (); }, json); + return (JsonData)ToWrapper( + delegate { return new JsonData(); }, json); } - public static T ToObject (JsonReader reader) + public static T ToObject(JsonReader reader) { - return (T) ReadValue (typeof (T), reader); + return (T)ReadValue(typeof(T), reader); } - public static T ToObject (TextReader reader) + public static T ToObject(TextReader reader) { - JsonReader json_reader = new JsonReader (reader); + JsonReader json_reader = new JsonReader(reader); - return (T) ReadValue (typeof (T), json_reader); + return (T)ReadValue(typeof(T), json_reader); } - public static T ToObject (string json) + public static T ToObject(string json) { - JsonReader reader = new JsonReader (json); + JsonReader reader = new JsonReader(json); - return (T) ReadValue (typeof (T), reader); + return (T)ReadValue(typeof(T), reader); } - - public static object ToObject(string json, Type ConvertType ) + + public static object ToObject(string json, Type ConvertType) { JsonReader reader = new JsonReader(json); return ReadValue(ConvertType, reader); } - public static IJsonWrapper ToWrapper (WrapperFactory factory, + public static IJsonWrapper ToWrapper(WrapperFactory factory, JsonReader reader) { - return ReadValue (factory, reader); + return ReadValue(factory, reader); } - public static IJsonWrapper ToWrapper (WrapperFactory factory, + public static IJsonWrapper ToWrapper(WrapperFactory factory, string json) { - JsonReader reader = new JsonReader (json); + JsonReader reader = new JsonReader(json); - return ReadValue (factory, reader); + return ReadValue(factory, reader); } - public static void RegisterExporter (ExporterFunc exporter) + public static void RegisterExporter(ExporterFunc exporter) { ExporterFunc exporter_wrapper = delegate (object obj, JsonWriter writer) { - exporter ((T) obj, writer); + exporter((T)obj, writer); }; - custom_exporters_table[typeof (T)] = exporter_wrapper; + custom_exporters_table[typeof(T)] = exporter_wrapper; } - public static void RegisterImporter ( + public static void RegisterImporter( ImporterFunc importer) { ImporterFunc importer_wrapper = delegate (object input) { - return importer ((TJson) input); + return importer((TJson)input); }; - RegisterImporter (custom_importers_table, typeof (TJson), - typeof (TValue), importer_wrapper); + RegisterImporter(custom_importers_table, typeof(TJson), + typeof(TValue), importer_wrapper); } - public static void UnregisterExporters () + public static void UnregisterExporters() { - custom_exporters_table.Clear (); + custom_exporters_table.Clear(); } - public static void UnregisterImporters () + public static void UnregisterImporters() { - custom_importers_table.Clear (); + custom_importers_table.Clear(); } } -} +} \ No newline at end of file diff --git a/src/Cake.Issues/Serialization/LitJson/JsonMockWrapper.cs b/src/Cake.Issues/Serialization/LitJson/JsonMockWrapper.cs index 2b02d338d..0671de12f 100644 --- a/src/Cake.Issues/Serialization/LitJson/JsonMockWrapper.cs +++ b/src/Cake.Issues/Serialization/LitJson/JsonMockWrapper.cs @@ -25,87 +25,91 @@ namespace LitJson { internal class JsonMockWrapper : IJsonWrapper { - public bool IsArray { get { return false; } } + public bool IsArray { get { return false; } } public bool IsBoolean { get { return false; } } - public bool IsDouble { get { return false; } } - public bool IsInt { get { return false; } } - public bool IsLong { get { return false; } } - public bool IsObject { get { return false; } } - public bool IsString { get { return false; } } - - public bool GetBoolean () { return false; } - public double GetDouble () { return 0.0; } - public int GetInt () { return 0; } - public JsonType GetJsonType () { return JsonType.None; } - public long GetLong () { return 0L; } - public string GetString () { return ""; } - - public void SetBoolean (bool val) {} - public void SetDouble (double val) {} - public void SetInt (int val) {} - public void SetJsonType (JsonType type) {} - public void SetLong (long val) {} - public void SetString (string val) {} - - public string ToJson () { return ""; } - public void ToJson (JsonWriter writer) {} + public bool IsDouble { get { return false; } } + public bool IsInt { get { return false; } } + public bool IsLong { get { return false; } } + public bool IsObject { get { return false; } } + public bool IsString { get { return false; } } + + public bool GetBoolean() { return false; } + public double GetDouble() { return 0.0; } + public int GetInt() { return 0; } + public JsonType GetJsonType() { return JsonType.None; } + public long GetLong() { return 0L; } + public string GetString() { return ""; } + + public void SetBoolean(bool val) { } + public void SetDouble(double val) { } + public void SetInt(int val) { } + public void SetJsonType(JsonType type) { } + public void SetLong(long val) { } + public void SetString(string val) { } + + public string ToJson() { return ""; } + public void ToJson(JsonWriter writer) { } bool IList.IsFixedSize { get { return true; } } - bool IList.IsReadOnly { get { return true; } } + bool IList.IsReadOnly { get { return true; } } - object IList.this[int index] { + object IList.this[int index] + { get { return null; } - set {} + set { } } - int IList.Add (object value) { return 0; } - void IList.Clear () {} - bool IList.Contains (object value) { return false; } - int IList.IndexOf (object value) { return -1; } - void IList.Insert (int i, object v) {} - void IList.Remove (object value) {} - void IList.RemoveAt (int index) {} + int IList.Add(object value) { return 0; } + void IList.Clear() { } + bool IList.Contains(object value) { return false; } + int IList.IndexOf(object value) { return -1; } + void IList.Insert(int i, object v) { } + void IList.Remove(object value) { } + void IList.RemoveAt(int index) { } - int ICollection.Count { get { return 0; } } - bool ICollection.IsSynchronized { get { return false; } } - object ICollection.SyncRoot { get { return null; } } + int ICollection.Count { get { return 0; } } + bool ICollection.IsSynchronized { get { return false; } } + object ICollection.SyncRoot { get { return null; } } - void ICollection.CopyTo (Array array, int index) {} + void ICollection.CopyTo(Array array, int index) { } - IEnumerator IEnumerable.GetEnumerator () { return null; } + IEnumerator IEnumerable.GetEnumerator() { return null; } bool IDictionary.IsFixedSize { get { return true; } } - bool IDictionary.IsReadOnly { get { return true; } } + bool IDictionary.IsReadOnly { get { return true; } } - ICollection IDictionary.Keys { get { return null; } } + ICollection IDictionary.Keys { get { return null; } } ICollection IDictionary.Values { get { return null; } } - object IDictionary.this[object key] { + object IDictionary.this[object key] + { get { return null; } - set {} + set { } } - void IDictionary.Add (object k, object v) {} - void IDictionary.Clear () {} - bool IDictionary.Contains (object key) { return false; } - void IDictionary.Remove (object key) {} + void IDictionary.Add(object k, object v) { } + void IDictionary.Clear() { } + bool IDictionary.Contains(object key) { return false; } + void IDictionary.Remove(object key) { } - IDictionaryEnumerator IDictionary.GetEnumerator () { return null; } + IDictionaryEnumerator IDictionary.GetEnumerator() { return null; } - object IOrderedDictionary.this[int idx] { + object IOrderedDictionary.this[int idx] + { get { return null; } - set {} + set { } } - IDictionaryEnumerator IOrderedDictionary.GetEnumerator () { + IDictionaryEnumerator IOrderedDictionary.GetEnumerator() + { return null; } - void IOrderedDictionary.Insert (int i, object k, object v) {} - void IOrderedDictionary.RemoveAt (int i) {} + void IOrderedDictionary.Insert(int i, object k, object v) { } + void IOrderedDictionary.RemoveAt(int i) { } } -} +} \ No newline at end of file diff --git a/src/Cake.Issues/Serialization/LitJson/JsonReader.cs b/src/Cake.Issues/Serialization/LitJson/JsonReader.cs index b298d6aad..e3457de32 100644 --- a/src/Cake.Issues/Serialization/LitJson/JsonReader.cs +++ b/src/Cake.Issues/Serialization/LitJson/JsonReader.cs @@ -51,90 +51,97 @@ internal class JsonReader #region Fields private static readonly IDictionary> parse_table; - private Stack automaton_stack; - private int current_input; - private int current_symbol; - private bool end_of_json; - private bool end_of_input; - private Lexer lexer; - private bool parser_in_string; - private bool parser_return; - private bool read_started; - private TextReader reader; - private bool reader_is_owned; - private bool skip_non_members; - private object token_value; - private JsonToken token; + private Stack automaton_stack; + private int current_input; + private int current_symbol; + private bool end_of_json; + private bool end_of_input; + private Lexer lexer; + private bool parser_in_string; + private bool parser_return; + private bool read_started; + private TextReader reader; + private bool reader_is_owned; + private bool skip_non_members; + private object token_value; + private JsonToken token; #endregion #region Public Properties - public bool AllowComments { + public bool AllowComments + { get { return lexer.AllowComments; } set { lexer.AllowComments = value; } } - public bool AllowSingleQuotedStrings { + public bool AllowSingleQuotedStrings + { get { return lexer.AllowSingleQuotedStrings; } set { lexer.AllowSingleQuotedStrings = value; } } - public bool SkipNonMembers { + public bool SkipNonMembers + { get { return skip_non_members; } set { skip_non_members = value; } } - public bool EndOfInput { + public bool EndOfInput + { get { return end_of_input; } } - public bool EndOfJson { + public bool EndOfJson + { get { return end_of_json; } } - public JsonToken Token { + public JsonToken Token + { get { return token; } } - public object Value { + public object Value + { get { return token_value; } } #endregion #region Constructors - static JsonReader () + static JsonReader() { - parse_table = PopulateParseTable (); + parse_table = PopulateParseTable(); } - public JsonReader (string json_text) : - this (new StringReader (json_text), true) + public JsonReader(string json_text) : + this(new StringReader(json_text), true) { } - public JsonReader (TextReader reader) : - this (reader, false) + public JsonReader(TextReader reader) : + this(reader, false) { } - private JsonReader (TextReader reader, bool owned) + private JsonReader(TextReader reader, bool owned) { if (reader == null) - throw new ArgumentNullException ("reader"); + throw new ArgumentNullException("reader"); parser_in_string = false; - parser_return = false; + parser_return = false; read_started = false; - automaton_stack = new Stack (); - automaton_stack.Push ((int) ParserToken.End); - automaton_stack.Push ((int) ParserToken.Text); + automaton_stack = new Stack(); + automaton_stack.Push((int)ParserToken.End); + automaton_stack.Push((int)ParserToken.Text); - lexer = new Lexer (reader); + lexer = new Lexer(reader); end_of_input = false; - end_of_json = false; + end_of_json = false; skip_non_members = true; @@ -145,137 +152,139 @@ private JsonReader (TextReader reader, bool owned) #region Static Methods - private static IDictionary> PopulateParseTable () + private static IDictionary> PopulateParseTable() { // See section A.2. of the manual for details - IDictionary> parse_table = new Dictionary> (); + IDictionary> parse_table = new Dictionary>(); - TableAddRow (parse_table, ParserToken.Array); - TableAddCol (parse_table, ParserToken.Array, '[', + TableAddRow(parse_table, ParserToken.Array); + TableAddCol(parse_table, ParserToken.Array, '[', '[', - (int) ParserToken.ArrayPrime); + (int)ParserToken.ArrayPrime); - TableAddRow (parse_table, ParserToken.ArrayPrime); - TableAddCol (parse_table, ParserToken.ArrayPrime, '"', - (int) ParserToken.Value, + TableAddRow(parse_table, ParserToken.ArrayPrime); + TableAddCol(parse_table, ParserToken.ArrayPrime, '"', + (int)ParserToken.Value, - (int) ParserToken.ValueRest, + (int)ParserToken.ValueRest, ']'); - TableAddCol (parse_table, ParserToken.ArrayPrime, '[', - (int) ParserToken.Value, - (int) ParserToken.ValueRest, + TableAddCol(parse_table, ParserToken.ArrayPrime, '[', + (int)ParserToken.Value, + (int)ParserToken.ValueRest, ']'); - TableAddCol (parse_table, ParserToken.ArrayPrime, ']', + TableAddCol(parse_table, ParserToken.ArrayPrime, ']', ']'); - TableAddCol (parse_table, ParserToken.ArrayPrime, '{', - (int) ParserToken.Value, - (int) ParserToken.ValueRest, + TableAddCol(parse_table, ParserToken.ArrayPrime, '{', + (int)ParserToken.Value, + (int)ParserToken.ValueRest, ']'); - TableAddCol (parse_table, ParserToken.ArrayPrime, (int) ParserToken.Number, - (int) ParserToken.Value, - (int) ParserToken.ValueRest, + TableAddCol(parse_table, ParserToken.ArrayPrime, (int)ParserToken.Number, + (int)ParserToken.Value, + (int)ParserToken.ValueRest, ']'); - TableAddCol (parse_table, ParserToken.ArrayPrime, (int) ParserToken.True, - (int) ParserToken.Value, - (int) ParserToken.ValueRest, + TableAddCol(parse_table, ParserToken.ArrayPrime, (int)ParserToken.True, + (int)ParserToken.Value, + (int)ParserToken.ValueRest, ']'); - TableAddCol (parse_table, ParserToken.ArrayPrime, (int) ParserToken.False, - (int) ParserToken.Value, - (int) ParserToken.ValueRest, + TableAddCol(parse_table, ParserToken.ArrayPrime, (int)ParserToken.False, + (int)ParserToken.Value, + (int)ParserToken.ValueRest, ']'); - TableAddCol (parse_table, ParserToken.ArrayPrime, (int) ParserToken.Null, - (int) ParserToken.Value, - (int) ParserToken.ValueRest, + TableAddCol(parse_table, ParserToken.ArrayPrime, (int)ParserToken.Null, + (int)ParserToken.Value, + (int)ParserToken.ValueRest, ']'); - TableAddRow (parse_table, ParserToken.Object); - TableAddCol (parse_table, ParserToken.Object, '{', + TableAddRow(parse_table, ParserToken.Object); + TableAddCol(parse_table, ParserToken.Object, '{', '{', - (int) ParserToken.ObjectPrime); + (int)ParserToken.ObjectPrime); - TableAddRow (parse_table, ParserToken.ObjectPrime); - TableAddCol (parse_table, ParserToken.ObjectPrime, '"', - (int) ParserToken.Pair, - (int) ParserToken.PairRest, + TableAddRow(parse_table, ParserToken.ObjectPrime); + TableAddCol(parse_table, ParserToken.ObjectPrime, '"', + (int)ParserToken.Pair, + (int)ParserToken.PairRest, '}'); - TableAddCol (parse_table, ParserToken.ObjectPrime, '}', + TableAddCol(parse_table, ParserToken.ObjectPrime, '}', '}'); - TableAddRow (parse_table, ParserToken.Pair); - TableAddCol (parse_table, ParserToken.Pair, '"', - (int) ParserToken.String, + TableAddRow(parse_table, ParserToken.Pair); + TableAddCol(parse_table, ParserToken.Pair, '"', + (int)ParserToken.String, ':', - (int) ParserToken.Value); + (int)ParserToken.Value); - TableAddRow (parse_table, ParserToken.PairRest); - TableAddCol (parse_table, ParserToken.PairRest, ',', + TableAddRow(parse_table, ParserToken.PairRest); + TableAddCol(parse_table, ParserToken.PairRest, ',', ',', - (int) ParserToken.Pair, - (int) ParserToken.PairRest); - TableAddCol (parse_table, ParserToken.PairRest, '}', - (int) ParserToken.Epsilon); + (int)ParserToken.Pair, + (int)ParserToken.PairRest); + TableAddCol(parse_table, ParserToken.PairRest, '}', + (int)ParserToken.Epsilon); - TableAddRow (parse_table, ParserToken.String); - TableAddCol (parse_table, ParserToken.String, '"', + TableAddRow(parse_table, ParserToken.String); + TableAddCol(parse_table, ParserToken.String, '"', '"', - (int) ParserToken.CharSeq, + (int)ParserToken.CharSeq, '"'); - TableAddRow (parse_table, ParserToken.Text); - TableAddCol (parse_table, ParserToken.Text, '[', - (int) ParserToken.Array); - TableAddCol (parse_table, ParserToken.Text, '{', - (int) ParserToken.Object); - - TableAddRow (parse_table, ParserToken.Value); - TableAddCol (parse_table, ParserToken.Value, '"', - (int) ParserToken.String); - TableAddCol (parse_table, ParserToken.Value, '[', - (int) ParserToken.Array); - TableAddCol (parse_table, ParserToken.Value, '{', - (int) ParserToken.Object); - TableAddCol (parse_table, ParserToken.Value, (int) ParserToken.Number, - (int) ParserToken.Number); - TableAddCol (parse_table, ParserToken.Value, (int) ParserToken.True, - (int) ParserToken.True); - TableAddCol (parse_table, ParserToken.Value, (int) ParserToken.False, - (int) ParserToken.False); - TableAddCol (parse_table, ParserToken.Value, (int) ParserToken.Null, - (int) ParserToken.Null); - - TableAddRow (parse_table, ParserToken.ValueRest); - TableAddCol (parse_table, ParserToken.ValueRest, ',', + TableAddRow(parse_table, ParserToken.Text); + TableAddCol(parse_table, ParserToken.Text, '[', + (int)ParserToken.Array); + TableAddCol(parse_table, ParserToken.Text, '{', + (int)ParserToken.Object); + + TableAddRow(parse_table, ParserToken.Value); + TableAddCol(parse_table, ParserToken.Value, '"', + (int)ParserToken.String); + TableAddCol(parse_table, ParserToken.Value, '[', + (int)ParserToken.Array); + TableAddCol(parse_table, ParserToken.Value, '{', + (int)ParserToken.Object); + TableAddCol(parse_table, ParserToken.Value, (int)ParserToken.Number, + (int)ParserToken.Number); + TableAddCol(parse_table, ParserToken.Value, (int)ParserToken.True, + (int)ParserToken.True); + TableAddCol(parse_table, ParserToken.Value, (int)ParserToken.False, + (int)ParserToken.False); + TableAddCol(parse_table, ParserToken.Value, (int)ParserToken.Null, + (int)ParserToken.Null); + + TableAddRow(parse_table, ParserToken.ValueRest); + TableAddCol(parse_table, ParserToken.ValueRest, ',', ',', - (int) ParserToken.Value, - (int) ParserToken.ValueRest); - TableAddCol (parse_table, ParserToken.ValueRest, ']', - (int) ParserToken.Epsilon); + (int)ParserToken.Value, + (int)ParserToken.ValueRest); + TableAddCol(parse_table, ParserToken.ValueRest, ']', + (int)ParserToken.Epsilon); return parse_table; } - private static void TableAddCol (IDictionary> parse_table, ParserToken row, int col, + private static void TableAddCol(IDictionary> parse_table, ParserToken row, int col, params int[] symbols) { - parse_table[(int) row].Add (col, symbols); + parse_table[(int)row].Add(col, symbols); } - private static void TableAddRow (IDictionary> parse_table, ParserToken rule) + private static void TableAddRow(IDictionary> parse_table, ParserToken rule) { - parse_table.Add ((int) rule, new Dictionary ()); + parse_table.Add((int)rule, new Dictionary()); } #endregion #region Private Methods - private void ProcessNumber (string number) + private void ProcessNumber(string number) { - if (number.IndexOf ('.') != -1 || - number.IndexOf ('e') != -1 || - number.IndexOf ('E') != -1) { + if (number.IndexOf('.') != -1 || + number.IndexOf('e') != -1 || + number.IndexOf('E') != -1) + { double n_double; - if (double.TryParse (number, NumberStyles.Any, CultureInfo.InvariantCulture, out n_double)) { + if (double.TryParse(number, NumberStyles.Any, CultureInfo.InvariantCulture, out n_double)) + { token = JsonToken.Double; token_value = n_double; @@ -284,7 +293,8 @@ private void ProcessNumber (string number) } int n_int32; - if (int.TryParse (number, NumberStyles.Integer, CultureInfo.InvariantCulture, out n_int32)) { + if (int.TryParse(number, NumberStyles.Integer, CultureInfo.InvariantCulture, out n_int32)) + { token = JsonToken.Int; token_value = n_int32; @@ -292,7 +302,8 @@ private void ProcessNumber (string number) } long n_int64; - if (long.TryParse (number, NumberStyles.Integer, CultureInfo.InvariantCulture, out n_int64)) { + if (long.TryParse(number, NumberStyles.Integer, CultureInfo.InvariantCulture, out n_int64)) + { token = JsonToken.Long; token_value = n_int64; @@ -313,58 +324,82 @@ private void ProcessNumber (string number) token_value = 0; } - private void ProcessSymbol () + private void ProcessSymbol() { - if (current_symbol == '[') { + if (current_symbol == '[') + { token = JsonToken.ArrayStart; parser_return = true; - } else if (current_symbol == ']') { + } + else if (current_symbol == ']') + { token = JsonToken.ArrayEnd; parser_return = true; - } else if (current_symbol == '{') { + } + else if (current_symbol == '{') + { token = JsonToken.ObjectStart; parser_return = true; - } else if (current_symbol == '}') { + } + else if (current_symbol == '}') + { token = JsonToken.ObjectEnd; parser_return = true; - } else if (current_symbol == '"') { - if (parser_in_string) { + } + else if (current_symbol == '"') + { + if (parser_in_string) + { parser_in_string = false; parser_return = true; - } else { + } + else + { if (token == JsonToken.None) token = JsonToken.String; parser_in_string = true; } - } else if (current_symbol == (int) ParserToken.CharSeq) { + } + else if (current_symbol == (int)ParserToken.CharSeq) + { token_value = lexer.StringValue; - } else if (current_symbol == (int) ParserToken.False) { + } + else if (current_symbol == (int)ParserToken.False) + { token = JsonToken.Boolean; token_value = false; parser_return = true; - } else if (current_symbol == (int) ParserToken.Null) { + } + else if (current_symbol == (int)ParserToken.Null) + { token = JsonToken.Null; parser_return = true; - } else if (current_symbol == (int) ParserToken.Number) { - ProcessNumber (lexer.StringValue); + } + else if (current_symbol == (int)ParserToken.Number) + { + ProcessNumber(lexer.StringValue); parser_return = true; - } else if (current_symbol == (int) ParserToken.Pair) { + } + else if (current_symbol == (int)ParserToken.Pair) + { token = JsonToken.PropertyName; - } else if (current_symbol == (int) ParserToken.True) { + } + else if (current_symbol == (int)ParserToken.True) + { token = JsonToken.Boolean; token_value = true; parser_return = true; @@ -372,15 +407,16 @@ private void ProcessSymbol () } } - private bool ReadToken () + private bool ReadToken() { if (end_of_input) return false; - lexer.NextToken (); + lexer.NextToken(); - if (lexer.EndOfInput) { - Close (); + if (lexer.EndOfInput) + { + Close(); return false; } @@ -392,66 +428,72 @@ private bool ReadToken () #endregion - public void Close () + public void Close() { if (end_of_input) return; end_of_input = true; - end_of_json = true; + end_of_json = true; if (reader_is_owned) { - using(reader){} + using (reader) { } } reader = null; } - public bool Read () + public bool Read() { if (end_of_input) return false; - if (end_of_json) { + if (end_of_json) + { end_of_json = false; - automaton_stack.Clear (); - automaton_stack.Push ((int) ParserToken.End); - automaton_stack.Push ((int) ParserToken.Text); + automaton_stack.Clear(); + automaton_stack.Push((int)ParserToken.End); + automaton_stack.Push((int)ParserToken.Text); } parser_in_string = false; - parser_return = false; + parser_return = false; - token = JsonToken.None; + token = JsonToken.None; token_value = null; - if (! read_started) { + if (!read_started) + { read_started = true; - if (! ReadToken ()) + if (!ReadToken()) return false; } int[] entry_symbols; - while (true) { - if (parser_return) { - if (automaton_stack.Peek () == (int) ParserToken.End) + while (true) + { + if (parser_return) + { + if (automaton_stack.Peek() == (int)ParserToken.End) end_of_json = true; return true; } - current_symbol = automaton_stack.Pop (); + current_symbol = automaton_stack.Pop(); - ProcessSymbol (); + ProcessSymbol(); - if (current_symbol == current_input) { - if (! ReadToken ()) { - if (automaton_stack.Peek () != (int) ParserToken.End) - throw new JsonException ( + if (current_symbol == current_input) + { + if (!ReadToken()) + { + if (automaton_stack.Peek() != (int)ParserToken.End) + throw new JsonException( "Input doesn't evaluate to proper JSON text"); if (parser_return) @@ -463,22 +505,25 @@ public bool Read () continue; } - try { + try + { entry_symbols = parse_table[current_symbol][current_input]; - } catch (KeyNotFoundException e) { - throw new JsonException ((ParserToken) current_input, e); + } + catch (KeyNotFoundException e) + { + throw new JsonException((ParserToken)current_input, e); } - if (entry_symbols[0] == (int) ParserToken.Epsilon) + if (entry_symbols[0] == (int)ParserToken.Epsilon) continue; for (int i = entry_symbols.Length - 1; i >= 0; i--) - automaton_stack.Push (entry_symbols[i]); + automaton_stack.Push(entry_symbols[i]); } } } -} +} \ No newline at end of file diff --git a/src/Cake.Issues/Serialization/LitJson/JsonWriter.cs b/src/Cake.Issues/Serialization/LitJson/JsonWriter.cs index 63af4dde8..1936e961f 100644 --- a/src/Cake.Issues/Serialization/LitJson/JsonWriter.cs +++ b/src/Cake.Issues/Serialization/LitJson/JsonWriter.cs @@ -35,11 +35,11 @@ internal enum Condition internal class WriterContext { - public int Count; + public int Count; public bool InArray; public bool InObject; public bool ExpectingValue; - public int Padding; + public int Padding; } internal class JsonWriter @@ -47,44 +47,50 @@ internal class JsonWriter #region Fields private static readonly NumberFormatInfo number_format; - private WriterContext context; + private WriterContext context; private Stack ctx_stack; - private bool has_reached_end; - private char[] hex_seq; - private int indentation; - private int indent_value; - private StringBuilder inst_string_builder; - private bool pretty_print; - private bool validate; - private bool lower_case_properties; - private TextWriter writer; + private bool has_reached_end; + private char[] hex_seq; + private int indentation; + private int indent_value; + private StringBuilder inst_string_builder; + private bool pretty_print; + private bool validate; + private bool lower_case_properties; + private TextWriter writer; #endregion #region Properties - public int IndentValue { + public int IndentValue + { get { return indent_value; } - set { + set + { indentation = (indentation / indent_value) * value; indent_value = value; } } - public bool PrettyPrint { + public bool PrettyPrint + { get { return pretty_print; } set { pretty_print = value; } } - public TextWriter TextWriter { + public TextWriter TextWriter + { get { return writer; } } - public bool Validate { + public bool Validate + { get { return validate; } set { validate = value; } } - public bool LowerCaseProperties { + public bool LowerCaseProperties + { get { return lower_case_properties; } set { lower_case_properties = value; } } @@ -92,85 +98,86 @@ public bool LowerCaseProperties { #region Constructors - static JsonWriter () + static JsonWriter() { number_format = NumberFormatInfo.InvariantInfo; } - public JsonWriter () + public JsonWriter() { - inst_string_builder = new StringBuilder (); - writer = new StringWriter (inst_string_builder); + inst_string_builder = new StringBuilder(); + writer = new StringWriter(inst_string_builder); - Init (); + Init(); } - public JsonWriter (StringBuilder sb) : - this (new StringWriter (sb)) + public JsonWriter(StringBuilder sb) : + this(new StringWriter(sb)) { } - public JsonWriter (TextWriter writer) + public JsonWriter(TextWriter writer) { if (writer == null) - throw new ArgumentNullException ("writer"); + throw new ArgumentNullException("writer"); this.writer = writer; - Init (); + Init(); } #endregion #region Private Methods - private void DoValidation (Condition cond) + private void DoValidation(Condition cond) { - if (! context.ExpectingValue) + if (!context.ExpectingValue) context.Count++; - if (! validate) + if (!validate) return; if (has_reached_end) - throw new JsonException ( + throw new JsonException( "A complete JSON symbol has already been written"); - switch (cond) { - case Condition.InArray: - if (! context.InArray) - throw new JsonException ( - "Can't close an array here"); - break; - - case Condition.InObject: - if (! context.InObject || context.ExpectingValue) - throw new JsonException ( - "Can't close an object here"); - break; - - case Condition.NotAProperty: - if (context.InObject && ! context.ExpectingValue) - throw new JsonException ( - "Expected a property"); - break; - - case Condition.Property: - if (! context.InObject || context.ExpectingValue) - throw new JsonException ( - "Can't add a property here"); - break; - - case Condition.Value: - if (! context.InArray && - (! context.InObject || ! context.ExpectingValue)) - throw new JsonException ( - "Can't add a value here"); - - break; + switch (cond) + { + case Condition.InArray: + if (!context.InArray) + throw new JsonException( + "Can't close an array here"); + break; + + case Condition.InObject: + if (!context.InObject || context.ExpectingValue) + throw new JsonException( + "Can't close an object here"); + break; + + case Condition.NotAProperty: + if (context.InObject && !context.ExpectingValue) + throw new JsonException( + "Expected a property"); + break; + + case Condition.Property: + if (!context.InObject || context.ExpectingValue) + throw new JsonException( + "Can't add a property here"); + break; + + case Condition.Value: + if (!context.InArray && + (!context.InObject || !context.ExpectingValue)) + throw new JsonException( + "Can't add a value here"); + + break; } } - private void Init () + private void Init() { has_reached_end = false; hex_seq = new char[4]; @@ -180,109 +187,113 @@ private void Init () validate = true; lower_case_properties = false; - ctx_stack = new Stack (); - context = new WriterContext (); - ctx_stack.Push (context); + ctx_stack = new Stack(); + context = new WriterContext(); + ctx_stack.Push(context); } - private static void IntToHex (int n, char[] hex) + private static void IntToHex(int n, char[] hex) { int num; - for (int i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) + { num = n % 16; if (num < 10) - hex[3 - i] = (char) ('0' + num); + hex[3 - i] = (char)('0' + num); else - hex[3 - i] = (char) ('A' + (num - 10)); + hex[3 - i] = (char)('A' + (num - 10)); n >>= 4; } } - private void Indent () + private void Indent() { if (pretty_print) indentation += indent_value; } - private void Put (string str) + private void Put(string str) { - if (pretty_print && ! context.ExpectingValue) + if (pretty_print && !context.ExpectingValue) for (int i = 0; i < indentation; i++) - writer.Write (' '); + writer.Write(' '); - writer.Write (str); + writer.Write(str); } - private void PutNewline () + private void PutNewline() { - PutNewline (true); + PutNewline(true); } - private void PutNewline (bool add_comma) + private void PutNewline(bool add_comma) { - if (add_comma && ! context.ExpectingValue && + if (add_comma && !context.ExpectingValue && context.Count > 1) - writer.Write (','); + writer.Write(','); - if (pretty_print && ! context.ExpectingValue) - writer.Write (Environment.NewLine); + if (pretty_print && !context.ExpectingValue) + writer.Write(Environment.NewLine); } - private void PutString (string str) + private void PutString(string str) { - Put (String.Empty); + Put(String.Empty); - writer.Write ('"'); + writer.Write('"'); int n = str.Length; - for (int i = 0; i < n; i++) { - switch (str[i]) { - case '\n': - writer.Write ("\\n"); - continue; - - case '\r': - writer.Write ("\\r"); - continue; - - case '\t': - writer.Write ("\\t"); - continue; - - case '"': - case '\\': - writer.Write ('\\'); - writer.Write (str[i]); - continue; - - case '\f': - writer.Write ("\\f"); - continue; - - case '\b': - writer.Write ("\\b"); - continue; + for (int i = 0; i < n; i++) + { + switch (str[i]) + { + case '\n': + writer.Write("\\n"); + continue; + + case '\r': + writer.Write("\\r"); + continue; + + case '\t': + writer.Write("\\t"); + continue; + + case '"': + case '\\': + writer.Write('\\'); + writer.Write(str[i]); + continue; + + case '\f': + writer.Write("\\f"); + continue; + + case '\b': + writer.Write("\\b"); + continue; } - if ((int) str[i] >= 32 && (int) str[i] <= 126) { - writer.Write (str[i]); + if ((int)str[i] >= 32 && (int)str[i] <= 126) + { + writer.Write(str[i]); continue; } // Default, turn into a \uXXXX sequence - IntToHex ((int) str[i], hex_seq); - writer.Write ("\\u"); - writer.Write (hex_seq); + IntToHex((int)str[i], hex_seq); + writer.Write("\\u"); + writer.Write(hex_seq); } - writer.Write ('"'); + writer.Write('"'); } - private void Unindent () + private void Unindent() { if (pretty_print) indentation -= indent_value; @@ -290,190 +301,205 @@ private void Unindent () #endregion - public override string ToString () + public override string ToString() { if (inst_string_builder == null) return String.Empty; - return inst_string_builder.ToString (); + return inst_string_builder.ToString(); } - public void Reset () + public void Reset() { has_reached_end = false; - ctx_stack.Clear (); - context = new WriterContext (); - ctx_stack.Push (context); + ctx_stack.Clear(); + context = new WriterContext(); + ctx_stack.Push(context); if (inst_string_builder != null) - inst_string_builder.Remove (0, inst_string_builder.Length); + inst_string_builder.Remove(0, inst_string_builder.Length); } - public void Write (bool boolean) + public void Write(bool boolean) { - DoValidation (Condition.Value); - PutNewline (); + DoValidation(Condition.Value); + PutNewline(); - Put (boolean ? "true" : "false"); + Put(boolean ? "true" : "false"); context.ExpectingValue = false; } - public void Write (decimal number) + public void Write(decimal number) { - DoValidation (Condition.Value); - PutNewline (); + DoValidation(Condition.Value); + PutNewline(); - Put (Convert.ToString (number, number_format)); + Put(Convert.ToString(number, number_format)); context.ExpectingValue = false; } - public void Write (double number) + public void Write(double number) { - DoValidation (Condition.Value); - PutNewline (); + DoValidation(Condition.Value); + PutNewline(); - string str = Convert.ToString (number, number_format); - Put (str); + string str = Convert.ToString(number, number_format); + Put(str); - if (str.IndexOf ('.') == -1 && - str.IndexOf ('E') == -1) - writer.Write (".0"); + if (str.IndexOf('.') == -1 && + str.IndexOf('E') == -1) + writer.Write(".0"); context.ExpectingValue = false; } - public void Write (int number) + public void Write(float number) { - DoValidation (Condition.Value); - PutNewline (); + DoValidation(Condition.Value); + PutNewline(); - Put (Convert.ToString (number, number_format)); + string str = Convert.ToString(number, number_format); + Put(str); context.ExpectingValue = false; } - public void Write (long number) + public void Write(int number) { - DoValidation (Condition.Value); - PutNewline (); + DoValidation(Condition.Value); + PutNewline(); - Put (Convert.ToString (number, number_format)); + Put(Convert.ToString(number, number_format)); context.ExpectingValue = false; } - public void Write (string str) + public void Write(long number) { - DoValidation (Condition.Value); - PutNewline (); + DoValidation(Condition.Value); + PutNewline(); + + Put(Convert.ToString(number, number_format)); + + context.ExpectingValue = false; + } + + public void Write(string str) + { + DoValidation(Condition.Value); + PutNewline(); if (str == null) - Put ("null"); + Put("null"); else - PutString (str); + PutString(str); context.ExpectingValue = false; } [CLSCompliant(false)] - public void Write (ulong number) + public void Write(ulong number) { - DoValidation (Condition.Value); - PutNewline (); + DoValidation(Condition.Value); + PutNewline(); - Put (Convert.ToString (number, number_format)); + Put(Convert.ToString(number, number_format)); context.ExpectingValue = false; } - public void WriteArrayEnd () + public void WriteArrayEnd() { - DoValidation (Condition.InArray); - PutNewline (false); + DoValidation(Condition.InArray); + PutNewline(false); - ctx_stack.Pop (); + ctx_stack.Pop(); if (ctx_stack.Count == 1) has_reached_end = true; - else { - context = ctx_stack.Peek (); + else + { + context = ctx_stack.Peek(); context.ExpectingValue = false; } - Unindent (); - Put ("]"); + Unindent(); + Put("]"); } - public void WriteArrayStart () + public void WriteArrayStart() { - DoValidation (Condition.NotAProperty); - PutNewline (); + DoValidation(Condition.NotAProperty); + PutNewline(); - Put ("["); + Put("["); - context = new WriterContext (); + context = new WriterContext(); context.InArray = true; - ctx_stack.Push (context); + ctx_stack.Push(context); - Indent (); + Indent(); } - public void WriteObjectEnd () + public void WriteObjectEnd() { - DoValidation (Condition.InObject); - PutNewline (false); + DoValidation(Condition.InObject); + PutNewline(false); - ctx_stack.Pop (); + ctx_stack.Pop(); if (ctx_stack.Count == 1) has_reached_end = true; - else { - context = ctx_stack.Peek (); + else + { + context = ctx_stack.Peek(); context.ExpectingValue = false; } - Unindent (); - Put ("}"); + Unindent(); + Put("}"); } - public void WriteObjectStart () + public void WriteObjectStart() { - DoValidation (Condition.NotAProperty); - PutNewline (); + DoValidation(Condition.NotAProperty); + PutNewline(); - Put ("{"); + Put("{"); - context = new WriterContext (); + context = new WriterContext(); context.InObject = true; - ctx_stack.Push (context); + ctx_stack.Push(context); - Indent (); + Indent(); } - public void WritePropertyName (string property_name) + public void WritePropertyName(string property_name) { - DoValidation (Condition.Property); - PutNewline (); + DoValidation(Condition.Property); + PutNewline(); string propertyName = (property_name == null || !lower_case_properties) ? property_name : property_name.ToLowerInvariant(); - PutString (propertyName); + PutString(propertyName); - if (pretty_print) { + if (pretty_print) + { if (propertyName.Length > context.Padding) context.Padding = propertyName.Length; for (int i = context.Padding - propertyName.Length; i >= 0; i--) - writer.Write (' '); + writer.Write(' '); - writer.Write (": "); - } else - writer.Write (':'); + writer.Write(": "); + } + else + writer.Write(':'); context.ExpectingValue = true; } } -} +} \ No newline at end of file diff --git a/src/Cake.Issues/Serialization/LitJson/Lexer.cs b/src/Cake.Issues/Serialization/LitJson/Lexer.cs index 9f604509d..dda3da955 100644 --- a/src/Cake.Issues/Serialization/LitJson/Lexer.cs +++ b/src/Cake.Issues/Serialization/LitJson/Lexer.cs @@ -25,118 +25,124 @@ namespace LitJson { internal class FsmContext { - public bool Return; - public int NextState; + public bool Return; + public int NextState; public Lexer L; - public int StateStack; + public int StateStack; } internal class Lexer { #region Fields - private delegate bool StateHandler (FsmContext ctx); + private delegate bool StateHandler(FsmContext ctx); - private static readonly int[] fsm_return_table; + private static readonly int[] fsm_return_table; private static readonly StateHandler[] fsm_handler_table; - private bool allow_comments; - private bool allow_single_quoted_strings; - private bool end_of_input; - private FsmContext fsm_context; - private int input_buffer; - private int input_char; - private TextReader reader; - private int state; + private bool allow_comments; + private bool allow_single_quoted_strings; + private bool end_of_input; + private FsmContext fsm_context; + private int input_buffer; + private int input_char; + private TextReader reader; + private int state; private StringBuilder string_buffer; - private string string_value; - private int token; - private int unichar; + private string string_value; + private int token; + private int unichar; #endregion #region Properties - public bool AllowComments { + public bool AllowComments + { get { return allow_comments; } set { allow_comments = value; } } - public bool AllowSingleQuotedStrings { + public bool AllowSingleQuotedStrings + { get { return allow_single_quoted_strings; } set { allow_single_quoted_strings = value; } } - public bool EndOfInput { + public bool EndOfInput + { get { return end_of_input; } } - public int Token { + public int Token + { get { return token; } } - public string StringValue { + public string StringValue + { get { return string_value; } } #endregion #region Constructors - static Lexer () + static Lexer() { - PopulateFsmTables (out fsm_handler_table, out fsm_return_table); + PopulateFsmTables(out fsm_handler_table, out fsm_return_table); } - public Lexer (TextReader reader) + public Lexer(TextReader reader) { allow_comments = true; allow_single_quoted_strings = true; input_buffer = 0; - string_buffer = new StringBuilder (128); + string_buffer = new StringBuilder(128); state = 1; end_of_input = false; this.reader = reader; - fsm_context = new FsmContext (); + fsm_context = new FsmContext(); fsm_context.L = this; } #endregion #region Static Methods - private static int HexValue (int digit) + private static int HexValue(int digit) { - switch (digit) { - case 'a': - case 'A': - return 10; + switch (digit) + { + case 'a': + case 'A': + return 10; - case 'b': - case 'B': - return 11; + case 'b': + case 'B': + return 11; - case 'c': - case 'C': - return 12; + case 'c': + case 'C': + return 12; - case 'd': - case 'D': - return 13; + case 'd': + case 'D': + return 13; - case 'e': - case 'E': - return 14; + case 'e': + case 'E': + return 14; - case 'f': - case 'F': - return 15; + case 'f': + case 'F': + return 15; - default: - return digit - '0'; + default: + return digit - '0'; } } - private static void PopulateFsmTables (out StateHandler[] fsm_handler_table, out int[] fsm_return_table) + private static void PopulateFsmTables(out StateHandler[] fsm_handler_table, out int[] fsm_return_table) { // See section A.1. of the manual for details of the finite // state machine. @@ -203,216 +209,229 @@ private static void PopulateFsmTables (out StateHandler[] fsm_handler_table, out }; } - private static char ProcessEscChar (int esc_char) + private static char ProcessEscChar(int esc_char) { - switch (esc_char) { - case '"': - case '\'': - case '\\': - case '/': - return Convert.ToChar (esc_char); + switch (esc_char) + { + case '"': + case '\'': + case '\\': + case '/': + return Convert.ToChar(esc_char); - case 'n': - return '\n'; + case 'n': + return '\n'; - case 't': - return '\t'; + case 't': + return '\t'; - case 'r': - return '\r'; + case 'r': + return '\r'; - case 'b': - return '\b'; + case 'b': + return '\b'; - case 'f': - return '\f'; + case 'f': + return '\f'; - default: - // Unreachable - return '?'; + default: + // Unreachable + return '?'; } } - private static bool State1 (FsmContext ctx) + private static bool State1(FsmContext ctx) { - while (ctx.L.GetChar ()) { + while (ctx.L.GetChar()) + { if (ctx.L.input_char == ' ' || ctx.L.input_char >= '\t' && ctx.L.input_char <= '\r') continue; - if (ctx.L.input_char >= '1' && ctx.L.input_char <= '9') { - ctx.L.string_buffer.Append ((char) ctx.L.input_char); + if (ctx.L.input_char >= '1' && ctx.L.input_char <= '9') + { + ctx.L.string_buffer.Append((char)ctx.L.input_char); ctx.NextState = 3; return true; } - switch (ctx.L.input_char) { - case '"': - ctx.NextState = 19; - ctx.Return = true; - return true; + switch (ctx.L.input_char) + { + case '"': + ctx.NextState = 19; + ctx.Return = true; + return true; - case ',': - case ':': - case '[': - case ']': - case '{': - case '}': - ctx.NextState = 1; - ctx.Return = true; - return true; + case ',': + case ':': + case '[': + case ']': + case '{': + case '}': + ctx.NextState = 1; + ctx.Return = true; + return true; - case '-': - ctx.L.string_buffer.Append ((char) ctx.L.input_char); - ctx.NextState = 2; - return true; + case '-': + ctx.L.string_buffer.Append((char)ctx.L.input_char); + ctx.NextState = 2; + return true; - case '0': - ctx.L.string_buffer.Append ((char) ctx.L.input_char); - ctx.NextState = 4; - return true; + case '0': + ctx.L.string_buffer.Append((char)ctx.L.input_char); + ctx.NextState = 4; + return true; - case 'f': - ctx.NextState = 12; - return true; + case 'f': + ctx.NextState = 12; + return true; - case 'n': - ctx.NextState = 16; - return true; + case 'n': + ctx.NextState = 16; + return true; - case 't': - ctx.NextState = 9; - return true; + case 't': + ctx.NextState = 9; + return true; - case '\'': - if (! ctx.L.allow_single_quoted_strings) - return false; + case '\'': + if (!ctx.L.allow_single_quoted_strings) + return false; - ctx.L.input_char = '"'; - ctx.NextState = 23; - ctx.Return = true; - return true; + ctx.L.input_char = '"'; + ctx.NextState = 23; + ctx.Return = true; + return true; - case '/': - if (! ctx.L.allow_comments) - return false; + case '/': + if (!ctx.L.allow_comments) + return false; - ctx.NextState = 25; - return true; + ctx.NextState = 25; + return true; - default: - return false; + default: + return false; } } return true; } - private static bool State2 (FsmContext ctx) + private static bool State2(FsmContext ctx) { - ctx.L.GetChar (); + ctx.L.GetChar(); - if (ctx.L.input_char >= '1' && ctx.L.input_char<= '9') { - ctx.L.string_buffer.Append ((char) ctx.L.input_char); + if (ctx.L.input_char >= '1' && ctx.L.input_char <= '9') + { + ctx.L.string_buffer.Append((char)ctx.L.input_char); ctx.NextState = 3; return true; } - switch (ctx.L.input_char) { - case '0': - ctx.L.string_buffer.Append ((char) ctx.L.input_char); - ctx.NextState = 4; - return true; + switch (ctx.L.input_char) + { + case '0': + ctx.L.string_buffer.Append((char)ctx.L.input_char); + ctx.NextState = 4; + return true; - default: - return false; + default: + return false; } } - private static bool State3 (FsmContext ctx) + private static bool State3(FsmContext ctx) { - while (ctx.L.GetChar ()) { - if (ctx.L.input_char >= '0' && ctx.L.input_char <= '9') { - ctx.L.string_buffer.Append ((char) ctx.L.input_char); + while (ctx.L.GetChar()) + { + if (ctx.L.input_char >= '0' && ctx.L.input_char <= '9') + { + ctx.L.string_buffer.Append((char)ctx.L.input_char); continue; } if (ctx.L.input_char == ' ' || - ctx.L.input_char >= '\t' && ctx.L.input_char <= '\r') { + ctx.L.input_char >= '\t' && ctx.L.input_char <= '\r') + { ctx.Return = true; ctx.NextState = 1; return true; } - switch (ctx.L.input_char) { - case ',': - case ']': - case '}': - ctx.L.UngetChar (); - ctx.Return = true; - ctx.NextState = 1; - return true; + switch (ctx.L.input_char) + { + case ',': + case ']': + case '}': + ctx.L.UngetChar(); + ctx.Return = true; + ctx.NextState = 1; + return true; - case '.': - ctx.L.string_buffer.Append ((char) ctx.L.input_char); - ctx.NextState = 5; - return true; + case '.': + ctx.L.string_buffer.Append((char)ctx.L.input_char); + ctx.NextState = 5; + return true; - case 'e': - case 'E': - ctx.L.string_buffer.Append ((char) ctx.L.input_char); - ctx.NextState = 7; - return true; + case 'e': + case 'E': + ctx.L.string_buffer.Append((char)ctx.L.input_char); + ctx.NextState = 7; + return true; - default: - return false; + default: + return false; } } return true; } - private static bool State4 (FsmContext ctx) + private static bool State4(FsmContext ctx) { - ctx.L.GetChar (); + ctx.L.GetChar(); if (ctx.L.input_char == ' ' || - ctx.L.input_char >= '\t' && ctx.L.input_char <= '\r') { + ctx.L.input_char >= '\t' && ctx.L.input_char <= '\r') + { ctx.Return = true; ctx.NextState = 1; return true; } - switch (ctx.L.input_char) { - case ',': - case ']': - case '}': - ctx.L.UngetChar (); - ctx.Return = true; - ctx.NextState = 1; - return true; + switch (ctx.L.input_char) + { + case ',': + case ']': + case '}': + ctx.L.UngetChar(); + ctx.Return = true; + ctx.NextState = 1; + return true; - case '.': - ctx.L.string_buffer.Append ((char) ctx.L.input_char); - ctx.NextState = 5; - return true; + case '.': + ctx.L.string_buffer.Append((char)ctx.L.input_char); + ctx.NextState = 5; + return true; - case 'e': - case 'E': - ctx.L.string_buffer.Append ((char) ctx.L.input_char); - ctx.NextState = 7; - return true; + case 'e': + case 'E': + ctx.L.string_buffer.Append((char)ctx.L.input_char); + ctx.NextState = 7; + return true; - default: - return false; + default: + return false; } } - private static bool State5 (FsmContext ctx) + private static bool State5(FsmContext ctx) { - ctx.L.GetChar (); + ctx.L.GetChar(); - if (ctx.L.input_char >= '0' && ctx.L.input_char <= '9') { - ctx.L.string_buffer.Append ((char) ctx.L.input_char); + if (ctx.L.input_char >= '0' && ctx.L.input_char <= '9') + { + ctx.L.string_buffer.Append((char)ctx.L.input_char); ctx.NextState = 6; return true; } @@ -420,329 +439,356 @@ private static bool State5 (FsmContext ctx) return false; } - private static bool State6 (FsmContext ctx) + private static bool State6(FsmContext ctx) { - while (ctx.L.GetChar ()) { - if (ctx.L.input_char >= '0' && ctx.L.input_char <= '9') { - ctx.L.string_buffer.Append ((char) ctx.L.input_char); + while (ctx.L.GetChar()) + { + if (ctx.L.input_char >= '0' && ctx.L.input_char <= '9') + { + ctx.L.string_buffer.Append((char)ctx.L.input_char); continue; } if (ctx.L.input_char == ' ' || - ctx.L.input_char >= '\t' && ctx.L.input_char <= '\r') { + ctx.L.input_char >= '\t' && ctx.L.input_char <= '\r') + { ctx.Return = true; ctx.NextState = 1; return true; } - switch (ctx.L.input_char) { - case ',': - case ']': - case '}': - ctx.L.UngetChar (); - ctx.Return = true; - ctx.NextState = 1; - return true; + switch (ctx.L.input_char) + { + case ',': + case ']': + case '}': + ctx.L.UngetChar(); + ctx.Return = true; + ctx.NextState = 1; + return true; - case 'e': - case 'E': - ctx.L.string_buffer.Append ((char) ctx.L.input_char); - ctx.NextState = 7; - return true; + case 'e': + case 'E': + ctx.L.string_buffer.Append((char)ctx.L.input_char); + ctx.NextState = 7; + return true; - default: - return false; + default: + return false; } } return true; } - private static bool State7 (FsmContext ctx) + private static bool State7(FsmContext ctx) { - ctx.L.GetChar (); + ctx.L.GetChar(); - if (ctx.L.input_char >= '0' && ctx.L.input_char<= '9') { - ctx.L.string_buffer.Append ((char) ctx.L.input_char); + if (ctx.L.input_char >= '0' && ctx.L.input_char <= '9') + { + ctx.L.string_buffer.Append((char)ctx.L.input_char); ctx.NextState = 8; return true; } - switch (ctx.L.input_char) { - case '+': - case '-': - ctx.L.string_buffer.Append ((char) ctx.L.input_char); - ctx.NextState = 8; - return true; + switch (ctx.L.input_char) + { + case '+': + case '-': + ctx.L.string_buffer.Append((char)ctx.L.input_char); + ctx.NextState = 8; + return true; - default: - return false; + default: + return false; } } - private static bool State8 (FsmContext ctx) + private static bool State8(FsmContext ctx) { - while (ctx.L.GetChar ()) { - if (ctx.L.input_char >= '0' && ctx.L.input_char<= '9') { - ctx.L.string_buffer.Append ((char) ctx.L.input_char); + while (ctx.L.GetChar()) + { + if (ctx.L.input_char >= '0' && ctx.L.input_char <= '9') + { + ctx.L.string_buffer.Append((char)ctx.L.input_char); continue; } if (ctx.L.input_char == ' ' || - ctx.L.input_char >= '\t' && ctx.L.input_char<= '\r') { + ctx.L.input_char >= '\t' && ctx.L.input_char <= '\r') + { ctx.Return = true; ctx.NextState = 1; return true; } - switch (ctx.L.input_char) { - case ',': - case ']': - case '}': - ctx.L.UngetChar (); - ctx.Return = true; - ctx.NextState = 1; - return true; + switch (ctx.L.input_char) + { + case ',': + case ']': + case '}': + ctx.L.UngetChar(); + ctx.Return = true; + ctx.NextState = 1; + return true; - default: - return false; + default: + return false; } } return true; } - private static bool State9 (FsmContext ctx) + private static bool State9(FsmContext ctx) { - ctx.L.GetChar (); + ctx.L.GetChar(); - switch (ctx.L.input_char) { - case 'r': - ctx.NextState = 10; - return true; + switch (ctx.L.input_char) + { + case 'r': + ctx.NextState = 10; + return true; - default: - return false; + default: + return false; } } - private static bool State10 (FsmContext ctx) + private static bool State10(FsmContext ctx) { - ctx.L.GetChar (); + ctx.L.GetChar(); - switch (ctx.L.input_char) { - case 'u': - ctx.NextState = 11; - return true; + switch (ctx.L.input_char) + { + case 'u': + ctx.NextState = 11; + return true; - default: - return false; + default: + return false; } } - private static bool State11 (FsmContext ctx) + private static bool State11(FsmContext ctx) { - ctx.L.GetChar (); + ctx.L.GetChar(); - switch (ctx.L.input_char) { - case 'e': - ctx.Return = true; - ctx.NextState = 1; - return true; + switch (ctx.L.input_char) + { + case 'e': + ctx.Return = true; + ctx.NextState = 1; + return true; - default: - return false; + default: + return false; } } - private static bool State12 (FsmContext ctx) + private static bool State12(FsmContext ctx) { - ctx.L.GetChar (); + ctx.L.GetChar(); - switch (ctx.L.input_char) { - case 'a': - ctx.NextState = 13; - return true; + switch (ctx.L.input_char) + { + case 'a': + ctx.NextState = 13; + return true; - default: - return false; + default: + return false; } } - private static bool State13 (FsmContext ctx) + private static bool State13(FsmContext ctx) { - ctx.L.GetChar (); + ctx.L.GetChar(); - switch (ctx.L.input_char) { - case 'l': - ctx.NextState = 14; - return true; + switch (ctx.L.input_char) + { + case 'l': + ctx.NextState = 14; + return true; - default: - return false; + default: + return false; } } - private static bool State14 (FsmContext ctx) + private static bool State14(FsmContext ctx) { - ctx.L.GetChar (); + ctx.L.GetChar(); - switch (ctx.L.input_char) { - case 's': - ctx.NextState = 15; - return true; + switch (ctx.L.input_char) + { + case 's': + ctx.NextState = 15; + return true; - default: - return false; + default: + return false; } } - private static bool State15 (FsmContext ctx) + private static bool State15(FsmContext ctx) { - ctx.L.GetChar (); + ctx.L.GetChar(); - switch (ctx.L.input_char) { - case 'e': - ctx.Return = true; - ctx.NextState = 1; - return true; + switch (ctx.L.input_char) + { + case 'e': + ctx.Return = true; + ctx.NextState = 1; + return true; - default: - return false; + default: + return false; } } - private static bool State16 (FsmContext ctx) + private static bool State16(FsmContext ctx) { - ctx.L.GetChar (); + ctx.L.GetChar(); - switch (ctx.L.input_char) { - case 'u': - ctx.NextState = 17; - return true; + switch (ctx.L.input_char) + { + case 'u': + ctx.NextState = 17; + return true; - default: - return false; + default: + return false; } } - private static bool State17 (FsmContext ctx) + private static bool State17(FsmContext ctx) { - ctx.L.GetChar (); + ctx.L.GetChar(); - switch (ctx.L.input_char) { - case 'l': - ctx.NextState = 18; - return true; + switch (ctx.L.input_char) + { + case 'l': + ctx.NextState = 18; + return true; - default: - return false; + default: + return false; } } - private static bool State18 (FsmContext ctx) + private static bool State18(FsmContext ctx) { - ctx.L.GetChar (); + ctx.L.GetChar(); - switch (ctx.L.input_char) { - case 'l': - ctx.Return = true; - ctx.NextState = 1; - return true; + switch (ctx.L.input_char) + { + case 'l': + ctx.Return = true; + ctx.NextState = 1; + return true; - default: - return false; + default: + return false; } } - private static bool State19 (FsmContext ctx) + private static bool State19(FsmContext ctx) { - while (ctx.L.GetChar ()) { - switch (ctx.L.input_char) { - case '"': - ctx.L.UngetChar (); - ctx.Return = true; - ctx.NextState = 20; - return true; + while (ctx.L.GetChar()) + { + switch (ctx.L.input_char) + { + case '"': + ctx.L.UngetChar(); + ctx.Return = true; + ctx.NextState = 20; + return true; - case '\\': - ctx.StateStack = 19; - ctx.NextState = 21; - return true; + case '\\': + ctx.StateStack = 19; + ctx.NextState = 21; + return true; - default: - ctx.L.string_buffer.Append ((char) ctx.L.input_char); - continue; + default: + ctx.L.string_buffer.Append((char)ctx.L.input_char); + continue; } } return true; } - private static bool State20 (FsmContext ctx) + private static bool State20(FsmContext ctx) { - ctx.L.GetChar (); + ctx.L.GetChar(); - switch (ctx.L.input_char) { - case '"': - ctx.Return = true; - ctx.NextState = 1; - return true; + switch (ctx.L.input_char) + { + case '"': + ctx.Return = true; + ctx.NextState = 1; + return true; - default: - return false; + default: + return false; } } - private static bool State21 (FsmContext ctx) + private static bool State21(FsmContext ctx) { - ctx.L.GetChar (); + ctx.L.GetChar(); - switch (ctx.L.input_char) { - case 'u': - ctx.NextState = 22; - return true; + switch (ctx.L.input_char) + { + case 'u': + ctx.NextState = 22; + return true; - case '"': - case '\'': - case '/': - case '\\': - case 'b': - case 'f': - case 'n': - case 'r': - case 't': - ctx.L.string_buffer.Append ( - ProcessEscChar (ctx.L.input_char)); - ctx.NextState = ctx.StateStack; - return true; + case '"': + case '\'': + case '/': + case '\\': + case 'b': + case 'f': + case 'n': + case 'r': + case 't': + ctx.L.string_buffer.Append( + ProcessEscChar(ctx.L.input_char)); + ctx.NextState = ctx.StateStack; + return true; - default: - return false; + default: + return false; } } - private static bool State22 (FsmContext ctx) + private static bool State22(FsmContext ctx) { int counter = 0; - int mult = 4096; + int mult = 4096; ctx.L.unichar = 0; - while (ctx.L.GetChar ()) { + while (ctx.L.GetChar()) + { if (ctx.L.input_char >= '0' && ctx.L.input_char <= '9' || ctx.L.input_char >= 'A' && ctx.L.input_char <= 'F' || - ctx.L.input_char >= 'a' && ctx.L.input_char <= 'f') { + ctx.L.input_char >= 'a' && ctx.L.input_char <= 'f') + { - ctx.L.unichar += HexValue (ctx.L.input_char) * mult; + ctx.L.unichar += HexValue(ctx.L.input_char) * mult; counter++; mult /= 16; - if (counter == 4) { - ctx.L.string_buffer.Append ( - Convert.ToChar (ctx.L.unichar)); + if (counter == 4) + { + ctx.L.string_buffer.Append( + Convert.ToChar(ctx.L.unichar)); ctx.NextState = ctx.StateStack; return true; } @@ -756,68 +802,74 @@ private static bool State22 (FsmContext ctx) return true; } - private static bool State23 (FsmContext ctx) + private static bool State23(FsmContext ctx) { - while (ctx.L.GetChar ()) { - switch (ctx.L.input_char) { - case '\'': - ctx.L.UngetChar (); - ctx.Return = true; - ctx.NextState = 24; - return true; + while (ctx.L.GetChar()) + { + switch (ctx.L.input_char) + { + case '\'': + ctx.L.UngetChar(); + ctx.Return = true; + ctx.NextState = 24; + return true; - case '\\': - ctx.StateStack = 23; - ctx.NextState = 21; - return true; + case '\\': + ctx.StateStack = 23; + ctx.NextState = 21; + return true; - default: - ctx.L.string_buffer.Append ((char) ctx.L.input_char); - continue; + default: + ctx.L.string_buffer.Append((char)ctx.L.input_char); + continue; } } return true; } - private static bool State24 (FsmContext ctx) + private static bool State24(FsmContext ctx) { - ctx.L.GetChar (); + ctx.L.GetChar(); - switch (ctx.L.input_char) { - case '\'': - ctx.L.input_char = '"'; - ctx.Return = true; - ctx.NextState = 1; - return true; + switch (ctx.L.input_char) + { + case '\'': + ctx.L.input_char = '"'; + ctx.Return = true; + ctx.NextState = 1; + return true; - default: - return false; + default: + return false; } } - private static bool State25 (FsmContext ctx) + private static bool State25(FsmContext ctx) { - ctx.L.GetChar (); + ctx.L.GetChar(); - switch (ctx.L.input_char) { - case '*': - ctx.NextState = 27; - return true; + switch (ctx.L.input_char) + { + case '*': + ctx.NextState = 27; + return true; - case '/': - ctx.NextState = 26; - return true; + case '/': + ctx.NextState = 26; + return true; - default: - return false; + default: + return false; } } - private static bool State26 (FsmContext ctx) + private static bool State26(FsmContext ctx) { - while (ctx.L.GetChar ()) { - if (ctx.L.input_char == '\n') { + while (ctx.L.GetChar()) + { + if (ctx.L.input_char == '\n') + { ctx.NextState = 1; return true; } @@ -826,10 +878,12 @@ private static bool State26 (FsmContext ctx) return true; } - private static bool State27 (FsmContext ctx) + private static bool State27(FsmContext ctx) { - while (ctx.L.GetChar ()) { - if (ctx.L.input_char == '*') { + while (ctx.L.GetChar()) + { + if (ctx.L.input_char == '*') + { ctx.NextState = 28; return true; } @@ -838,13 +892,15 @@ private static bool State27 (FsmContext ctx) return true; } - private static bool State28 (FsmContext ctx) + private static bool State28(FsmContext ctx) { - while (ctx.L.GetChar ()) { + while (ctx.L.GetChar()) + { if (ctx.L.input_char == '*') continue; - if (ctx.L.input_char == '/') { + if (ctx.L.input_char == '/') + { ctx.NextState = 1; return true; } @@ -858,47 +914,50 @@ private static bool State28 (FsmContext ctx) #endregion - private bool GetChar () + private bool GetChar() { - if ((input_char = NextChar ()) != -1) + if ((input_char = NextChar()) != -1) return true; end_of_input = true; return false; } - private int NextChar () + private int NextChar() { - if (input_buffer != 0) { + if (input_buffer != 0) + { int tmp = input_buffer; input_buffer = 0; return tmp; } - return reader.Read (); + return reader.Read(); } - public bool NextToken () + public bool NextToken() { StateHandler handler; fsm_context.Return = false; - while (true) { + while (true) + { handler = fsm_handler_table[state - 1]; - if (! handler (fsm_context)) - throw new JsonException (input_char); + if (!handler(fsm_context)) + throw new JsonException(input_char); if (end_of_input) return false; - if (fsm_context.Return) { - string_value = string_buffer.ToString (); - string_buffer.Remove (0, string_buffer.Length); + if (fsm_context.Return) + { + string_value = string_buffer.ToString(); + string_buffer.Remove(0, string_buffer.Length); token = fsm_return_table[state - 1]; - if (token == (int) ParserToken.Char) + if (token == (int)ParserToken.Char) token = input_char; state = fsm_context.NextState; @@ -910,9 +969,9 @@ public bool NextToken () } } - private void UngetChar () + private void UngetChar() { input_buffer = input_char; } } -} +} \ No newline at end of file diff --git a/src/Cake.Issues/Serialization/LitJson/ParserToken.cs b/src/Cake.Issues/Serialization/LitJson/ParserToken.cs index 85dd10da3..027655442 100644 --- a/src/Cake.Issues/Serialization/LitJson/ParserToken.cs +++ b/src/Cake.Issues/Serialization/LitJson/ParserToken.cs @@ -14,6 +14,7 @@ // #endregion + namespace LitJson { internal enum ParserToken @@ -46,4 +47,4 @@ internal enum ParserToken // The empty rule Epsilon } -} +} \ No newline at end of file From cfadfbfe458135d8b72e0c08b0fda8cb57f19cdd Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Mon, 2 Jan 2023 09:02:01 +0000 Subject: [PATCH 31/44] Add editorconfig file (#317) --- src/.editorconfig | 226 ++++++++++++++++++++++++++++++++++++++++++++ src/Cake.Issues.sln | 6 ++ 2 files changed, 232 insertions(+) create mode 100644 src/.editorconfig diff --git a/src/.editorconfig b/src/.editorconfig new file mode 100644 index 000000000..7b7f11fae --- /dev/null +++ b/src/.editorconfig @@ -0,0 +1,226 @@ +# Remove the line below if you want to inherit .editorconfig settings from higher directories +root = true + +# C# files +[*.cs] + +#### Core EditorConfig Options #### + +# Indentation and spacing +indent_size = 4 +indent_style = space +tab_width = 4 + +# New line preferences +end_of_line = crlf +insert_final_newline = false + +#### .NET Coding Conventions #### + +# Organize usings +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = true +file_header_template = unset + +# this. and Me. preferences +dotnet_style_qualification_for_event = true +dotnet_style_qualification_for_field = true +dotnet_style_qualification_for_method = true +dotnet_style_qualification_for_property = true + +# Language keywords vs BCL types preferences +dotnet_style_predefined_type_for_locals_parameters_members = true +dotnet_style_predefined_type_for_member_access = true + +# Parentheses preferences +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_operators = never_if_unnecessary +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity + +# Modifier preferences +dotnet_style_require_accessibility_modifiers = for_non_interface_members + +# Expression-level preferences +dotnet_style_coalesce_expression = true +dotnet_style_collection_initializer = true +dotnet_style_explicit_tuple_names = true +dotnet_style_namespace_match_folder = true +dotnet_style_null_propagation = true +dotnet_style_object_initializer = true +dotnet_style_operator_placement_when_wrapping = beginning_of_line +dotnet_style_prefer_auto_properties = true +dotnet_style_prefer_compound_assignment = true +dotnet_style_prefer_conditional_expression_over_assignment = true +dotnet_style_prefer_conditional_expression_over_return = true +dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed +dotnet_style_prefer_inferred_anonymous_type_member_names = true +dotnet_style_prefer_inferred_tuple_names = true +dotnet_style_prefer_is_null_check_over_reference_equality_method = true +dotnet_style_prefer_simplified_boolean_expressions = true +dotnet_style_prefer_simplified_interpolation = true + +# Field preferences +dotnet_style_readonly_field = true + +# Parameter preferences +dotnet_code_quality_unused_parameters = all + +# Suppression preferences +dotnet_remove_unnecessary_suppression_exclusions = 0 + +# New line preferences +dotnet_style_allow_multiple_blank_lines_experimental = true +dotnet_style_allow_statement_immediately_after_block_experimental = true + +#### C# Coding Conventions #### + +# var preferences +csharp_style_var_elsewhere = false +csharp_style_var_for_built_in_types = false +csharp_style_var_when_type_is_apparent = false + +# Expression-bodied members +csharp_style_expression_bodied_accessors = true +csharp_style_expression_bodied_constructors = false +csharp_style_expression_bodied_indexers = true +csharp_style_expression_bodied_lambdas = true +csharp_style_expression_bodied_local_functions = false +csharp_style_expression_bodied_methods = false +csharp_style_expression_bodied_operators = false +csharp_style_expression_bodied_properties = true + +# Pattern matching preferences +csharp_style_pattern_matching_over_as_with_null_check = true +csharp_style_pattern_matching_over_is_with_cast_check = true +csharp_style_prefer_extended_property_pattern = true +csharp_style_prefer_not_pattern = true +csharp_style_prefer_pattern_matching = true +csharp_style_prefer_switch_expression = true + +# Null-checking preferences +csharp_style_conditional_delegate_call = true + +# Modifier preferences +csharp_prefer_static_local_function = true +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async +csharp_style_prefer_readonly_struct = true + +# Code-block preferences +csharp_prefer_braces = true +csharp_prefer_simple_using_statement = false +csharp_style_namespace_declarations = block_scoped +csharp_style_prefer_method_group_conversion = true +csharp_style_prefer_top_level_statements = true + +# Expression-level preferences +csharp_prefer_simple_default_expression = true +csharp_style_deconstructed_variable_declaration = true +csharp_style_implicit_object_creation_when_type_is_apparent = true +csharp_style_inlined_variable_declaration = true +csharp_style_prefer_index_operator = true +csharp_style_prefer_local_over_anonymous_function = true +csharp_style_prefer_null_check_over_type_check = true +csharp_style_prefer_range_operator = true +csharp_style_prefer_tuple_swap = true +csharp_style_prefer_utf8_string_literals = true +csharp_style_throw_expression = true +csharp_style_unused_value_assignment_preference = discard_variable +csharp_style_unused_value_expression_statement_preference = discard_variable + +# 'using' directive preferences +csharp_using_directive_placement = inside_namespace:error + +# New line preferences +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true +csharp_style_allow_embedded_statements_on_same_line_experimental = true + +#### C# Formatting Rules #### + +# New line preferences +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_open_brace = all +csharp_new_line_between_query_expression_clauses = true + +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true +csharp_indent_labels = no_change +csharp_indent_switch_labels = true + +# Space preferences +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_name_and_open_parenthesis = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false + +# Wrapping preferences +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +#### Naming styles #### + +# Naming rules + +dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i + +dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.types_should_be_pascal_case.symbols = types +dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case + +# Symbol specifications + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types.required_modifiers = + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = + +# Naming styles + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case + +dotnet_naming_style.begins_with_i.required_prefix = I +dotnet_naming_style.begins_with_i.required_suffix = +dotnet_naming_style.begins_with_i.word_separator = +dotnet_naming_style.begins_with_i.capitalization = pascal_case diff --git a/src/Cake.Issues.sln b/src/Cake.Issues.sln index 3af713397..ec4857500 100644 --- a/src/Cake.Issues.sln +++ b/src/Cake.Issues.sln @@ -28,6 +28,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cake.Issues.Reporting", "Ca EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cake.Issues.Reporting.Tests", "Cake.Issues.Reporting.Tests\Cake.Issues.Reporting.Tests.csproj", "{07C79C7F-D854-43F3-8C2E-6E8147A78B94}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8756998D-64BF-4554-A14F-15AAFE78C8E8}" + ProjectSection(SolutionItems) = preProject + Directory.Build.props = Directory.Build.props + editorconfig = editorconfig + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU From 619060cb7dd33f1c5c4c084c568dd90b89c09372 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Mon, 2 Jan 2023 09:19:40 +0000 Subject: [PATCH 32/44] Fix ordering of methods (#318) --- .../IssueDeserializationExtensions.cs | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Cake.Issues/Serialization/IssueDeserializationExtensions.cs b/src/Cake.Issues/Serialization/IssueDeserializationExtensions.cs index d1f037f2d..10ecd0ccb 100644 --- a/src/Cake.Issues/Serialization/IssueDeserializationExtensions.cs +++ b/src/Cake.Issues/Serialization/IssueDeserializationExtensions.cs @@ -28,32 +28,32 @@ public static Issue DeserializeToIssue(this string jsonString) } /// - /// Deserializes an from a JSON string. + /// Deserializes an from a JSON file. /// - /// JSON representation of the issues. - /// List of issues. - public static IEnumerable DeserializeToIssues(this string jsonString) + /// Path to the JSON file. + /// Instance of the issue. + public static Issue DeserializeToIssue(this FilePath filePath) { - jsonString.NotNullOrWhiteSpace(nameof(jsonString)); + filePath.NotNull(nameof(filePath)); - using (var stream = new MemoryStream(Encoding.Default.GetBytes(jsonString))) + using (var stream = File.Open(filePath.FullPath, FileMode.Open)) { - return DeserializeStreamToIssues(stream); + return DeserializeStreamToIssue(stream); } } /// - /// Deserializes an from a JSON file. + /// Deserializes an from a JSON string. /// - /// Path to the JSON file. - /// Instance of the issue. - public static Issue DeserializeToIssue(this FilePath filePath) + /// JSON representation of the issues. + /// List of issues. + public static IEnumerable DeserializeToIssues(this string jsonString) { - filePath.NotNull(nameof(filePath)); + jsonString.NotNullOrWhiteSpace(nameof(jsonString)); - using (var stream = File.Open(filePath.FullPath, FileMode.Open)) + using (var stream = new MemoryStream(Encoding.Default.GetBytes(jsonString))) { - return DeserializeStreamToIssue(stream); + return DeserializeStreamToIssues(stream); } } From 30451329a3147f64dfb8f56dba2e3d0f5bac77ce Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Mon, 2 Jan 2023 09:31:50 +0000 Subject: [PATCH 33/44] Improve null check (#319) --- src/Cake.Issues/IIssueComparer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cake.Issues/IIssueComparer.cs b/src/Cake.Issues/IIssueComparer.cs index b5589c1ec..745b0bbe4 100644 --- a/src/Cake.Issues/IIssueComparer.cs +++ b/src/Cake.Issues/IIssueComparer.cs @@ -160,7 +160,7 @@ private static int GetHashCode(params object[] objects) foreach (var obj in objects) { - hash = (23 * hash) + (obj is object ? obj.GetHashCode() : 0); + hash = (23 * hash) + (obj is not null ? obj.GetHashCode() : 0); } return hash; From d8a6ecd73e047af9fa58b3ee069a00ddcc8f98aa Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Mon, 2 Jan 2023 09:53:35 +0000 Subject: [PATCH 34/44] Simplify new statement (#320) --- src/Cake.Issues.Tests/Testing/FakeIssueProviderFixture.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cake.Issues.Tests/Testing/FakeIssueProviderFixture.cs b/src/Cake.Issues.Tests/Testing/FakeIssueProviderFixture.cs index 35406df52..d268ccfc7 100644 --- a/src/Cake.Issues.Tests/Testing/FakeIssueProviderFixture.cs +++ b/src/Cake.Issues.Tests/Testing/FakeIssueProviderFixture.cs @@ -5,7 +5,7 @@ internal sealed class FakeIssueProviderFixture : BaseIssueProviderFixture { - private readonly List issues = new List(); + private readonly List issues = new (); public FakeIssueProviderFixture() { From 2ee4922dd8c9af966f1dfcd4f6db9f49811b0d53 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Mon, 2 Jan 2023 10:07:46 +0000 Subject: [PATCH 35/44] Mark assertion methods (#321) --- src/Cake.Issues.Testing/AssertionMethodAttribute.cs | 11 +++++++++++ src/Cake.Issues.Testing/ExceptionAssertExtensions.cs | 4 ++++ src/Cake.Issues.Testing/IssueChecker.cs | 3 +++ 3 files changed, 18 insertions(+) create mode 100644 src/Cake.Issues.Testing/AssertionMethodAttribute.cs diff --git a/src/Cake.Issues.Testing/AssertionMethodAttribute.cs b/src/Cake.Issues.Testing/AssertionMethodAttribute.cs new file mode 100644 index 000000000..5b947c83c --- /dev/null +++ b/src/Cake.Issues.Testing/AssertionMethodAttribute.cs @@ -0,0 +1,11 @@ +namespace Cake.Issues.Testing +{ + using System; + + /// + /// Attribute for marking custom assertion methods. + /// + public class AssertionMethodAttribute : Attribute + { + } +} diff --git a/src/Cake.Issues.Testing/ExceptionAssertExtensions.cs b/src/Cake.Issues.Testing/ExceptionAssertExtensions.cs index cf1713d37..1a2e11bd0 100644 --- a/src/Cake.Issues.Testing/ExceptionAssertExtensions.cs +++ b/src/Cake.Issues.Testing/ExceptionAssertExtensions.cs @@ -12,6 +12,7 @@ public static class ExceptionAssertExtensions /// /// Exception to check. /// Expected name of the parameter which has caused the exception. + [AssertionMethod] public static void IsArgumentException(this Exception exception, string parameterName) { var argumentException = exception.CheckExceptionType(); @@ -27,6 +28,7 @@ public static void IsArgumentException(this Exception exception, string paramete /// /// Exception to check. /// Expected name of the parameter which has caused the exception. + [AssertionMethod] public static void IsArgumentNullException(this Exception exception, string parameterName) { var argumentNullException = exception.CheckExceptionType(); @@ -42,6 +44,7 @@ public static void IsArgumentNullException(this Exception exception, string para /// /// Exception to check. /// Expected name of the parameter which has caused the exception. + [AssertionMethod] public static void IsArgumentOutOfRangeException(this Exception exception, string parameterName) { var argumentOutOfRangeException = exception.CheckExceptionType(); @@ -57,6 +60,7 @@ public static void IsArgumentOutOfRangeException(this Exception exception, strin /// /// Exception to check. /// Expected exception message. + [AssertionMethod] public static void IsInvalidOperationException(this Exception exception, string message) { var invalidOperationException = exception.CheckExceptionType(); diff --git a/src/Cake.Issues.Testing/IssueChecker.cs b/src/Cake.Issues.Testing/IssueChecker.cs index c9e7b5dd5..9edb97735 100644 --- a/src/Cake.Issues.Testing/IssueChecker.cs +++ b/src/Cake.Issues.Testing/IssueChecker.cs @@ -15,6 +15,7 @@ public static class IssueChecker /// /// Issue which should be checked. /// Description of the expected issue. + [AssertionMethod] public static void Check( IIssue issueToCheck, IssueBuilder expectedIssue) @@ -32,6 +33,7 @@ public static void Check( /// /// Issue which should be checked. /// Description of the expected issue. + [AssertionMethod] public static void Check( IIssue issueToCheck, IIssue expectedIssue) @@ -102,6 +104,7 @@ public static void Check( /// Expected URL containing information about the failing rule. /// null if no rule Url is expected. /// Custom information regarding the issue. + [AssertionMethod] public static void Check( IIssue issue, string providerType, From 94667465851ad8940bab2b5d7d5013173219ff48 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Mon, 2 Jan 2023 18:14:01 +0000 Subject: [PATCH 36/44] Make type parameters contravariant (#326) --- src/Cake.Issues/ILogFileFormat.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cake.Issues/ILogFileFormat.cs b/src/Cake.Issues/ILogFileFormat.cs index 663536495..ceed25a33 100644 --- a/src/Cake.Issues/ILogFileFormat.cs +++ b/src/Cake.Issues/ILogFileFormat.cs @@ -7,7 +7,7 @@ /// /// Type of the issue provider. /// Type of the settings. - public interface ILogFileFormat + public interface ILogFileFormat where TIssueProvider : BaseMultiFormatIssueProvider where TSettings : BaseMultiFormatIssueProviderSettings { From 4b70eb78df5ff4a332e2518c077720e49371f58d Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Mon, 2 Jan 2023 18:32:02 +0000 Subject: [PATCH 37/44] (GH-324) Fix typo in method name (#327) --- .../StringPathExtensionsTests.cs | 16 ++++++++-------- src/Cake.Issues/StringPathExtensions.cs | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Cake.Issues.Tests/StringPathExtensionsTests.cs b/src/Cake.Issues.Tests/StringPathExtensionsTests.cs index 6e4251d71..2bccff81f 100644 --- a/src/Cake.Issues.Tests/StringPathExtensionsTests.cs +++ b/src/Cake.Issues.Tests/StringPathExtensionsTests.cs @@ -404,7 +404,7 @@ public void Should_Handle_Trailing_Slashes(string path, string expectedResult) } } - public sealed class TheIsValideRepositoryFilePathExtension + public sealed class TheIsValidRepositoryFilePathExtension { [Fact] public void Should_Throw_If_FilePath_Is_Null() @@ -413,7 +413,7 @@ public void Should_Throw_If_FilePath_Is_Null() var result = Record.Exception( () => - ((string)null).IsValideRepositoryFilePath(new RepositorySettings(@"C:\repo"))); + ((string)null).IsValidRepositoryFilePath(new RepositorySettings(@"C:\repo"))); // Then result.IsArgumentNullException("filePath"); @@ -426,7 +426,7 @@ public void Should_Throw_If_FilePath_Is_Empty() var result = Record.Exception( () => - string.Empty.IsValideRepositoryFilePath(new RepositorySettings(@"C:\repo"))); + string.Empty.IsValidRepositoryFilePath(new RepositorySettings(@"C:\repo"))); // Then result.IsArgumentOutOfRangeException("filePath"); @@ -439,7 +439,7 @@ public void Should_Throw_If_FilePath_Is_WhiteSpace() var result = Record.Exception( () => - " ".IsValideRepositoryFilePath(new RepositorySettings(@"C:\repo"))); + " ".IsValidRepositoryFilePath(new RepositorySettings(@"C:\repo"))); // Then result.IsArgumentOutOfRangeException("filePath"); @@ -452,7 +452,7 @@ public void Should_Throw_If_RepositorySettings_Are_Null() var result = Record.Exception( () => - @"C:\repo".IsValideRepositoryFilePath(null)); + @"C:\repo".IsValidRepositoryFilePath(null)); // Then result.IsArgumentNullException("repositorySettings"); @@ -471,7 +471,7 @@ public void Should_Return_True_If_File_Is_Valid_Repository_FilePath(string repoR var repositorySettings = new RepositorySettings(repoRoot); // When - var (valid, _) = filePath.IsValideRepositoryFilePath(repositorySettings); + var (valid, _) = filePath.IsValidRepositoryFilePath(repositorySettings); // Then valid.ShouldBeTrue(); @@ -490,7 +490,7 @@ public void Should_Return_False_If_File_Is_Outside_Repository(string repoRoot, s var repositorySettings = new RepositorySettings(repoRoot); // When - var (valid, _) = filePath.IsValideRepositoryFilePath(repositorySettings); + var (valid, _) = filePath.IsValidRepositoryFilePath(repositorySettings); // Then valid.ShouldBeFalse(); @@ -510,7 +510,7 @@ public void Should_Return_Correct_FilePath(string repoRoot, string filePath, str var repositorySettings = new RepositorySettings(repoRoot); // When - var (_, filePathResult) = filePath.IsValideRepositoryFilePath(repositorySettings); + var (_, filePathResult) = filePath.IsValidRepositoryFilePath(repositorySettings); // Then filePathResult.ShouldBe(expectedResult); diff --git a/src/Cake.Issues/StringPathExtensions.cs b/src/Cake.Issues/StringPathExtensions.cs index 6322c3c18..ef919ee57 100644 --- a/src/Cake.Issues/StringPathExtensions.cs +++ b/src/Cake.Issues/StringPathExtensions.cs @@ -133,7 +133,7 @@ public static string WithEnding(this string value, string ending) /// Repository settings. /// Tuple containing a value if validation was successful, /// and file path relative to . - public static (bool Valid, string FilePath) IsValideRepositoryFilePath(this string filePath, IRepositorySettings repositorySettings) + public static (bool Valid, string FilePath) IsValidRepositoryFilePath(this string filePath, IRepositorySettings repositorySettings) { filePath.NotNullOrWhiteSpace(nameof(filePath)); repositorySettings.NotNull(nameof(repositorySettings)); From f7aa46a9f2bbc356e3b18839996d8951e3fc753b Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sat, 7 Jan 2023 22:10:18 +0000 Subject: [PATCH 38/44] Fix linting issues and typos (#325) --- src/.editorconfig | 10 +- .../BaseCheckingCommitIdCapabilityTests.cs | 4 +- .../BaseDiscussionThreadsCapabilityTests.cs | 4 +- ...FilteringByModifiedFilesCapabilityTests.cs | 4 +- .../BasePullRequestSystemCapabilityTests.cs | 4 +- .../BasePullRequestSystemTests.cs | 4 +- .../FakePullRequestSystem.cs | 2 +- .../IIssueExtensionsTests.cs | 10 +- ...ISupportCheckingCommitIdExtensionsTests.cs | 18 +- .../IssueCommentInfoTests.cs | 4 +- .../IssueFiltererFixture.cs | 2 +- .../IssueFiltererTests.cs | 902 +++--- .../OrchestratorForIssueProvidersFixture.cs | 4 +- .../OrchestratorForIssuesFixture.cs | 2 +- .../OrchestratorTests.cs | 58 +- .../PullRequestIssueResultTests.cs | 4 +- .../ReportIssuesToPullRequestSettingsTests.cs | 2 +- .../BaseDiscussionThreadsCapability.cs | 2 +- .../BasePullRequestSystem.cs | 2 +- .../IPullRequestDiscussionThread.cs | 4 +- .../IPullRequestSystem.cs | 2 +- .../IReportIssuesToPullRequestSettings.cs | 2 +- .../ISupportCheckingCommitId.cs | 2 - .../ISupportDiscussionThreads.cs | 2 +- .../ISupportFilteringByModifiedFiles.cs | 1 - src/Cake.Issues.PullRequests/IssueFilterer.cs | 25 +- src/Cake.Issues.PullRequests/Orchestrator.cs | 38 +- ...sToPullRequestFromIssueProviderSettings.cs | 3 +- .../ReportIssuesToPullRequestSettings.cs | 3 +- .../CreateIssueReportSettingsTests.cs | 4 +- .../FakeIssueReportFormat.cs | 2 +- .../IssueReportCreatorTests.cs | 26 +- .../Properties/ProjectInfo.cs | 3 +- ...ateIssueReportFromIssueProviderSettings.cs | 2 +- .../CreateIssueReportSettings.cs | 2 +- ...ateIssueReportFromIssueProviderSettings.cs | 2 - .../Properties/ProjectInfo.cs | 1 - .../BaseMultiFormatIssueProviderFixture.cs | 1 - .../ExceptionAssertExtensions.cs | 8 +- .../FakeMultiFormatIssueProviderSettings.cs | 2 +- src/Cake.Issues.Testing/IssueChecker.cs | 12 +- .../Properties/ProjectInfo.cs | 1 - .../BaseConfigurableIssueProviderTests.cs | 4 +- .../BaseLogFileFormatTests.cs | 2 +- ...seMultiFormatIssueProviderSettingsTests.cs | 6 +- .../BaseMultiFormatIssueProviderTests.cs | 9 +- .../ByteArrayExtensionsTests.cs | 22 +- .../FileLinkSettingsTests.cs | 15 +- ...AzureDevOpsFileLinkSettingsBuilderTests.cs | 6 +- .../FileLinkOptionalSettingsBuilderTests.cs | 4 +- .../GitHubFileLinkSettingsBuilderTests.cs | 8 +- .../FileLinking/IDictionaryExtensionsTests.cs | 8 +- src/Cake.Issues.Tests/IIssueComparerTests.cs | 38 +- .../IIssueExtensionsTests.cs | 40 +- src/Cake.Issues.Tests/IssueBuilderFixture.cs | 2 +- src/Cake.Issues.Tests/IssueBuilderTests.cs | 335 +-- .../IssueProviderSettingsTests.cs | 8 +- src/Cake.Issues.Tests/IssueTests.cs | 2454 ++++++++--------- .../IssuesArgumentChecksTests.cs | 16 +- src/Cake.Issues.Tests/IssuesFixture.cs | 8 +- .../ReadIssuesSettingsTests.cs | 2 +- .../RepositorySettingsTests.cs | 2 +- .../IssueDeserializationExtensionsTests.cs | 13 +- .../IssueSerializationExtensionsTests.cs | 490 ++-- .../SerializableIssueExtensionsTests.cs | 2 +- .../SerializableIssueV2ExtensionsTests.cs | 2 +- .../SerializableIssueV3ExtensionsTests.cs | 2 +- .../SerializableIssueV4ExtensionsTests.cs | 2 +- ...seConfigurableIssueProviderFixtureTests.cs | 7 +- .../Testing/BaseIssueProviderFixtureTests.cs | 4 +- ...aseMultiFormatIssueProviderFixtureTests.cs | 7 +- .../Testing/ExceptionAssertExtensionsTests.cs | 24 +- .../Testing/IssueCheckerFixture.cs | 46 +- .../Testing/IssueCheckerTests.cs | 16 +- .../Testing/ResourceTempFileTests.cs | 12 +- src/Cake.Issues.Tests/UriExtensionsTests.cs | 2 +- src/Cake.Issues.sln | 2 +- src/Cake.Issues.sln.DotSettings | 9 + .../BaseConfigurableIssueProvider.cs | 2 +- src/Cake.Issues/BaseIssueComponent.cs | 2 +- src/Cake.Issues/BaseIssueProvider.cs | 8 +- src/Cake.Issues/BaseLogFileFormat.cs | 2 +- .../BaseMultiFormatIssueProviderSettings.cs | 4 +- src/Cake.Issues/Cake.Issues.csproj | 1 + src/Cake.Issues/FileLinkSettings.cs | 7 +- src/Cake.Issues/IIssue.cs | 12 +- src/Cake.Issues/IIssueComparer.cs | 2 +- src/Cake.Issues/IIssueExtensions.cs | 2 +- src/Cake.Issues/Issue.cs | 22 +- src/Cake.Issues/IssueBuilder.cs | 30 +- src/Cake.Issues/IssueProviderSettings.cs | 4 +- src/Cake.Issues/IssuesArgumentChecks.cs | 9 +- .../IssueDeserializationExtensions.cs | 2 +- .../Serialization/LitJson/IJsonWrapper.cs | 2 +- .../Serialization/LitJson/JsonData.cs | 1 + .../Serialization/LitJson/JsonException.cs | 1 + .../Serialization/LitJson/JsonMapper.cs | 1 + .../Serialization/LitJson/JsonMockWrapper.cs | 1 + .../Serialization/LitJson/JsonReader.cs | 1 + .../Serialization/LitJson/JsonWriter.cs | 1 + .../Serialization/LitJson/Lexer.cs | 1 + .../Serialization/LitJson/ParserToken.cs | 1 + .../Serialization/SerializableIssueV2.cs | 8 +- .../Serialization/SerializableIssueV3.cs | 8 +- .../Serialization/SerializableIssueV4.cs | 8 +- .../Serialization/SerializableIssueV5.cs | 8 +- src/Cake.Issues/StringPathExtensions.cs | 6 +- 107 files changed, 2537 insertions(+), 2439 deletions(-) diff --git a/src/.editorconfig b/src/.editorconfig index 7b7f11fae..bef3dc195 100644 --- a/src/.editorconfig +++ b/src/.editorconfig @@ -1,5 +1,5 @@ -# Remove the line below if you want to inherit .editorconfig settings from higher directories root = true +# Remove the line below if you want to inherit .editorconfig settings from higher directories # C# files [*.cs] @@ -20,7 +20,7 @@ insert_final_newline = false # Organize usings dotnet_separate_import_directive_groups = false dotnet_sort_system_directives_first = true -file_header_template = unset +file_header_template = # this. and Me. preferences dotnet_style_qualification_for_event = true @@ -76,9 +76,9 @@ dotnet_style_allow_statement_immediately_after_block_experimental = true #### C# Coding Conventions #### # var preferences -csharp_style_var_elsewhere = false -csharp_style_var_for_built_in_types = false -csharp_style_var_when_type_is_apparent = false +csharp_style_var_elsewhere = true:suggestion +csharp_style_var_for_built_in_types = true:suggestion +csharp_style_var_when_type_is_apparent = true:suggestion # Expression-bodied members csharp_style_expression_bodied_accessors = true diff --git a/src/Cake.Issues.PullRequests.Tests/BaseCheckingCommitIdCapabilityTests.cs b/src/Cake.Issues.PullRequests.Tests/BaseCheckingCommitIdCapabilityTests.cs index ce84041ba..5cd6ef9c0 100644 --- a/src/Cake.Issues.PullRequests.Tests/BaseCheckingCommitIdCapabilityTests.cs +++ b/src/Cake.Issues.PullRequests.Tests/BaseCheckingCommitIdCapabilityTests.cs @@ -14,7 +14,7 @@ public sealed class TheCtor public void Should_Throw_If_Log_Is_Null() { // Given - ICakeLog log = null; + const ICakeLog log = null; var pullRequestSystem = new FakePullRequestSystem(new FakeLog()); // When @@ -29,7 +29,7 @@ public void Should_Throw_If_PullRequestSystem_Is_Null() { // Given var log = new FakeLog(); - FakePullRequestSystem pullRequestSystem = null; + const FakePullRequestSystem pullRequestSystem = null; // When var result = Record.Exception(() => new FakeCheckingCommitIdCapability(log, pullRequestSystem)); diff --git a/src/Cake.Issues.PullRequests.Tests/BaseDiscussionThreadsCapabilityTests.cs b/src/Cake.Issues.PullRequests.Tests/BaseDiscussionThreadsCapabilityTests.cs index 4f2aeaa8e..672dc5622 100644 --- a/src/Cake.Issues.PullRequests.Tests/BaseDiscussionThreadsCapabilityTests.cs +++ b/src/Cake.Issues.PullRequests.Tests/BaseDiscussionThreadsCapabilityTests.cs @@ -16,7 +16,7 @@ public sealed class TheCtor public void Should_Throw_If_Log_Is_Null() { // Given - ICakeLog log = null; + const ICakeLog log = null; var pullRequestSystem = new FakePullRequestSystem(new FakeLog()); var discussionThreads = new List(); @@ -34,7 +34,7 @@ public void Should_Throw_If_PullRequestSystem_Is_Null() { // Given var log = new FakeLog(); - FakePullRequestSystem pullRequestSystem = null; + const FakePullRequestSystem pullRequestSystem = null; var discussionThreads = new List(); // When diff --git a/src/Cake.Issues.PullRequests.Tests/BaseFilteringByModifiedFilesCapabilityTests.cs b/src/Cake.Issues.PullRequests.Tests/BaseFilteringByModifiedFilesCapabilityTests.cs index 467ee02cf..c5b75c8c1 100644 --- a/src/Cake.Issues.PullRequests.Tests/BaseFilteringByModifiedFilesCapabilityTests.cs +++ b/src/Cake.Issues.PullRequests.Tests/BaseFilteringByModifiedFilesCapabilityTests.cs @@ -16,7 +16,7 @@ public sealed class TheCtor public void Should_Throw_If_Log_Is_Null() { // Given - ICakeLog log = null; + const ICakeLog log = null; var pullRequestSystem = new FakePullRequestSystem(new FakeLog()); var modifiedFiles = new List(); @@ -34,7 +34,7 @@ public void Should_Throw_If_PullRequestSystem_Is_Null() { // Given var log = new FakeLog(); - FakePullRequestSystem pullRequestSystem = null; + const FakePullRequestSystem pullRequestSystem = null; var modifiedFiles = new List(); // When diff --git a/src/Cake.Issues.PullRequests.Tests/BasePullRequestSystemCapabilityTests.cs b/src/Cake.Issues.PullRequests.Tests/BasePullRequestSystemCapabilityTests.cs index 4bae21ee7..1c519289e 100644 --- a/src/Cake.Issues.PullRequests.Tests/BasePullRequestSystemCapabilityTests.cs +++ b/src/Cake.Issues.PullRequests.Tests/BasePullRequestSystemCapabilityTests.cs @@ -14,7 +14,7 @@ public sealed class TheCtor public void Should_Throw_If_Log_Is_Null() { // Given - ICakeLog log = null; + const ICakeLog log = null; var pullRequestSystem = new FakePullRequestSystem(new FakeLog()); // When @@ -29,7 +29,7 @@ public void Should_Throw_If_PullRequestSystem_Is_Null() { // Given var log = new FakeLog(); - FakePullRequestSystem pullRequestSystem = null; + const FakePullRequestSystem pullRequestSystem = null; // When var result = Record.Exception(() => new FakePullRequestSystemCapability(log, pullRequestSystem)); diff --git a/src/Cake.Issues.PullRequests.Tests/BasePullRequestSystemTests.cs b/src/Cake.Issues.PullRequests.Tests/BasePullRequestSystemTests.cs index 66474f42b..412c96046 100644 --- a/src/Cake.Issues.PullRequests.Tests/BasePullRequestSystemTests.cs +++ b/src/Cake.Issues.PullRequests.Tests/BasePullRequestSystemTests.cs @@ -15,7 +15,7 @@ public sealed class TheCtor public void Should_Throw_If_Log_Is_Null() { // Given - ICakeLog log = null; + const ICakeLog log = null; // When var result = Record.Exception(() => new FakePullRequestSystem(log)); @@ -46,7 +46,7 @@ public void Should_Throw_If_Capability_Is_Null() // Given var log = new FakeLog(); var pullRequestSystem = new FakePullRequestSystem(log); - IPullRequestSystemCapability capability = null; + const IPullRequestSystemCapability capability = null; // When var result = Record.Exception(() => pullRequestSystem.AddCapability(capability)); diff --git a/src/Cake.Issues.PullRequests.Tests/FakePullRequestSystem.cs b/src/Cake.Issues.PullRequests.Tests/FakePullRequestSystem.cs index 7b8bf891e..af0c0f60d 100644 --- a/src/Cake.Issues.PullRequests.Tests/FakePullRequestSystem.cs +++ b/src/Cake.Issues.PullRequests.Tests/FakePullRequestSystem.cs @@ -55,7 +55,7 @@ public FakePullRequestSystem(ICakeLog log) /// /// Gets or sets a value indicating whether the pull request system should return false during . /// - public bool ShouldFailOnInitialization { get; set; } = false; + public bool ShouldFailOnInitialization { get; set; } /// public override bool Initialize(IReportIssuesToPullRequestSettings settings) diff --git a/src/Cake.Issues.PullRequests.Tests/IIssueExtensionsTests.cs b/src/Cake.Issues.PullRequests.Tests/IIssueExtensionsTests.cs index e02e6fa43..5fb085bbb 100644 --- a/src/Cake.Issues.PullRequests.Tests/IIssueExtensionsTests.cs +++ b/src/Cake.Issues.PullRequests.Tests/IIssueExtensionsTests.cs @@ -14,7 +14,7 @@ public sealed class TheSortWithDefaultPriorizationMethod public void Should_Throw_If_Issues_Are_Null() { // Given - IEnumerable issues = null; + const IEnumerable issues = null; // When var result = @@ -51,7 +51,7 @@ public void Should_Order_By_Priority() }; // When - var result = issues.SortWithDefaultPriorization(); + var result = issues.SortWithDefaultPriorization().ToList(); // Then result.First().ShouldBe(issue2); @@ -59,7 +59,7 @@ public void Should_Order_By_Priority() } [Fact] - public void Should_Order_By_Existance_Of_FilePath() + public void Should_Order_By_Existence_Of_FilePath() { // Given var issue1 = @@ -83,7 +83,7 @@ public void Should_Order_By_Existance_Of_FilePath() }; // When - var result = issues.SortWithDefaultPriorization(); + var result = issues.SortWithDefaultPriorization().ToList(); // Then result.First().ShouldBe(issue2); @@ -116,7 +116,7 @@ public void Should_Order_By_FilePath() }; // When - var result = issues.SortWithDefaultPriorization(); + var result = issues.SortWithDefaultPriorization().ToList(); // Then result.First().ShouldBe(issue2); diff --git a/src/Cake.Issues.PullRequests.Tests/ISupportCheckingCommitIdExtensionsTests.cs b/src/Cake.Issues.PullRequests.Tests/ISupportCheckingCommitIdExtensionsTests.cs index d892e658b..e8c3d53a8 100644 --- a/src/Cake.Issues.PullRequests.Tests/ISupportCheckingCommitIdExtensionsTests.cs +++ b/src/Cake.Issues.PullRequests.Tests/ISupportCheckingCommitIdExtensionsTests.cs @@ -12,7 +12,7 @@ public sealed class TheIsCurrentCommitIdExtension public void Should_Throw_If_PullRequestSystem_Is_Null() { // Given - ISupportCheckingCommitId capability = null; + const ISupportCheckingCommitId capability = null; // When var result = Record.Exception(() => capability.IsCurrentCommitId(string.Empty)); @@ -31,7 +31,7 @@ public void Should_Throw_If_CommitId_Is_Null() .WithCheckingCommitIdCapability() .Create(); var capability = pullRequestSystem.CheckingCommitIdCapability; - string commitId = null; + const string commitId = null; // When var result = @@ -73,7 +73,7 @@ public void Should_Throw_If_CommitId_Is_Whitespace() .WithCheckingCommitIdCapability() .Create(); var capability = pullRequestSystem.CheckingCommitIdCapability; - var commitId = " "; + const string commitId = " "; // When var result = @@ -94,7 +94,7 @@ public void Should_Return_True_If_Commit_Is_Current() .WithCheckingCommitIdCapability() .Create(); var capability = pullRequestSystem.CheckingCommitIdCapability; - var commitId = "15c54be6435cfb6b6973896d7be79f1d9b7497a9"; + const string commitId = "15c54be6435cfb6b6973896d7be79f1d9b7497a9"; capability.LastSourceCommitId = commitId; // When @@ -114,7 +114,7 @@ public void Should_Ignore_Casing() .WithCheckingCommitIdCapability() .Create(); var capability = pullRequestSystem.CheckingCommitIdCapability; - var commitId = "15c54be6435cfb6b6973896d7be79f1d9b7497a9"; + const string commitId = "15c54be6435cfb6b6973896d7be79f1d9b7497a9"; capability.LastSourceCommitId = commitId.ToLowerInvariant(); // When @@ -134,7 +134,7 @@ public void Should_Return_False_If_Commit_Is_Different() .WithCheckingCommitIdCapability() .Create(); var capability = pullRequestSystem.CheckingCommitIdCapability; - var commitId = "15c54be6435cfb6b6973896d7be79f1d9b7497a9"; + const string commitId = "15c54be6435cfb6b6973896d7be79f1d9b7497a9"; capability.LastSourceCommitId = "9ebcec39e16c39b5ffcb10f253d0c2bcf8438cf6"; // When @@ -154,7 +154,7 @@ public void Should_Return_False_If_PullRequestSystems_Returns_Null() .WithCheckingCommitIdCapability() .Create(); var capability = pullRequestSystem.CheckingCommitIdCapability; - var commitId = "15c54be6435cfb6b6973896d7be79f1d9b7497a9"; + const string commitId = "15c54be6435cfb6b6973896d7be79f1d9b7497a9"; capability.LastSourceCommitId = null; // When @@ -174,7 +174,7 @@ public void Should_Return_False_If_PullRequestSystems_Returns_Empty_String() .WithCheckingCommitIdCapability() .Create(); var capability = pullRequestSystem.CheckingCommitIdCapability; - var commitId = "15c54be6435cfb6b6973896d7be79f1d9b7497a9"; + const string commitId = "15c54be6435cfb6b6973896d7be79f1d9b7497a9"; capability.LastSourceCommitId = string.Empty; // When @@ -194,7 +194,7 @@ public void Should_Return_False_If_PullRequestSystems_Returns_Whitespace() .WithCheckingCommitIdCapability() .Create(); var capability = pullRequestSystem.CheckingCommitIdCapability; - var commitId = "15c54be6435cfb6b6973896d7be79f1d9b7497a9"; + const string commitId = "15c54be6435cfb6b6973896d7be79f1d9b7497a9"; capability.LastSourceCommitId = " "; // When diff --git a/src/Cake.Issues.PullRequests.Tests/IssueCommentInfoTests.cs b/src/Cake.Issues.PullRequests.Tests/IssueCommentInfoTests.cs index 142c434ad..419e2c9f5 100644 --- a/src/Cake.Issues.PullRequests.Tests/IssueCommentInfoTests.cs +++ b/src/Cake.Issues.PullRequests.Tests/IssueCommentInfoTests.cs @@ -32,7 +32,7 @@ public void Should_Throw_If_Wont_Fix_Comments_Are_Null() { // Given var activeComments = new List(); - IEnumerable wontFixComments = null; + const IEnumerable wontFixComments = null; var resolvedComments = new List(); // When @@ -50,7 +50,7 @@ public void Should_Throw_If_Resolved_Comments_Are_Null() // Given var activeComments = new List(); var wontFixComments = new List(); - IEnumerable resolvedComments = null; + const IEnumerable resolvedComments = null; // When var result = diff --git a/src/Cake.Issues.PullRequests.Tests/IssueFiltererFixture.cs b/src/Cake.Issues.PullRequests.Tests/IssueFiltererFixture.cs index 5749dd5d6..433c0ea7a 100644 --- a/src/Cake.Issues.PullRequests.Tests/IssueFiltererFixture.cs +++ b/src/Cake.Issues.PullRequests.Tests/IssueFiltererFixture.cs @@ -8,7 +8,7 @@ namespace Cake.Issues.PullRequests.Tests internal class IssueFiltererFixture { public IssueFiltererFixture() - : this((builder, settings) => builder) + : this((builder, _) => builder) { } diff --git a/src/Cake.Issues.PullRequests.Tests/IssueFiltererTests.cs b/src/Cake.Issues.PullRequests.Tests/IssueFiltererTests.cs index 4345b2990..87ca76e20 100644 --- a/src/Cake.Issues.PullRequests.Tests/IssueFiltererTests.cs +++ b/src/Cake.Issues.PullRequests.Tests/IssueFiltererTests.cs @@ -112,16 +112,18 @@ public void Should_Apply_Custom_Filters() // When var issues = - fixture.FilterIssues( - new List - { - issue1, - issue2, - }, - new Dictionary()); + fixture + .FilterIssues( + new List + { + issue1, + issue2, + }, + new Dictionary()) + .ToList(); // Then - issues.Count().ShouldBe(1); + issues.Count.ShouldBe(1); issues.ShouldContain(issue1); } @@ -133,11 +135,11 @@ public void Should_Throw_If_Modified_Files_Contain_Absolute_Path() // Given var fixture = new IssueFiltererFixture( - (builder, settings) => builder + (builder, _) => builder .WithFilteringByModifiedFilesCapability( new List { - new FilePath(@"c:\FakeIssueProvider.cs"), + new (@"c:\FakeIssueProvider.cs"), })); // When @@ -155,7 +157,7 @@ public void Should_Throw_If_Modified_Files_Contain_Absolute_Path() new Dictionary())); // Then - result.IsPullRequestIssuesException(@"Absolute file paths are not suported for modified files. Path: c:/FakeIssueProvider.cs"); + result.IsPullRequestIssuesException(@"Absolute file paths are not supported for modified files. Path: c:/FakeIssueProvider.cs"); } [Fact] @@ -164,11 +166,11 @@ public void Should_Filter_Issues_If_File_Is_Not_Modified() // Given var fixture = new IssueFiltererFixture( - (builder, settings) => builder + (builder, _) => builder .WithFilteringByModifiedFilesCapability( new List { - new FilePath(@"src\Cake.Issues.Tests\FakeIssueProvider.cs"), + new (@"src\Cake.Issues.Tests\FakeIssueProvider.cs"), })); var issue1 = @@ -188,16 +190,18 @@ public void Should_Filter_Issues_If_File_Is_Not_Modified() // When var issues = - fixture.FilterIssues( - new List - { - issue1, - issue2, - }, - new Dictionary()); + fixture + .FilterIssues( + new List + { + issue1, + issue2, + }, + new Dictionary()) + .ToList(); // Then - issues.Count().ShouldBe(1); + issues.Count.ShouldBe(1); issues.ShouldContain(issue1); fixture.Log.Entries.ShouldContain(x => x.Message == "1 issue(s) were filtered because they do not belong to files that were changed in this pull request"); } @@ -228,32 +232,34 @@ public void Should_Filter_Issues_With_Existing_Active_Comment() // When var issues = - fixture.FilterIssues( - new List - { - issue1, - issue2, - }, - new Dictionary - { - { - issue1, - new IssueCommentInfo( - new List + fixture + .FilterIssues( + new List + { + issue1, + issue2, + }, + new Dictionary + { { - new PullRequestDiscussionComment - { - Content = "Message Foo", - IsDeleted = false, - }, + issue1, + new IssueCommentInfo( + new List + { + new PullRequestDiscussionComment + { + Content = "Message Foo", + IsDeleted = false, + }, + }, + new List(), + new List()) }, - new List(), - new List()) - }, - }); + }) + .ToList(); // Then - issues.Count().ShouldBe(1); + issues.Count.ShouldBe(1); issues.ShouldContain(issue2); } @@ -280,31 +286,33 @@ public void Should_Filter_Issues_With_Existing_WontFix_Comment() // When var issues = - fixture.FilterIssues( - new List - { - issue1, issue2, - }, - new Dictionary - { - { - issue1, - new IssueCommentInfo( - new List(), - new List + fixture + .FilterIssues( + new List + { + issue1, issue2, + }, + new Dictionary + { { - new PullRequestDiscussionComment - { - Content = "Message Foo", - IsDeleted = false, - }, + issue1, + new IssueCommentInfo( + new List(), + new List + { + new PullRequestDiscussionComment + { + Content = "Message Foo", + IsDeleted = false, + }, + }, + new List()) }, - new List()) - }, - }); + }) + .ToList(); // Then - issues.Count().ShouldBe(1); + issues.Count.ShouldBe(1); issues.ShouldContain(issue2); } @@ -331,31 +339,33 @@ public void Should_Filter_Issues_With_Existing_Resolved_Comment() // When var issues = - fixture.FilterIssues( - new List - { - issue1, issue2, - }, - new Dictionary - { - { - issue1, - new IssueCommentInfo( - new List(), - new List(), - new List + fixture + .FilterIssues( + new List + { + issue1, issue2, + }, + new Dictionary + { { - new PullRequestDiscussionComment - { - Content = "Message Foo", - IsDeleted = false, - }, - }) - }, - }); + issue1, + new IssueCommentInfo( + new List(), + new List(), + new List + { + new PullRequestDiscussionComment + { + Content = "Message Foo", + IsDeleted = false, + }, + }) + }, + }) + .ToList(); // Then - issues.Count().ShouldBe(1); + issues.Count.ShouldBe(1); issues.ShouldContain(issue2); } } @@ -368,8 +378,14 @@ public sealed class ForPropertyMaxIssuesToPost public void Should_Limit_Messages_To_Maximum() { // Given - var fixture = new IssueFiltererFixture(); - fixture.Settings.MaxIssuesToPost = 1; + var fixture = + new IssueFiltererFixture + { + Settings = + { + MaxIssuesToPost = 1, + }, + }; var issue1 = IssueBuilder @@ -388,15 +404,17 @@ public void Should_Limit_Messages_To_Maximum() // When var issues = - fixture.FilterIssues( - new List - { - issue1, issue2, - }, - new Dictionary()); + fixture + .FilterIssues( + new List + { + issue1, issue2, + }, + new Dictionary()) + .ToList(); // Then - issues.Count().ShouldBe(1); + issues.Count.ShouldBe(1); issues.ShouldContain(issue1); fixture.Log.Entries.ShouldContain(x => x.Message == "1 issue(s) were filtered to match the global issue limit of 1"); } @@ -405,8 +423,14 @@ public void Should_Limit_Messages_To_Maximum() public void Should_Limit_Messages_To_Maximum_By_Priority() { // Given - var fixture = new IssueFiltererFixture(); - fixture.Settings.MaxIssuesToPost = 1; + var fixture = + new IssueFiltererFixture + { + Settings = + { + MaxIssuesToPost = 1, + }, + }; var issue1 = IssueBuilder @@ -425,15 +449,17 @@ public void Should_Limit_Messages_To_Maximum_By_Priority() // When var issues = - fixture.FilterIssues( - new List - { - issue1, issue2, - }, - new Dictionary()); + fixture + .FilterIssues( + new List + { + issue1, issue2, + }, + new Dictionary()) + .ToList(); // Then - issues.Count().ShouldBe(1); + issues.Count.ShouldBe(1); issues.ShouldContain(issue2); fixture.Log.Entries.ShouldContain(x => x.Message == "1 issue(s) were filtered to match the global issue limit of 1"); } @@ -442,8 +468,14 @@ public void Should_Limit_Messages_To_Maximum_By_Priority() public void Should_Limit_Messages_To_Maximum_By_FilePath() { // Given - var fixture = new IssueFiltererFixture(); - fixture.Settings.MaxIssuesToPost = 1; + var fixture = + new IssueFiltererFixture + { + Settings = + { + MaxIssuesToPost = 1, + }, + }; var issue1 = IssueBuilder @@ -461,15 +493,17 @@ public void Should_Limit_Messages_To_Maximum_By_FilePath() // When var issues = - fixture.FilterIssues( - new List - { - issue1, issue2, - }, - new Dictionary()); + fixture + .FilterIssues( + new List + { + issue1, issue2, + }, + new Dictionary()) + .ToList(); // Then - issues.Count().ShouldBe(1); + issues.Count.ShouldBe(1); issues.ShouldContain(issue2); fixture.Log.Entries.ShouldContain(x => x.Message == "1 issue(s) were filtered to match the global issue limit of 1"); } @@ -504,48 +538,50 @@ public void Should_Limit_Messages_To_Maximum() // When var issues = - fixture.FilterIssues( - new List - { - newIssue1, newIssue2, - }, - new Dictionary(), - new List - { - new PullRequestDiscussionThread( - 1, - PullRequestDiscussionStatus.Active, - @"src\Cake.Issues.Tests\FakeIssueProvider.cs", - new List - { - new PullRequestDiscussionComment - { - Content = "Message FooBar", - IsDeleted = false, - }, - }) + fixture + .FilterIssues( + new List { - ProviderType = "ProviderType Foo", + newIssue1, newIssue2, }, - new PullRequestDiscussionThread( - 1, - PullRequestDiscussionStatus.Active, - @"src\Cake.Issues.Tests\FakeIssueProvider.cs", - new List + new Dictionary(), + new List + { + new PullRequestDiscussionThread( + 1, + PullRequestDiscussionStatus.Active, + @"src\Cake.Issues.Tests\FakeIssueProvider.cs", + new List + { + new PullRequestDiscussionComment + { + Content = "Message FooBar", + IsDeleted = false, + }, + }) { - new PullRequestDiscussionComment + ProviderType = "ProviderType Foo", + }, + new PullRequestDiscussionThread( + 1, + PullRequestDiscussionStatus.Active, + @"src\Cake.Issues.Tests\FakeIssueProvider.cs", + new List { - Content = "Message FooBar", - IsDeleted = false, - }, - }) - { - ProviderType = "ProviderType Foo", - }, - }); + new PullRequestDiscussionComment + { + Content = "Message FooBar", + IsDeleted = false, + }, + }) + { + ProviderType = "ProviderType Foo", + }, + }) + .ToList(); // Then - issues.Count().ShouldBe(1); + issues.Count.ShouldBe(1); issues.ShouldContain(newIssue2); fixture.Log.Entries.ShouldContain(x => x.Message == "1 issue(s) were filtered to match the global issue limit of 2 across all runs for provider 'ProviderType Foo' (2 issues already posted in previous runs)"); } @@ -577,48 +613,50 @@ public void Should_Limit_Messages_To_Zero() // When var issues = - fixture.FilterIssues( - new List - { - newIssue1, newIssue2, - }, - new Dictionary(), - new List - { - new PullRequestDiscussionThread( - 1, - PullRequestDiscussionStatus.Active, - @"src\Cake.Issues.Tests\FakeIssueProvider.cs", - new List - { - new PullRequestDiscussionComment - { - Content = "Message FooBar", - IsDeleted = false, - }, - }) + fixture + .FilterIssues( + new List { - ProviderType = "ProviderType Foo", + newIssue1, newIssue2, }, - new PullRequestDiscussionThread( - 1, - PullRequestDiscussionStatus.Active, - @"src\Cake.Issues.Tests\FakeIssueProvider.cs", - new List + new Dictionary(), + new List + { + new PullRequestDiscussionThread( + 1, + PullRequestDiscussionStatus.Active, + @"src\Cake.Issues.Tests\FakeIssueProvider.cs", + new List + { + new PullRequestDiscussionComment + { + Content = "Message FooBar", + IsDeleted = false, + }, + }) { - new PullRequestDiscussionComment + ProviderType = "ProviderType Foo", + }, + new PullRequestDiscussionThread( + 1, + PullRequestDiscussionStatus.Active, + @"src\Cake.Issues.Tests\FakeIssueProvider.cs", + new List { - Content = "Message FooBar", - IsDeleted = false, - }, - }) - { - ProviderType = "ProviderType Foo", - }, - }); + new PullRequestDiscussionComment + { + Content = "Message FooBar", + IsDeleted = false, + }, + }) + { + ProviderType = "ProviderType Foo", + }, + }) + .ToList(); // Then - issues.Count().ShouldBe(1); + issues.Count.ShouldBe(1); issues.ShouldContain(newIssue2); fixture.Log.Entries.ShouldContain(x => x.Message == "1 issue(s) were filtered to match the global issue limit of 0 across all runs for provider 'ProviderType Foo' (2 issues already posted in previous runs)"); } @@ -650,48 +688,50 @@ public void Should_Ignore_Limit_When_Negative() // When var issues = - fixture.FilterIssues( - new List - { - newIssue1, newIssue2, - }, - new Dictionary(), - new List - { - new PullRequestDiscussionThread( - 1, - PullRequestDiscussionStatus.Active, - @"src\Cake.Issues.Tests\FakeIssueProvider.cs", - new List - { - new PullRequestDiscussionComment - { - Content = "Message FooBar", - IsDeleted = false, - }, - }) + fixture + .FilterIssues( + new List { - ProviderType = "ProviderType Foo", + newIssue1, newIssue2, }, - new PullRequestDiscussionThread( - 1, - PullRequestDiscussionStatus.Active, - @"src\Cake.Issues.Tests\FakeIssueProvider.cs", - new List + new Dictionary(), + new List + { + new PullRequestDiscussionThread( + 1, + PullRequestDiscussionStatus.Active, + @"src\Cake.Issues.Tests\FakeIssueProvider.cs", + new List + { + new PullRequestDiscussionComment + { + Content = "Message FooBar", + IsDeleted = false, + }, + }) { - new PullRequestDiscussionComment + ProviderType = "ProviderType Foo", + }, + new PullRequestDiscussionThread( + 1, + PullRequestDiscussionStatus.Active, + @"src\Cake.Issues.Tests\FakeIssueProvider.cs", + new List { - Content = "Message FooBar", - IsDeleted = false, - }, - }) - { - ProviderType = "ProviderType Foo", - }, - }); + new PullRequestDiscussionComment + { + Content = "Message FooBar", + IsDeleted = false, + }, + }) + { + ProviderType = "ProviderType Foo", + }, + }) + .ToList(); // Then - issues.Count().ShouldBe(2); + issues.Count.ShouldBe(2); issues.ShouldContain(newIssue1); issues.ShouldContain(newIssue2); } @@ -730,33 +770,35 @@ public void Should_Limit_Messages_To_Maximum_By_Priority() // When var issues = - fixture.FilterIssues( - new List - { - issue1, issue2, issue3, - }, - new Dictionary(), - new List - { - new PullRequestDiscussionThread( - 1, - PullRequestDiscussionStatus.Active, - @"src\Cake.Issues.Tests\FakeIssueProvider.cs", - new List + fixture + .FilterIssues( + new List + { + issue1, issue2, issue3, + }, + new Dictionary(), + new List { - new PullRequestDiscussionComment + new PullRequestDiscussionThread( + 1, + PullRequestDiscussionStatus.Active, + @"src\Cake.Issues.Tests\FakeIssueProvider.cs", + new List { - Content = "Message FooBar", - IsDeleted = false, - }, + new PullRequestDiscussionComment + { + Content = "Message FooBar", + IsDeleted = false, + }, + }) + { + ProviderType = "ProviderType Foo", + }, }) - { - ProviderType = "ProviderType Foo", - }, - }); + .ToList(); // Then - issues.Count().ShouldBe(2); + issues.Count.ShouldBe(2); issues.ShouldContain(issue2); issues.ShouldContain(issue3); fixture.Log.Entries.ShouldContain(x => x.Message == "1 issue(s) were filtered to match the global issue limit of 2 across all runs for provider 'ProviderType Foo' (1 issues already posted in previous runs)"); @@ -804,33 +846,35 @@ public void Should_Limit_Messages_To_Maximum_By_FilePath() // When var issues = - fixture.FilterIssues( - new List - { - issue1, issue2, issue3, issue4, - }, - new Dictionary(), - new List - { - new PullRequestDiscussionThread( - 1, - PullRequestDiscussionStatus.Active, - @"src\Cake.Issues.Tests\FakeIssueProvider.cs", - new List + fixture + .FilterIssues( + new List + { + issue1, issue2, issue3, issue4, + }, + new Dictionary(), + new List { - new PullRequestDiscussionComment + new PullRequestDiscussionThread( + 1, + PullRequestDiscussionStatus.Active, + @"src\Cake.Issues.Tests\FakeIssueProvider.cs", + new List + { + new PullRequestDiscussionComment + { + Content = "Message FooBar", + IsDeleted = false, + }, + }) { - Content = "Message FooBar", - IsDeleted = false, + ProviderType = "ProviderType Foo", }, }) - { - ProviderType = "ProviderType Foo", - }, - }); + .ToList(); // Then - issues.Count().ShouldBe(2); + issues.Count.ShouldBe(2); issues.ShouldContain(issue2); issues.ShouldContain(issue4); fixture.Log.Entries.ShouldContain(x => x.Message == "2 issue(s) were filtered to match the global issue limit of 2 across all runs for provider 'ProviderType Foo' (1 issues already posted in previous runs)"); @@ -882,15 +926,17 @@ public void Should_Limit_Messages_To_Maximum() // When var issues = - fixture.FilterIssues( - new List - { - issue1, issue2, issue3, issue4, - }, - new Dictionary()); + fixture + .FilterIssues( + new List + { + issue1, issue2, issue3, issue4, + }, + new Dictionary()) + .ToList(); // Then - issues.Count().ShouldBe(2); + issues.Count.ShouldBe(2); issues.ShouldContain(issue1); issues.ShouldContain(issue3); @@ -941,15 +987,17 @@ public void Should_Limit_Messages_To_Zero() // When var issues = - fixture.FilterIssues( - new List - { - issue1, issue2, issue3, issue4, - }, - new Dictionary()); + fixture + .FilterIssues( + new List + { + issue1, issue2, issue3, issue4, + }, + new Dictionary()) + .ToList(); // Then - issues.Count().ShouldBe(0); + issues.Count.ShouldBe(0); fixture.Log.Entries.ShouldContain(x => x.Message == "2 issue(s) were filtered to match the global limit of 0 issues which should be reported for issue provider 'ProviderTypeA'"); fixture.Log.Entries.ShouldContain(x => x.Message == "2 issue(s) were filtered to match the global limit of 0 issues which should be reported for issue provider 'ProviderTypeB'"); @@ -998,15 +1046,17 @@ public void Should_Ignore_Limit_When_Negative() // When var issues = - fixture.FilterIssues( - new List - { - issue1, issue2, issue3, issue4, - }, - new Dictionary()); + fixture + .FilterIssues( + new List + { + issue1, issue2, issue3, issue4, + }, + new Dictionary()) + .ToList(); // Then - issues.Count().ShouldBe(4); + issues.Count.ShouldBe(4); issues.ShouldContain(issue1); issues.ShouldContain(issue2); issues.ShouldContain(issue3); @@ -1056,15 +1106,17 @@ public void Should_Limit_Messages_To_Maximum_By_Priority() // When var issues = - fixture.FilterIssues( - new List - { - issue1, issue2, issue3, issue4, - }, - new Dictionary()); + fixture + .FilterIssues( + new List + { + issue1, issue2, issue3, issue4, + }, + new Dictionary()) + .ToList(); // Then - issues.Count().ShouldBe(2); + issues.Count.ShouldBe(2); issues.ShouldContain(issue2); issues.ShouldContain(issue3); fixture.Log.Entries.ShouldContain(x => x.Message == "1 issue(s) were filtered to match the global limit of 1 issues which should be reported for issue provider 'ProviderTypeA'"); @@ -1112,15 +1164,17 @@ public void Should_Limit_Messages_To_Maximum_By_FilePath() // When var issues = - fixture.FilterIssues( - new List - { - issue1, issue2, issue3, issue4, - }, - new Dictionary()); + fixture + .FilterIssues( + new List + { + issue1, issue2, issue3, issue4, + }, + new Dictionary()) + .ToList(); // Then - issues.Count().ShouldBe(2); + issues.Count.ShouldBe(2); issues.ShouldContain(issue2); issues.ShouldContain(issue3); fixture.Log.Entries.ShouldContain(x => x.Message == "1 issue(s) were filtered to match the global limit of 1 issues which should be reported for issue provider 'ProviderTypeA'"); @@ -1205,15 +1259,17 @@ public void Should_Limit_Messages_To_Maximum_With_Different_Maximum_Limits() // When var issues = - fixture.FilterIssues( - new List - { - issue1, issue2, issue3, issue4, issue5, issue6, issue7, issue8, issue9, - }, - new Dictionary()); + fixture + .FilterIssues( + new List + { + issue1, issue2, issue3, issue4, issue5, issue6, issue7, issue8, issue9, + }, + new Dictionary()) + .ToList(); // Then - issues.Count().ShouldBe(4); + issues.Count.ShouldBe(4); fixture.Log.Entries.ShouldContain(x => x.Message == "1 issue(s) were filtered to match the global limit of 1 issues which should be reported for issue provider 'ProviderTypeA'"); fixture.Log.Entries.ShouldContain(x => x.Message == "4 issue(s) were filtered to match the global limit of 3 issues which should be reported for issue provider 'ProviderTypeB'"); @@ -1226,8 +1282,14 @@ public sealed class ForPropertyMaxIssuesToPostAcrossRuns public void Should_Limit_Messages_To_Maximum() { // Given - var fixture = new IssueFiltererFixture(); - fixture.Settings.MaxIssuesToPostAcrossRuns = 2; + var fixture = + new IssueFiltererFixture + { + Settings = + { + MaxIssuesToPostAcrossRuns = 2, + }, + }; var issue1 = IssueBuilder @@ -1246,30 +1308,32 @@ public void Should_Limit_Messages_To_Maximum() // When var issues = - fixture.FilterIssues( - new List - { - issue1, issue2, - }, - new Dictionary(), - new List - { - new PullRequestDiscussionThread( - 1, - PullRequestDiscussionStatus.Active, - @"src\Cake.Issues.Tests\FakeIssueProvider.cs", - new List + fixture + .FilterIssues( + new List + { + issue1, issue2, + }, + new Dictionary(), + new List { - new PullRequestDiscussionComment + new PullRequestDiscussionThread( + 1, + PullRequestDiscussionStatus.Active, + @"src\Cake.Issues.Tests\FakeIssueProvider.cs", + new List { - Content = "Message FooBar", - IsDeleted = false, - }, - }), - }); + new PullRequestDiscussionComment + { + Content = "Message FooBar", + IsDeleted = false, + }, + }), + }) + .ToList(); // Then - issues.Count().ShouldBe(1); + issues.Count.ShouldBe(1); issues.ShouldContain(issue1); fixture.Log.Entries.ShouldContain(x => x.Message == "1 issue(s) were filtered to match the global issue limit of 2 across all runs (1 issues already posted in previous runs)"); } @@ -1278,8 +1342,14 @@ public void Should_Limit_Messages_To_Maximum() public void Should_Limit_Messages_To_Maximum_By_Priority() { // Given - var fixture = new IssueFiltererFixture(); - fixture.Settings.MaxIssuesToPostAcrossRuns = 2; + var fixture = + new IssueFiltererFixture + { + Settings = + { + MaxIssuesToPostAcrossRuns = 2, + }, + }; var issue1 = IssueBuilder @@ -1298,30 +1368,32 @@ public void Should_Limit_Messages_To_Maximum_By_Priority() // When var issues = - fixture.FilterIssues( - new List - { - issue1, issue2, - }, - new Dictionary(), - new List - { - new PullRequestDiscussionThread( - 1, - PullRequestDiscussionStatus.Active, - @"src\Cake.Issues.Tests\FakeIssueProvider.cs", - new List + fixture + .FilterIssues( + new List + { + issue1, issue2, + }, + new Dictionary(), + new List { - new PullRequestDiscussionComment + new PullRequestDiscussionThread( + 1, + PullRequestDiscussionStatus.Active, + @"src\Cake.Issues.Tests\FakeIssueProvider.cs", + new List { - Content = "Message FooBar", - IsDeleted = false, - }, - }), - }); + new PullRequestDiscussionComment + { + Content = "Message FooBar", + IsDeleted = false, + }, + }), + }) + .ToList(); // Then - issues.Count().ShouldBe(1); + issues.Count.ShouldBe(1); issues.ShouldContain(issue2); fixture.Log.Entries.ShouldContain(x => x.Message == "1 issue(s) were filtered to match the global issue limit of 2 across all runs (1 issues already posted in previous runs)"); } @@ -1330,8 +1402,14 @@ public void Should_Limit_Messages_To_Maximum_By_Priority() public void Should_Limit_Messages_To_Maximum_By_FilePath() { // Given - var fixture = new IssueFiltererFixture(); - fixture.Settings.MaxIssuesToPostAcrossRuns = 2; + var fixture = + new IssueFiltererFixture + { + Settings = + { + MaxIssuesToPostAcrossRuns = 2, + }, + }; var issue1 = IssueBuilder @@ -1349,30 +1427,32 @@ public void Should_Limit_Messages_To_Maximum_By_FilePath() // When var issues = - fixture.FilterIssues( - new List - { - issue1, issue2, - }, - new Dictionary(), - new List - { - new PullRequestDiscussionThread( - 1, - PullRequestDiscussionStatus.Active, - @"src\Cake.Issues.Tests\FakeIssueProvider.cs", - new List + fixture + .FilterIssues( + new List + { + issue1, issue2, + }, + new Dictionary(), + new List { - new PullRequestDiscussionComment + new PullRequestDiscussionThread( + 1, + PullRequestDiscussionStatus.Active, + @"src\Cake.Issues.Tests\FakeIssueProvider.cs", + new List { - Content = "Message FooBar", - IsDeleted = false, - }, - }), - }); + new PullRequestDiscussionComment + { + Content = "Message FooBar", + IsDeleted = false, + }, + }), + }) + .ToList(); // Then - issues.Count().ShouldBe(1); + issues.Count.ShouldBe(1); issues.ShouldContain(issue2); fixture.Log.Entries.ShouldContain(x => x.Message == "1 issue(s) were filtered to match the global issue limit of 2 across all runs (1 issues already posted in previous runs)"); } @@ -1384,8 +1464,14 @@ public sealed class ForPropertyMaxIssuesToPostForEachIssueProvider public void Should_Limit_Messages_To_Maximum() { // Given - var fixture = new IssueFiltererFixture(); - fixture.Settings.MaxIssuesToPostForEachIssueProvider = 1; + var fixture = + new IssueFiltererFixture + { + Settings = + { + MaxIssuesToPostForEachIssueProvider = 1, + }, + }; var issue1 = IssueBuilder @@ -1418,15 +1504,17 @@ public void Should_Limit_Messages_To_Maximum() // When var issues = - fixture.FilterIssues( - new List - { - issue1, issue2, issue3, issue4, - }, - new Dictionary()); + fixture + .FilterIssues( + new List + { + issue1, issue2, issue3, issue4, + }, + new Dictionary()) + .ToList(); // Then - issues.Count().ShouldBe(2); + issues.Count.ShouldBe(2); issues.ShouldContain(issue1); issues.ShouldContain(issue3); fixture.Log.Entries.ShouldContain(x => x.Message == "1 issue(s) of type ProviderTypeA were filtered to match the maximum of 1 issues which should be reported for each issue provider"); @@ -1437,8 +1525,14 @@ public void Should_Limit_Messages_To_Maximum() public void Should_Limit_Messages_To_Maximum_By_Priority() { // Given - var fixture = new IssueFiltererFixture(); - fixture.Settings.MaxIssuesToPostForEachIssueProvider = 1; + var fixture = + new IssueFiltererFixture + { + Settings = + { + MaxIssuesToPostForEachIssueProvider = 1, + }, + }; var issue1 = IssueBuilder @@ -1471,15 +1565,17 @@ public void Should_Limit_Messages_To_Maximum_By_Priority() // When var issues = - fixture.FilterIssues( - new List - { - issue1, issue2, issue3, issue4, - }, - new Dictionary()); + fixture + .FilterIssues( + new List + { + issue1, issue2, issue3, issue4, + }, + new Dictionary()) + .ToList(); // Then - issues.Count().ShouldBe(2); + issues.Count.ShouldBe(2); issues.ShouldContain(issue2); issues.ShouldContain(issue3); fixture.Log.Entries.ShouldContain(x => x.Message == "1 issue(s) of type ProviderTypeA were filtered to match the maximum of 1 issues which should be reported for each issue provider"); @@ -1490,8 +1586,14 @@ public void Should_Limit_Messages_To_Maximum_By_Priority() public void Should_Limit_Messages_To_Maximum_By_FilePath() { // Given - var fixture = new IssueFiltererFixture(); - fixture.Settings.MaxIssuesToPostForEachIssueProvider = 1; + var fixture = + new IssueFiltererFixture + { + Settings = + { + MaxIssuesToPostForEachIssueProvider = 1, + }, + }; var issue1 = IssueBuilder @@ -1522,15 +1624,17 @@ public void Should_Limit_Messages_To_Maximum_By_FilePath() // When var issues = - fixture.FilterIssues( - new List - { - issue1, issue2, issue3, issue4, - }, - new Dictionary()); + fixture + .FilterIssues( + new List + { + issue1, issue2, issue3, issue4, + }, + new Dictionary()) + .ToList(); // Then - issues.Count().ShouldBe(2); + issues.Count.ShouldBe(2); issues.ShouldContain(issue2); issues.ShouldContain(issue3); fixture.Log.Entries.ShouldContain(x => x.Message == "1 issue(s) of type ProviderTypeA were filtered to match the maximum of 1 issues which should be reported for each issue provider"); diff --git a/src/Cake.Issues.PullRequests.Tests/OrchestratorForIssueProvidersFixture.cs b/src/Cake.Issues.PullRequests.Tests/OrchestratorForIssueProvidersFixture.cs index 5b5f52bb7..26c4079f2 100644 --- a/src/Cake.Issues.PullRequests.Tests/OrchestratorForIssueProvidersFixture.cs +++ b/src/Cake.Issues.PullRequests.Tests/OrchestratorForIssueProvidersFixture.cs @@ -9,7 +9,7 @@ namespace Cake.Issues.PullRequests.Tests internal class OrchestratorForIssueProvidersFixture { public OrchestratorForIssueProvidersFixture() - : this((builder, settings) => builder) + : this((builder, _) => builder) { } @@ -20,7 +20,7 @@ public OrchestratorForIssueProvidersFixture( this.Log = new FakeLog { Verbosity = Verbosity.Normal }; - this.IssueProviders = new List { new FakeIssueProvider(this.Log) }; + this.IssueProviders = new List { new (this.Log) }; this.Settings = new ReportIssuesToPullRequestFromIssueProviderSettings( diff --git a/src/Cake.Issues.PullRequests.Tests/OrchestratorForIssuesFixture.cs b/src/Cake.Issues.PullRequests.Tests/OrchestratorForIssuesFixture.cs index 5d5a4fcff..5549f311e 100644 --- a/src/Cake.Issues.PullRequests.Tests/OrchestratorForIssuesFixture.cs +++ b/src/Cake.Issues.PullRequests.Tests/OrchestratorForIssuesFixture.cs @@ -8,7 +8,7 @@ namespace Cake.Issues.PullRequests.Tests internal class OrchestratorForIssuesFixture { public OrchestratorForIssuesFixture() - : this((builder, settings) => builder) + : this((builder, _) => builder) { } diff --git a/src/Cake.Issues.PullRequests.Tests/OrchestratorTests.cs b/src/Cake.Issues.PullRequests.Tests/OrchestratorTests.cs index 3cba57eae..52fd5c004 100644 --- a/src/Cake.Issues.PullRequests.Tests/OrchestratorTests.cs +++ b/src/Cake.Issues.PullRequests.Tests/OrchestratorTests.cs @@ -33,7 +33,7 @@ public void Should_Throw_If_Issues_Are_Null() { // Given var fixture = new OrchestratorForIssuesFixture(); - List issues = null; + const List issues = null; // When var result = Record.Exception(() => fixture.RunOrchestrator(issues)); @@ -360,8 +360,14 @@ public void Should_Return_Reported_Issues_If_PullRequestSystem_Could_Not_Be_Init .WithPriority(IssuePriority.Warning) .Create(); - var fixture = new OrchestratorForIssueProvidersFixture(); - fixture.PullRequestSystem.ShouldFailOnInitialization = true; + var fixture = + new OrchestratorForIssueProvidersFixture + { + PullRequestSystem = + { + ShouldFailOnInitialization = true, + }, + }; fixture.IssueProviders.Clear(); fixture.IssueProviders.Add( @@ -992,7 +998,7 @@ public void Should_Skip_Posting_If_Commit_Is_Outdate() var fixture = new OrchestratorForIssueProvidersFixture( - (builder, settings) => builder + (builder, _) => builder .WithCheckingCommitIdCapability()); fixture.IssueProviders.Clear(); @@ -1041,7 +1047,7 @@ public void Should_Limit_Messages_To_Maximum_Across_Runs() var fixture = new OrchestratorForIssueProvidersFixture( - (builder, settings) => builder + (builder, _) => builder .WithDiscussionThreadsCapability( new List())); @@ -1088,7 +1094,7 @@ public void Should_Limit_Messages_To_Maximum_Across_Runs_By_Priority() var fixture = new OrchestratorForIssueProvidersFixture( - (builder, settings) => builder + (builder, _) => builder .WithDiscussionThreadsCapability( new List())); @@ -1135,7 +1141,7 @@ public void Should_Limit_Messages_To_Maximum_Across_Runs_By_FilePath() var fixture = new OrchestratorForIssueProvidersFixture( - (builder, settings) => builder + (builder, _) => builder .WithDiscussionThreadsCapability( new List())); @@ -1190,7 +1196,7 @@ public void Should_Limit_Messages_To_Maximum_Across_Runs_With_Unresolved_Issues_ var fixture = new OrchestratorForIssueProvidersFixture( - (builder, settings) => builder + (builder, _) => builder .WithDiscussionThreadsCapability( new List { @@ -1269,7 +1275,7 @@ public void Should_Limit_Messages_To_Maximum_Across_Runs_With_Unresolved_Issues_ var fixture = new OrchestratorForIssueProvidersFixture( - (builder, settings) => builder + (builder, _) => builder .WithDiscussionThreadsCapability( new List { @@ -1336,7 +1342,7 @@ public void Should_Limit_Messages_To_Maximum_Across_Runs_With_Resolved_Issues_Fr var fixture = new OrchestratorForIssueProvidersFixture( - (builder, settings) => builder + (builder, _) => builder .WithDiscussionThreadsCapability( new List { @@ -1407,7 +1413,7 @@ public void Should_Limit_Messages_To_Maximum_Across_Runs_For_A_Specific_Provider var fixture = new OrchestratorForIssueProvidersFixture( - (builder, settings) => builder + (builder, _) => builder .WithDiscussionThreadsCapability( new List())); @@ -1456,7 +1462,7 @@ public void Should_Limit_Messages_To_Maximum_Across_Runs_For_A_Specific_Provider var fixture = new OrchestratorForIssueProvidersFixture( - (builder, settings) => builder + (builder, _) => builder .WithDiscussionThreadsCapability( new List())); @@ -1513,7 +1519,7 @@ public void Should_Limit_Messages_To_Maximum_Across_Runs_For_A_Specific_Provider var fixture = new OrchestratorForIssueProvidersFixture( - (builder, settings) => builder + (builder, _) => builder .WithDiscussionThreadsCapability( new List())); @@ -1570,7 +1576,7 @@ public void Should_Limit_Messages_To_Maximum_Across_Runs_For_A_Specific_Provider var fixture = new OrchestratorForIssueProvidersFixture( - (builder, settings) => builder + (builder, _) => builder .WithDiscussionThreadsCapability( new List { @@ -1653,7 +1659,7 @@ public void Should_Limit_Messages_To_Maximum_Across_Runs_For_A_Specific_Provider var fixture = new OrchestratorForIssueProvidersFixture( - (builder, settings) => builder + (builder, _) => builder .WithDiscussionThreadsCapability( new List { @@ -1725,7 +1731,7 @@ public void Should_Limit_Messages_To_Maximum_Across_Runs_For_A_Specific_Provider var fixture = new OrchestratorForIssueProvidersFixture( - (builder, settings) => builder + (builder, _) => builder .WithDiscussionThreadsCapability( new List { @@ -1998,7 +2004,7 @@ public void Should_Only_Ignore_Issues_With_Same_Comment_Source() var fixture = new OrchestratorForIssueProvidersFixture( - (builder, settings) => builder + (builder, _) => builder .WithDiscussionThreadsCapability( new List { @@ -2106,7 +2112,7 @@ public void Should_Only_Resolve_Issues_From_Same_Comment_Source() // Given var fixture = new OrchestratorForIssueProvidersFixture( - (builder, settings) => builder + (builder, _) => builder .WithDiscussionThreadsCapability( new List { @@ -2209,7 +2215,7 @@ public void Should_Only_Reopen_Still_Active_Issues_From_Same_Comment_Source() // Given var fixture = new OrchestratorForIssueProvidersFixture( - (builder, settings) => builder + (builder, _) => builder .WithDiscussionThreadsCapability( new List { @@ -2259,7 +2265,7 @@ public void Should_Not_Throw_If_No_Existing_Threads() // Given var fixture = new OrchestratorForIssueProvidersFixture( - (builder, settings) => builder + (builder, _) => builder .WithDiscussionThreadsCapability( new List())); @@ -2281,8 +2287,8 @@ public void Should_Not_Throw_If_No_Existing_Threads() fixture.RunOrchestrator(); // Then - fixture.Log.Entries.ShouldContain(x => x.Message == "No existings threads to resolve."); - fixture.Log.Entries.ShouldContain(x => x.Message == "No existings threads to reopen."); + fixture.Log.Entries.ShouldContain(x => x.Message == "No existing threads to resolve."); + fixture.Log.Entries.ShouldContain(x => x.Message == "No existing threads to reopen."); } [Fact] @@ -2291,7 +2297,7 @@ public void Should_Output_A_Warning_If_Unknown_Thread_Status() // Given var fixture = new OrchestratorForIssueProvidersFixture( - (builder, settings) => builder + (builder, _) => builder .WithDiscussionThreadsCapability( new List { @@ -2357,11 +2363,11 @@ public void Should_Ignore_Issues_If_File_Is_Not_Modified() var fixture = new OrchestratorForIssueProvidersFixture( - (builder, settings) => builder + (builder, _) => builder .WithFilteringByModifiedFilesCapability( new List { - new FilePath(@"src\Cake.Issues.Tests\FakeIssueProvider.cs"), + new (@"src\Cake.Issues.Tests\FakeIssueProvider.cs"), })); fixture.IssueProviders.Clear(); @@ -2397,7 +2403,7 @@ public void Should_Log_Message_If_All_Issues_Are_Filtered() // Given var fixture = new OrchestratorForIssueProvidersFixture( - (builder, settings) => builder + (builder, _) => builder .WithFilteringByModifiedFilesCapability( new List())); diff --git a/src/Cake.Issues.PullRequests.Tests/PullRequestIssueResultTests.cs b/src/Cake.Issues.PullRequests.Tests/PullRequestIssueResultTests.cs index d2a85eac3..d95dd570b 100644 --- a/src/Cake.Issues.PullRequests.Tests/PullRequestIssueResultTests.cs +++ b/src/Cake.Issues.PullRequests.Tests/PullRequestIssueResultTests.cs @@ -13,7 +13,7 @@ public sealed class TheCtor public void Should_Throw_If_ReportedIssues_Is_Null() { // Given - IEnumerable reportedIssues = null; + const IEnumerable reportedIssues = null; IEnumerable postedIssues = new List(); // When @@ -28,7 +28,7 @@ public void Should_Throw_If_PostedIssues_Is_Null() { // Given IEnumerable reportedIssues = new List(); - IEnumerable postedIssues = null; + const IEnumerable postedIssues = null; // When var result = Record.Exception(() => new PullRequestIssueResult(reportedIssues, postedIssues)); diff --git a/src/Cake.Issues.PullRequests.Tests/ReportIssuesToPullRequestSettingsTests.cs b/src/Cake.Issues.PullRequests.Tests/ReportIssuesToPullRequestSettingsTests.cs index c3c4a3743..63ae26dc9 100644 --- a/src/Cake.Issues.PullRequests.Tests/ReportIssuesToPullRequestSettingsTests.cs +++ b/src/Cake.Issues.PullRequests.Tests/ReportIssuesToPullRequestSettingsTests.cs @@ -13,7 +13,7 @@ public sealed class TheCtor public void Should_Throw_If_RepositoryRoot_Is_Null() { // Given - DirectoryPath repoRoot = null; + const DirectoryPath repoRoot = null; // When var result = Record.Exception(() => new ReportIssuesToPullRequestSettings(repoRoot)); diff --git a/src/Cake.Issues.PullRequests/BaseDiscussionThreadsCapability.cs b/src/Cake.Issues.PullRequests/BaseDiscussionThreadsCapability.cs index ef347a9e3..52f9090c0 100644 --- a/src/Cake.Issues.PullRequests/BaseDiscussionThreadsCapability.cs +++ b/src/Cake.Issues.PullRequests/BaseDiscussionThreadsCapability.cs @@ -49,7 +49,7 @@ public void ReopenDiscussionThreads(IEnumerable th /// Returns a list of all discussion threads. /// Compared to it is safe to access Settings from this method. /// - /// Value used to indicate threads created by this addin. + /// Value used to indicate threads created by this add-in. /// List of all discussion threads. protected abstract IEnumerable InternalFetchDiscussionThreads(string commentSource); diff --git a/src/Cake.Issues.PullRequests/BasePullRequestSystem.cs b/src/Cake.Issues.PullRequests/BasePullRequestSystem.cs index dc9f8d369..cd4ae0cb0 100644 --- a/src/Cake.Issues.PullRequests/BasePullRequestSystem.cs +++ b/src/Cake.Issues.PullRequests/BasePullRequestSystem.cs @@ -56,7 +56,7 @@ public void PostDiscussionThreads(IEnumerable issues, string commentSour /// Compared to it is safe to access Settings from this method. /// /// Issues which need to be posted. - /// Value used to decorate comments created by this addin. + /// Value used to decorate comments created by this add-in. protected abstract void InternalPostDiscussionThreads(IEnumerable issues, string commentSource); } } diff --git a/src/Cake.Issues.PullRequests/IPullRequestDiscussionThread.cs b/src/Cake.Issues.PullRequests/IPullRequestDiscussionThread.cs index 30611b7bf..5d4ff5073 100644 --- a/src/Cake.Issues.PullRequests/IPullRequestDiscussionThread.cs +++ b/src/Cake.Issues.PullRequests/IPullRequestDiscussionThread.cs @@ -19,7 +19,7 @@ public interface IPullRequestDiscussionThread PullRequestDiscussionStatus Status { get; set; } /// - /// Gets or sets the resolution of the thred if is . + /// Gets or sets the resolution of the thread if is . /// PullRequestDiscussionResolution Resolution { get; set; } @@ -31,7 +31,7 @@ public interface IPullRequestDiscussionThread FilePath AffectedFileRelativePath { get; set; } /// - /// Gets or sets a value used to decorate comments created by this addin. + /// Gets or sets a value used to decorate comments created by this add-in. /// string CommentSource { get; set; } diff --git a/src/Cake.Issues.PullRequests/IPullRequestSystem.cs b/src/Cake.Issues.PullRequests/IPullRequestSystem.cs index 6b468c75f..04dad69d8 100644 --- a/src/Cake.Issues.PullRequests/IPullRequestSystem.cs +++ b/src/Cake.Issues.PullRequests/IPullRequestSystem.cs @@ -33,7 +33,7 @@ T GetCapability() /// Posts discussion threads for all issues which need to be posted. /// /// Issues which need to be posted. - /// Value used to decorate comments created by this addin. + /// Value used to decorate comments created by this add-in. void PostDiscussionThreads(IEnumerable issues, string commentSource); } } diff --git a/src/Cake.Issues.PullRequests/IReportIssuesToPullRequestSettings.cs b/src/Cake.Issues.PullRequests/IReportIssuesToPullRequestSettings.cs index 7b987ef57..66478cea2 100644 --- a/src/Cake.Issues.PullRequests/IReportIssuesToPullRequestSettings.cs +++ b/src/Cake.Issues.PullRequests/IReportIssuesToPullRequestSettings.cs @@ -52,7 +52,7 @@ public interface IReportIssuesToPullRequestSettings : IRepositorySettings Dictionary ProviderIssueLimits { get; } /// - /// Gets or sets a value used to decorate comments created by this addin. + /// Gets or sets a value used to decorate comments created by this add-in. /// Only comments with the same source will be resolved. /// string CommentSource { get; set; } diff --git a/src/Cake.Issues.PullRequests/ISupportCheckingCommitId.cs b/src/Cake.Issues.PullRequests/ISupportCheckingCommitId.cs index 80ddf89b7..1c83c87ac 100644 --- a/src/Cake.Issues.PullRequests/ISupportCheckingCommitId.cs +++ b/src/Cake.Issues.PullRequests/ISupportCheckingCommitId.cs @@ -1,7 +1,5 @@ namespace Cake.Issues.PullRequests { - using System.Collections.Generic; - /// /// Interface describing that a pull request system supports checking if commit Id is still up to date. /// diff --git a/src/Cake.Issues.PullRequests/ISupportDiscussionThreads.cs b/src/Cake.Issues.PullRequests/ISupportDiscussionThreads.cs index bfa548244..1ab4ecca6 100644 --- a/src/Cake.Issues.PullRequests/ISupportDiscussionThreads.cs +++ b/src/Cake.Issues.PullRequests/ISupportDiscussionThreads.cs @@ -11,7 +11,7 @@ public interface ISupportDiscussionThreads /// /// Returns a list of all discussion threads. /// - /// Value used to indicate threads created by this addin. + /// Value used to indicate threads created by this add-in. /// List of all discussion threads. IEnumerable FetchDiscussionThreads(string commentSource); diff --git a/src/Cake.Issues.PullRequests/ISupportFilteringByModifiedFiles.cs b/src/Cake.Issues.PullRequests/ISupportFilteringByModifiedFiles.cs index e3850289f..d78c72a1f 100644 --- a/src/Cake.Issues.PullRequests/ISupportFilteringByModifiedFiles.cs +++ b/src/Cake.Issues.PullRequests/ISupportFilteringByModifiedFiles.cs @@ -1,7 +1,6 @@ namespace Cake.Issues.PullRequests { using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; using Cake.Core.IO; /// diff --git a/src/Cake.Issues.PullRequests/IssueFilterer.cs b/src/Cake.Issues.PullRequests/IssueFilterer.cs index 3b49090b8..b6f55096e 100644 --- a/src/Cake.Issues.PullRequests/IssueFilterer.cs +++ b/src/Cake.Issues.PullRequests/IssueFilterer.cs @@ -108,7 +108,7 @@ private static void ValidateModifiedFiles(IEnumerable modifiedFilePath foreach (var filePath in modifiedFilePaths.Where(x => !x.IsRelative)) { throw new PullRequestIssuesException( - $"Absolute file paths are not suported for modified files. Path: {filePath}"); + $"Absolute file paths are not supported for modified files. Path: {filePath}"); } } @@ -217,7 +217,7 @@ private IList FilterIssuesByNumber( var stopwatch = new Stopwatch(); stopwatch.Start(); - int totalIssuesFilteredCount = 0; + var totalIssuesFilteredCount = 0; // Apply issue limits per issue provider var result = new List(); @@ -229,8 +229,9 @@ private IList FilterIssuesByNumber( var issuesFiltered = group .SortWithDefaultPriorization() - .Take(this.settings.MaxIssuesToPostForEachIssueProvider.Value); - var issuesFilteredCount = countBefore - issuesFiltered.Count(); + .Take(this.settings.MaxIssuesToPostForEachIssueProvider.Value) + .ToList(); + var issuesFilteredCount = countBefore - issuesFiltered.Count; totalIssuesFilteredCount += issuesFilteredCount; this.log.Information( @@ -315,20 +316,18 @@ private IList FilterIssuesByNumber( this.settings.MaxIssuesToPost); } - // Apply issue limits per provider across mulitple runs - foreach (var currentProviderLimitPair in this.settings.ProviderIssueLimits) + // Apply issue limits per provider across multiple runs + foreach (var (currentProviderType, value) in this.settings.ProviderIssueLimits) { - var currentProviderType = currentProviderLimitPair.Key; - this.log.Verbose( - "Applying filter for issue provider '{0}' across mulitple runs...", + "Applying filter for issue provider '{0}' across multiple runs...", currentProviderType); - var currentProviderTypeMaxLimit = currentProviderLimitPair.Value?.MaxIssuesToPostAcrossRuns; + var currentProviderTypeMaxLimit = value?.MaxIssuesToPostAcrossRuns; if (!currentProviderTypeMaxLimit.HasValue) { this.log.Verbose( - "No issues filtered for issue provider '{0}' across mulitple runs since `MaxIssuesToPostAcrossRuns` is not set", + "No issues filtered for issue provider '{0}' across multiple runs since `MaxIssuesToPostAcrossRuns` is not set", currentProviderType); continue; } @@ -336,7 +335,7 @@ private IList FilterIssuesByNumber( if (currentProviderTypeMaxLimit < 0) { this.log.Verbose( - "No issues filtered for issue provider '{0}' across mulitple runs since `MaxIssuesToPostAcrossRuns` is not set", + "No issues filtered for issue provider '{0}' across multiple runs since `MaxIssuesToPostAcrossRuns` is not set", currentProviderType); continue; } @@ -358,7 +357,7 @@ private IList FilterIssuesByNumber( if (newIssuesForProviderType.Length <= maxIssuesLeftToTakeForProviderType) { this.log.Verbose( - "No issues filtered for issue provider '{0}' across mulitple runs since number of issues of this type is '{1}' which is less or equal to the value '{2}' configured in `MaxIssuesToPostAcrossRuns`", + "No issues filtered for issue provider '{0}' across multiple runs since number of issues of this type is '{1}' which is less or equal to the value '{2}' configured in `MaxIssuesToPostAcrossRuns`", currentProviderType, newIssuesForProviderType.Length, maxIssuesLeftToTakeForProviderType); diff --git a/src/Cake.Issues.PullRequests/Orchestrator.cs b/src/Cake.Issues.PullRequests/Orchestrator.cs index e37417716..ec220ad9e 100644 --- a/src/Cake.Issues.PullRequests/Orchestrator.cs +++ b/src/Cake.Issues.PullRequests/Orchestrator.cs @@ -76,10 +76,11 @@ public PullRequestIssueResult Run( return new PullRequestIssueResult(issues, new List()); } - this.log.Information("Processing {0} new issues", issues.Count()); - var postedIssues = this.PostAndResolveComments(settings, issues.ToList()); + var issuesList = issues.ToList(); + this.log.Information("Processing {0} new issues", issuesList.Count); + var postedIssues = this.PostAndResolveComments(settings, issuesList); - return new PullRequestIssueResult(issues, postedIssues); + return new PullRequestIssueResult(issuesList, postedIssues); } /// @@ -249,17 +250,23 @@ private IDictionary GetCommentsForIssue( issue, existingThreads); - if (activeComments.Any() || - wontFixComments.Any() || - resolvedComments.Any()) + var activeCommentsList = activeComments.ToList(); + var wontFixCommentsList = wontFixComments.ToList(); + var resolvedCommentsList = resolvedComments.ToList(); + + if (!activeCommentsList.Any() && + !wontFixCommentsList.Any() && + !resolvedCommentsList.Any()) { - var issueCommentInfo = - new IssueCommentInfo( - activeComments, - wontFixComments, - resolvedComments); - threadsWithIssues.Add(issue, issueCommentInfo); + continue; } + + var issueCommentInfo = + new IssueCommentInfo( + activeCommentsList, + wontFixCommentsList, + resolvedCommentsList); + threadsWithIssues.Add(issue, issueCommentInfo); } this.log.Verbose("Built a issue to comment dictionary in {0} ms", stopwatch.ElapsedMilliseconds); @@ -314,8 +321,7 @@ private IDictionary GetCommentsForIssue( var matchingComments = (from comment in thread.Comments where - comment != null && - !comment.IsDeleted + comment is { IsDeleted: false } select comment).ToList(); @@ -374,7 +380,7 @@ private void ResolveExistingComments( if (!existingThreads.Any()) { - this.log.Verbose("No existings threads to resolve."); + this.log.Verbose("No existing threads to resolve."); return; } @@ -438,7 +444,7 @@ private void ReopenExistingComments( if (!existingThreads.Any()) { - this.log.Verbose("No existings threads to reopen."); + this.log.Verbose("No existing threads to reopen."); return; } diff --git a/src/Cake.Issues.PullRequests/ReportIssuesToPullRequestFromIssueProviderSettings.cs b/src/Cake.Issues.PullRequests/ReportIssuesToPullRequestFromIssueProviderSettings.cs index d5b348c27..235f944de 100644 --- a/src/Cake.Issues.PullRequests/ReportIssuesToPullRequestFromIssueProviderSettings.cs +++ b/src/Cake.Issues.PullRequests/ReportIssuesToPullRequestFromIssueProviderSettings.cs @@ -30,8 +30,7 @@ public ReportIssuesToPullRequestFromIssueProviderSettings(DirectoryPath reposito public int? MaxIssuesToPostAcrossRuns { get; set; } /// - public Dictionary ProviderIssueLimits { get; } = - new Dictionary(); + public Dictionary ProviderIssueLimits { get; } = new (); /// public int? MaxIssuesToPostForEachIssueProvider { get; set; } = 100; diff --git a/src/Cake.Issues.PullRequests/ReportIssuesToPullRequestSettings.cs b/src/Cake.Issues.PullRequests/ReportIssuesToPullRequestSettings.cs index cf67046be..8115696dc 100644 --- a/src/Cake.Issues.PullRequests/ReportIssuesToPullRequestSettings.cs +++ b/src/Cake.Issues.PullRequests/ReportIssuesToPullRequestSettings.cs @@ -33,8 +33,7 @@ public ReportIssuesToPullRequestSettings(DirectoryPath repositoryRoot) public int? MaxIssuesToPostForEachIssueProvider { get; set; } = 100; /// - public Dictionary ProviderIssueLimits { get; } = - new Dictionary(); + public Dictionary ProviderIssueLimits { get; } = new (); /// public string CommentSource { get; set; } = "CakeIssues"; diff --git a/src/Cake.Issues.Reporting.Tests/CreateIssueReportSettingsTests.cs b/src/Cake.Issues.Reporting.Tests/CreateIssueReportSettingsTests.cs index 793a6dba5..30a140c26 100644 --- a/src/Cake.Issues.Reporting.Tests/CreateIssueReportSettingsTests.cs +++ b/src/Cake.Issues.Reporting.Tests/CreateIssueReportSettingsTests.cs @@ -13,7 +13,7 @@ public sealed class TheCtor public void Should_Throw_If_RepositoryRoot_Is_Null() { // Given - DirectoryPath repoRoot = null; + const DirectoryPath repoRoot = null; FilePath outputFile = @"C:\report.html"; // When @@ -28,7 +28,7 @@ public void Should_Throw_If_OutputFilePath_Is_Null() { // Given DirectoryPath repoRoot = @"c:\repo"; - FilePath outputFile = null; + const FilePath outputFile = null; // When var result = Record.Exception(() => new CreateIssueReportSettings(repoRoot, outputFile)); diff --git a/src/Cake.Issues.Reporting.Tests/FakeIssueReportFormat.cs b/src/Cake.Issues.Reporting.Tests/FakeIssueReportFormat.cs index 072bcaa30..c5b5c04b4 100644 --- a/src/Cake.Issues.Reporting.Tests/FakeIssueReportFormat.cs +++ b/src/Cake.Issues.Reporting.Tests/FakeIssueReportFormat.cs @@ -25,7 +25,7 @@ public FakeIssueReportFormat(ICakeLog log) /// /// Gets or sets a value indicating whether the report format should return false during . /// - public bool ShouldFailOnInitialization { get; set; } = false; + public bool ShouldFailOnInitialization { get; set; } /// public override bool Initialize(ICreateIssueReportSettings settings) diff --git a/src/Cake.Issues.Reporting.Tests/IssueReportCreatorTests.cs b/src/Cake.Issues.Reporting.Tests/IssueReportCreatorTests.cs index 1c60f286f..ed6c43a8a 100644 --- a/src/Cake.Issues.Reporting.Tests/IssueReportCreatorTests.cs +++ b/src/Cake.Issues.Reporting.Tests/IssueReportCreatorTests.cs @@ -49,7 +49,7 @@ public void Should_Initialize_Report_Format() { // Given var fixture = new IssueReportFormatFixture(); - var issueProviders = new List { new FakeIssueProvider(fixture.Log) }; + var issueProviders = new List { new (fixture.Log) }; // When fixture.CreateReport(issueProviders); @@ -62,9 +62,15 @@ public void Should_Initialize_Report_Format() public void Should_Return_Null_If_Initialization_Fails() { // Given - var fixture = new IssueReportFormatFixture(); - fixture.IssueReportFormat.ShouldFailOnInitialization = true; - var issueProviders = new List { new FakeIssueProvider(fixture.Log) }; + var fixture = + new IssueReportFormatFixture + { + IssueReportFormat = + { + ShouldFailOnInitialization = true, + }, + }; + var issueProviders = new List { new (fixture.Log) }; // When var result = fixture.CreateReport(issueProviders); @@ -78,7 +84,7 @@ public void Should_Return_File_Path() { // Given var fixture = new IssueReportFormatFixture(); - var issueProviders = new List { new FakeIssueProvider(fixture.Log) }; + var issueProviders = new List { new (fixture.Log) }; // When var result = fixture.CreateReport(issueProviders); @@ -117,8 +123,14 @@ public void Should_Initialize_Report_Format() public void Should_Return_Null_If_Initialization_Fails() { // Given - var fixture = new IssueReportFormatFixture(); - fixture.IssueReportFormat.ShouldFailOnInitialization = true; + var fixture = + new IssueReportFormatFixture + { + IssueReportFormat = + { + ShouldFailOnInitialization = true, + }, + }; var issues = new List { diff --git a/src/Cake.Issues.Reporting.Tests/Properties/ProjectInfo.cs b/src/Cake.Issues.Reporting.Tests/Properties/ProjectInfo.cs index d55f80df6..9480afbc2 100644 --- a/src/Cake.Issues.Reporting.Tests/Properties/ProjectInfo.cs +++ b/src/Cake.Issues.Reporting.Tests/Properties/ProjectInfo.cs @@ -1,5 +1,4 @@ -using System.Reflection; -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; // 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 diff --git a/src/Cake.Issues.Reporting/CreateIssueReportFromIssueProviderSettings.cs b/src/Cake.Issues.Reporting/CreateIssueReportFromIssueProviderSettings.cs index 92e94340a..dfbf12fb2 100644 --- a/src/Cake.Issues.Reporting/CreateIssueReportFromIssueProviderSettings.cs +++ b/src/Cake.Issues.Reporting/CreateIssueReportFromIssueProviderSettings.cs @@ -21,6 +21,6 @@ public CreateIssueReportFromIssueProviderSettings(DirectoryPath repositoryRoot, } /// - public FilePath OutputFilePath { get; private set; } + public FilePath OutputFilePath { get; } } } diff --git a/src/Cake.Issues.Reporting/CreateIssueReportSettings.cs b/src/Cake.Issues.Reporting/CreateIssueReportSettings.cs index 97328f092..ec7168b17 100644 --- a/src/Cake.Issues.Reporting/CreateIssueReportSettings.cs +++ b/src/Cake.Issues.Reporting/CreateIssueReportSettings.cs @@ -21,6 +21,6 @@ public CreateIssueReportSettings(DirectoryPath repositoryRoot, FilePath outputFi } /// - public FilePath OutputFilePath { get; private set; } + public FilePath OutputFilePath { get; } } } diff --git a/src/Cake.Issues.Reporting/ICreateIssueReportFromIssueProviderSettings.cs b/src/Cake.Issues.Reporting/ICreateIssueReportFromIssueProviderSettings.cs index 367bece1a..a36a43b5d 100644 --- a/src/Cake.Issues.Reporting/ICreateIssueReportFromIssueProviderSettings.cs +++ b/src/Cake.Issues.Reporting/ICreateIssueReportFromIssueProviderSettings.cs @@ -1,7 +1,5 @@ namespace Cake.Issues.Reporting { - using Cake.Core.IO; - /// /// Setting affecting how reports are created which are built passing issue providers. /// diff --git a/src/Cake.Issues.Reporting/Properties/ProjectInfo.cs b/src/Cake.Issues.Reporting/Properties/ProjectInfo.cs index c4c962622..47378c15b 100644 --- a/src/Cake.Issues.Reporting/Properties/ProjectInfo.cs +++ b/src/Cake.Issues.Reporting/Properties/ProjectInfo.cs @@ -1,5 +1,4 @@ using System; -using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/src/Cake.Issues.Testing/BaseMultiFormatIssueProviderFixture.cs b/src/Cake.Issues.Testing/BaseMultiFormatIssueProviderFixture.cs index eda982313..97441a4d5 100644 --- a/src/Cake.Issues.Testing/BaseMultiFormatIssueProviderFixture.cs +++ b/src/Cake.Issues.Testing/BaseMultiFormatIssueProviderFixture.cs @@ -2,7 +2,6 @@ { using System; using System.Collections.Generic; - using System.Linq; /// /// Base class for test fixtures for testing issue providers inherited from . diff --git a/src/Cake.Issues.Testing/ExceptionAssertExtensions.cs b/src/Cake.Issues.Testing/ExceptionAssertExtensions.cs index 1a2e11bd0..31eed5c7e 100644 --- a/src/Cake.Issues.Testing/ExceptionAssertExtensions.cs +++ b/src/Cake.Issues.Testing/ExceptionAssertExtensions.cs @@ -8,7 +8,7 @@ public static class ExceptionAssertExtensions { /// - /// Checks if an execption is of type . + /// Checks if an exception is of type . /// /// Exception to check. /// Expected name of the parameter which has caused the exception. @@ -24,7 +24,7 @@ public static void IsArgumentException(this Exception exception, string paramete } /// - /// Checks if an execption is of type . + /// Checks if an exception is of type . /// /// Exception to check. /// Expected name of the parameter which has caused the exception. @@ -40,7 +40,7 @@ public static void IsArgumentNullException(this Exception exception, string para } /// - /// Checks if an execption is of type . + /// Checks if an exception is of type . /// /// Exception to check. /// Expected name of the parameter which has caused the exception. @@ -56,7 +56,7 @@ public static void IsArgumentOutOfRangeException(this Exception exception, strin } /// - /// Checks if an execption is of type . + /// Checks if an exception is of type . /// /// Exception to check. /// Expected exception message. diff --git a/src/Cake.Issues.Testing/FakeMultiFormatIssueProviderSettings.cs b/src/Cake.Issues.Testing/FakeMultiFormatIssueProviderSettings.cs index 9a0c84641..678ec854b 100644 --- a/src/Cake.Issues.Testing/FakeMultiFormatIssueProviderSettings.cs +++ b/src/Cake.Issues.Testing/FakeMultiFormatIssueProviderSettings.cs @@ -22,7 +22,7 @@ public FakeMultiFormatIssueProviderSettings(FilePath logFilePath, FakeLogFileFor /// /// Initializes a new instance of the class - /// for a log file content in memoy. + /// for a log file content in memory. /// /// Content of the log file. /// The log file needs to be in the format as defined by the parameter. diff --git a/src/Cake.Issues.Testing/IssueChecker.cs b/src/Cake.Issues.Testing/IssueChecker.cs index 9edb97735..ba0e56454 100644 --- a/src/Cake.Issues.Testing/IssueChecker.cs +++ b/src/Cake.Issues.Testing/IssueChecker.cs @@ -174,7 +174,7 @@ public static void Check( if (!issue.ProjectFileRelativePath.IsRelative) { throw new Exception( - $"Expected issue.ProjectFileRelativePath to be a relative path"); + "Expected issue.ProjectFileRelativePath to be a relative path"); } } @@ -203,7 +203,7 @@ public static void Check( if (!issue.AffectedFileRelativePath.IsRelative) { throw new Exception( - $"Expected issue.AffectedFileRelativePath to be a relative path"); + "Expected issue.AffectedFileRelativePath to be a relative path"); } } @@ -282,14 +282,14 @@ public static void Check( if (issue.RuleUrl?.ToString() != ruleUrl?.ToString()) { throw new Exception( - $"Expected issue.RuleUrl to be '{ruleUrl?.ToString()}' but was '{issue.RuleUrl?.ToString()}'."); + $"Expected issue.RuleUrl to be '{ruleUrl}' but was '{issue.RuleUrl}'."); } CheckAdditionalInformation(additionalInformation, issue.AdditionalInformation); } /// - /// Checks additional informations passed to an issue. + /// Checks additional information passed to an issue. /// /// Expected additional information. /// Actual additional information. @@ -305,13 +305,13 @@ private static void CheckAdditionalInformation( if (expected == null) { throw new Exception( - $"Expected issue.AdditionalInformation to be null but was not null."); + "Expected issue.AdditionalInformation to be null but was not null."); } if (actual == null) { throw new Exception( - $"Expected issue.AdditionalInformation to be not null but was null."); + "Expected issue.AdditionalInformation to be not null but was null."); } var expectedItemsNotFound = expected.Except(actual).ToArray(); diff --git a/src/Cake.Issues.Testing/Properties/ProjectInfo.cs b/src/Cake.Issues.Testing/Properties/ProjectInfo.cs index 7ca23649b..249ee0a47 100644 --- a/src/Cake.Issues.Testing/Properties/ProjectInfo.cs +++ b/src/Cake.Issues.Testing/Properties/ProjectInfo.cs @@ -1,5 +1,4 @@ using System; -using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/src/Cake.Issues.Tests/BaseConfigurableIssueProviderTests.cs b/src/Cake.Issues.Tests/BaseConfigurableIssueProviderTests.cs index 2c9901de4..573ddb128 100644 --- a/src/Cake.Issues.Tests/BaseConfigurableIssueProviderTests.cs +++ b/src/Cake.Issues.Tests/BaseConfigurableIssueProviderTests.cs @@ -14,7 +14,7 @@ public sealed class TheCtor public void Should_Throw_If_Log_Is_Null() { // Given - ICakeLog log = null; + const ICakeLog log = null; var settings = new IssueProviderSettings("Foo".ToByteArray()); // When @@ -29,7 +29,7 @@ public void Should_Throw_If_IssueProviderSettings_Are_Null() { // Given var log = new FakeLog(); - IssueProviderSettings settings = null; + const IssueProviderSettings settings = null; // When var result = Record.Exception(() => new FakeConfigurableIssueProvider(log, settings)); diff --git a/src/Cake.Issues.Tests/BaseLogFileFormatTests.cs b/src/Cake.Issues.Tests/BaseLogFileFormatTests.cs index ef6be1180..4c6d8bc8e 100644 --- a/src/Cake.Issues.Tests/BaseLogFileFormatTests.cs +++ b/src/Cake.Issues.Tests/BaseLogFileFormatTests.cs @@ -14,7 +14,7 @@ public sealed class TheCtor public void Should_Throw_If_Log_Is_Null() { // Given - ICakeLog log = null; + const ICakeLog log = null; // When var result = Record.Exception(() => new FakeLogFileFormat(log)); diff --git a/src/Cake.Issues.Tests/BaseMultiFormatIssueProviderSettingsTests.cs b/src/Cake.Issues.Tests/BaseMultiFormatIssueProviderSettingsTests.cs index bd68e8d6e..8e8ebe03c 100644 --- a/src/Cake.Issues.Tests/BaseMultiFormatIssueProviderSettingsTests.cs +++ b/src/Cake.Issues.Tests/BaseMultiFormatIssueProviderSettingsTests.cs @@ -15,7 +15,7 @@ public sealed class TheCtor public void Should_Throw_If_LogFilePath_Is_Null() { // Given - FilePath logFilePath = null; + const FilePath logFilePath = null; var format = new FakeLogFileFormat(new FakeLog()); // When @@ -29,7 +29,7 @@ public void Should_Throw_If_LogFilePath_Is_Null() public void Should_Throw_If_LogContent_Is_Null() { // Given - byte[] logFileContent = null; + const byte[] logFileContent = null; var format = new FakeLogFileFormat(new FakeLog()); // When @@ -57,7 +57,7 @@ public void Should_Set_LogContent() public void Should_Set_LogContent_If_Empty() { // Given - byte[] logFileContent = Array.Empty(); + var logFileContent = Array.Empty(); var format = new FakeLogFileFormat(new FakeLog()); // When diff --git a/src/Cake.Issues.Tests/BaseMultiFormatIssueProviderTests.cs b/src/Cake.Issues.Tests/BaseMultiFormatIssueProviderTests.cs index af78a89b0..00668cb42 100644 --- a/src/Cake.Issues.Tests/BaseMultiFormatIssueProviderTests.cs +++ b/src/Cake.Issues.Tests/BaseMultiFormatIssueProviderTests.cs @@ -2,7 +2,6 @@ { using System.Collections.Generic; using System.Linq; - using System.Text; using Cake.Core.Diagnostics; using Cake.Issues.Testing; using Cake.Testing; @@ -17,7 +16,7 @@ public sealed class TheCtor public void Should_Throw_If_Log_Is_Null() { // Given - ICakeLog log = null; + const ICakeLog log = null; var settings = new FakeMultiFormatIssueProviderSettings( "Foo".ToByteArray(), @@ -35,7 +34,7 @@ public void Should_Throw_If_IssueProviderSettings_Are_Null() { // Given var log = new FakeLog(); - FakeMultiFormatIssueProviderSettings settings = null; + const FakeMultiFormatIssueProviderSettings settings = null; // When var result = Record.Exception(() => new FakeMultiFormatIssueProvider(log, settings)); @@ -113,10 +112,10 @@ public void Should_Read_Issues_From_Format() provider.Initialize(new ReadIssuesSettings(@"c:\repo")); // When - var result = provider.ReadIssues(); + var result = provider.ReadIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.ShouldContain(issue1); result.ShouldContain(issue2); } diff --git a/src/Cake.Issues.Tests/ByteArrayExtensionsTests.cs b/src/Cake.Issues.Tests/ByteArrayExtensionsTests.cs index 3a6223769..c47ba8eee 100644 --- a/src/Cake.Issues.Tests/ByteArrayExtensionsTests.cs +++ b/src/Cake.Issues.Tests/ByteArrayExtensionsTests.cs @@ -15,7 +15,7 @@ public sealed class TheRemovePreambleExtension public void Should_Throw_If_Value_Is_Null() { // Given - byte[] value = null; + const byte[] value = null; // When var result = Record.Exception(() => value.RemovePreamble()); @@ -49,7 +49,7 @@ public sealed class TheRemovePreambleWithEncodingExtension public void Should_Throw_If_Value_Is_Null() { // Given - byte[] value = null; + const byte[] value = null; var encoding = Encoding.UTF32; // When @@ -64,7 +64,7 @@ public void Should_Throw_If_Encoding_Is_Null() { // Given var encoding = Encoding.UTF32; - var stringValue = "foo🐱bar"; + const string stringValue = "foo🐱bar"; var byteArrayValue = stringValue.ToByteArray(encoding); // When @@ -95,7 +95,7 @@ public void Should_Remove_Preamble(string value) [Theory] [InlineData("foo🐱bar")] [InlineData("")] - public void Should_Return_Correct_Value_If_Enconding_Has_Preamble_But_Value_Not(string value) + public void Should_Return_Correct_Value_If_Encoding_Has_Preamble_But_Value_Not(string value) { // Given var encoding = Encoding.UTF32; @@ -133,7 +133,7 @@ public sealed class TheToStringUsingEncodingExtension public void Should_Throw_If_Value_Is_Null() { // Given - byte[] value = null; + const byte[] value = null; // When var result = Record.Exception(() => value.ToStringUsingEncoding()); @@ -164,7 +164,7 @@ public sealed class TheToStringUsingEncodingWithSkipPreambleExtension public void Should_Throw_If_Value_Is_Null() { // Given - byte[] value = null; + const byte[] value = null; // When var result = Record.Exception(() => value.ToStringUsingEncoding(true)); @@ -238,7 +238,7 @@ public sealed class TheToStringUsingEncodingWithEncodingAndSkipPreambleExtension public void Should_Throw_If_Value_Is_Null() { // Given - byte[] value = null; + const byte[] value = null; var encoding = Encoding.UTF32; // When @@ -319,7 +319,7 @@ public sealed class TheToByteArrayExtension public void Should_Throw_If_Value_Is_Null() { // Given - string value = null; + const string value = null; // When var result = Record.Exception(() => value.ToByteArray()); @@ -349,7 +349,7 @@ public sealed class TheToByteArrayWithEncodingExtension public void Should_Throw_If_Value_Is_Null() { // Given - string value = null; + const string value = null; var encoding = Encoding.UTF8; // When @@ -363,8 +363,8 @@ public void Should_Throw_If_Value_Is_Null() public void Should_Throw_If_Encoding_Is_Null() { // Given - var value = "foo"; - Encoding encoding = null; + const string value = "foo"; + const Encoding encoding = null; // When var result = Record.Exception(() => value.ToByteArray(encoding)); diff --git a/src/Cake.Issues.Tests/FileLinkSettingsTests.cs b/src/Cake.Issues.Tests/FileLinkSettingsTests.cs index a80847747..e781411f4 100644 --- a/src/Cake.Issues.Tests/FileLinkSettingsTests.cs +++ b/src/Cake.Issues.Tests/FileLinkSettingsTests.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; using Cake.Issues.Testing; - using Shouldly; using Xunit; public sealed class FileLinkSettingsTests @@ -14,7 +13,7 @@ public sealed class TheCtor public void Should_Throw_If_Builder_Is_Null() { // Given - Func, Uri> builder = null; + const Func, Uri> builder = null; // When var result = Record.Exception(() => new FileLinkSettings(builder)); @@ -30,7 +29,7 @@ public sealed class TheForPatternMethod public void Should_Throw_If_Pattern_Is_Null() { // Given - string pattern = null; + const string pattern = null; // When var result = Record.Exception(() => FileLinkSettings.ForPattern(pattern)); @@ -56,7 +55,7 @@ public void Should_Throw_If_Pattern_Is_Empty() public void Should_Throw_If_Pattern_Is_WhiteSpace() { // Given - var pattern = " "; + const string pattern = " "; // When var result = Record.Exception(() => FileLinkSettings.ForPattern(pattern)); @@ -72,7 +71,7 @@ public sealed class TheForActionMethod public void Should_Throw_If_Builder_Is_Null() { // Given - Func builder = null; + const Func builder = null; // When var result = Record.Exception(() => FileLinkSettings.ForAction(builder)); @@ -88,7 +87,7 @@ public sealed class TheForGitHubMethod public void Should_Throw_If_RepositoryUrl_Is_Null() { // Given - Uri repositoryUrl = null; + const Uri repositoryUrl = null; // When var result = Record.Exception(() => FileLinkSettings.ForGitHub(repositoryUrl)); @@ -104,7 +103,7 @@ public sealed class TheForAzureDevOpsMethod public void Should_Throw_If_RepositoryUrl_Is_Null() { // Given - Uri repositoryUrl = null; + const Uri repositoryUrl = null; // When var result = Record.Exception(() => FileLinkSettings.ForAzureDevOps(repositoryUrl)); @@ -120,7 +119,7 @@ public sealed class TheGetFileLinkMethod public void Should_Throw_If_Issue_Is_Null() { // Given - IIssue issue = null; + const IIssue issue = null; // When var result = Record.Exception(() => FileLinkSettings.ForPattern("foo").GetFileLink(issue)); diff --git a/src/Cake.Issues.Tests/FileLinking/AzureDevOpsFileLinkSettingsBuilderTests.cs b/src/Cake.Issues.Tests/FileLinking/AzureDevOpsFileLinkSettingsBuilderTests.cs index cb9f18c89..bdccba14e 100644 --- a/src/Cake.Issues.Tests/FileLinking/AzureDevOpsFileLinkSettingsBuilderTests.cs +++ b/src/Cake.Issues.Tests/FileLinking/AzureDevOpsFileLinkSettingsBuilderTests.cs @@ -14,7 +14,7 @@ public sealed class TheCtor public void Should_Throw_If_RepositoryUrl_Is_Null() { // Given - Uri repositoryUrl = null; + const Uri repositoryUrl = null; // When var result = Record.Exception(() => new AzureDevOpsFileLinkSettingsBuilder(repositoryUrl)); @@ -30,7 +30,7 @@ public sealed class TheBranchMethod public void Should_Throw_If_BranchName_Is_Null() { // Given - string branch = null; + const string branch = null; // When var result = @@ -222,7 +222,7 @@ public sealed class TheCommitMethod public void Should_Throw_If_CommitId_Is_Null() { // Given - string commitId = null; + const string commitId = null; // When var result = diff --git a/src/Cake.Issues.Tests/FileLinking/FileLinkOptionalSettingsBuilderTests.cs b/src/Cake.Issues.Tests/FileLinking/FileLinkOptionalSettingsBuilderTests.cs index 75f48322e..db07f137c 100644 --- a/src/Cake.Issues.Tests/FileLinking/FileLinkOptionalSettingsBuilderTests.cs +++ b/src/Cake.Issues.Tests/FileLinking/FileLinkOptionalSettingsBuilderTests.cs @@ -15,7 +15,7 @@ public sealed class TheCtor public void Should_Throw_If_Builder_Is_Null() { // Given - Func, Uri> builder = null; + const Func, Uri> builder = null; // When var result = Record.Exception(() => new FileLinkOptionalSettingsBuilder(builder)); @@ -31,7 +31,7 @@ public sealed class TheWithRootPathMethod public void Should_Not_Throw_If_RootPath_Is_Null() { // Given - string rootPath = null; + const string rootPath = null; // When var result = diff --git a/src/Cake.Issues.Tests/FileLinking/GitHubFileLinkSettingsBuilderTests.cs b/src/Cake.Issues.Tests/FileLinking/GitHubFileLinkSettingsBuilderTests.cs index 7db305c89..38c90d452 100644 --- a/src/Cake.Issues.Tests/FileLinking/GitHubFileLinkSettingsBuilderTests.cs +++ b/src/Cake.Issues.Tests/FileLinking/GitHubFileLinkSettingsBuilderTests.cs @@ -14,7 +14,7 @@ public sealed class TheCtor public void Should_Throw_If_RepositoryUrl_Is_Null() { // Given - Uri repositoryUrl = null; + const Uri repositoryUrl = null; // When var result = Record.Exception(() => new GitHubFileLinkSettingsBuilder(repositoryUrl)); @@ -30,7 +30,7 @@ public sealed class TheBranchMethod public void Should_Throw_If_BranchName_Is_Null() { // Given - string branch = null; + const string branch = null; // When var result = @@ -58,7 +58,7 @@ public void Should_Throw_If_BranchName_Is_Empty() public void Should_Throw_If_BranchName_Is_WhiteSpace() { // Given - var branch = " "; + const string branch = " "; // When var result = @@ -185,7 +185,7 @@ public sealed class TheCommitMethod public void Should_Throw_If_CommitId_Is_Null() { // Given - string commitId = null; + const string commitId = null; // When var result = diff --git a/src/Cake.Issues.Tests/FileLinking/IDictionaryExtensionsTests.cs b/src/Cake.Issues.Tests/FileLinking/IDictionaryExtensionsTests.cs index 430b7705d..ecde3b450 100644 --- a/src/Cake.Issues.Tests/FileLinking/IDictionaryExtensionsTests.cs +++ b/src/Cake.Issues.Tests/FileLinking/IDictionaryExtensionsTests.cs @@ -13,7 +13,7 @@ public sealed class TheGetValueOrDefaultExtension public void Should_Throw_If_Dictionary_Is_Null() { // Given - System.Collections.Generic.IDictionary dictionary = null; + const System.Collections.Generic.IDictionary dictionary = null; // When var result = Record.Exception(() => dictionary.GetValueOrDefault("foo", null)); @@ -26,8 +26,8 @@ public void Should_Throw_If_Dictionary_Is_Null() public void Should_Return_Value_If_Exists() { // Given - var key = "foo"; - var value = "bar"; + const string key = "foo"; + const string value = "bar"; var dictionary = new System.Collections.Generic.Dictionary { { key, value } }; // When @@ -41,7 +41,7 @@ public void Should_Return_Value_If_Exists() public void Should_Return_DefaultValue_If_Value_Does_Not_Exist() { // Given - var defaultValue = "defaultValue"; + const string defaultValue = "defaultValue"; var dictionary = new System.Collections.Generic.Dictionary { { "foo", "bar" } }; // When diff --git a/src/Cake.Issues.Tests/IIssueComparerTests.cs b/src/Cake.Issues.Tests/IIssueComparerTests.cs index 3cfb59cb6..b39fb3a01 100644 --- a/src/Cake.Issues.Tests/IIssueComparerTests.cs +++ b/src/Cake.Issues.Tests/IIssueComparerTests.cs @@ -14,7 +14,7 @@ public sealed class TheCtorWithCompareOnlyPersistentPropertiesSetToFalse public void Should_Return_False_If_First_Issue_Is_Null() { // Given - IIssue issue1 = null; + const IIssue issue1 = null; var issue2 = IssueBuilder .NewIssue("message", "providerType", "providerName") @@ -32,7 +32,7 @@ public void Should_Return_False_If_Second_Issue_Is_Null() IssueBuilder .NewIssue("message", "providerType", "providerName") .Create(); - IIssue issue2 = null; + const IIssue issue2 = null; // When / Then CompareIssues(issue1, issue2, false); @@ -429,8 +429,8 @@ public void Should_Return_True_If_Same_Reference() public void Should_Return_True_If_Both_Are_Null() { // Given - IIssue issue1 = null; - IIssue issue2 = null; + const IIssue issue1 = null; + const IIssue issue2 = null; // When / Then CompareIssues(issue1, issue2, true); @@ -786,9 +786,9 @@ public void Should_Return_True_If_ProviderType_Is_Same() [Fact] public void Should_Return_True_If_AdditionalInformation_Is_Same() { - var id = "123"; - var lastname = "Kelso"; - var firstName = "Haley"; + const string id = "123"; + const string lastname = "Kelso"; + const string firstName = "Haley"; // Given var issue1 = @@ -813,10 +813,10 @@ public void Should_Return_True_If_AdditionalInformation_Is_Same() [Fact] public void Should_Return_False_If_AdditionalInformation_Is_Not_Same() { - var id = "123"; - var lastname = "Kelso"; - var correctFirstName = "Haley"; - var wrongFirstName = "Michael"; + const string id = "123"; + const string lastname = "Kelso"; + const string correctFirstName = "Haley"; + const string wrongFirstName = "Michael"; // Given var issue1 = @@ -899,10 +899,10 @@ public void Should_Remove_Identical_Issues_From_List_Of_Issues() var comparer = new IIssueComparer(); // When - var result = issues1.Except(issues2, comparer); + var result = issues1.Except(issues2, comparer).ToList(); // Then - result.Count().ShouldBe(1); + result.Count.ShouldBe(1); result.ShouldContain(issue2); } @@ -929,7 +929,7 @@ public sealed class TheCtorWithCompareOnlyPersistentPropertiesSetToTrue public void Should_Return_False_If_First_Issue_Is_Null() { // Given - IIssue issue1 = null; + const IIssue issue1 = null; var issue2 = IssueBuilder .NewIssue("message", "providerType", "providerName") @@ -947,7 +947,7 @@ public void Should_Return_False_If_Second_Issue_Is_Null() IssueBuilder .NewIssue("message", "providerType", "providerName") .Create(); - IIssue issue2 = null; + const IIssue issue2 = null; // When / Then CompareIssues(issue1, issue2, false); @@ -1215,8 +1215,8 @@ public void Should_Return_True_If_Same_Reference() public void Should_Return_True_If_Both_Are_Null() { // Given - IIssue issue1 = null; - IIssue issue2 = null; + const IIssue issue1 = null; + const IIssue issue2 = null; // When / Then CompareIssues(issue1, issue2, true); @@ -1761,10 +1761,10 @@ public void Should_Remove_Identical_Issues_From_List_Of_Issues() var comparer = new IIssueComparer(true); // When - var result = issues1.Except(issues2, comparer); + var result = issues1.Except(issues2, comparer).ToList(); // Then - result.Count().ShouldBe(1); + result.Count.ShouldBe(1); result.ShouldContain(issue2); } diff --git a/src/Cake.Issues.Tests/IIssueExtensionsTests.cs b/src/Cake.Issues.Tests/IIssueExtensionsTests.cs index faf1af023..a971d0b56 100644 --- a/src/Cake.Issues.Tests/IIssueExtensionsTests.cs +++ b/src/Cake.Issues.Tests/IIssueExtensionsTests.cs @@ -13,7 +13,7 @@ public sealed class TheLineRangeExtension public void Should_Throw_If_Issue_Is_Null() { // Given - IIssue issue = null; + const IIssue issue = null; // When var result = Record.Exception(() => issue.LineRange()); @@ -56,7 +56,7 @@ public sealed class TheLineRangeExtensionWithAddColumnParameter public void Should_Throw_If_Issue_Is_Null() { // Given - IIssue issue = null; + const IIssue issue = null; // When var result = Record.Exception(() => issue.LineRange(false)); @@ -105,7 +105,7 @@ public sealed class TheProjectPathExtension public void Should_Throw_If_Issue_Is_Null() { // Given - IIssue issue = null; + const IIssue issue = null; // When var result = Record.Exception(() => issue.ProjectPath()); @@ -118,7 +118,7 @@ public void Should_Throw_If_Issue_Is_Null() public void Should_Return_Full_Path() { // Given - var projectPath = @"src\Cake.Issues\Cake.Issues.csproj"; + const string projectPath = @"src\Cake.Issues\Cake.Issues.csproj"; var issue = IssueBuilder .NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo") @@ -155,7 +155,7 @@ public sealed class TheProjectDirectoryExtension public void Should_Throw_If_Issue_Is_Null() { // Given - IIssue issue = null; + const IIssue issue = null; // When var result = Record.Exception(() => issue.ProjectDirectory()); @@ -168,7 +168,7 @@ public void Should_Throw_If_Issue_Is_Null() public void Should_Return_Full_Path() { // Given - var filePath = @"src\Cake.Issues\Foo.cs"; + const string filePath = @"src\Cake.Issues\Foo.cs"; var issue = IssueBuilder .NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo") @@ -205,7 +205,7 @@ public sealed class TheFilePathExtension public void Should_Throw_If_Issue_Is_Null() { // Given - IIssue issue = null; + const IIssue issue = null; // When var result = Record.Exception(() => issue.FilePath()); @@ -218,7 +218,7 @@ public void Should_Throw_If_Issue_Is_Null() public void Should_Return_Full_Path() { // Given - var filePath = @"src\Cake.Issues\Foo.cs"; + const string filePath = @"src\Cake.Issues\Foo.cs"; var issue = IssueBuilder .NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo") @@ -255,7 +255,7 @@ public sealed class TheFileDirectoryExtension public void Should_Throw_If_Issue_Is_Null() { // Given - IIssue issue = null; + const IIssue issue = null; // When var result = Record.Exception(() => issue.FileDirectory()); @@ -268,7 +268,7 @@ public void Should_Throw_If_Issue_Is_Null() public void Should_Return_Full_Path() { // Given - var filePath = @"src\Cake.Issues\Foo.cs"; + const string filePath = @"src\Cake.Issues\Foo.cs"; var issue = IssueBuilder .NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo") @@ -305,7 +305,7 @@ public sealed class TheFileNameExtension public void Should_Throw_If_Issue_Is_Null() { // Given - IIssue issue = null; + const IIssue issue = null; // When var result = Record.Exception(() => issue.FileName()); @@ -318,7 +318,7 @@ public void Should_Throw_If_Issue_Is_Null() public void Should_Return_Full_Path() { // Given - var filePath = @"src\Cake.Issues\Foo.cs"; + const string filePath = @"src\Cake.Issues\Foo.cs"; var issue = IssueBuilder .NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo") @@ -355,7 +355,7 @@ public sealed class TheRuleExtension public void Should_Throw_If_Issue_Is_Null() { // Given - IIssue issue = null; + const IIssue issue = null; // When var result = Record.Exception(() => issue.Rule()); @@ -368,8 +368,8 @@ public void Should_Throw_If_Issue_Is_Null() public void Should_Return_RuleName_If_Set() { // Given - var ruleId = "RuleId"; - var ruleName = "RuleName"; + const string ruleId = "RuleId"; + const string ruleName = "RuleName"; var issue = IssueBuilder .NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo") @@ -390,7 +390,7 @@ public void Should_Return_RuleName_If_Set() public void Should_Return_RuleId_If_RuleName_Not_Set(string ruleName) { // Given - var ruleId = "RuleId"; + const string ruleId = "RuleId"; var issue = IssueBuilder .NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo") @@ -411,7 +411,7 @@ public sealed class TheReplaceIssuePatternExtension public void Should_Throw_If_Pattern_Is_Null() { // Given - string pattern = null; + const string pattern = null; var issue = IssueBuilder .NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo") @@ -428,8 +428,8 @@ public void Should_Throw_If_Pattern_Is_Null() public void Should_Throw_If_Issue_Is_Null() { // Given - var pattern = "foo"; - IIssue issue = null; + const string pattern = "foo"; + const IIssue issue = null; // When var result = Record.Exception(() => pattern.ReplaceIssuePattern(issue)); @@ -466,7 +466,7 @@ public void Should_Throw_If_Issue_Is_Null() [InlineData("foo {MessageHtml} bar", "foo MessageHtml Foo bar")] [InlineData("foo {MessageMarkdown} bar", "foo MessageMarkdown Foo bar")] [InlineData("foo {AdditionalInformation:cost} bar", "foo 1000 bar")] - [InlineData("foo {AdditionalInformation:cost} {AdditionalInformation:notExistantKey} bar", "foo 1000 {AdditionalInformation:notExistantKey} bar")] + [InlineData("foo {AdditionalInformation:cost} {AdditionalInformation:notExistentKey} bar", "foo 1000 {AdditionalInformation:notExistentKey} bar")] public void Should_Replace_Tokens(string pattern, string expectedResult) { // Given diff --git a/src/Cake.Issues.Tests/IssueBuilderFixture.cs b/src/Cake.Issues.Tests/IssueBuilderFixture.cs index c81ff3cf1..cd0c34ab2 100644 --- a/src/Cake.Issues.Tests/IssueBuilderFixture.cs +++ b/src/Cake.Issues.Tests/IssueBuilderFixture.cs @@ -13,6 +13,6 @@ public IssueBuilderFixture(string identifier, string messageText, string provide IssueBuilder.NewIssue(identifier, messageText, providerType, providerName); } - public IssueBuilder IssueBuilder { get; private set; } + public IssueBuilder IssueBuilder { get; } } } diff --git a/src/Cake.Issues.Tests/IssueBuilderTests.cs b/src/Cake.Issues.Tests/IssueBuilderTests.cs index 6e3967f89..9a0974440 100644 --- a/src/Cake.Issues.Tests/IssueBuilderTests.cs +++ b/src/Cake.Issues.Tests/IssueBuilderTests.cs @@ -15,9 +15,9 @@ public sealed class TheNewIssueMethodWithMessageAsIdentifier public void Should_Throw_If_Message_Is_Null() { // Given - string message = null; - var providerType = "ProviderType"; - var providerName = "ProviderName"; + const string message = null; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; // When var result = Record.Exception(() => @@ -32,8 +32,8 @@ public void Should_Throw_If_Message_Is_Empty() { // Given var message = string.Empty; - var providerType = "ProviderType"; - var providerName = "ProviderName"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; // When var result = Record.Exception(() => @@ -47,9 +47,9 @@ public void Should_Throw_If_Message_Is_Empty() public void Should_Throw_If_Message_Is_WhiteSpace() { // Given - var message = " "; - var providerType = "ProviderType"; - var providerName = "ProviderName"; + const string message = " "; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; // When var result = Record.Exception(() => @@ -63,9 +63,9 @@ public void Should_Throw_If_Message_Is_WhiteSpace() public void Should_Throw_If_ProviderType_Is_Null() { // Given - var message = "Message"; - string providerType = null; - var providerName = "ProviderName"; + const string message = "Message"; + const string providerType = null; + const string providerName = "ProviderName"; // When var result = Record.Exception(() => @@ -79,9 +79,9 @@ public void Should_Throw_If_ProviderType_Is_Null() public void Should_Throw_If_ProviderType_Is_Empty() { // Given - var message = "Message"; + const string message = "Message"; var providerType = string.Empty; - var providerName = "ProviderName"; + const string providerName = "ProviderName"; // When var result = Record.Exception(() => @@ -95,9 +95,9 @@ public void Should_Throw_If_ProviderType_Is_Empty() public void Should_Throw_If_ProviderType_Is_WhiteSpace() { // Given - var message = "Message"; - var providerType = " "; - var providerName = "ProviderName"; + const string message = "Message"; + const string providerType = " "; + const string providerName = "ProviderName"; // When var result = Record.Exception(() => @@ -111,9 +111,9 @@ public void Should_Throw_If_ProviderType_Is_WhiteSpace() public void Should_Throw_If_ProviderName_Is_Null() { // Given - var message = "Message"; - var providerType = "ProviderType"; - string providerName = null; + const string message = "Message"; + const string providerType = "ProviderType"; + const string providerName = null; // When var result = Record.Exception(() => @@ -127,8 +127,8 @@ public void Should_Throw_If_ProviderName_Is_Null() public void Should_Throw_If_ProviderName_Is_Empty() { // Given - var message = "Message"; - var providerType = "ProviderType"; + const string message = "Message"; + const string providerType = "ProviderType"; var providerName = string.Empty; // When @@ -143,9 +143,9 @@ public void Should_Throw_If_ProviderName_Is_Empty() public void Should_Throw_If_ProviderName_Is_WhiteSpace() { // Given - var message = "Message"; - var providerType = "ProviderType"; - var providerName = " "; + const string message = "Message"; + const string providerType = "ProviderType"; + const string providerName = " "; // When var result = Record.Exception(() => @@ -159,9 +159,9 @@ public void Should_Throw_If_ProviderName_Is_WhiteSpace() public void Should_Set_Identifier() { // Given - var message = "Message"; - var providerType = "ProviderType"; - var providerName = "ProviderName"; + const string message = "Message"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; // When var result = @@ -177,9 +177,9 @@ public void Should_Set_Identifier() public void Should_Set_Message() { // Given - var message = "Message"; - var providerType = "ProviderType"; - var providerName = "ProviderName"; + const string message = "Message"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; // When var result = @@ -195,9 +195,9 @@ public void Should_Set_Message() public void Should_Set_ProviderType() { // Given - var message = "Message"; - var providerType = "ProviderType"; - var providerName = "ProviderName"; + const string message = "Message"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; // When var result = @@ -213,9 +213,9 @@ public void Should_Set_ProviderType() public void Should_Set_ProviderName() { // Given - var message = "Message"; - var providerType = "ProviderType"; - var providerName = "ProviderName"; + const string message = "Message"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; // When var result = @@ -234,10 +234,10 @@ public sealed class TheNewIssueMethod public void Should_Throw_If_Identifier_Is_Null() { // Given - string identifier = null; - var message = "Message"; - var providerType = "ProviderType"; - var providerName = "ProviderName"; + const string identifier = null; + const string message = "Message"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; // When var result = Record.Exception(() => @@ -252,9 +252,9 @@ public void Should_Throw_If_Identifier_Is_Empty() { // Given var identifier = string.Empty; - var message = "Message"; - var providerType = "ProviderType"; - var providerName = "ProviderName"; + const string message = "Message"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; // When var result = Record.Exception(() => @@ -268,10 +268,10 @@ public void Should_Throw_If_Identifier_Is_Empty() public void Should_Throw_If_Identifier_Is_WhiteSpace() { // Given - var identifier = " "; - var message = "Message"; - var providerType = "ProviderType"; - var providerName = "ProviderName"; + const string identifier = " "; + const string message = "Message"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; // When var result = Record.Exception(() => @@ -285,10 +285,10 @@ public void Should_Throw_If_Identifier_Is_WhiteSpace() public void Should_Throw_If_Message_Is_Null() { // Given - var identifier = "Identifier"; - string message = null; - var providerType = "ProviderType"; - var providerName = "ProviderName"; + const string identifier = "Identifier"; + const string message = null; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; // When var result = Record.Exception(() => @@ -302,10 +302,10 @@ public void Should_Throw_If_Message_Is_Null() public void Should_Throw_If_Message_Is_Empty() { // Given - var identifier = "Identifier"; + const string identifier = "Identifier"; var message = string.Empty; - var providerType = "ProviderType"; - var providerName = "ProviderName"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; // When var result = Record.Exception(() => @@ -319,10 +319,10 @@ public void Should_Throw_If_Message_Is_Empty() public void Should_Throw_If_Message_Is_WhiteSpace() { // Given - var identifier = "Identifier"; - var message = " "; - var providerType = "ProviderType"; - var providerName = "ProviderName"; + const string identifier = "Identifier"; + const string message = " "; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; // When var result = Record.Exception(() => @@ -336,10 +336,10 @@ public void Should_Throw_If_Message_Is_WhiteSpace() public void Should_Throw_If_ProviderType_Is_Null() { // Given - var identifier = "Identifier"; - var message = "Message"; - string providerType = null; - var providerName = "ProviderName"; + const string identifier = "Identifier"; + const string message = "Message"; + const string providerType = null; + const string providerName = "ProviderName"; // When var result = Record.Exception(() => @@ -353,10 +353,10 @@ public void Should_Throw_If_ProviderType_Is_Null() public void Should_Throw_If_ProviderType_Is_Empty() { // Given - var identifier = "Identifier"; - var message = "Message"; + const string identifier = "Identifier"; + const string message = "Message"; var providerType = string.Empty; - var providerName = "ProviderName"; + const string providerName = "ProviderName"; // When var result = Record.Exception(() => @@ -370,10 +370,10 @@ public void Should_Throw_If_ProviderType_Is_Empty() public void Should_Throw_If_ProviderType_Is_WhiteSpace() { // Given - var identifier = "Identifier"; - var message = "Message"; - var providerType = " "; - var providerName = "ProviderName"; + const string identifier = "Identifier"; + const string message = "Message"; + const string providerType = " "; + const string providerName = "ProviderName"; // When var result = Record.Exception(() => @@ -387,10 +387,10 @@ public void Should_Throw_If_ProviderType_Is_WhiteSpace() public void Should_Throw_If_ProviderName_Is_Null() { // Given - var identifier = "Identifier"; - var message = "Message"; - var providerType = "ProviderType"; - string providerName = null; + const string identifier = "Identifier"; + const string message = "Message"; + const string providerType = "ProviderType"; + const string providerName = null; // When var result = Record.Exception(() => @@ -404,9 +404,9 @@ public void Should_Throw_If_ProviderName_Is_Null() public void Should_Throw_If_ProviderName_Is_Empty() { // Given - var identifier = "Identifier"; - var message = "Message"; - var providerType = "ProviderType"; + const string identifier = "Identifier"; + const string message = "Message"; + const string providerType = "ProviderType"; var providerName = string.Empty; // When @@ -421,10 +421,10 @@ public void Should_Throw_If_ProviderName_Is_Empty() public void Should_Throw_If_ProviderName_Is_WhiteSpace() { // Given - var identifier = "Identifier"; - var message = "Message"; - var providerType = "ProviderType"; - var providerName = " "; + const string identifier = "Identifier"; + const string message = "Message"; + const string providerType = "ProviderType"; + const string providerName = " "; // When var result = Record.Exception(() => @@ -438,10 +438,10 @@ public void Should_Throw_If_ProviderName_Is_WhiteSpace() public void Should_Set_Identifier() { // Given - var identifier = "Identifier"; - var message = "Message"; - var providerType = "ProviderType"; - var providerName = "ProviderName"; + const string identifier = "Identifier"; + const string message = "Message"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; // When var result = @@ -457,10 +457,10 @@ public void Should_Set_Identifier() public void Should_Set_Message() { // Given - var identifier = "Identifier"; - var message = "Message"; - var providerType = "ProviderType"; - var providerName = "ProviderName"; + const string identifier = "Identifier"; + const string message = "Message"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; // When var result = @@ -476,9 +476,9 @@ public void Should_Set_Message() public void Should_Set_ProviderType() { // Given - var identifier = "Identifier"; - var message = "Message"; - var providerType = "ProviderType"; + const string identifier = "Identifier"; + const string message = "Message"; + const string providerType = "ProviderType"; var providerName = "ProviderName"; // When @@ -495,10 +495,10 @@ public void Should_Set_ProviderType() public void Should_Set_ProviderName() { // Given - var identifier = "Identifier"; - var message = "Message"; - var providerType = "ProviderType"; - var providerName = "ProviderName"; + const string identifier = "Identifier"; + const string message = "Message"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; // When var result = @@ -517,7 +517,7 @@ public sealed class TheNewIssueOfTMethodWithMessageAsIdentifier public void Should_Throw_If_Message_Is_Null() { // Given - string message = null; + const string message = null; var issueProvider = new FakeIssueProvider(new FakeLog()); // When @@ -547,7 +547,7 @@ public void Should_Throw_If_Message_Is_Empty() public void Should_Throw_If_Message_Is_WhiteSpace() { // Given - var message = " "; + const string message = " "; var issueProvider = new FakeIssueProvider(new FakeLog()); // When @@ -562,8 +562,8 @@ public void Should_Throw_If_Message_Is_WhiteSpace() public void Should_Throw_If_IssueProvider_Is_Null() { // Given - var message = "Message"; - IIssueProvider issueProvider = null; + const string message = "Message"; + const IIssueProvider issueProvider = null; // When var result = Record.Exception(() => @@ -577,7 +577,7 @@ public void Should_Throw_If_IssueProvider_Is_Null() public void Should_Set_Identifier() { // Given - var message = "Message"; + const string message = "Message"; var issueProvider = new FakeIssueProvider(new FakeLog()); // When @@ -594,7 +594,7 @@ public void Should_Set_Identifier() public void Should_Set_Message() { // Given - var message = "Message"; + const string message = "Message"; var issueProvider = new FakeIssueProvider(new FakeLog()); // When @@ -611,7 +611,7 @@ public void Should_Set_Message() public void Should_Set_ProviderType() { // Given - var message = "Message"; + const string message = "Message"; var issueProvider = new FakeIssueProvider(new FakeLog()); // When @@ -628,7 +628,7 @@ public void Should_Set_ProviderType() public void Should_Set_ProviderName() { // Given - var message = "Message"; + const string message = "Message"; var issueProvider = new FakeIssueProvider(new FakeLog()); // When @@ -648,8 +648,8 @@ public sealed class TheNewIssueOfTMethod public void Should_Throw_If_Identifier_Is_Null() { // Given - string identifier = null; - var message = "Message"; + const string identifier = null; + const string message = "Message"; var issueProvider = new FakeIssueProvider(new FakeLog()); // When @@ -665,7 +665,7 @@ public void Should_Throw_If_Identifier_Is_Empty() { // Given var identifier = string.Empty; - var message = "Message"; + const string message = "Message"; var issueProvider = new FakeIssueProvider(new FakeLog()); // When @@ -680,8 +680,8 @@ public void Should_Throw_If_Identifier_Is_Empty() public void Should_Throw_If_Identifier_Is_WhiteSpace() { // Given - var identifier = " "; - var message = "Message"; + const string identifier = " "; + const string message = "Message"; var issueProvider = new FakeIssueProvider(new FakeLog()); // When @@ -696,8 +696,8 @@ public void Should_Throw_If_Identifier_Is_WhiteSpace() public void Should_Throw_If_Message_Is_Null() { // Given - var identifier = "Identifier"; - string message = null; + const string identifier = "Identifier"; + const string message = null; var issueProvider = new FakeIssueProvider(new FakeLog()); // When @@ -712,7 +712,7 @@ public void Should_Throw_If_Message_Is_Null() public void Should_Throw_If_Message_Is_Empty() { // Given - var identifier = "Identifier"; + const string identifier = "Identifier"; var message = string.Empty; var issueProvider = new FakeIssueProvider(new FakeLog()); @@ -728,8 +728,8 @@ public void Should_Throw_If_Message_Is_Empty() public void Should_Throw_If_Message_Is_WhiteSpace() { // Given - var identifier = "Identifier"; - var message = " "; + const string identifier = "Identifier"; + const string message = " "; var issueProvider = new FakeIssueProvider(new FakeLog()); // When @@ -744,9 +744,9 @@ public void Should_Throw_If_Message_Is_WhiteSpace() public void Should_Throw_If_IssueProvider_Is_Null() { // Given - var identifier = "Identifier"; - var message = "Message"; - IIssueProvider issueProvider = null; + const string identifier = "Identifier"; + const string message = "Message"; + const IIssueProvider issueProvider = null; // When var result = Record.Exception(() => @@ -760,8 +760,8 @@ public void Should_Throw_If_IssueProvider_Is_Null() public void Should_Set_Identifier() { // Given - var identifier = "Identifier"; - var message = "Message"; + const string identifier = "Identifier"; + const string message = "Message"; var issueProvider = new FakeIssueProvider(new FakeLog()); // When @@ -778,8 +778,8 @@ public void Should_Set_Identifier() public void Should_Set_Message() { // Given - var identifier = "Identifier"; - var message = "Message"; + const string identifier = "Identifier"; + const string message = "Message"; var issueProvider = new FakeIssueProvider(new FakeLog()); // When @@ -796,8 +796,8 @@ public void Should_Set_Message() public void Should_Set_ProviderType() { // Given - var identifier = "Identifier"; - var message = "Message"; + const string identifier = "Identifier"; + const string message = "Message"; var issueProvider = new FakeIssueProvider(new FakeLog()); // When @@ -814,8 +814,8 @@ public void Should_Set_ProviderType() public void Should_Set_ProviderName() { // Given - var identifier = "Identifier"; - var message = "Message"; + const string identifier = "Identifier"; + const string message = "Message"; var issueProvider = new FakeIssueProvider(new FakeLog()); // When @@ -836,7 +836,7 @@ public void Should_Handle_Project_Paths_Which_Are_Null() { // Given var fixture = new IssueBuilderFixture(); - string projectPath = null; + const string projectPath = null; // When var issue = fixture.IssueBuilder.InProjectFile(projectPath).Create(); @@ -864,7 +864,7 @@ public void Should_Handle_Project_Path_Which_Are_WhiteSpace() { // Given var fixture = new IssueBuilderFixture(); - var projectPath = " "; + const string projectPath = " "; // When var issue = fixture.IssueBuilder.InProjectFile(projectPath).Create(); @@ -895,7 +895,7 @@ public void Should_Handle_Project_Names_Which_Are_Null() { // Given var fixture = new IssueBuilderFixture(); - string projectName = null; + const string projectName = null; // When var issue = fixture.IssueBuilder.InProjectOfName(projectName).Create(); @@ -923,7 +923,7 @@ public void Should_Handle_Project_Names_Which_Are_WhiteSpace() { // Given var fixture = new IssueBuilderFixture(); - var projectName = " "; + const string projectName = " "; // When var issue = fixture.IssueBuilder.InProjectOfName(projectName).Create(); @@ -954,8 +954,8 @@ public void Should_Handle_Project_Paths_Which_Are_Null() { // Given var fixture = new IssueBuilderFixture(); - string projectPath = null; - var projectName = "foo"; + const string projectPath = null; + const string projectName = "foo"; // When var issue = fixture.IssueBuilder.InProject(projectPath, projectName).Create(); @@ -970,7 +970,7 @@ public void Should_Handle_Project_Paths_Which_Are_Empty() // Given var fixture = new IssueBuilderFixture(); var projectPath = string.Empty; - var projectName = "foo"; + const string projectName = "foo"; // When var issue = fixture.IssueBuilder.InProject(projectPath, projectName).Create(); @@ -984,8 +984,8 @@ public void Should_Handle_Project_Paths_Which_Are_WhiteSpace() { // Given var fixture = new IssueBuilderFixture(); - var projectPath = " "; - var projectName = "foo"; + const string projectPath = " "; + const string projectName = "foo"; // When var issue = fixture.IssueBuilder.InProject(projectPath, projectName).Create(); @@ -999,8 +999,8 @@ public void Should_Handle_Project_Names_Which_Are_Null() { // Given var fixture = new IssueBuilderFixture(); - string projectName = null; - var projectPath = "foo"; + const string projectName = null; + const string projectPath = "foo"; // When var issue = fixture.IssueBuilder.InProject(projectPath, projectName).Create(); @@ -1015,7 +1015,7 @@ public void Should_Handle_Project_Names_Which_Are_Empty() // Given var fixture = new IssueBuilderFixture(); var projectName = string.Empty; - var projectPath = "foo"; + const string projectPath = "foo"; // When var issue = fixture.IssueBuilder.InProject(projectPath, projectName).Create(); @@ -1029,8 +1029,8 @@ public void Should_Handle_Project_Names_Which_Are_WhiteSpace() { // Given var fixture = new IssueBuilderFixture(); - var projectName = " "; - var projectPath = "foo"; + const string projectName = " "; + const string projectPath = "foo"; // When var issue = fixture.IssueBuilder.InProject(projectPath, projectName).Create(); @@ -1045,7 +1045,7 @@ public void Should_Set_ProjectFileRelativePath(string projectPath) { // Given var fixture = new IssueBuilderFixture(); - var projectName = "foo"; + const string projectName = "foo"; // When var issue = fixture.IssueBuilder.InProject(projectPath, projectName).Create(); @@ -1060,7 +1060,7 @@ public void Should_Set_ProjectName(string projectName) { // Given var fixture = new IssueBuilderFixture(); - var projectPath = "foo"; + const string projectPath = "foo"; // When var issue = fixture.IssueBuilder.InProject(projectPath, projectName).Create(); @@ -1612,7 +1612,7 @@ public void Should_Throw_If_FileLink_Is_Null() { // Given var fixture = new IssueBuilderFixture(); - Uri fileLink = null; + const Uri fileLink = null; // When var result = Record.Exception(() => @@ -1644,7 +1644,7 @@ public void Should_Throw_If_FileLinkSettings_Are_Null() { // Given var fixture = new IssueBuilderFixture(); - FileLinkSettings fileLinkSettings = null; + const FileLinkSettings fileLinkSettings = null; // When var result = Record.Exception(() => @@ -1718,7 +1718,7 @@ public void Should_Handle_PriorityNames_Which_Are_Null() { // Given var fixture = new IssueBuilderFixture(); - string priorityName = null; + const string priorityName = null; // When var issue = fixture.IssueBuilder.WithPriority(0, priorityName).Create(); @@ -1816,7 +1816,7 @@ public void Should_Handle_RulesIds_Which_Are_Null() { // Given var fixture = new IssueBuilderFixture(); - string ruleId = null; + const string ruleId = null; // When var issue = fixture.IssueBuilder.OfRule(ruleId).Create(); @@ -1844,7 +1844,7 @@ public void Should_Handle_RulesIds_Which_Are_WhiteSpace() { // Given var fixture = new IssueBuilderFixture(); - var ruleId = " "; + const string ruleId = " "; // When var issue = fixture.IssueBuilder.OfRule(ruleId).Create(); @@ -1875,7 +1875,7 @@ public void Should_Handle_RuleIds_Which_Are_Null() { // Given var fixture = new IssueBuilderFixture(); - string ruleId = null; + const string ruleId = null; // When var issue = fixture.IssueBuilder.OfRule(ruleId, "Some Rule").Create(); @@ -1903,7 +1903,7 @@ public void Should_Handle_RuleIds_Which_Are_WhiteSpace() { // Given var fixture = new IssueBuilderFixture(); - var ruleId = " "; + const string ruleId = " "; // When var issue = fixture.IssueBuilder.OfRule(ruleId, "Some Rule").Create(); @@ -1917,7 +1917,7 @@ public void Should_Handle_RuleNames_Which_Are_Null() { // Given var fixture = new IssueBuilderFixture(); - string ruleName = null; + const string ruleName = null; // When var issue = fixture.IssueBuilder.OfRule("RuleId", ruleName).Create(); @@ -1945,7 +1945,7 @@ public void Should_Handle_RuleNames_Which_Are_WhiteSpace() { // Given var fixture = new IssueBuilderFixture(); - var ruleName = " "; + const string ruleName = " "; // When var issue = fixture.IssueBuilder.OfRule("RuleId", ruleName).Create(); @@ -1960,7 +1960,7 @@ public void Should_Set_Rule(string ruleId) { // Given var fixture = new IssueBuilderFixture(); - var ruleName = "Some Rule"; + const string ruleName = "Some Rule"; // When var issue = fixture.IssueBuilder.OfRule(ruleId, ruleName).Create(); @@ -1991,7 +1991,7 @@ public void Should_Handle_RuleIds_Which_Are_Null() { // Given var fixture = new IssueBuilderFixture(); - string ruleId = null; + const string ruleId = null; // When var issue = fixture.IssueBuilder.OfRule(ruleId, new Uri("https://google.com")).Create(); @@ -2019,7 +2019,7 @@ public void Should_Handle_RuleIds_Which_Are_WhiteSpace() { // Given var fixture = new IssueBuilderFixture(); - var ruleIds = " "; + const string ruleIds = " "; // When var issue = fixture.IssueBuilder.OfRule(ruleIds, new Uri("https://google.com")).Create(); @@ -2047,13 +2047,13 @@ public void Should_Set_Rule(string ruleId) { // Given var fixture = new IssueBuilderFixture(); - var ruleUri = "https://google.com/"; + const string ruleUri = "https://google.com/"; // When var issue = fixture.IssueBuilder.OfRule(ruleId, new Uri(ruleUri)).Create(); // Then - issue.RuleId.ToString().ShouldBe(ruleId); + issue.RuleId.ShouldBe(ruleId); } [Theory] @@ -2078,7 +2078,7 @@ public void Should_Handle_RuleIds_Which_Are_Null() { // Given var fixture = new IssueBuilderFixture(); - string ruleId = null; + const string ruleId = null; // When var issue = fixture.IssueBuilder.OfRule(ruleId, "Some Rule", new Uri("https://google.com")).Create(); @@ -2106,7 +2106,7 @@ public void Should_Handle_RuleIds_Which_Are_WhiteSpace() { // Given var fixture = new IssueBuilderFixture(); - var ruleId = " "; + const string ruleId = " "; // When var issue = fixture.IssueBuilder.OfRule(ruleId, "Some Rule", new Uri("https://google.com")).Create(); @@ -2120,7 +2120,7 @@ public void Should_Handle_RuleNames_Which_Are_Null() { // Given var fixture = new IssueBuilderFixture(); - string ruleName = null; + const string ruleName = null; // When var issue = fixture.IssueBuilder.OfRule("RuleId", ruleName, new Uri("https://google.com")).Create(); @@ -2148,7 +2148,7 @@ public void Should_Handle_RuleNames_Which_Are_WhiteSpace() { // Given var fixture = new IssueBuilderFixture(); - var ruleName = " "; + const string ruleName = " "; // When var issue = fixture.IssueBuilder.OfRule("RuleId", ruleName, new Uri("https://google.com")).Create(); @@ -2162,9 +2162,10 @@ public void Should_Handle_Rule_Uri_Which_Are_Null() { // Given var fixture = new IssueBuilderFixture(); + const Uri ruleUri = null; // When - var issue = fixture.IssueBuilder.OfRule("RuleId", "RuleName", (Uri)null).Create(); + var issue = fixture.IssueBuilder.OfRule("RuleId", "RuleName", ruleUri).Create(); // Then issue.RuleUrl.ShouldBe(null); @@ -2176,7 +2177,7 @@ public void Should_Set_Rule(string ruleId) { // Given var fixture = new IssueBuilderFixture(); - var ruleName = "Some Rule"; + const string ruleName = "Some Rule"; // When var issue = fixture.IssueBuilder.OfRule(ruleId, ruleName, new Uri("https://google.com")).Create(); @@ -2205,7 +2206,7 @@ public void Should_Set_RuleUrl(string ruleUri) { // Given var fixture = new IssueBuilderFixture(); - var ruleName = "Some Rule"; + const string ruleName = "Some Rule"; // When var issue = fixture.IssueBuilder.OfRule("Rule", ruleName, new Uri(ruleUri)).Create(); @@ -2222,7 +2223,7 @@ public void Should_Throw_If_Run_Is_Null() { // Given var fixture = new IssueBuilderFixture(); - string run = null; + const string run = null; // When var result = Record.Exception(() => @@ -2237,7 +2238,7 @@ public void Should_Throw_If_Run_Is_Empty() { // Given var fixture = new IssueBuilderFixture(); - string run = string.Empty; + var run = string.Empty; // When var result = Record.Exception(() => @@ -2252,7 +2253,7 @@ public void Should_Throw_If_Run_Is_WhiteSpace() { // Given var fixture = new IssueBuilderFixture(); - string run = " "; + const string run = " "; // When var result = Record.Exception(() => @@ -2273,7 +2274,7 @@ public void Should_Set_Run(string run) var issue = fixture.IssueBuilder.ForRun(run).Create(); // Then - issue.Run.ToString().ShouldBe(run); + issue.Run.ShouldBe(run); } } @@ -2311,7 +2312,7 @@ public void Should_Throw_If_Key_Is_Null() { // Given var fixture = new IssueBuilderFixture(); - string key = null; + const string key = null; // When var result = Record.Exception(() => @@ -2341,7 +2342,7 @@ public void Should_Throw_If_Key_Is_WhiteSpace() { // Given var fixture = new IssueBuilderFixture(); - var key = " "; + const string key = " "; // When var result = Record.Exception(() => diff --git a/src/Cake.Issues.Tests/IssueProviderSettingsTests.cs b/src/Cake.Issues.Tests/IssueProviderSettingsTests.cs index fe31054e4..db29aa008 100644 --- a/src/Cake.Issues.Tests/IssueProviderSettingsTests.cs +++ b/src/Cake.Issues.Tests/IssueProviderSettingsTests.cs @@ -1,8 +1,6 @@ namespace Cake.Issues.Tests { using System; - using System.IO; - using System.Text; using Cake.Core.IO; using Cake.Issues.Testing; using Shouldly; @@ -16,7 +14,7 @@ public sealed class TheCtor public void Should_Throw_If_LogFilePath_Is_Null() { // Given - FilePath logFilePath = null; + const FilePath logFilePath = null; // When var result = Record.Exception(() => new IssueProviderSettings(logFilePath)); @@ -29,7 +27,7 @@ public void Should_Throw_If_LogFilePath_Is_Null() public void Should_Throw_If_LogContent_Is_Null() { // Given - byte[] logFileContent = null; + const byte[] logFileContent = null; // When var result = Record.Exception(() => new IssueProviderSettings(logFileContent)); @@ -55,7 +53,7 @@ public void Should_Set_LogContent() public void Should_Set_If_LogContent_If_Empty() { // Given - byte[] logFileContent = Array.Empty(); + var logFileContent = Array.Empty(); // When var settings = new IssueProviderSettings(logFileContent); diff --git a/src/Cake.Issues.Tests/IssueTests.cs b/src/Cake.Issues.Tests/IssueTests.cs index 2cf951504..43f2e14cd 100644 --- a/src/Cake.Issues.Tests/IssueTests.cs +++ b/src/Cake.Issues.Tests/IssueTests.cs @@ -16,26 +16,26 @@ public sealed class TheIdentifierArgument public void Should_Throw_If_Identifier_Is_Null() { // Given - string identifier = null; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = null; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -72,25 +72,25 @@ public void Should_Throw_If_Identifier_Is_Empty() { // Given var identifier = string.Empty; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -126,26 +126,26 @@ public void Should_Throw_If_Identifier_Is_Empty() public void Should_Throw_If_Identifier_Is_WhiteSpace() { // Given - var identifier = " "; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = " "; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -182,25 +182,25 @@ public void Should_Throw_If_Identifier_Is_WhiteSpace() public void Should_Set_Identifier(string identifier) { // Given - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -240,25 +240,25 @@ public sealed class TheProjectFileRelativePathArgument public void Should_Throw_If_Project_Path_Is_Invalid(string projectPath) { // Given - var identifier = "identifier"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -297,25 +297,25 @@ public void Should_Throw_If_Project_Path_Is_Invalid(string projectPath) public void Should_Throw_If_File_Path_Is_Absolute(string projectPath) { // Given - var identifier = "identifier"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -351,26 +351,26 @@ public void Should_Throw_If_File_Path_Is_Absolute(string projectPath) public void Should_Handle_Project_Paths_Which_Are_Null() { // Given - var identifier = "identifier"; - string projectPath = null; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = null; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -406,26 +406,26 @@ public void Should_Handle_Project_Paths_Which_Are_Null() public void Should_Handle_Project_Paths_Which_Are_Empty() { // Given - var identifier = "identifier"; + const string identifier = "identifier"; var projectPath = string.Empty; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -461,26 +461,26 @@ public void Should_Handle_Project_Paths_Which_Are_Empty() public void Should_Handle_Project_Paths_Which_Are_WhiteSpace() { // Given - var identifier = "identifier"; - var projectPath = " "; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = " "; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -517,25 +517,25 @@ public void Should_Handle_Project_Paths_Which_Are_WhiteSpace() public void Should_Set_ProjectFileRelativePath(string projectPath) { // Given - var identifier = "identifier"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -574,26 +574,26 @@ public sealed class TheProjectNameArgument public void Should_Handle_Projects_Which_Are_Null() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - string projectName = null; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = null; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -629,26 +629,26 @@ public void Should_Handle_Projects_Which_Are_Null() public void Should_Handle_Projects_Which_Are_Empty() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; var projectName = string.Empty; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -684,26 +684,26 @@ public void Should_Handle_Projects_Which_Are_Empty() public void Should_Handle_Projects_Which_Are_WhiteSpace() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = " "; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = " "; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -740,25 +740,25 @@ public void Should_Handle_Projects_Which_Are_WhiteSpace() public void Should_Set_ProjectName(string projectName) { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -798,25 +798,25 @@ public sealed class TheAffectedFileRelativePathArgument public void Should_Throw_If_File_Path_Is_Invalid(string filePath) { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -855,25 +855,25 @@ public void Should_Throw_If_File_Path_Is_Invalid(string filePath) public void Should_Throw_If_File_Path_Is_Absolute(string filePath) { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -909,26 +909,26 @@ public void Should_Throw_If_File_Path_Is_Absolute(string filePath) public void Should_Handle_File_Paths_Which_Are_Null() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - string filePath = null; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = null; int? line = null; int? endLine = null; int? column = null; int? endColumn = null; - Uri fileLink = null; - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const Uri fileLink = null; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -964,26 +964,26 @@ public void Should_Handle_File_Paths_Which_Are_Null() public void Should_Handle_File_Paths_Which_Are_Empty() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; var filePath = string.Empty; int? line = null; int? endLine = null; int? column = null; int? endColumn = null; - Uri fileLink = null; - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const Uri fileLink = null; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -1019,26 +1019,26 @@ public void Should_Handle_File_Paths_Which_Are_Empty() public void Should_Handle_File_Paths_Which_Are_WhiteSpace() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = " "; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = " "; int? line = null; int? endLine = null; int? column = null; int? endColumn = null; - Uri fileLink = null; - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const Uri fileLink = null; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -1083,25 +1083,25 @@ public void Should_Handle_File_Paths_Which_Are_WhiteSpace() public void Should_Set_File_Path(string filePath, string expectedFilePath) { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -1141,26 +1141,26 @@ public sealed class TheLineArgument public void Should_Throw_If_Line_Is_Negative() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = -1; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = -1; int? endLine = null; int? column = null; int? endColumn = null; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -1196,26 +1196,26 @@ public void Should_Throw_If_Line_Is_Negative() public void Should_Throw_If_Line_Is_Zero() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 0; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 0; int? endLine = null; int? column = null; int? endColumn = null; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -1251,26 +1251,26 @@ public void Should_Throw_If_Line_Is_Zero() public void Should_Throw_If_Line_Is_Set_But_No_File() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - string filePath = null; - var line = 10; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = null; + const int line = 10; int? endLine = null; int? column = null; int? endColumn = null; Uri fileLink = null; - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -1306,26 +1306,26 @@ public void Should_Throw_If_Line_Is_Set_But_No_File() public void Should_Handle_Line_Which_Is_Null() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; int? line = null; int? endLine = null; int? column = null; int? endColumn = null; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -1363,25 +1363,25 @@ public void Should_Handle_Line_Which_Is_Null() public void Should_Set_Line(int line) { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; int? endLine = null; - var column = 50; - var endColumn = 55; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -1420,26 +1420,26 @@ public sealed class TheEndLineArgument public void Should_Throw_If_EndLine_Is_Negative() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = -1; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = -1; int? column = null; int? endColumn = null; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -1475,26 +1475,26 @@ public void Should_Throw_If_EndLine_Is_Negative() public void Should_Throw_If_EndLine_Is_Zero() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 0; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 0; int? column = null; int? endColumn = null; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -1530,26 +1530,26 @@ public void Should_Throw_If_EndLine_Is_Zero() public void Should_Throw_If_EndLine_Is_Set_But_No_Line() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; int? line = null; - var endLine = 12; + const int endLine = 12; int? column = null; int? endColumn = null; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -1585,26 +1585,26 @@ public void Should_Throw_If_EndLine_Is_Set_But_No_Line() public void Should_Throw_If_EndLine_Is_Smaller_Line() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 100; - var endLine = 12; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 100; + const int endLine = 12; int? column = null; int? endColumn = null; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -1640,26 +1640,26 @@ public void Should_Throw_If_EndLine_Is_Smaller_Line() public void Should_Handle_EndLine_Which_Is_Null() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; int? endLine = null; int? column = null; int? endColumn = null; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -1695,26 +1695,26 @@ public void Should_Handle_EndLine_Which_Is_Null() public void Should_Handle_EndLine_Which_Is_Equals_Line() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 10; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 10; int? column = null; int? endColumn = null; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -1752,25 +1752,25 @@ public void Should_Handle_EndLine_Which_Is_Equals_Line() public void Should_Set_EndLine(int endLine) { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 1; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 1; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -1809,26 +1809,26 @@ public sealed class TheColumnArgument public void Should_Throw_If_Column_Is_Negative() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = -1; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = -1; int? endColumn = null; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -1864,26 +1864,26 @@ public void Should_Throw_If_Column_Is_Negative() public void Should_Throw_If_Column_Is_Zero() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 0; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 0; int? endColumn = null; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -1919,26 +1919,26 @@ public void Should_Throw_If_Column_Is_Zero() public void Should_Throw_If_Column_Is_Set_But_No_Line() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; int? line = null; int? endLine = null; - var column = 50; + const int column = 50; int? endColumn = null; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -1974,26 +1974,26 @@ public void Should_Throw_If_Column_Is_Set_But_No_Line() public void Should_Handle_Column_Which_Is_Null() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; int? column = null; int? endColumn = null; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -2032,25 +2032,25 @@ public void Should_Handle_Column_Which_Is_Null() public void Should_Set_Column(int? column) { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; int? endColumn = null; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -2089,26 +2089,26 @@ public sealed class TheEndColumnArgument public void Should_Throw_If_EndColumn_Is_Negative() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = -1; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = -1; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -2144,26 +2144,26 @@ public void Should_Throw_If_EndColumn_Is_Negative() public void Should_Throw_If_EndColumn_Is_Zero() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 0; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 0; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -2199,26 +2199,26 @@ public void Should_Throw_If_EndColumn_Is_Zero() public void Should_Throw_If_EndColumn_Is_Set_But_No_Column() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; int? column = null; - var endColumn = 55; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -2254,26 +2254,26 @@ public void Should_Throw_If_EndColumn_Is_Set_But_No_Column() public void Should_Throw_If_EndColumn_Is_Smaller_Column() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 5; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 5; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -2309,26 +2309,26 @@ public void Should_Throw_If_EndColumn_Is_Smaller_Column() public void Should_Handle_EndColumn_Which_Is_Null() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; int? column = null; int? endColumn = null; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -2364,26 +2364,26 @@ public void Should_Handle_EndColumn_Which_Is_Null() public void Should_Handle_EndColumn_Which_Is_Equals_Column() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 50; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 50; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -2422,25 +2422,25 @@ public void Should_Handle_EndColumn_Which_Is_Equals_Column() public void Should_Set_EndColumn(int? endColumn) { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 1; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 1; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -2479,26 +2479,26 @@ public sealed class TheFileLinkArgument public void Should_Set_FileLink() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -2534,26 +2534,26 @@ public void Should_Set_FileLink() public void Should_Set_FileLink_If_Null() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; - Uri fileLink = null; - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; + const Uri fileLink = null; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -2592,26 +2592,26 @@ public sealed class TheMessageTextArgument public void Should_Throw_If_MessageText_Is_Null() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - string messageText = null; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = null; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -2647,26 +2647,26 @@ public void Should_Throw_If_MessageText_Is_Null() public void Should_Throw_If_MessageText_Is_Empty() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); var messageText = string.Empty; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -2702,26 +2702,26 @@ public void Should_Throw_If_MessageText_Is_Empty() public void Should_Throw_If_MessageText_Is_WhiteSpace() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = " "; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = " "; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -2758,25 +2758,25 @@ public void Should_Throw_If_MessageText_Is_WhiteSpace() public void Should_Set_MessageText(string messageText) { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -2819,25 +2819,25 @@ public sealed class TheMessageHtmlArgument public void Should_Set_MessageHtml(string messageHtml) { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -2880,25 +2880,25 @@ public sealed class TheMessageMarkdownArgument public void Should_Set_MessageHtml(string messageMarkdown) { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -2943,25 +2943,25 @@ public sealed class ThePriorityArgument public void Should_Set_Priority(int? priority) { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -3000,26 +3000,26 @@ public sealed class ThePriorityNameArgument public void Should_Handle_PriorityNames_Which_Are_Null() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - string priorityName = null; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = null; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -3055,26 +3055,26 @@ public void Should_Handle_PriorityNames_Which_Are_Null() public void Should_Handle_PriorityNames_Which_Are_Empty() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; var priorityName = string.Empty; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -3110,26 +3110,26 @@ public void Should_Handle_PriorityNames_Which_Are_Empty() public void Should_Handle_PriorityNames_Which_Are_WhiteSpace() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = " "; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = " "; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -3166,25 +3166,25 @@ public void Should_Handle_PriorityNames_Which_Are_WhiteSpace() public void Should_Set_Priority_Name(string priorityName) { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -3226,25 +3226,25 @@ public sealed class TheRuleIdArgument public void Should_Set_RuleId(string ruleId) { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -3286,25 +3286,25 @@ public sealed class TheRuleNameArgument public void Should_Set_RuleName(string ruleName) { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var ruleId = "Rule"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string ruleId = "Rule"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -3343,26 +3343,26 @@ public sealed class TheRuleUrlArgument public void Should_Set_Rule_Url() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -3398,26 +3398,26 @@ public void Should_Set_Rule_Url() public void Should_Set_Rule_Url_If_Null() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; - Uri ruleUri = null; - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; + const Uri ruleUri = null; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -3459,25 +3459,25 @@ public sealed class TheRunArgument public void Should_Set_Run(string run) { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; var additionalInformation = new Dictionary(); // When @@ -3516,26 +3516,26 @@ public sealed class TheProviderTypeArgument public void Should_Throw_If_Provider_Type_Is_Null() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - string providerType = null; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = null; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -3571,26 +3571,26 @@ public void Should_Throw_If_Provider_Type_Is_Null() public void Should_Throw_If_Provider_Type_Is_Empty() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); var providerType = string.Empty; - var providerName = "ProviderName"; - var run = "Run"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -3626,26 +3626,26 @@ public void Should_Throw_If_Provider_Type_Is_Empty() public void Should_Throw_If_Provider_Type_Is_WhiteSpace() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = " "; - var providerName = "ProviderName"; - var run = "Run"; + const string providerType = " "; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -3682,25 +3682,25 @@ public void Should_Throw_If_Provider_Type_Is_WhiteSpace() public void Should_Set_ProviderType(string providerType) { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerName = "ProviderName"; - var run = "Run"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -3739,26 +3739,26 @@ public sealed class TheProviderNameArgument public void Should_Throw_If_Provider_Name_Is_Null() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - string providerName = null; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = null; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -3794,26 +3794,26 @@ public void Should_Throw_If_Provider_Name_Is_Null() public void Should_Throw_If_Provider_Name_Is_Empty() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; - var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; - var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; + var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; + var ruleUri = new Uri("https://google.com"); + const string providerType = "ProviderType"; var providerName = string.Empty; - var run = "Run"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -3849,26 +3849,26 @@ public void Should_Throw_If_Provider_Name_Is_Empty() public void Should_Throw_If_Provider_Name_Is_WhiteSpace() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = " "; - var run = "Run"; + const string providerType = "ProviderType"; + const string providerName = " "; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -3905,25 +3905,25 @@ public void Should_Throw_If_Provider_Name_Is_WhiteSpace() public void Should_Set_ProviderName(string providerName) { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var run = "Run"; + const string providerType = "ProviderType"; + const string run = "Run"; var additionalInformation = new Dictionary(); // When @@ -3962,26 +3962,26 @@ public sealed class TheAdditionalInformationArgument public void Should_Set_AdditionalInformation() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; - var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; - var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; + var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; + var ruleUri = new Uri("https://google.com"); + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; var additionalInformation = new Dictionary { @@ -4028,27 +4028,27 @@ public void Should_Set_AdditionalInformation() public void Should_Set_AdditionalInformation_To_Empty_Dictionary() { // Given - var identifier = "identifier"; - var projectPath = @"src\foo.csproj"; - var projectName = "foo"; - var filePath = @"src\foo.cs"; - var line = 10; - var endLine = 12; - var column = 50; - var endColumn = 55; - var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); - var messageText = "MessageText"; - var messageHtml = "MessageHtml"; - var messageMarkdown = "MessageMarkdown"; - var priority = 1; - var priorityName = "Warning"; - var rule = "Rule"; - var ruleName = "Rule Name"; - var ruleUri = new Uri("https://google.com"); - var providerType = "ProviderType"; - var providerName = "ProviderName"; - var run = "Run"; - IReadOnlyDictionary additionalInformation = null; + const string identifier = "identifier"; + const string projectPath = @"src\foo.csproj"; + const string projectName = "foo"; + const string filePath = @"src\foo.cs"; + const int line = 10; + const int endLine = 12; + const int column = 50; + const int endColumn = 55; + var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"); + const string messageText = "MessageText"; + const string messageHtml = "MessageHtml"; + const string messageMarkdown = "MessageMarkdown"; + const int priority = 1; + const string priorityName = "Warning"; + const string rule = "Rule"; + const string ruleName = "Rule Name"; + var ruleUri = new Uri("https://google.com"); + const string providerType = "ProviderType"; + const string providerName = "ProviderName"; + const string run = "Run"; + const IReadOnlyDictionary additionalInformation = null; // When var issue = new Issue( diff --git a/src/Cake.Issues.Tests/IssuesArgumentChecksTests.cs b/src/Cake.Issues.Tests/IssuesArgumentChecksTests.cs index 3c35b6ec7..6d9d03a2e 100644 --- a/src/Cake.Issues.Tests/IssuesArgumentChecksTests.cs +++ b/src/Cake.Issues.Tests/IssuesArgumentChecksTests.cs @@ -12,7 +12,7 @@ public sealed class TheNotNullExtension public void Should_Throw_If_Value_Is_Null() { // Given - string value = null; + const string value = null; // When var result = Record.Exception(() => value.NotNull("foo")); @@ -35,7 +35,7 @@ public sealed class TheNotNullOrWhiteSpaceExtension public void Should_Throw_If_Value_Is_Null() { // Given - string value = null; + const string value = null; // When var result = Record.Exception(() => value.NotNullOrWhiteSpace("foo")); @@ -48,7 +48,7 @@ public void Should_Throw_If_Value_Is_Null() public void Should_Throw_If_Value_Is_Empty() { // Given - string value = string.Empty; + var value = string.Empty; // When var result = Record.Exception(() => value.NotNullOrWhiteSpace("foo")); @@ -61,7 +61,7 @@ public void Should_Throw_If_Value_Is_Empty() public void Should_Throw_If_Value_Is_WhiteSpace() { // Given - string value = " "; + const string value = " "; // When var result = Record.Exception(() => value.NotNullOrWhiteSpace("foo")); @@ -120,7 +120,7 @@ public void Should_Throw_If_Value_Is_Negative(int value) public void Should_Throw_If_Value_Is_Zero() { // Given - var value = 0; + const int value = 0; // When var result = Record.Exception(() => value.NotNegativeOrZero("foo")); @@ -144,7 +144,7 @@ public sealed class TheNotNullOrEmptyExtension public void Should_Throw_If_Value_Is_Null() { // Given - List value = null; + const List value = null; // When var result = Record.Exception(() => value.NotNullOrEmpty("foo")); @@ -188,7 +188,7 @@ public sealed class TheNotNullOrEmptyElementExtension public void Should_Throw_If_Value_Is_Null() { // Given - List value = null; + const List value = null; // When var result = Record.Exception(() => value.NotNullOrEmptyElement("foo")); @@ -243,7 +243,7 @@ public sealed class TheNotNullOrEmptyOrEmptyElementExtension public void Should_Throw_If_Value_Is_Null() { // Given - List value = null; + const List value = null; // When var result = Record.Exception(() => value.NotNullOrEmptyOrEmptyElement("foo")); diff --git a/src/Cake.Issues.Tests/IssuesFixture.cs b/src/Cake.Issues.Tests/IssuesFixture.cs index 810ca5076..8279a0f18 100644 --- a/src/Cake.Issues.Tests/IssuesFixture.cs +++ b/src/Cake.Issues.Tests/IssuesFixture.cs @@ -10,17 +10,17 @@ public class IssuesFixture public IssuesFixture() { this.Log = new FakeLog { Verbosity = Verbosity.Normal }; - this.IssueProviders = new List { new FakeIssueProvider(this.Log) }; + this.IssueProviders = new List { new (this.Log) }; this.Settings = new ReadIssuesSettings( new Core.IO.DirectoryPath(@"c:\Source\Cake.Issues")); } - public FakeLog Log { get; set; } + public FakeLog Log { get; init; } - public IList IssueProviders { get; set; } + public IList IssueProviders { get; init; } - public ReadIssuesSettings Settings { get; set; } + public ReadIssuesSettings Settings { get; init; } public IEnumerable ReadIssues() { diff --git a/src/Cake.Issues.Tests/ReadIssuesSettingsTests.cs b/src/Cake.Issues.Tests/ReadIssuesSettingsTests.cs index bffd076e6..c7da7f4e0 100644 --- a/src/Cake.Issues.Tests/ReadIssuesSettingsTests.cs +++ b/src/Cake.Issues.Tests/ReadIssuesSettingsTests.cs @@ -13,7 +13,7 @@ public sealed class TheCtor public void Should_Throw_If_RepositoryRoot_Is_Null() { // Given - DirectoryPath repoRoot = null; + const DirectoryPath repoRoot = null; // When var result = Record.Exception(() => new ReadIssuesSettings(repoRoot)); diff --git a/src/Cake.Issues.Tests/RepositorySettingsTests.cs b/src/Cake.Issues.Tests/RepositorySettingsTests.cs index 7513a96c3..8bdcf9e2c 100644 --- a/src/Cake.Issues.Tests/RepositorySettingsTests.cs +++ b/src/Cake.Issues.Tests/RepositorySettingsTests.cs @@ -13,7 +13,7 @@ public sealed class TheCtor public void Should_Throw_If_RepositoryRoot_Is_Null() { // Given - DirectoryPath repoRoot = null; + const DirectoryPath repoRoot = null; // When var result = Record.Exception(() => new RepositorySettings(repoRoot)); diff --git a/src/Cake.Issues.Tests/Serialization/IssueDeserializationExtensionsTests.cs b/src/Cake.Issues.Tests/Serialization/IssueDeserializationExtensionsTests.cs index 2f24d8c0b..7432b88c5 100644 --- a/src/Cake.Issues.Tests/Serialization/IssueDeserializationExtensionsTests.cs +++ b/src/Cake.Issues.Tests/Serialization/IssueDeserializationExtensionsTests.cs @@ -16,7 +16,7 @@ public sealed class TheDeserializeToIssueExtensionForAJsonString public void Should_Throw_If_JsonString_Is_Null() { // Given - string jsonString = null; + const string jsonString = null; // When var result = Record.Exception(() => jsonString.DeserializeToIssue()); @@ -29,12 +29,13 @@ public void Should_Throw_If_JsonString_Is_Null() public void Should_Throw_If_JsonString_Has_Unknown_Version() { // Given - var jsonString = "{\"Version\": -1}"; + const string jsonString = "{\"Version\": -1}"; // When var result = Record.Exception(() => jsonString.DeserializeToIssue()); // Then + result.ShouldNotBeNull(); result.Message.ShouldBe("Not supported issue serialization format -1"); } } @@ -45,7 +46,7 @@ public sealed class TheDeserializeToIssuesExtensionForAJsonString public void Should_Throw_If_JsonString_Is_Null() { // Given - string jsonString = null; + const string jsonString = null; // When var result = Record.Exception(() => jsonString.DeserializeToIssues()); @@ -58,7 +59,7 @@ public void Should_Throw_If_JsonString_Is_Null() public void Should_Return_An_Empty_List_For_An_Empty_Array() { // Given - string jsonString = "[]"; + const string jsonString = "[]"; // When var result = jsonString.DeserializeToIssues(); @@ -74,7 +75,7 @@ public sealed class TheDeserializeToIssueExtensionForAJsonFile public void Should_Throw_If_FilePath_Is_Null() { // Given - FilePath filePath = null; + const FilePath filePath = null; // When var result = Record.Exception(() => filePath.DeserializeToIssue()); @@ -162,7 +163,7 @@ public sealed class TheDeserializeToIssuesExtensionForAJsonFile public void Should_Throw_If_FilePath_Is_Null() { // Given - FilePath filePath = null; + const FilePath filePath = null; // When var result = Record.Exception(() => filePath.DeserializeToIssues()); diff --git a/src/Cake.Issues.Tests/Serialization/IssueSerializationExtensionsTests.cs b/src/Cake.Issues.Tests/Serialization/IssueSerializationExtensionsTests.cs index 8fb49e190..a5daa1871 100644 --- a/src/Cake.Issues.Tests/Serialization/IssueSerializationExtensionsTests.cs +++ b/src/Cake.Issues.Tests/Serialization/IssueSerializationExtensionsTests.cs @@ -17,7 +17,7 @@ public sealed class TheSerializeToJsonStringExtensionForASingleIssue public void Should_Throw_If_Issue_Is_Null() { // Given - IIssue issue = null; + const IIssue issue = null; // When var result = Record.Exception(() => issue.SerializeToJsonString()); @@ -30,7 +30,7 @@ public void Should_Throw_If_Issue_Is_Null() public void Should_Give_Correct_Result_For_Identifier_After_Roundtrip() { // Given - var identifier = "identifier"; + const string identifier = "identifier"; var issue = IssueBuilder .NewIssue(identifier, "message", "providerType", "providerName") @@ -47,7 +47,7 @@ public void Should_Give_Correct_Result_For_Identifier_After_Roundtrip() public void Should_Give_Correct_Result_For_MessageText_After_Roundtrip() { // Given - var message = "message"; + const string message = "message"; var issue = IssueBuilder .NewIssue(message, "providerType", "providerName") @@ -64,7 +64,7 @@ public void Should_Give_Correct_Result_For_MessageText_After_Roundtrip() public void Should_Give_Correct_Result_For_MessageMarkdown_After_Roundtrip() { // Given - var messageMarkdown = "messageMarkdown"; + const string messageMarkdown = "messageMarkdown"; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") @@ -82,7 +82,7 @@ public void Should_Give_Correct_Result_For_MessageMarkdown_After_Roundtrip() public void Should_Give_Correct_Result_For_MessageHtml_After_Roundtrip() { // Given - var messageHtml = "messageHtml"; + const string messageHtml = "messageHtml"; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") @@ -100,7 +100,7 @@ public void Should_Give_Correct_Result_For_MessageHtml_After_Roundtrip() public void Should_Give_Correct_Result_For_ProviderType_After_Roundtrip() { // Given - var providerType = "providerType"; + const string providerType = "providerType"; var issue = IssueBuilder .NewIssue("message", providerType, "providerName") @@ -117,7 +117,7 @@ public void Should_Give_Correct_Result_For_ProviderType_After_Roundtrip() public void Should_Give_Correct_Result_For_ProviderName_After_Roundtrip() { // Given - var providerName = "providerName"; + const string providerName = "providerName"; var issue = IssueBuilder .NewIssue("message", "providerType", providerName) @@ -134,7 +134,7 @@ public void Should_Give_Correct_Result_For_ProviderName_After_Roundtrip() public void Should_Give_Correct_Result_For_Run_After_Roundtrip() { // Given - var run = "run"; + const string run = "run"; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") @@ -152,7 +152,7 @@ public void Should_Give_Correct_Result_For_Run_After_Roundtrip() public void Should_Give_Correct_Result_For_ProjectFileRelativePath_After_Roundtrip() { // Given - var projectFileRelativePath = @"src/myproj.file"; + const string projectFileRelativePath = @"src/myproj.file"; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") @@ -170,7 +170,7 @@ public void Should_Give_Correct_Result_For_ProjectFileRelativePath_After_Roundtr public void Should_Give_Correct_Result_For_ProjectName_After_Roundtrip() { // Given - var projectName = "projectName"; + const string projectName = "projectName"; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") @@ -188,7 +188,7 @@ public void Should_Give_Correct_Result_For_ProjectName_After_Roundtrip() public void Should_Give_Correct_Result_For_AffectedFileRelativePath_After_Roundtrip() { // Given - var affectedFileRelativePath = @"src/foo.bar"; + const string affectedFileRelativePath = @"src/foo.bar"; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") @@ -206,7 +206,7 @@ public void Should_Give_Correct_Result_For_AffectedFileRelativePath_After_Roundt public void Should_Give_Correct_Result_For_Line_After_Roundtrip() { // Given - var line = 42; + const int line = 42; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") @@ -224,7 +224,7 @@ public void Should_Give_Correct_Result_For_Line_After_Roundtrip() public void Should_Give_Correct_Result_For_EndLine_After_Roundtrip() { // Given - var endLine = 420; + const int endLine = 420; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") @@ -242,7 +242,7 @@ public void Should_Give_Correct_Result_For_EndLine_After_Roundtrip() public void Should_Give_Correct_Result_For_Column_After_Roundtrip() { // Given - var column = 23; + const int column = 23; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") @@ -260,7 +260,7 @@ public void Should_Give_Correct_Result_For_Column_After_Roundtrip() public void Should_Give_Correct_Result_For_EndColumn_After_Roundtrip() { // Given - var endColumn = 230; + const int endColumn = 230; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") @@ -278,7 +278,7 @@ public void Should_Give_Correct_Result_For_EndColumn_After_Roundtrip() public void Should_Give_Correct_Result_For_FileLink_After_Roundtrip() { // Given - var fileLink = "https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"; + const string fileLink = "https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") @@ -296,7 +296,7 @@ public void Should_Give_Correct_Result_For_FileLink_After_Roundtrip() public void Should_Give_Correct_Result_For_Priority_After_Roundtrip() { // Given - var priority = 42; + const int priority = 42; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") @@ -314,7 +314,7 @@ public void Should_Give_Correct_Result_For_Priority_After_Roundtrip() public void Should_Give_Correct_Result_For_PriorityName_After_Roundtrip() { // Given - var priorityName = "priorityName"; + const string priorityName = "priorityName"; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") @@ -332,7 +332,7 @@ public void Should_Give_Correct_Result_For_PriorityName_After_Roundtrip() public void Should_Give_Correct_Result_For_RuleId_After_Roundtrip() { // Given - var ruleId = "rule"; + const string ruleId = "rule"; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") @@ -350,7 +350,7 @@ public void Should_Give_Correct_Result_For_RuleId_After_Roundtrip() public void Should_Give_Correct_Result_For_RuleName_After_Roundtrip() { // Given - var ruleName = "Rule Name"; + const string ruleName = "Rule Name"; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") @@ -389,7 +389,7 @@ public sealed class TheSerializeToJsonStringExtensionForAnEnumerableOfIssues public void Should_Throw_If_Issue_Is_Null() { // Given - IEnumerable issues = null; + const IEnumerable issues = null; // When var result = Record.Exception(() => issues.SerializeToJsonString()); @@ -402,8 +402,8 @@ public void Should_Throw_If_Issue_Is_Null() public void Should_Give_Correct_Result_For_Identifier_After_Roundtrip() { // Given - var identifier1 = "identifier1"; - var identifier2 = "identifier2"; + const string identifier1 = "identifier1"; + const string identifier2 = "identifier2"; var issues = new List { @@ -416,10 +416,10 @@ public void Should_Give_Correct_Result_For_Identifier_After_Roundtrip() }; // When - var result = issues.SerializeToJsonString().DeserializeToIssues(); + var result = issues.SerializeToJsonString().DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().Identifier.ShouldBe(identifier1); result.Last().Identifier.ShouldBe(identifier2); } @@ -428,8 +428,8 @@ public void Should_Give_Correct_Result_For_Identifier_After_Roundtrip() public void Should_Give_Correct_Result_For_MessageText_After_Roundtrip() { // Given - var messageText1 = "messageText1"; - var messageText2 = "messageText2"; + const string messageText1 = "messageText1"; + const string messageText2 = "messageText2"; var issues = new List { @@ -442,10 +442,10 @@ public void Should_Give_Correct_Result_For_MessageText_After_Roundtrip() }; // When - var result = issues.SerializeToJsonString().DeserializeToIssues(); + var result = issues.SerializeToJsonString().DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().MessageText.ShouldBe(messageText1); result.Last().MessageText.ShouldBe(messageText2); } @@ -454,8 +454,8 @@ public void Should_Give_Correct_Result_For_MessageText_After_Roundtrip() public void Should_Give_Correct_Result_For_MessageMarkdown_After_Roundtrip() { // Given - var messageMarkdown1 = "messageMarkdown1"; - var messageMarkdown2 = "messageMarkdown2"; + const string messageMarkdown1 = "messageMarkdown1"; + const string messageMarkdown2 = "messageMarkdown2"; var issues = new List { @@ -470,10 +470,10 @@ public void Should_Give_Correct_Result_For_MessageMarkdown_After_Roundtrip() }; // When - var result = issues.SerializeToJsonString().DeserializeToIssues(); + var result = issues.SerializeToJsonString().DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().MessageMarkdown.ShouldBe(messageMarkdown1); result.Last().MessageMarkdown.ShouldBe(messageMarkdown2); } @@ -482,8 +482,8 @@ public void Should_Give_Correct_Result_For_MessageMarkdown_After_Roundtrip() public void Should_Give_Correct_Result_For_MessageHtml_After_Roundtrip() { // Given - var messageHtml1 = "messageHtml1"; - var messageHtml2 = "messageHtml2"; + const string messageHtml1 = "messageHtml1"; + const string messageHtml2 = "messageHtml2"; var issues = new List { @@ -498,10 +498,10 @@ public void Should_Give_Correct_Result_For_MessageHtml_After_Roundtrip() }; // When - var result = issues.SerializeToJsonString().DeserializeToIssues(); + var result = issues.SerializeToJsonString().DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().MessageHtml.ShouldBe(messageHtml1); result.Last().MessageHtml.ShouldBe(messageHtml2); } @@ -510,8 +510,8 @@ public void Should_Give_Correct_Result_For_MessageHtml_After_Roundtrip() public void Should_Give_Correct_Result_For_ProviderType_After_Roundtrip() { // Given - var providerType1 = "providerType1"; - var providerType2 = "providerType2"; + const string providerType1 = "providerType1"; + const string providerType2 = "providerType2"; var issues = new List { @@ -524,10 +524,10 @@ public void Should_Give_Correct_Result_For_ProviderType_After_Roundtrip() }; // When - var result = issues.SerializeToJsonString().DeserializeToIssues(); + var result = issues.SerializeToJsonString().DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().ProviderType.ShouldBe(providerType1); result.Last().ProviderType.ShouldBe(providerType2); } @@ -536,8 +536,8 @@ public void Should_Give_Correct_Result_For_ProviderType_After_Roundtrip() public void Should_Give_Correct_Result_For_ProviderName_After_Roundtrip() { // Given - var providerName1 = "providerName1"; - var providerName2 = "providerName2"; + const string providerName1 = "providerName1"; + const string providerName2 = "providerName2"; var issues = new List { @@ -550,10 +550,10 @@ public void Should_Give_Correct_Result_For_ProviderName_After_Roundtrip() }; // When - var result = issues.SerializeToJsonString().DeserializeToIssues(); + var result = issues.SerializeToJsonString().DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().ProviderName.ShouldBe(providerName1); result.Last().ProviderName.ShouldBe(providerName2); } @@ -562,8 +562,8 @@ public void Should_Give_Correct_Result_For_ProviderName_After_Roundtrip() public void Should_Give_Correct_Result_For_Run_After_Roundtrip() { // Given - var run1 = "run1"; - var run2 = "run2"; + const string run1 = "run1"; + const string run2 = "run2"; var issues = new List { @@ -578,10 +578,10 @@ public void Should_Give_Correct_Result_For_Run_After_Roundtrip() }; // When - var result = issues.SerializeToJsonString().DeserializeToIssues(); + var result = issues.SerializeToJsonString().DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().Run.ShouldBe(run1); result.Last().Run.ShouldBe(run2); } @@ -590,8 +590,8 @@ public void Should_Give_Correct_Result_For_Run_After_Roundtrip() public void Should_Give_Correct_Result_For_ProjectFileRelativePath_After_Roundtrip() { // Given - var projectFileRelativePath1 = @"src/myproj1.file"; - var projectFileRelativePath2 = @"src/myproj2.file"; + const string projectFileRelativePath1 = @"src/myproj1.file"; + const string projectFileRelativePath2 = @"src/myproj2.file"; var issues = new List { @@ -606,10 +606,10 @@ public void Should_Give_Correct_Result_For_ProjectFileRelativePath_After_Roundtr }; // When - var result = issues.SerializeToJsonString().DeserializeToIssues(); + var result = issues.SerializeToJsonString().DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().ProjectFileRelativePath.FullPath.ShouldBe(projectFileRelativePath1); result.Last().ProjectFileRelativePath.FullPath.ShouldBe(projectFileRelativePath2); } @@ -618,8 +618,8 @@ public void Should_Give_Correct_Result_For_ProjectFileRelativePath_After_Roundtr public void Should_Give_Correct_Result_For_ProjectName_After_Roundtrip() { // Given - var projectName1 = "projectName1"; - var projectName2 = "projectName2"; + const string projectName1 = "projectName1"; + const string projectName2 = "projectName2"; var issues = new List { @@ -634,10 +634,10 @@ public void Should_Give_Correct_Result_For_ProjectName_After_Roundtrip() }; // When - var result = issues.SerializeToJsonString().DeserializeToIssues(); + var result = issues.SerializeToJsonString().DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().ProjectName.ShouldBe(projectName1); result.Last().ProjectName.ShouldBe(projectName2); } @@ -646,8 +646,8 @@ public void Should_Give_Correct_Result_For_ProjectName_After_Roundtrip() public void Should_Give_Correct_Result_For_AffectedFileRelativePath_After_Roundtrip() { // Given - var affectedFileRelativePath1 = @"src/foo1.bar"; - var affectedFileRelativePath2 = @"src/foo2.bar"; + const string affectedFileRelativePath1 = @"src/foo1.bar"; + const string affectedFileRelativePath2 = @"src/foo2.bar"; var issues = new List { @@ -662,10 +662,10 @@ public void Should_Give_Correct_Result_For_AffectedFileRelativePath_After_Roundt }; // When - var result = issues.SerializeToJsonString().DeserializeToIssues(); + var result = issues.SerializeToJsonString().DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().AffectedFileRelativePath.FullPath.ShouldBe(affectedFileRelativePath1); result.Last().AffectedFileRelativePath.FullPath.ShouldBe(affectedFileRelativePath2); } @@ -674,8 +674,8 @@ public void Should_Give_Correct_Result_For_AffectedFileRelativePath_After_Roundt public void Should_Give_Correct_Result_For_Line_After_Roundtrip() { // Given - var line1 = 23; - var line2 = 42; + const int line1 = 23; + const int line2 = 42; var issues = new List { @@ -690,10 +690,10 @@ public void Should_Give_Correct_Result_For_Line_After_Roundtrip() }; // When - var result = issues.SerializeToJsonString().DeserializeToIssues(); + var result = issues.SerializeToJsonString().DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().Line.ShouldBe(line1); result.Last().Line.ShouldBe(line2); } @@ -702,8 +702,8 @@ public void Should_Give_Correct_Result_For_Line_After_Roundtrip() public void Should_Give_Correct_Result_For_EndLine_After_Roundtrip() { // Given - var endLine1 = 230; - var endLine2 = 420; + const int endLine1 = 230; + const int endLine2 = 420; var issues = new List { @@ -718,10 +718,10 @@ public void Should_Give_Correct_Result_For_EndLine_After_Roundtrip() }; // When - var result = issues.SerializeToJsonString().DeserializeToIssues(); + var result = issues.SerializeToJsonString().DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().EndLine.ShouldBe(endLine1); result.Last().EndLine.ShouldBe(endLine2); } @@ -730,8 +730,8 @@ public void Should_Give_Correct_Result_For_EndLine_After_Roundtrip() public void Should_Give_Correct_Result_For_Column_After_Roundtrip() { // Given - var column1 = 23; - var column2 = 42; + const int column1 = 23; + const int column2 = 42; var issues = new List { @@ -746,10 +746,10 @@ public void Should_Give_Correct_Result_For_Column_After_Roundtrip() }; // When - var result = issues.SerializeToJsonString().DeserializeToIssues(); + var result = issues.SerializeToJsonString().DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().Column.ShouldBe(column1); result.Last().Column.ShouldBe(column2); } @@ -758,8 +758,8 @@ public void Should_Give_Correct_Result_For_Column_After_Roundtrip() public void Should_Give_Correct_Result_For_EndColumn_After_Roundtrip() { // Given - var endColumn1 = 230; - var endColumn2 = 420; + const int endColumn1 = 230; + const int endColumn2 = 420; var issues = new List { @@ -774,10 +774,10 @@ public void Should_Give_Correct_Result_For_EndColumn_After_Roundtrip() }; // When - var result = issues.SerializeToJsonString().DeserializeToIssues(); + var result = issues.SerializeToJsonString().DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().EndColumn.ShouldBe(endColumn1); result.Last().EndColumn.ShouldBe(endColumn2); } @@ -786,8 +786,8 @@ public void Should_Give_Correct_Result_For_EndColumn_After_Roundtrip() public void Should_Give_Correct_Result_For_FileLink_After_Roundtrip() { // Given - var fileLink1 = "https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"; - var fileLink2 = "https://github.com/myorg/myrepo/blob/develop/src/bar.cs#L23-L42"; + const string fileLink1 = "https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"; + const string fileLink2 = "https://github.com/myorg/myrepo/blob/develop/src/bar.cs#L23-L42"; var issues = new List { @@ -802,10 +802,10 @@ public void Should_Give_Correct_Result_For_FileLink_After_Roundtrip() }; // When - var result = issues.SerializeToJsonString().DeserializeToIssues(); + var result = issues.SerializeToJsonString().DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().FileLink.ToString().ShouldBe(fileLink1); result.Last().FileLink.ToString().ShouldBe(fileLink2); } @@ -814,8 +814,8 @@ public void Should_Give_Correct_Result_For_FileLink_After_Roundtrip() public void Should_Give_Correct_Result_For_Priority_After_Roundtrip() { // Given - var priority1 = 23; - var priority2 = 42; + const int priority1 = 23; + const int priority2 = 42; var issues = new List { @@ -830,10 +830,10 @@ public void Should_Give_Correct_Result_For_Priority_After_Roundtrip() }; // When - var result = issues.SerializeToJsonString().DeserializeToIssues(); + var result = issues.SerializeToJsonString().DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().Priority.ShouldBe(priority1); result.Last().Priority.ShouldBe(priority2); } @@ -842,8 +842,8 @@ public void Should_Give_Correct_Result_For_Priority_After_Roundtrip() public void Should_Give_Correct_Result_For_PriorityName_After_Roundtrip() { // Given - var priorityName1 = "priorityName1"; - var priorityName2 = "priorityName2"; + const string priorityName1 = "priorityName1"; + const string priorityName2 = "priorityName2"; var issues = new List { @@ -858,10 +858,10 @@ public void Should_Give_Correct_Result_For_PriorityName_After_Roundtrip() }; // When - var result = issues.SerializeToJsonString().DeserializeToIssues(); + var result = issues.SerializeToJsonString().DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().PriorityName.ShouldBe(priorityName1); result.Last().PriorityName.ShouldBe(priorityName2); } @@ -870,8 +870,8 @@ public void Should_Give_Correct_Result_For_PriorityName_After_Roundtrip() public void Should_Give_Correct_Result_For_RuleId_After_Roundtrip() { // Given - var ruleId1 = "rule1"; - var ruleId2 = "rule2"; + const string ruleId1 = "rule1"; + const string ruleId2 = "rule2"; var issues = new List { @@ -886,10 +886,10 @@ public void Should_Give_Correct_Result_For_RuleId_After_Roundtrip() }; // When - var result = issues.SerializeToJsonString().DeserializeToIssues(); + var result = issues.SerializeToJsonString().DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().RuleId.ShouldBe(ruleId1); result.Last().RuleId.ShouldBe(ruleId2); } @@ -898,8 +898,8 @@ public void Should_Give_Correct_Result_For_RuleId_After_Roundtrip() public void Should_Give_Correct_Result_For_RuleName_After_Roundtrip() { // Given - var ruleName1 = "Rule Name 1"; - var ruleName2 = "Rule Name 2"; + const string ruleName1 = "Rule Name 1"; + const string ruleName2 = "Rule Name 2"; var issues = new List { @@ -914,10 +914,10 @@ public void Should_Give_Correct_Result_For_RuleName_After_Roundtrip() }; // When - var result = issues.SerializeToJsonString().DeserializeToIssues(); + var result = issues.SerializeToJsonString().DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().RuleName.ShouldBe(ruleName1); result.Last().RuleName.ShouldBe(ruleName2); } @@ -942,10 +942,10 @@ public void Should_Give_Correct_Result_For_RuleUrl_After_Roundtrip() }; // When - var result = issues.SerializeToJsonString().DeserializeToIssues(); + var result = issues.SerializeToJsonString().DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().RuleUrl.ToString().ShouldBe(ruleUrl1.ToString()); result.Last().RuleUrl.ToString().ShouldBe(ruleUrl2.ToString()); } @@ -957,8 +957,8 @@ public sealed class TheSerializeToJsonFileExtensionForASingleIssue public void Should_Throw_If_Issue_Is_Null() { // Given - IIssue issue = null; - var filePath = @"c:\issue.json"; + const IIssue issue = null; + const string filePath = @"c:\issue.json"; // When var result = Record.Exception(() => issue.SerializeToJsonFile(filePath)); @@ -975,7 +975,7 @@ public void Should_Throw_If_FilePath_Is_Null() IssueBuilder .NewIssue("message", "providerType", "providerName") .Create(); - FilePath filePath = null; + const FilePath filePath = null; // When var result = Record.Exception(() => issue.SerializeToJsonFile(filePath)); @@ -988,12 +988,12 @@ public void Should_Throw_If_FilePath_Is_Null() public void Should_Give_Correct_Result_For_Identifier_After_Roundtrip() { // Given - var identifier = "identifier"; + const string identifier = "identifier"; var issue = IssueBuilder .NewIssue(identifier, "messageText", "providerType", "providerName") .Create(); - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { @@ -1017,12 +1017,12 @@ public void Should_Give_Correct_Result_For_Identifier_After_Roundtrip() public void Should_Give_Correct_Result_For_MessageText_After_Roundtrip() { // Given - var messageText = "messageText"; + const string messageText = "messageText"; var issue = IssueBuilder .NewIssue(messageText, "providerType", "providerName") .Create(); - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { @@ -1046,13 +1046,13 @@ public void Should_Give_Correct_Result_For_MessageText_After_Roundtrip() public void Should_Give_Correct_Result_For_MessageMarkdown_After_Roundtrip() { // Given - var messageMarkdown = "messageMarkdown"; + const string messageMarkdown = "messageMarkdown"; var issue = IssueBuilder .NewIssue("messageText", "providerType", "providerName") .WithMessageInMarkdownFormat(messageMarkdown) .Create(); - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { @@ -1076,13 +1076,13 @@ public void Should_Give_Correct_Result_For_MessageMarkdown_After_Roundtrip() public void Should_Give_Correct_Result_For_MessageHtml_After_Roundtrip() { // Given - var messageHtml = "messageHtml"; + const string messageHtml = "messageHtml"; var issue = IssueBuilder .NewIssue("messageText", "providerType", "providerName") .WithMessageInHtmlFormat(messageHtml) .Create(); - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { @@ -1106,12 +1106,12 @@ public void Should_Give_Correct_Result_For_MessageHtml_After_Roundtrip() public void Should_Give_Correct_Result_For_ProviderType_After_Roundtrip() { // Given - var providerType = "providerType"; + const string providerType = "providerType"; var issue = IssueBuilder .NewIssue("message", providerType, "providerName") .Create(); - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { @@ -1135,12 +1135,12 @@ public void Should_Give_Correct_Result_For_ProviderType_After_Roundtrip() public void Should_Give_Correct_Result_For_ProviderName_After_Roundtrip() { // Given - var providerName = "providerName"; + const string providerName = "providerName"; var issue = IssueBuilder .NewIssue("message", "providerType", providerName) .Create(); - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { @@ -1164,13 +1164,13 @@ public void Should_Give_Correct_Result_For_ProviderName_After_Roundtrip() public void Should_Give_Correct_Result_For_Run_After_Roundtrip() { // Given - var run = "run"; + const string run = "run"; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") .ForRun(run) .Create(); - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { @@ -1200,7 +1200,7 @@ public void Should_Give_Correct_Result_For_AdditionalInformation_After_Roundtrip .WithAdditionalInformation("Foo", "Bar") .Create(); - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { @@ -1224,13 +1224,13 @@ public void Should_Give_Correct_Result_For_AdditionalInformation_After_Roundtrip public void Should_Give_Correct_Result_For_ProjectFileRelativePath_After_Roundtrip() { // Given - var projectFileRelativePath = @"src/myproj.file"; + const string projectFileRelativePath = @"src/myproj.file"; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") .InProjectFile(projectFileRelativePath) .Create(); - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { @@ -1254,13 +1254,13 @@ public void Should_Give_Correct_Result_For_ProjectFileRelativePath_After_Roundtr public void Should_Give_Correct_Result_For_ProjectName_After_Roundtrip() { // Given - var projectName = "projectName"; + const string projectName = "projectName"; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") .InProjectOfName(projectName) .Create(); - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { @@ -1284,13 +1284,13 @@ public void Should_Give_Correct_Result_For_ProjectName_After_Roundtrip() public void Should_Give_Correct_Result_For_AffectedFileRelativePath_After_Roundtrip() { // Given - var affectedFileRelativePath = @"src/foo.bar"; + const string affectedFileRelativePath = @"src/foo.bar"; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") .InFile(affectedFileRelativePath) .Create(); - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { @@ -1314,13 +1314,13 @@ public void Should_Give_Correct_Result_For_AffectedFileRelativePath_After_Roundt public void Should_Give_Correct_Result_For_Line_After_Roundtrip() { // Given - var line = 42; + const int line = 42; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") .InFile(@"src/foo.bar", line) .Create(); - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { @@ -1344,13 +1344,13 @@ public void Should_Give_Correct_Result_For_Line_After_Roundtrip() public void Should_Give_Correct_Result_For_EndLine_After_Roundtrip() { // Given - var endLine = 420; + const int endLine = 420; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") .InFile(@"src/foo.bar", 42, endLine, null, null) .Create(); - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { @@ -1374,13 +1374,13 @@ public void Should_Give_Correct_Result_For_EndLine_After_Roundtrip() public void Should_Give_Correct_Result_For_Column_After_Roundtrip() { // Given - var column = 23; + const int column = 23; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") .InFile(@"src/foo.bar", 42, column) .Create(); - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { @@ -1404,13 +1404,13 @@ public void Should_Give_Correct_Result_For_Column_After_Roundtrip() public void Should_Give_Correct_Result_For_EndColumn_After_Roundtrip() { // Given - var endColumn = 230; + const int endColumn = 230; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") .InFile(@"src/foo.bar", 42, 50, 1, endColumn) .Create(); - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { @@ -1434,13 +1434,13 @@ public void Should_Give_Correct_Result_For_EndColumn_After_Roundtrip() public void Should_Give_Correct_Result_For_FileLink_After_Roundtrip() { // Given - var fileLink = "https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"; + const string fileLink = "https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") .WithFileLink(new Uri(fileLink)) .Create(); - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { @@ -1464,13 +1464,13 @@ public void Should_Give_Correct_Result_For_FileLink_After_Roundtrip() public void Should_Give_Correct_Result_For_Priority_After_Roundtrip() { // Given - var priority = 42; + const int priority = 42; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") .WithPriority(priority, "priorityName") .Create(); - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { @@ -1494,13 +1494,13 @@ public void Should_Give_Correct_Result_For_Priority_After_Roundtrip() public void Should_Give_Correct_Result_For_PriorityName_After_Roundtrip() { // Given - var priorityName = "priorityName"; + const string priorityName = "priorityName"; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") .WithPriority(42, priorityName) .Create(); - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { @@ -1524,13 +1524,13 @@ public void Should_Give_Correct_Result_For_PriorityName_After_Roundtrip() public void Should_Give_Correct_Result_For_RuleId_After_Roundtrip() { // Given - var ruleId = "rule"; + const string ruleId = "rule"; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") .OfRule(ruleId) .Create(); - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { @@ -1554,13 +1554,13 @@ public void Should_Give_Correct_Result_For_RuleId_After_Roundtrip() public void Should_Give_Correct_Result_For_RuleName_After_Roundtrip() { // Given - var ruleName = "Rule Name"; + const string ruleName = "Rule Name"; var issue = IssueBuilder .NewIssue("message", "providerType", "providerName") .OfRule("rule", ruleName) .Create(); - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { @@ -1590,7 +1590,7 @@ public void Should_Give_Correct_Result_For_RuleUrl_After_Roundtrip() .NewIssue("message", "providerType", "providerName") .OfRule("rule", ruleUrl) .Create(); - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { @@ -1617,8 +1617,8 @@ public sealed class TheSerializeToJsonFileExtensionForAnEnumerableOfIssues public void Should_Throw_If_Issue_Is_Null() { // Given - IEnumerable issues = null; - var filePath = @"c:\issues.json"; + const IEnumerable issues = null; + const string filePath = @"c:\issues.json"; // When var result = Record.Exception(() => issues.SerializeToJsonFile(filePath)); @@ -1645,8 +1645,8 @@ public void Should_Throw_If_FilePath_Is_Null() public void Should_Give_Correct_Result_For_Identifier_After_Roundtrip() { // Given - var identifier1 = "identifier1"; - var identifier2 = "identifier2"; + const string identifier1 = "identifier1"; + const string identifier2 = "identifier2"; var issues = new List { @@ -1657,16 +1657,16 @@ public void Should_Give_Correct_Result_For_Identifier_After_Roundtrip() .NewIssue(identifier2, "messageText2", "providerType2", "providerName2") .Create(), }; - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { // When issues.SerializeToJsonFile(filePath); - var result = filePath.DeserializeToIssues(); + var result = filePath.DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().Identifier.ShouldBe(identifier1); result.Last().Identifier.ShouldBe(identifier2); } @@ -1683,8 +1683,8 @@ public void Should_Give_Correct_Result_For_Identifier_After_Roundtrip() public void Should_Give_Correct_Result_For_MessageText_After_Roundtrip() { // Given - var messageText1 = "messageText1"; - var messageText2 = "messageText2"; + const string messageText1 = "messageText1"; + const string messageText2 = "messageText2"; var issues = new List { @@ -1695,16 +1695,16 @@ public void Should_Give_Correct_Result_For_MessageText_After_Roundtrip() .NewIssue(messageText2, "providerType2", "providerName2") .Create(), }; - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { // When issues.SerializeToJsonFile(filePath); - var result = filePath.DeserializeToIssues(); + var result = filePath.DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().MessageText.ShouldBe(messageText1); result.Last().MessageText.ShouldBe(messageText2); } @@ -1721,8 +1721,8 @@ public void Should_Give_Correct_Result_For_MessageText_After_Roundtrip() public void Should_Give_Correct_Result_For_MessageMarkdown_After_Roundtrip() { // Given - var messageMarkdown1 = "messageMarkdown1"; - var messageMarkdown2 = "messageMarkdown2"; + const string messageMarkdown1 = "messageMarkdown1"; + const string messageMarkdown2 = "messageMarkdown2"; var issues = new List { @@ -1735,16 +1735,16 @@ public void Should_Give_Correct_Result_For_MessageMarkdown_After_Roundtrip() .WithMessageInMarkdownFormat(messageMarkdown2) .Create(), }; - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { // When issues.SerializeToJsonFile(filePath); - var result = filePath.DeserializeToIssues(); + var result = filePath.DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().MessageMarkdown.ShouldBe(messageMarkdown1); result.Last().MessageMarkdown.ShouldBe(messageMarkdown2); } @@ -1761,8 +1761,8 @@ public void Should_Give_Correct_Result_For_MessageMarkdown_After_Roundtrip() public void Should_Give_Correct_Result_For_MessageHtml_After_Roundtrip() { // Given - var messageHtml1 = "messageHtml1"; - var messageHtml2 = "messageHtml2"; + const string messageHtml1 = "messageHtml1"; + const string messageHtml2 = "messageHtml2"; var issues = new List { @@ -1775,16 +1775,16 @@ public void Should_Give_Correct_Result_For_MessageHtml_After_Roundtrip() .WithMessageInHtmlFormat(messageHtml2) .Create(), }; - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { // When issues.SerializeToJsonFile(filePath); - var result = filePath.DeserializeToIssues(); + var result = filePath.DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().MessageHtml.ShouldBe(messageHtml1); result.Last().MessageHtml.ShouldBe(messageHtml2); } @@ -1801,8 +1801,8 @@ public void Should_Give_Correct_Result_For_MessageHtml_After_Roundtrip() public void Should_Give_Correct_Result_For_ProviderType_After_Roundtrip() { // Given - var providerType1 = "providerType1"; - var providerType2 = "providerType2"; + const string providerType1 = "providerType1"; + const string providerType2 = "providerType2"; var issues = new List { @@ -1813,16 +1813,16 @@ public void Should_Give_Correct_Result_For_ProviderType_After_Roundtrip() .NewIssue("message2", providerType2, "providerName2") .Create(), }; - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { // When issues.SerializeToJsonFile(filePath); - var result = filePath.DeserializeToIssues(); + var result = filePath.DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().ProviderType.ShouldBe(providerType1); result.Last().ProviderType.ShouldBe(providerType2); } @@ -1839,8 +1839,8 @@ public void Should_Give_Correct_Result_For_ProviderType_After_Roundtrip() public void Should_Give_Correct_Result_For_ProviderName_After_Roundtrip() { // Given - var providerName1 = "providerName1"; - var providerName2 = "providerName2"; + const string providerName1 = "providerName1"; + const string providerName2 = "providerName2"; var issues = new List { @@ -1851,16 +1851,16 @@ public void Should_Give_Correct_Result_For_ProviderName_After_Roundtrip() .NewIssue("message2", "providerType2", providerName2) .Create(), }; - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { // When issues.SerializeToJsonFile(filePath); - var result = filePath.DeserializeToIssues(); + var result = filePath.DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().ProviderName.ShouldBe(providerName1); result.Last().ProviderName.ShouldBe(providerName2); } @@ -1877,8 +1877,8 @@ public void Should_Give_Correct_Result_For_ProviderName_After_Roundtrip() public void Should_Give_Correct_Result_For_Run_After_Roundtrip() { // Given - var run1 = "run1"; - var run2 = "run2"; + const string run1 = "run1"; + const string run2 = "run2"; var issues = new List { @@ -1891,16 +1891,16 @@ public void Should_Give_Correct_Result_For_Run_After_Roundtrip() .ForRun(run2) .Create(), }; - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { // When issues.SerializeToJsonFile(filePath); - var result = filePath.DeserializeToIssues(); + var result = filePath.DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().Run.ShouldBe(run1); result.Last().Run.ShouldBe(run2); } @@ -1917,8 +1917,8 @@ public void Should_Give_Correct_Result_For_Run_After_Roundtrip() public void Should_Give_Correct_Result_For_ProjectFileRelativePath_After_Roundtrip() { // Given - var projectFileRelativePath1 = @"src/myproj1.file"; - var projectFileRelativePath2 = @"src/myproj2.file"; + const string projectFileRelativePath1 = @"src/myproj1.file"; + const string projectFileRelativePath2 = @"src/myproj2.file"; var issues = new List { @@ -1931,16 +1931,16 @@ public void Should_Give_Correct_Result_For_ProjectFileRelativePath_After_Roundtr .InProjectFile(projectFileRelativePath2) .Create(), }; - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { // When issues.SerializeToJsonFile(filePath); - var result = filePath.DeserializeToIssues(); + var result = filePath.DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().ProjectFileRelativePath.FullPath.ShouldBe(projectFileRelativePath1); result.Last().ProjectFileRelativePath.FullPath.ShouldBe(projectFileRelativePath2); } @@ -1957,8 +1957,8 @@ public void Should_Give_Correct_Result_For_ProjectFileRelativePath_After_Roundtr public void Should_Give_Correct_Result_For_ProjectName_After_Roundtrip() { // Given - var projectName1 = "projectName1"; - var projectName2 = "projectName2"; + const string projectName1 = "projectName1"; + const string projectName2 = "projectName2"; var issues = new List { @@ -1971,16 +1971,16 @@ public void Should_Give_Correct_Result_For_ProjectName_After_Roundtrip() .InProjectOfName(projectName2) .Create(), }; - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { // When issues.SerializeToJsonFile(filePath); - var result = filePath.DeserializeToIssues(); + var result = filePath.DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().ProjectName.ShouldBe(projectName1); result.Last().ProjectName.ShouldBe(projectName2); } @@ -1997,8 +1997,8 @@ public void Should_Give_Correct_Result_For_ProjectName_After_Roundtrip() public void Should_Give_Correct_Result_For_AffectedFileRelativePath_After_Roundtrip() { // Given - var affectedFileRelativePath1 = @"src/foo1.bar"; - var affectedFileRelativePath2 = @"src/foo2.bar"; + const string affectedFileRelativePath1 = @"src/foo1.bar"; + const string affectedFileRelativePath2 = @"src/foo2.bar"; var issues = new List { @@ -2011,16 +2011,16 @@ public void Should_Give_Correct_Result_For_AffectedFileRelativePath_After_Roundt .InFile(affectedFileRelativePath2) .Create(), }; - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { // When issues.SerializeToJsonFile(filePath); - var result = filePath.DeserializeToIssues(); + var result = filePath.DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().AffectedFileRelativePath.FullPath.ShouldBe(affectedFileRelativePath1); result.Last().AffectedFileRelativePath.FullPath.ShouldBe(affectedFileRelativePath2); } @@ -2037,8 +2037,8 @@ public void Should_Give_Correct_Result_For_AffectedFileRelativePath_After_Roundt public void Should_Give_Correct_Result_For_Line_After_Roundtrip() { // Given - var line1 = 23; - var line2 = 42; + const int line1 = 23; + const int line2 = 42; var issues = new List { @@ -2051,16 +2051,16 @@ public void Should_Give_Correct_Result_For_Line_After_Roundtrip() .InFile(@"src/foo.bar", line2) .Create(), }; - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { // When issues.SerializeToJsonFile(filePath); - var result = filePath.DeserializeToIssues(); + var result = filePath.DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().Line.ShouldBe(line1); result.Last().Line.ShouldBe(line2); } @@ -2077,8 +2077,8 @@ public void Should_Give_Correct_Result_For_Line_After_Roundtrip() public void Should_Give_Correct_Result_For_EndLine_After_Roundtrip() { // Given - var endLine1 = 230; - var endLine2 = 420; + const int endLine1 = 230; + const int endLine2 = 420; var issues = new List { @@ -2091,16 +2091,16 @@ public void Should_Give_Correct_Result_For_EndLine_After_Roundtrip() .InFile(@"src/foo.bar", 42, endLine2, null, null) .Create(), }; - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { // When issues.SerializeToJsonFile(filePath); - var result = filePath.DeserializeToIssues(); + var result = filePath.DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().EndLine.ShouldBe(endLine1); result.Last().EndLine.ShouldBe(endLine2); } @@ -2117,8 +2117,8 @@ public void Should_Give_Correct_Result_For_EndLine_After_Roundtrip() public void Should_Give_Correct_Result_For_Column_After_Roundtrip() { // Given - var column1 = 23; - var column2 = 42; + const int column1 = 23; + const int column2 = 42; var issues = new List { @@ -2131,16 +2131,16 @@ public void Should_Give_Correct_Result_For_Column_After_Roundtrip() .InFile(@"src/foo.bar", 123, column2) .Create(), }; - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { // When issues.SerializeToJsonFile(filePath); - var result = filePath.DeserializeToIssues(); + var result = filePath.DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().Column.ShouldBe(column1); result.Last().Column.ShouldBe(column2); } @@ -2157,8 +2157,8 @@ public void Should_Give_Correct_Result_For_Column_After_Roundtrip() public void Should_Give_Correct_Result_For_EndColumn_After_Roundtrip() { // Given - var endColumn1 = 23; - var endColumn2 = 42; + const int endColumn1 = 23; + const int endColumn2 = 42; var issues = new List { @@ -2171,16 +2171,16 @@ public void Should_Give_Correct_Result_For_EndColumn_After_Roundtrip() .InFile(@"src/foo.bar", 5, 50, 1, endColumn2) .Create(), }; - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { // When issues.SerializeToJsonFile(filePath); - var result = filePath.DeserializeToIssues(); + var result = filePath.DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().EndColumn.ShouldBe(endColumn1); result.Last().EndColumn.ShouldBe(endColumn2); } @@ -2197,8 +2197,8 @@ public void Should_Give_Correct_Result_For_EndColumn_After_Roundtrip() public void Should_Give_Correct_Result_For_FileLink_After_Roundtrip() { // Given - var fileLink1 = "https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"; - var fileLink2 = "https://github.com/myorg/myrepo/blob/develop/src/bar.cs#L23-L42"; + const string fileLink1 = "https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12"; + const string fileLink2 = "https://github.com/myorg/myrepo/blob/develop/src/bar.cs#L23-L42"; var issues = new List { @@ -2211,16 +2211,16 @@ public void Should_Give_Correct_Result_For_FileLink_After_Roundtrip() .WithFileLink(new Uri(fileLink2)) .Create(), }; - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { // When issues.SerializeToJsonFile(filePath); - var result = filePath.DeserializeToIssues(); + var result = filePath.DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().FileLink.ToString().ShouldBe(fileLink1); result.Last().FileLink.ToString().ShouldBe(fileLink2); } @@ -2237,8 +2237,8 @@ public void Should_Give_Correct_Result_For_FileLink_After_Roundtrip() public void Should_Give_Correct_Result_For_Priority_After_Roundtrip() { // Given - var priority1 = 23; - var priority2 = 42; + const int priority1 = 23; + const int priority2 = 42; var issues = new List { @@ -2251,16 +2251,16 @@ public void Should_Give_Correct_Result_For_Priority_After_Roundtrip() .WithPriority(priority2, "priorityName") .Create(), }; - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { // When issues.SerializeToJsonFile(filePath); - var result = filePath.DeserializeToIssues(); + var result = filePath.DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().Priority.ShouldBe(priority1); result.Last().Priority.ShouldBe(priority2); } @@ -2277,8 +2277,8 @@ public void Should_Give_Correct_Result_For_Priority_After_Roundtrip() public void Should_Give_Correct_Result_For_PriorityName_After_Roundtrip() { // Given - var priorityName1 = "priorityName1"; - var priorityName2 = "priorityName2"; + const string priorityName1 = "priorityName1"; + const string priorityName2 = "priorityName2"; var issues = new List { @@ -2291,16 +2291,16 @@ public void Should_Give_Correct_Result_For_PriorityName_After_Roundtrip() .WithPriority(42, priorityName2) .Create(), }; - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { // When issues.SerializeToJsonFile(filePath); - var result = filePath.DeserializeToIssues(); + var result = filePath.DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().PriorityName.ShouldBe(priorityName1); result.Last().PriorityName.ShouldBe(priorityName2); } @@ -2317,8 +2317,8 @@ public void Should_Give_Correct_Result_For_PriorityName_After_Roundtrip() public void Should_Give_Correct_Result_For_RuleId_After_Roundtrip() { // Given - var ruleId1 = "rule1"; - var ruleId2 = "rule2"; + const string ruleId1 = "rule1"; + const string ruleId2 = "rule2"; var issues = new List { @@ -2331,16 +2331,16 @@ public void Should_Give_Correct_Result_For_RuleId_After_Roundtrip() .OfRule(ruleId2) .Create(), }; - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { // When issues.SerializeToJsonFile(filePath); - var result = filePath.DeserializeToIssues(); + var result = filePath.DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().RuleId.ShouldBe(ruleId1); result.Last().RuleId.ShouldBe(ruleId2); } @@ -2357,8 +2357,8 @@ public void Should_Give_Correct_Result_For_RuleId_After_Roundtrip() public void Should_Give_Correct_Result_For_RuleName_After_Roundtrip() { // Given - var ruleName1 = "Rule Name 1"; - var ruleName2 = "Rule Name 2"; + const string ruleName1 = "Rule Name 1"; + const string ruleName2 = "Rule Name 2"; var issues = new List { @@ -2371,18 +2371,18 @@ public void Should_Give_Correct_Result_For_RuleName_After_Roundtrip() .OfRule("rule", ruleName2) .Create(), }; - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { // When issues.SerializeToJsonFile(filePath); - var result = filePath.DeserializeToIssues(); + var result = filePath.DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); - result.First().RuleName.ToString().ShouldBe(ruleName1); - result.Last().RuleName.ToString().ShouldBe(ruleName2); + result.Count.ShouldBe(2); + result.First().RuleName.ShouldBe(ruleName1); + result.Last().RuleName.ShouldBe(ruleName2); } finally { @@ -2411,16 +2411,16 @@ public void Should_Give_Correct_Result_For_RuleUrl_After_Roundtrip() .OfRule("rule", ruleUrl2) .Create(), }; - var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".json"); + var filePath = new FilePath(System.IO.Path.GetTempPath() + Guid.NewGuid() + ".json"); try { // When issues.SerializeToJsonFile(filePath); - var result = filePath.DeserializeToIssues(); + var result = filePath.DeserializeToIssues().ToList(); // Then - result.Count().ShouldBe(2); + result.Count.ShouldBe(2); result.First().RuleUrl.ToString().ShouldBe(ruleUrl1.ToString()); result.Last().RuleUrl.ToString().ShouldBe(ruleUrl2.ToString()); } @@ -2440,7 +2440,7 @@ public sealed class TheToSerializableIssueExtension public void Should_Throw_If_Issue_Is_Null() { // Given - IIssue issue = null; + const IIssue issue = null; // When var result = Record.Exception(() => issue.ToSerializableIssue()); diff --git a/src/Cake.Issues.Tests/Serialization/SerializableIssueExtensionsTests.cs b/src/Cake.Issues.Tests/Serialization/SerializableIssueExtensionsTests.cs index 79e174bae..9872dc6a8 100644 --- a/src/Cake.Issues.Tests/Serialization/SerializableIssueExtensionsTests.cs +++ b/src/Cake.Issues.Tests/Serialization/SerializableIssueExtensionsTests.cs @@ -12,7 +12,7 @@ public sealed class TheToIssueExtension public void Should_Throw_If_SerializableIssue_Is_Null() { // Given - SerializableIssue serializableIssue = null; + const SerializableIssue serializableIssue = null; // When var result = Record.Exception(() => serializableIssue.ToIssue()); diff --git a/src/Cake.Issues.Tests/Serialization/SerializableIssueV2ExtensionsTests.cs b/src/Cake.Issues.Tests/Serialization/SerializableIssueV2ExtensionsTests.cs index 4ef0f43c0..9f6bbb2e4 100644 --- a/src/Cake.Issues.Tests/Serialization/SerializableIssueV2ExtensionsTests.cs +++ b/src/Cake.Issues.Tests/Serialization/SerializableIssueV2ExtensionsTests.cs @@ -12,7 +12,7 @@ public sealed class TheToIssueExtension public void Should_Throw_If_SerializableIssue_Is_Null() { // Given - SerializableIssueV2 serializableIssue = null; + const SerializableIssueV2 serializableIssue = null; // When var result = Record.Exception(() => serializableIssue.ToIssue()); diff --git a/src/Cake.Issues.Tests/Serialization/SerializableIssueV3ExtensionsTests.cs b/src/Cake.Issues.Tests/Serialization/SerializableIssueV3ExtensionsTests.cs index c223b55cb..a64fb02d8 100644 --- a/src/Cake.Issues.Tests/Serialization/SerializableIssueV3ExtensionsTests.cs +++ b/src/Cake.Issues.Tests/Serialization/SerializableIssueV3ExtensionsTests.cs @@ -12,7 +12,7 @@ public sealed class TheToIssueExtension public void Should_Throw_If_SerializableIssue_Is_Null() { // Given - SerializableIssueV3 serializableIssue = null; + const SerializableIssueV3 serializableIssue = null; // When var result = Record.Exception(() => serializableIssue.ToIssue()); diff --git a/src/Cake.Issues.Tests/Serialization/SerializableIssueV4ExtensionsTests.cs b/src/Cake.Issues.Tests/Serialization/SerializableIssueV4ExtensionsTests.cs index 0e08e27cf..4f9987263 100644 --- a/src/Cake.Issues.Tests/Serialization/SerializableIssueV4ExtensionsTests.cs +++ b/src/Cake.Issues.Tests/Serialization/SerializableIssueV4ExtensionsTests.cs @@ -12,7 +12,7 @@ public sealed class TheToIssueExtension public void Should_Throw_If_SerializableIssue_Is_Null() { // Given - SerializableIssueV4 serializableIssue = null; + const SerializableIssueV4 serializableIssue = null; // When var result = Record.Exception(() => serializableIssue.ToIssue()); diff --git a/src/Cake.Issues.Tests/Testing/BaseConfigurableIssueProviderFixtureTests.cs b/src/Cake.Issues.Tests/Testing/BaseConfigurableIssueProviderFixtureTests.cs index 182507833..14178a38a 100644 --- a/src/Cake.Issues.Tests/Testing/BaseConfigurableIssueProviderFixtureTests.cs +++ b/src/Cake.Issues.Tests/Testing/BaseConfigurableIssueProviderFixtureTests.cs @@ -1,6 +1,5 @@ namespace Cake.Issues.Tests.Testing { - using System.Linq; using Cake.Issues.Testing; using Shouldly; using Xunit; @@ -13,7 +12,7 @@ public sealed class TheCtor public void Should_Throw_If_FileResourceName_Is_Null() { // Given - string fileResourceName = null; + const string fileResourceName = null; // When var result = Record.Exception(() => new FakeConfigurableIssueProviderFixture(fileResourceName)); @@ -39,7 +38,7 @@ public void Should_Throw_If_FileResourceName_Is_Empty() public void Should_Throw_If_FileResourceName_Is_WhiteSpace() { // Given - var fileResourceName = " "; + const string fileResourceName = " "; // When var result = Record.Exception(() => new FakeConfigurableIssueProviderFixture(fileResourceName)); @@ -52,7 +51,7 @@ public void Should_Throw_If_FileResourceName_Is_WhiteSpace() public void Should_Throw_If_File_Resource_Does_Not_Exist() { // Given - var fileResourceName = "foo"; + const string fileResourceName = "foo"; // When var result = Record.Exception(() => new FakeConfigurableIssueProviderFixture(fileResourceName)); diff --git a/src/Cake.Issues.Tests/Testing/BaseIssueProviderFixtureTests.cs b/src/Cake.Issues.Tests/Testing/BaseIssueProviderFixtureTests.cs index 5aa2d628b..5872ba5d6 100644 --- a/src/Cake.Issues.Tests/Testing/BaseIssueProviderFixtureTests.cs +++ b/src/Cake.Issues.Tests/Testing/BaseIssueProviderFixtureTests.cs @@ -80,10 +80,10 @@ public void Should_Return_Issues() var fixture = new FakeIssueProviderFixture(new List { issue }); // When - var result = fixture.ReadIssues(); + var result = fixture.ReadIssues().ToList(); // Then - result.Count().ShouldBe(1); + result.Count.ShouldBe(1); result.ShouldContain(issue); } } diff --git a/src/Cake.Issues.Tests/Testing/BaseMultiFormatIssueProviderFixtureTests.cs b/src/Cake.Issues.Tests/Testing/BaseMultiFormatIssueProviderFixtureTests.cs index be71cbfff..014be96ae 100644 --- a/src/Cake.Issues.Tests/Testing/BaseMultiFormatIssueProviderFixtureTests.cs +++ b/src/Cake.Issues.Tests/Testing/BaseMultiFormatIssueProviderFixtureTests.cs @@ -1,6 +1,5 @@ namespace Cake.Issues.Tests.Testing { - using System.Linq; using Cake.Issues.Testing; using Shouldly; using Xunit; @@ -13,7 +12,7 @@ public sealed class TheCtor public void Should_Throw_If_FileResourceName_Is_Null() { // Given - string fileResourceName = null; + const string fileResourceName = null; // When var result = Record.Exception(() => new FakeMultiFormatIssueProviderFixture(fileResourceName)); @@ -39,7 +38,7 @@ public void Should_Throw_If_FileResourceName_Is_Empty() public void Should_Throw_If_FileResourceName_Is_WhiteSpace() { // Given - var fileResourceName = " "; + const string fileResourceName = " "; // When var result = Record.Exception(() => new FakeMultiFormatIssueProviderFixture(fileResourceName)); @@ -52,7 +51,7 @@ public void Should_Throw_If_FileResourceName_Is_WhiteSpace() public void Should_Throw_If_File_Resource_Does_Not_Exist() { // Given - var fileResourceName = "foo"; + const string fileResourceName = "foo"; // When var result = Record.Exception(() => new FakeMultiFormatIssueProviderFixture(fileResourceName)); diff --git a/src/Cake.Issues.Tests/Testing/ExceptionAssertExtensionsTests.cs b/src/Cake.Issues.Tests/Testing/ExceptionAssertExtensionsTests.cs index 7e6474d93..e856ed217 100644 --- a/src/Cake.Issues.Tests/Testing/ExceptionAssertExtensionsTests.cs +++ b/src/Cake.Issues.Tests/Testing/ExceptionAssertExtensionsTests.cs @@ -13,14 +13,14 @@ public sealed class TheIsArgumentExceptionMethod public void Should_Throw_If_Exception_Type_Is_Null() { // Given - Exception exception = null; + const Exception exception = null; // When var result = Record.Exception(() => exception.IsArgumentException("Foo")); // Then result.ShouldBeOfType(); - result.Message.ShouldBe($"Expected exception of type 'System.ArgumentException' but no exception was thrown."); + result.Message.ShouldBe("Expected exception of type 'System.ArgumentException' but no exception was thrown."); } [Fact] @@ -34,7 +34,7 @@ public void Should_Throw_If_Exception_Type_Is_Not_ArgumentException() // Then result.ShouldBeOfType(); - result.Message.ShouldBe($"Expected exception of type 'System.ArgumentException' but was 'System.Exception'."); + result.Message.ShouldBe("Expected exception of type 'System.ArgumentException' but was 'System.Exception'."); } [Fact] @@ -88,14 +88,14 @@ public sealed class TheIsArgumentNullExceptionMethod public void Should_Throw_If_Exception_Type_Is_Null() { // Given - Exception exception = null; + const Exception exception = null; // When var result = Record.Exception(() => exception.IsArgumentNullException("Foo")); // Then result.ShouldBeOfType(); - result.Message.ShouldBe($"Expected exception of type 'System.ArgumentNullException' but no exception was thrown."); + result.Message.ShouldBe("Expected exception of type 'System.ArgumentNullException' but no exception was thrown."); } [Fact] @@ -109,7 +109,7 @@ public void Should_Throw_If_Exception_Type_Is_Not_ArgumentNullException() // Then result.ShouldBeOfType(); - result.Message.ShouldBe($"Expected exception of type 'System.ArgumentNullException' but was 'System.Exception'."); + result.Message.ShouldBe("Expected exception of type 'System.ArgumentNullException' but was 'System.Exception'."); } [Fact] @@ -163,14 +163,14 @@ public sealed class TheIsArgumentOutOfRangeExceptionMethod public void Should_Throw_If_Exception_Type_Is_Null() { // Given - Exception exception = null; + const Exception exception = null; // When var result = Record.Exception(() => exception.IsArgumentOutOfRangeException("Foo")); // Then result.ShouldBeOfType(); - result.Message.ShouldBe($"Expected exception of type 'System.ArgumentOutOfRangeException' but no exception was thrown."); + result.Message.ShouldBe("Expected exception of type 'System.ArgumentOutOfRangeException' but no exception was thrown."); } [Fact] @@ -184,7 +184,7 @@ public void Should_Throw_If_Exception_Type_Is_Not_ArgumentOutOfRangeException() // Then result.ShouldBeOfType(); - result.Message.ShouldBe($"Expected exception of type 'System.ArgumentOutOfRangeException' but was 'System.Exception'."); + result.Message.ShouldBe("Expected exception of type 'System.ArgumentOutOfRangeException' but was 'System.Exception'."); } [Fact] @@ -238,14 +238,14 @@ public sealed class TheIsInvalidOperationExceptionMethod public void Should_Throw_If_Exception_Type_Is_Null() { // Given - Exception exception = null; + const Exception exception = null; // When var result = Record.Exception(() => exception.IsInvalidOperationException("Foo")); // Then result.ShouldBeOfType(); - result.Message.ShouldBe($"Expected exception of type 'System.InvalidOperationException' but no exception was thrown."); + result.Message.ShouldBe("Expected exception of type 'System.InvalidOperationException' but no exception was thrown."); } [Fact] @@ -259,7 +259,7 @@ public void Should_Throw_If_Exception_Type_Is_Not_InvalidOperationException() // Then result.ShouldBeOfType(); - result.Message.ShouldBe($"Expected exception of type 'System.InvalidOperationException' but was 'System.Exception'."); + result.Message.ShouldBe("Expected exception of type 'System.InvalidOperationException' but was 'System.Exception'."); } [Fact] diff --git a/src/Cake.Issues.Tests/Testing/IssueCheckerFixture.cs b/src/Cake.Issues.Tests/Testing/IssueCheckerFixture.cs index 776151024..d001512af 100644 --- a/src/Cake.Issues.Tests/Testing/IssueCheckerFixture.cs +++ b/src/Cake.Issues.Tests/Testing/IssueCheckerFixture.cs @@ -1,4 +1,4 @@ -namespace Cake.Issues.Tests +namespace Cake.Issues.Tests.Testing { using System; using System.Collections.Generic; @@ -50,48 +50,48 @@ public IssueCheckerFixture(string identifier, string messageText, string provide this.IssueBuilder.Create(); } - public IIssue Issue { get; private set; } + public IIssue Issue { get; } - public string ProviderType { get; private set; } + public string ProviderType { get; } - public string ProviderName { get; private set; } + public string ProviderName { get; } - public string Run { get; private set; } + public string Run { get; } - public string Identifier { get; private set; } + public string Identifier { get; } - public string ProjectFileRelativePath { get; private set; } + public string ProjectFileRelativePath { get; } - public string ProjectName { get; private set; } + public string ProjectName { get; } - public string AffectedFileRelativePath { get; private set; } + public string AffectedFileRelativePath { get; } - public int Line { get; private set; } + public int Line { get; } - public int EndLine { get; private set; } + public int EndLine { get; } - public int Column { get; private set; } + public int Column { get; } - public int EndColumn { get; private set; } + public int EndColumn { get; } - public Uri FileLink { get; private set; } + public Uri FileLink { get; } - public string MessageText { get; private set; } + public string MessageText { get; } - public string MessageHtml { get; private set; } + public string MessageHtml { get; } - public string MessageMarkdown { get; private set; } + public string MessageMarkdown { get; } - public int Priority { get; private set; } + public int Priority { get; } - public string PriorityName { get; private set; } + public string PriorityName { get; } - public string Rule { get; private set; } + public string Rule { get; } - public string RuleName { get; private set; } + public string RuleName { get; } - public Uri RuleUrl { get; private set; } + public Uri RuleUrl { get; } - public Dictionary AdditionalInformation { get; private set; } + public Dictionary AdditionalInformation { get; } } } diff --git a/src/Cake.Issues.Tests/Testing/IssueCheckerTests.cs b/src/Cake.Issues.Tests/Testing/IssueCheckerTests.cs index 0b32f6003..b8b370cbd 100644 --- a/src/Cake.Issues.Tests/Testing/IssueCheckerTests.cs +++ b/src/Cake.Issues.Tests/Testing/IssueCheckerTests.cs @@ -15,7 +15,7 @@ public void Should_Throw_If_IssueToCheck_Is_Null() { // Given var fixture = new IssueBuilderFixture(); - IIssue issueToCheck = null; + const IIssue issueToCheck = null; var expectedIssue = fixture.IssueBuilder; // When @@ -32,7 +32,7 @@ public void Should_Throw_If_ExpectedIssue_Is_Null() // Given var fixture = new IssueBuilderFixture(); var issueToCheck = fixture.IssueBuilder.Create(); - IssueBuilder expectedIssue = null; + const IssueBuilder expectedIssue = null; // When var result = Record.Exception(() => @@ -64,7 +64,7 @@ public void Should_Throw_If_IssueToCheck_Is_Null() { // Given var fixture = new IssueBuilderFixture(); - IIssue issueToCheck = null; + const IIssue issueToCheck = null; var expectedIssue = fixture.IssueBuilder.Create(); // When @@ -81,7 +81,7 @@ public void Should_Throw_If_ExpectedIssue_Is_Null() // Given var fixture = new IssueBuilderFixture(); var issueToCheck = fixture.IssueBuilder.Create(); - IIssue expectedIssue = null; + const IIssue expectedIssue = null; // When var result = Record.Exception(() => @@ -113,7 +113,7 @@ public void Should_Throw_If_Issue_Is_Null() { // Given var fixture = new IssueCheckerFixture(); - IIssue issue = null; + const IIssue issue = null; // When var result = Record.Exception(() => @@ -278,7 +278,7 @@ public void Should_Throw_If_Run_Is_Different(string expectedValue, string actual // When var result = Record.Exception(() => IssueChecker.Check( - fixture.Issue, + issue, fixture.ProviderType, fixture.ProviderName, expectedValue, @@ -753,7 +753,7 @@ public void Should_Throw_If_MessageHtml_Is_Different(string expectedValue, strin // When var result = Record.Exception(() => IssueChecker.Check( - fixture.Issue, + issue, fixture.ProviderType, fixture.ProviderName, fixture.Run, @@ -798,7 +798,7 @@ public void Should_Throw_If_MessageMarkdown_Is_Different(string expectedValue, s // When var result = Record.Exception(() => IssueChecker.Check( - fixture.Issue, + issue, fixture.ProviderType, fixture.ProviderName, fixture.Run, diff --git a/src/Cake.Issues.Tests/Testing/ResourceTempFileTests.cs b/src/Cake.Issues.Tests/Testing/ResourceTempFileTests.cs index 012a2780f..4c58b0026 100644 --- a/src/Cake.Issues.Tests/Testing/ResourceTempFileTests.cs +++ b/src/Cake.Issues.Tests/Testing/ResourceTempFileTests.cs @@ -13,7 +13,7 @@ public sealed class TheCtor public void Should_Throw_If_ResourceName_Is_Null() { // Given - string resourceName = null; + const string resourceName = null; // When var result = Record.Exception(() => new ResourceTempFile(resourceName)); @@ -39,7 +39,7 @@ public void Should_Throw_If_ResourceName_Is_Empty() public void Should_Throw_If_ResourceName_Is_WhiteSpace() { // Given - var resourceName = " "; + const string resourceName = " "; // When var result = Record.Exception(() => new ResourceTempFile(resourceName)); @@ -52,7 +52,7 @@ public void Should_Throw_If_ResourceName_Is_WhiteSpace() public void Should_Throw_If_ResourceName_Does_Not_Exist() { // Given - var resourceName = "foo"; + const string resourceName = "foo"; // When var result = Record.Exception(() => new ResourceTempFile(resourceName)); @@ -65,7 +65,7 @@ public void Should_Throw_If_ResourceName_Does_Not_Exist() public void Should_Create_Temp_File() { // Given - var resourceName = "Cake.Issues.Tests.Testfiles.Build.log"; + const string resourceName = "Cake.Issues.Tests.Testfiles.Build.log"; // When using (var tempFile = new ResourceTempFile(resourceName)) @@ -79,7 +79,7 @@ public void Should_Create_Temp_File() public void Should_Write_Content() { // Given - var resourceName = "Cake.Issues.Tests.Testfiles.Build.log"; + const string resourceName = "Cake.Issues.Tests.Testfiles.Build.log"; // When using (var tempFile = new ResourceTempFile(resourceName)) @@ -96,7 +96,7 @@ public sealed class TheDisposeMethod public void Should_Remove_Temp_File() { // Given - var resourceName = "Cake.Issues.Tests.Testfiles.Build.log"; + const string resourceName = "Cake.Issues.Tests.Testfiles.Build.log"; string tempFileName; // When diff --git a/src/Cake.Issues.Tests/UriExtensionsTests.cs b/src/Cake.Issues.Tests/UriExtensionsTests.cs index 6907df88e..e5bd665d4 100644 --- a/src/Cake.Issues.Tests/UriExtensionsTests.cs +++ b/src/Cake.Issues.Tests/UriExtensionsTests.cs @@ -14,7 +14,7 @@ public void Should_Throw_If_Uri_Is_Null() { // Given Uri uri = null; - var path = "foo"; + const string path = "foo"; // When var result = Record.Exception(() => diff --git a/src/Cake.Issues.sln b/src/Cake.Issues.sln index ec4857500..e6d5b57f6 100644 --- a/src/Cake.Issues.sln +++ b/src/Cake.Issues.sln @@ -31,7 +31,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8756998D-64BF-4554-A14F-15AAFE78C8E8}" ProjectSection(SolutionItems) = preProject Directory.Build.props = Directory.Build.props - editorconfig = editorconfig + .editorconfig = .editorconfig EndProjectSection EndProject Global diff --git a/src/Cake.Issues.sln.DotSettings b/src/Cake.Issues.sln.DotSettings index 7cc51a4e8..fcaca3b72 100644 --- a/src/Cake.Issues.sln.DotSettings +++ b/src/Cake.Issues.sln.DotSettings @@ -1,3 +1,12 @@  DO_NOT_SHOW + DO_NOT_SHOW + DO_NOT_SHOW + DO_NOT_SHOW + DO_NOT_SHOW + + DO_NOT_SHOW + DO_NOT_SHOW + Field, Property, Event, Method + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> \ No newline at end of file diff --git a/src/Cake.Issues/BaseConfigurableIssueProvider.cs b/src/Cake.Issues/BaseConfigurableIssueProvider.cs index acd10e5c8..ec7ff2b12 100644 --- a/src/Cake.Issues/BaseConfigurableIssueProvider.cs +++ b/src/Cake.Issues/BaseConfigurableIssueProvider.cs @@ -25,6 +25,6 @@ protected BaseConfigurableIssueProvider(ICakeLog log, T issueProviderSettings) /// /// Gets the settings for the issue provider. /// - protected T IssueProviderSettings { get; private set; } + protected T IssueProviderSettings { get; } } } diff --git a/src/Cake.Issues/BaseIssueComponent.cs b/src/Cake.Issues/BaseIssueComponent.cs index e56c0f404..c006917d7 100644 --- a/src/Cake.Issues/BaseIssueComponent.cs +++ b/src/Cake.Issues/BaseIssueComponent.cs @@ -28,7 +28,7 @@ protected BaseIssueComponent(ICakeLog log) /// /// Gets the settings. - /// Is set after was called from the core addin. + /// Is set after was called from the core add-in. /// protected T Settings { get; private set; } diff --git a/src/Cake.Issues/BaseIssueProvider.cs b/src/Cake.Issues/BaseIssueProvider.cs index 5b93ce515..2e9beecab 100644 --- a/src/Cake.Issues/BaseIssueProvider.cs +++ b/src/Cake.Issues/BaseIssueProvider.cs @@ -21,13 +21,7 @@ protected BaseIssueProvider(ICakeLog log) public abstract string ProviderName { get; } /// - public virtual string ProviderType - { - get - { - return this.GetType().FullName; - } - } + public virtual string ProviderType => this.GetType().FullName; /// public IEnumerable ReadIssues() diff --git a/src/Cake.Issues/BaseLogFileFormat.cs b/src/Cake.Issues/BaseLogFileFormat.cs index 5c70409e2..0f385f933 100644 --- a/src/Cake.Issues/BaseLogFileFormat.cs +++ b/src/Cake.Issues/BaseLogFileFormat.cs @@ -26,7 +26,7 @@ protected BaseLogFileFormat(ICakeLog log) /// /// Gets the Cake log instance. /// - protected ICakeLog Log { get; private set; } + protected ICakeLog Log { get; } /// public abstract IEnumerable ReadIssues( diff --git a/src/Cake.Issues/BaseMultiFormatIssueProviderSettings.cs b/src/Cake.Issues/BaseMultiFormatIssueProviderSettings.cs index 1c0df2363..e436fd05f 100644 --- a/src/Cake.Issues/BaseMultiFormatIssueProviderSettings.cs +++ b/src/Cake.Issues/BaseMultiFormatIssueProviderSettings.cs @@ -28,7 +28,7 @@ protected BaseMultiFormatIssueProviderSettings(FilePath logFilePath, ILogFileFor /// /// Initializes a new instance of the class - /// for a log file content in memoy. + /// for a log file content in memory. /// /// Content of the log file. /// The log file needs to be in the format as defined by the parameter. @@ -44,6 +44,6 @@ protected BaseMultiFormatIssueProviderSettings(byte[] logFileContent, ILogFileFo /// /// Gets the format of the log file. /// - public ILogFileFormat Format { get; private set; } + public ILogFileFormat Format { get; } } } diff --git a/src/Cake.Issues/Cake.Issues.csproj b/src/Cake.Issues/Cake.Issues.csproj index 46f32b336..d9915a402 100644 --- a/src/Cake.Issues/Cake.Issues.csproj +++ b/src/Cake.Issues/Cake.Issues.csproj @@ -18,6 +18,7 @@ + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Cake.Issues/FileLinkSettings.cs b/src/Cake.Issues/FileLinkSettings.cs index c1c54fcc3..08cd82fa3 100644 --- a/src/Cake.Issues/FileLinkSettings.cs +++ b/src/Cake.Issues/FileLinkSettings.cs @@ -35,10 +35,7 @@ public static FileLinkSettings ForPattern(string pattern) return new FileLinkSettings( - (issue, values) => - { - return new Uri(pattern.ReplaceIssuePattern(issue)); - }); + (issue, _) => new Uri(pattern.ReplaceIssuePattern(issue))); } /// @@ -50,7 +47,7 @@ public static FileLinkSettings ForAction(Func builder) { builder.NotNull(nameof(builder)); - return new FileLinkSettings((issue, values) => builder(issue)); + return new FileLinkSettings((issue, _) => builder(issue)); } /// diff --git a/src/Cake.Issues/IIssue.cs b/src/Cake.Issues/IIssue.cs index 97b9b0ab2..822e9981d 100644 --- a/src/Cake.Issues/IIssue.cs +++ b/src/Cake.Issues/IIssue.cs @@ -29,7 +29,7 @@ public interface IIssue string ProjectName { get; } /// - /// Gets the path to the file affacted by the issue. + /// Gets the path to the file affected by the issue. /// The path is relative to the repository root. /// Can be null if issue is not related to a change in a file. /// @@ -37,30 +37,30 @@ public interface IIssue /// /// Gets the line in the file where the issues has occurred. - /// null if the issue affects the whole file or an asssembly. + /// null if the issue affects the whole file or an assembly. /// int? Line { get; } /// /// Gets the end of the line range in the file where the issues has occurred. - /// null if the issue affects the whole file, an asssembly or only a single line. + /// null if the issue affects the whole file, an assembly or only a single line. /// int? EndLine { get; } /// /// Gets the column in the file where the issues has occurred. - /// null if the issue affects the whole file or an asssembly. + /// null if the issue affects the whole file or an assembly. /// int? Column { get; } /// /// Gets the end of the column range in the file where the issues has occurred. - /// null if the issue affects the whole file, an asssembly or only a single column. + /// null if the issue affects the whole file, an assembly or only a single column. /// int? EndColumn { get; } /// - /// Gets or sets a link to the position in the file where the issue ocurred. + /// Gets or sets a link to the position in the file where the issue occurred. /// null if was not set while reading issue. /// Uri FileLink { get; set; } diff --git a/src/Cake.Issues/IIssueComparer.cs b/src/Cake.Issues/IIssueComparer.cs index 745b0bbe4..8c1837993 100644 --- a/src/Cake.Issues/IIssueComparer.cs +++ b/src/Cake.Issues/IIssueComparer.cs @@ -156,7 +156,7 @@ private static int GetHashCode(params object[] objects) { unchecked { - int hash = 17; + var hash = 17; foreach (var obj in objects) { diff --git a/src/Cake.Issues/IIssueExtensions.cs b/src/Cake.Issues/IIssueExtensions.cs index 1486c2e45..885fb8157 100644 --- a/src/Cake.Issues/IIssueExtensions.cs +++ b/src/Cake.Issues/IIssueExtensions.cs @@ -30,7 +30,7 @@ public static string LineRange(this IIssue issue, bool addColumn) { issue.NotNull(nameof(issue)); - string result = string.Empty; + var result = string.Empty; if (issue.Line.HasValue) { diff --git a/src/Cake.Issues/Issue.cs b/src/Cake.Issues/Issue.cs index 4560db6cd..4ebf57a24 100644 --- a/src/Cake.Issues/Issue.cs +++ b/src/Cake.Issues/Issue.cs @@ -19,18 +19,18 @@ public class Issue : IIssue /// Can be null or if issue is not related to a project. /// The name of the project to which the file affected by the issue belongs. /// Can be null or if issue is not related to a project. - /// The path to the file affacted by the issue. + /// The path to the file affected by the issue. /// The path needs to be relative to the repository root. /// null or if issue is not related to a change in a file. /// The line in the file where the issues has occurred. - /// null if the issue affects the whole file or an asssembly. + /// null if the issue affects the whole file or an assembly. /// The end of the line range in the file where the issues has occurred. - /// null if the issue affects the whole file, an asssembly or only a single line. + /// null if the issue affects the whole file, an assembly or only a single line. /// The column in the file where the issues has occurred. - /// null if the issue affects the whole file or an asssembly. + /// null if the issue affects the whole file or an assembly. /// The end of the column range in the file where the issues has occurred. - /// null if the issue affects the whole file, an asssembly or only a single column. - /// Link to the position in the file where the issue ocurred. + /// null if the issue affects the whole file, an assembly or only a single column. + /// Link to the position in the file where the issue occurred. /// null if no link is available. /// The message of the issue in plain text format. /// The message of the issue in Html format. @@ -124,27 +124,27 @@ public Issue( if (!line.HasValue && (column.HasValue || endColumn.HasValue)) { - throw new ArgumentOutOfRangeException(nameof(column), $"Cannot specify a column while not specifying a line."); + throw new ArgumentOutOfRangeException(nameof(column), "Cannot specify a column while not specifying a line."); } if (!line.HasValue && endLine.HasValue) { - throw new ArgumentOutOfRangeException(nameof(endLine), $"Cannot specify the end of line range while not specifying start of line range."); + throw new ArgumentOutOfRangeException(nameof(endLine), "Cannot specify the end of line range while not specifying start of line range."); } if (line.HasValue && endLine.HasValue && line.Value > endLine.Value) { - throw new ArgumentOutOfRangeException(nameof(endLine), $"Line range needs to end after start of range."); + throw new ArgumentOutOfRangeException(nameof(endLine), "Line range needs to end after start of range."); } if (!column.HasValue && endColumn.HasValue) { - throw new ArgumentOutOfRangeException(nameof(endColumn), $"Cannot specify the end of column range while not specifying start of column range."); + throw new ArgumentOutOfRangeException(nameof(endColumn), "Cannot specify the end of column range while not specifying start of column range."); } if (column.HasValue && endColumn.HasValue && column.Value > endColumn.Value) { - throw new ArgumentOutOfRangeException(nameof(endColumn), $"Column range needs to end after start of range."); + throw new ArgumentOutOfRangeException(nameof(endColumn), "Column range needs to end after start of range."); } this.Identifier = identifier; diff --git a/src/Cake.Issues/IssueBuilder.cs b/src/Cake.Issues/IssueBuilder.cs index f2bcac613..4f1ce91a0 100644 --- a/src/Cake.Issues/IssueBuilder.cs +++ b/src/Cake.Issues/IssueBuilder.cs @@ -216,7 +216,7 @@ public IssueBuilder InProject(string projectFileRelativePath, string projectName /// /// Sets the path to the file affected by the issue. /// - /// The path to the file affacted by the issue. + /// The path to the file affected by the issue. /// The path needs to be relative to the repository root. /// null or if issue is not related to a change in a file. /// Issue Builder instance. @@ -230,11 +230,11 @@ public IssueBuilder InFile(string filePath) /// /// Sets the path to the file affected by the issue and the line in the file where the issues has occurred. /// - /// The path to the file affacted by the issue. + /// The path to the file affected by the issue. /// The path needs to be relative to the repository root. /// null or if issue is not related to a change in a file. /// The line in the file where the issues has occurred. - /// null if the issue affects the whole file or an asssembly. + /// null if the issue affects the whole file or an assembly. /// Issue Builder instance. public IssueBuilder InFile(string filePath, int? line) { @@ -248,13 +248,13 @@ public IssueBuilder InFile(string filePath, int? line) /// /// Sets the path to the file affected by the issue and the line and column in the file where the issues has occurred. /// - /// The path to the file affacted by the issue. + /// The path to the file affected by the issue. /// The path needs to be relative to the repository root. /// null or if issue is not related to a change in a file. /// The line in the file where the issues has occurred. - /// null if the issue affects the whole file or an asssembly. + /// null if the issue affects the whole file or an assembly. /// The column in the file where the issues has occurred. - /// null if the issue affects the whole file or an asssembly. + /// null if the issue affects the whole file or an assembly. /// Issue Builder instance. public IssueBuilder InFile(string filePath, int? line, int? column) { @@ -269,17 +269,17 @@ public IssueBuilder InFile(string filePath, int? line, int? column) /// /// Sets the path to the file affected by the issue and the line and column in the file where the issues has occurred. /// - /// The path to the file affacted by the issue. + /// The path to the file affected by the issue. /// The path needs to be relative to the repository root. /// null or if issue is not related to a change in a file. /// The line in the file where the issues has occurred. - /// null if the issue affects the whole file or an asssembly. + /// null if the issue affects the whole file or an assembly. /// The end of the line range in the file where the issues has occurred. - /// null if the issue affects the whole file, an asssembly or only a single line. + /// null if the issue affects the whole file, an assembly or only a single line. /// The column in the file where the issues has occurred. - /// null if the issue affects the whole file or an asssembly. + /// null if the issue affects the whole file or an assembly. /// The end of the column range in the file where the issues has occurred. - /// null if the issue affects the whole file, an asssembly or only a single column. + /// null if the issue affects the whole file, an assembly or only a single column. /// Issue Builder instance. public IssueBuilder InFile(string filePath, int? startLine, int? endLine, int? startColumn, int? endColumn) { @@ -330,9 +330,9 @@ public IssueBuilder WithAdditionalInformation(IDictionary additi } /// - /// Sets the the link to the position in the file where the issue ocurred. + /// Sets the the link to the position in the file where the issue occurred. /// - /// Link to the position in the file where the issue ocurred. + /// Link to the position in the file where the issue occurred. /// Issue Builder instance. public IssueBuilder WithFileLink(Uri fileLink) { @@ -344,9 +344,9 @@ public IssueBuilder WithFileLink(Uri fileLink) } /// - /// Sets a to create the link of the position in the file where the issue ocurred. + /// Sets a to create the link of the position in the file where the issue occurred. /// - /// Settings to create the link of the position in the file where the issue ocurred. + /// Settings to create the link of the position in the file where the issue occurred. /// Issue Builder instance. public IssueBuilder WithFileLinkSettings(FileLinkSettings fileLinkSettings) { diff --git a/src/Cake.Issues/IssueProviderSettings.cs b/src/Cake.Issues/IssueProviderSettings.cs index 688a0977e..660418a59 100644 --- a/src/Cake.Issues/IssueProviderSettings.cs +++ b/src/Cake.Issues/IssueProviderSettings.cs @@ -22,7 +22,7 @@ public IssueProviderSettings(FilePath logFilePath) /// /// Initializes a new instance of the class - /// for a log file content in memoy. + /// for a log file content in memory. /// /// Content of the log file. public IssueProviderSettings(byte[] logFileContent) @@ -35,6 +35,6 @@ public IssueProviderSettings(byte[] logFileContent) /// /// Gets the content of the log file. /// - public byte[] LogFileContent { get; private set; } + public byte[] LogFileContent { get; } } } diff --git a/src/Cake.Issues/IssuesArgumentChecks.cs b/src/Cake.Issues/IssuesArgumentChecks.cs index 678048352..3ce43de15 100644 --- a/src/Cake.Issues/IssuesArgumentChecks.cs +++ b/src/Cake.Issues/IssuesArgumentChecks.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; + using JetBrains.Annotations; /// /// Common runtime checks that throw upon failure. @@ -18,7 +19,7 @@ public static class IssuesArgumentChecks /// The name of the parameter to include in any thrown exception. /// Thrown if is null. [DebuggerStepThrough] - public static void NotNull([ValidatedNotNull]this T value, string parameterName) + public static void NotNull([ValidatedNotNull][NoEnumeration] this T value, string parameterName) where T : class { if (value == null) @@ -87,7 +88,7 @@ public static void NotNegativeOrZero(this int value, string parameterName) /// Thrown if is null. /// Thrown if is empty. [DebuggerStepThrough] - public static void NotNullOrEmpty(this IEnumerable value, string parameterName) + public static void NotNullOrEmpty([NoEnumeration] this IEnumerable value, string parameterName) { // ReSharper disable once PossibleMultipleEnumeration value.NotNull(parameterName); @@ -109,7 +110,7 @@ public static void NotNullOrEmpty(this IEnumerable value, string parameter /// Thrown if is empty. /// Thrown if contains an empty element. [DebuggerStepThrough] - public static void NotNullOrEmptyElement(this IEnumerable value, string parameterName) + public static void NotNullOrEmptyElement([NoEnumeration] this IEnumerable value, string parameterName) { // ReSharper disable once PossibleMultipleEnumeration value.NotNull(parameterName); @@ -131,7 +132,7 @@ public static void NotNullOrEmptyElement(this IEnumerable value, string pa /// Thrown if is empty. /// Thrown if contains an empty element. [DebuggerStepThrough] - public static void NotNullOrEmptyOrEmptyElement(this IEnumerable value, string parameterName) + public static void NotNullOrEmptyOrEmptyElement([NoEnumeration] this IEnumerable value, string parameterName) { // ReSharper disable once PossibleMultipleEnumeration value.NotNullOrEmpty(parameterName); diff --git a/src/Cake.Issues/Serialization/IssueDeserializationExtensions.cs b/src/Cake.Issues/Serialization/IssueDeserializationExtensions.cs index 10ecd0ccb..5ce48d905 100644 --- a/src/Cake.Issues/Serialization/IssueDeserializationExtensions.cs +++ b/src/Cake.Issues/Serialization/IssueDeserializationExtensions.cs @@ -112,7 +112,7 @@ private static IEnumerable DeserializeStreamToIssues(Stream stream) } /// - /// Deserializes JSON repesentation of an issue to an . + /// Deserializes JSON representation of an issue to an . /// Supports serialization format of the current version of Cake.Issues as versions /// written with previous versions of Cake.Issues. /// diff --git a/src/Cake.Issues/Serialization/LitJson/IJsonWrapper.cs b/src/Cake.Issues/Serialization/LitJson/IJsonWrapper.cs index 5d76dde91..2e28a66ab 100644 --- a/src/Cake.Issues/Serialization/LitJson/IJsonWrapper.cs +++ b/src/Cake.Issues/Serialization/LitJson/IJsonWrapper.cs @@ -1,3 +1,4 @@ +// ReSharper disable All #pragma warning disable 1587 #pragma warning disable 1591 @@ -20,7 +21,6 @@ using System.Collections; using System.Collections.Specialized; - namespace LitJson { internal enum JsonType diff --git a/src/Cake.Issues/Serialization/LitJson/JsonData.cs b/src/Cake.Issues/Serialization/LitJson/JsonData.cs index 41f65cd11..4f5a431fb 100644 --- a/src/Cake.Issues/Serialization/LitJson/JsonData.cs +++ b/src/Cake.Issues/Serialization/LitJson/JsonData.cs @@ -1,3 +1,4 @@ +// ReSharper disable All #pragma warning disable 1587 #pragma warning disable 1591 diff --git a/src/Cake.Issues/Serialization/LitJson/JsonException.cs b/src/Cake.Issues/Serialization/LitJson/JsonException.cs index e3b612ed0..a84710d8f 100644 --- a/src/Cake.Issues/Serialization/LitJson/JsonException.cs +++ b/src/Cake.Issues/Serialization/LitJson/JsonException.cs @@ -1,3 +1,4 @@ +// ReSharper disable All #pragma warning disable 1587 #pragma warning disable 1591 diff --git a/src/Cake.Issues/Serialization/LitJson/JsonMapper.cs b/src/Cake.Issues/Serialization/LitJson/JsonMapper.cs index 24873ab7a..44dd2457a 100644 --- a/src/Cake.Issues/Serialization/LitJson/JsonMapper.cs +++ b/src/Cake.Issues/Serialization/LitJson/JsonMapper.cs @@ -1,3 +1,4 @@ +// ReSharper disable All #pragma warning disable 1587 #pragma warning disable 1591 diff --git a/src/Cake.Issues/Serialization/LitJson/JsonMockWrapper.cs b/src/Cake.Issues/Serialization/LitJson/JsonMockWrapper.cs index 0671de12f..f6442249d 100644 --- a/src/Cake.Issues/Serialization/LitJson/JsonMockWrapper.cs +++ b/src/Cake.Issues/Serialization/LitJson/JsonMockWrapper.cs @@ -1,3 +1,4 @@ +// ReSharper disable All #pragma warning disable 1587 #pragma warning disable 1591 diff --git a/src/Cake.Issues/Serialization/LitJson/JsonReader.cs b/src/Cake.Issues/Serialization/LitJson/JsonReader.cs index e3457de32..f688b9d63 100644 --- a/src/Cake.Issues/Serialization/LitJson/JsonReader.cs +++ b/src/Cake.Issues/Serialization/LitJson/JsonReader.cs @@ -1,3 +1,4 @@ +// ReSharper disable All #pragma warning disable 1587 #pragma warning disable 1591 diff --git a/src/Cake.Issues/Serialization/LitJson/JsonWriter.cs b/src/Cake.Issues/Serialization/LitJson/JsonWriter.cs index 1936e961f..f56af7466 100644 --- a/src/Cake.Issues/Serialization/LitJson/JsonWriter.cs +++ b/src/Cake.Issues/Serialization/LitJson/JsonWriter.cs @@ -1,3 +1,4 @@ +// ReSharper disable All #pragma warning disable 1587 #pragma warning disable 1591 diff --git a/src/Cake.Issues/Serialization/LitJson/Lexer.cs b/src/Cake.Issues/Serialization/LitJson/Lexer.cs index dda3da955..8c124869b 100644 --- a/src/Cake.Issues/Serialization/LitJson/Lexer.cs +++ b/src/Cake.Issues/Serialization/LitJson/Lexer.cs @@ -1,3 +1,4 @@ +// ReSharper disable All #pragma warning disable 1587 #pragma warning disable 1591 diff --git a/src/Cake.Issues/Serialization/LitJson/ParserToken.cs b/src/Cake.Issues/Serialization/LitJson/ParserToken.cs index 027655442..eced93c4c 100644 --- a/src/Cake.Issues/Serialization/LitJson/ParserToken.cs +++ b/src/Cake.Issues/Serialization/LitJson/ParserToken.cs @@ -1,3 +1,4 @@ +// ReSharper disable All #pragma warning disable 1587 #pragma warning disable 1591 diff --git a/src/Cake.Issues/Serialization/SerializableIssueV2.cs b/src/Cake.Issues/Serialization/SerializableIssueV2.cs index bc1ad2959..5c94687af 100644 --- a/src/Cake.Issues/Serialization/SerializableIssueV2.cs +++ b/src/Cake.Issues/Serialization/SerializableIssueV2.cs @@ -12,13 +12,7 @@ internal class SerializableIssueV2 /// Gets the version of the serialization format. /// [DataMember] - public int Version - { - get - { - return 2; - } - } + public int Version => 2; /// [DataMember] diff --git a/src/Cake.Issues/Serialization/SerializableIssueV3.cs b/src/Cake.Issues/Serialization/SerializableIssueV3.cs index 408171b1f..3985bef2a 100644 --- a/src/Cake.Issues/Serialization/SerializableIssueV3.cs +++ b/src/Cake.Issues/Serialization/SerializableIssueV3.cs @@ -12,13 +12,7 @@ internal class SerializableIssueV3 /// Gets the version of the serialization format. /// [DataMember] - public int Version - { - get - { - return 3; - } - } + public int Version => 3; /// [DataMember] diff --git a/src/Cake.Issues/Serialization/SerializableIssueV4.cs b/src/Cake.Issues/Serialization/SerializableIssueV4.cs index d7aa9d637..a23055c6a 100644 --- a/src/Cake.Issues/Serialization/SerializableIssueV4.cs +++ b/src/Cake.Issues/Serialization/SerializableIssueV4.cs @@ -13,13 +13,7 @@ internal class SerializableIssueV4 /// Gets the version of the serialization format. /// [DataMember] - public int Version - { - get - { - return 4; - } - } + public int Version => 4; /// [DataMember] diff --git a/src/Cake.Issues/Serialization/SerializableIssueV5.cs b/src/Cake.Issues/Serialization/SerializableIssueV5.cs index 51b7ea449..6cfc5870a 100644 --- a/src/Cake.Issues/Serialization/SerializableIssueV5.cs +++ b/src/Cake.Issues/Serialization/SerializableIssueV5.cs @@ -13,13 +13,7 @@ internal class SerializableIssueV5 /// Gets the version of the serialization format. /// [DataMember] - public int Version - { - get - { - return 5; - } - } + public int Version => 5; /// [DataMember] diff --git a/src/Cake.Issues/StringPathExtensions.cs b/src/Cake.Issues/StringPathExtensions.cs index ef919ee57..712568f58 100644 --- a/src/Cake.Issues/StringPathExtensions.cs +++ b/src/Cake.Issues/StringPathExtensions.cs @@ -109,14 +109,14 @@ public static string WithEnding(this string value, string ending) return ending; } - string result = value; + var result = value; // Right() is 1-indexed, so include these cases // * Append no characters // * Append up to N characters, where N is ending length - for (int i = 0; i <= ending.Length; i++) + for (var i = 0; i <= ending.Length; i++) { - string tmp = result + ending.Right(i); + var tmp = result + ending.Right(i); if (tmp.EndsWith(ending, StringComparison.OrdinalIgnoreCase)) { return tmp; From f2273b6740c78c9553871a37fe78319d2a7d894f Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sat, 7 Jan 2023 22:21:22 +0000 Subject: [PATCH 39/44] Make BaseRuleDescription.Rule immutable (#328) --- src/Cake.Issues/BaseRuleDescription.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Cake.Issues/BaseRuleDescription.cs b/src/Cake.Issues/BaseRuleDescription.cs index abceadb42..73b6a459b 100644 --- a/src/Cake.Issues/BaseRuleDescription.cs +++ b/src/Cake.Issues/BaseRuleDescription.cs @@ -6,8 +6,8 @@ public class BaseRuleDescription { /// - /// Gets or sets the full identifier of the rule. + /// Gets the full identifier of the rule. /// - public string Rule { get; set; } + public string Rule { get; init; } } } \ No newline at end of file From 3b6898922aae4c72014025f518f38b0038a6a5a5 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sat, 7 Jan 2023 22:41:45 +0000 Subject: [PATCH 40/44] Make BaseRuleDescription abstract (#330) --- src/Cake.Issues/BaseRuleDescription.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cake.Issues/BaseRuleDescription.cs b/src/Cake.Issues/BaseRuleDescription.cs index 73b6a459b..7b7c296d1 100644 --- a/src/Cake.Issues/BaseRuleDescription.cs +++ b/src/Cake.Issues/BaseRuleDescription.cs @@ -3,7 +3,7 @@ /// /// Base class for all rule descriptions. /// - public class BaseRuleDescription + public abstract class BaseRuleDescription { /// /// Gets the full identifier of the rule. From 215643af4e0d58f77f5a13f3b74c3a817241436a Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sat, 7 Jan 2023 23:43:03 +0100 Subject: [PATCH 41/44] Update release notes link --- nuspec/nuget/Cake.Issues.PullRequests.nuspec | 2 +- nuspec/nuget/Cake.Issues.Reporting.nuspec | 2 +- nuspec/nuget/Cake.Issues.Testing.nuspec | 2 +- nuspec/nuget/Cake.Issues.nuspec | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nuspec/nuget/Cake.Issues.PullRequests.nuspec b/nuspec/nuget/Cake.Issues.PullRequests.nuspec index 089a77a8c..94e9b2bf1 100644 --- a/nuspec/nuget/Cake.Issues.PullRequests.nuspec +++ b/nuspec/nuget/Cake.Issues.PullRequests.nuspec @@ -22,7 +22,7 @@ See the Project Site for an overview of the whole ecosystem of addins for workin Copyright © BBT Software AG and contributors Cake Script Cake-Issues CodeAnalysis Linting Issues Pull-Requests - https://github.com/cake-contrib/Cake.Issues/releases/tag/2.0.0 + https://github.com/cake-contrib/Cake.Issues/releases/tag/3.0.0 diff --git a/nuspec/nuget/Cake.Issues.Reporting.nuspec b/nuspec/nuget/Cake.Issues.Reporting.nuspec index 137a8f7f8..1293a2d3e 100644 --- a/nuspec/nuget/Cake.Issues.Reporting.nuspec +++ b/nuspec/nuget/Cake.Issues.Reporting.nuspec @@ -22,7 +22,7 @@ See the Project Site for an overview of the whole ecosystem of addins for workin Copyright © BBT Software AG and contributors Cake Script Cake-Issues CodeAnalysis Linting Issues Reporting - https://github.com/cake-contrib/Cake.Issues/releases/tag/2.0.0 + https://github.com/cake-contrib/Cake.Issues/releases/tag/3.0.0 diff --git a/nuspec/nuget/Cake.Issues.Testing.nuspec b/nuspec/nuget/Cake.Issues.Testing.nuspec index c2df48bb4..947b30f4f 100644 --- a/nuspec/nuget/Cake.Issues.Testing.nuspec +++ b/nuspec/nuget/Cake.Issues.Testing.nuspec @@ -17,7 +17,7 @@ Common helpers for testing add-ins based on Cake.Issues Copyright © BBT Software AG and contributors Cake Script Cake-Issues Issues Testing - https://github.com/cake-contrib/Cake.Issues/releases/tag/2.0.0 + https://github.com/cake-contrib/Cake.Issues/releases/tag/3.0.0 diff --git a/nuspec/nuget/Cake.Issues.nuspec b/nuspec/nuget/Cake.Issues.nuspec index 06fecb3b6..a92332e10 100644 --- a/nuspec/nuget/Cake.Issues.nuspec +++ b/nuspec/nuget/Cake.Issues.nuspec @@ -24,7 +24,7 @@ See the Project Site for an overview of the whole ecosystem of addins for workin Copyright © BBT Software AG and contributors cake cake-addin cake-issues code-analysis linting issues - https://github.com/cake-contrib/Cake.Issues/releases/tag/2.0.0 + https://github.com/cake-contrib/Cake.Issues/releases/tag/3.0.0 From 1186a05fb6293ab28496dcd11407e4bc991ef3eb Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sat, 11 Feb 2023 21:30:52 +0000 Subject: [PATCH 42/44] Ensure required .NET SDK are available on build images (#332) --- .appveyor.yml | 15 ++++++++++++--- azure-pipelines.yml | 10 ++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index da4485dc0..8bfb756ba 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -9,12 +9,21 @@ environment: image: Visual Studio 2022 #---------------------------------# -# Build Script # +# Install .NET # #---------------------------------# install: - # Update to latest NuGet version since we require 5.3.0 for embedded icon - - ps: nuget update -self + - ps: $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetsdk" + - ps: mkdir $env:DOTNET_INSTALL_DIR -Force | Out-Null + - ps: Invoke-WebRequest -Uri "https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.ps1" -OutFile "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" + - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 5.0.408 -InstallDir $env:DOTNET_INSTALL_DIR' + - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 6.0.405 -InstallDir $env:DOTNET_INSTALL_DIR' + - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 7.0.102 -InstallDir $env:DOTNET_INSTALL_DIR' + - ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path" + - ps: dotnet --info +#---------------------------------# +# Build Script # +#---------------------------------# build_script: - ps: .\build.ps1 --target=CI diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c2b96e385..85c0c755e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -14,5 +14,15 @@ jobs: pool: vmImage: 'windows-2022' steps: + # .NET 5 required for GitVersion + - task: UseDotNet@2 + inputs: + version: '5.x' + - task: UseDotNet@2 + inputs: + version: '6.x' + - task: UseDotNet@2 + inputs: + version: '7.x' - powershell: ./build.ps1 displayName: 'Cake Build' \ No newline at end of file From 7a8f8fb4a84cc7ddabbabddf0b47ed42b6a12eb8 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Wed, 14 Jun 2023 21:31:51 +0200 Subject: [PATCH 43/44] Revert "Make BaseRuleDescription abstract (#330)" This reverts commit 3b6898922aae4c72014025f518f38b0038a6a5a5. --- src/Cake.Issues/BaseRuleDescription.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cake.Issues/BaseRuleDescription.cs b/src/Cake.Issues/BaseRuleDescription.cs index 7b7c296d1..73b6a459b 100644 --- a/src/Cake.Issues/BaseRuleDescription.cs +++ b/src/Cake.Issues/BaseRuleDescription.cs @@ -3,7 +3,7 @@ /// /// Base class for all rule descriptions. /// - public abstract class BaseRuleDescription + public class BaseRuleDescription { /// /// Gets the full identifier of the rule. From 1e5f14d658418cd1b88a911c6bb00a3bb29deb90 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Wed, 14 Jun 2023 21:41:46 +0200 Subject: [PATCH 44/44] Ensure that it is possible to define a custom URL resolver for BaseRuleDescription --- .../BaseRuleUrlResolverTests.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Cake.Issues.Tests/BaseRuleUrlResolverTests.cs b/src/Cake.Issues.Tests/BaseRuleUrlResolverTests.cs index bf6e1ebfc..0079056d9 100644 --- a/src/Cake.Issues.Tests/BaseRuleUrlResolverTests.cs +++ b/src/Cake.Issues.Tests/BaseRuleUrlResolverTests.cs @@ -1,12 +1,29 @@ namespace Cake.Issues.Tests { using System; + using System.Diagnostics.CodeAnalysis; using Cake.Issues.Testing; using Shouldly; using Xunit; public class BaseRuleUrlResolverTests { + public sealed class TheClass + { + [SuppressMessage( + "Major Code Smell", + "S1144:Unused private types or members should be removed", + Justification = "Ensure that it is possible to define a custom URL resolver for BaseRuleDescription")] + private class FakeRuleUrlResolverForBaseRuleDescription : BaseRuleUrlResolver + { + /// + protected override bool TryGetRuleDescription(string rule, BaseRuleDescription ruleDescription) + { + return true; + } + } + } + public sealed class TheAddUrlResolverMethod { [Fact]