Skip to content

Commit 15126bd

Browse files
authored
Merge pull request #242 from bkoelman/formatting
Various small fixes and improvements
2 parents c1365d6 + 6eeaf39 commit 15126bd

55 files changed

Lines changed: 300 additions & 303 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Build.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
@echo off
2-
powershell -NoProfile -ExecutionPolicy unrestricted -Command ".\Build\psake.ps1 .\Build\default.ps1
2+
powershell -NoProfile -ExecutionPolicy unrestricted -Command ".\Build\psake.ps1 .\Build\default.ps1

Build/Modules/IO.psm1

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ function Clean-Item {
33
[parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true)]
44
[string] $path
55
)
6-
Process
6+
Process
77
{
88
if(($path -ne $null) -and (test-path $path))
99
{
1010
write-verbose ("Removing {0}" -f $path)
1111
remove-item -force -recurse $path | Out-Null
12-
}
12+
}
1313
}
1414
}
1515

@@ -27,7 +27,7 @@ function New-Directory
2727
[parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true)]
2828
[string] $path
2929
)
30-
30+
3131
mkdir $path -ErrorAction SilentlyContinue | out-null
3232
}
3333

@@ -42,23 +42,23 @@ function Copy-Files {
4242
)
4343

4444
New-Directory $destination
45-
46-
#Get-ChildItem $source -Recurse -Exclude $exclude | Copy-Item -Destination {Join-Path $destination $_.FullName.Substring($source.length)}
47-
48-
45+
46+
#Get-ChildItem $source -Recurse -Exclude $exclude | Copy-Item -Destination {Join-Path $destination $_.FullName.Substring($source.length)}
47+
48+
4949
$arguments = @($source, $destination, "*.*", "/e")
50-
50+
5151
if(($excludeFiles -ne $null) -and ($excludeFiles.Length -gt 0)) {
5252
$arguments += "/xf"
5353
$arguments += $excludeFiles
5454
}
55-
55+
5656
if(($excludeDirectories -ne $null) -and ($excludeFiles.Length -gt 0)) {
5757
$arguments += "/xd"
5858
$arguments += $excludeDirectories
5959
}
60-
60+
6161
robocopy.exe $arguments | out-null
62-
62+
6363
Expect-ExitCode -expectedExitCode 0,1 -formatMessage { param($taskName) "Copy was not successful" }
6464
}

Build/Modules/teamcity.psm1

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function TeamCity-TestStarted([string]$name) {
2121

2222
function TeamCity-TestFinished([string]$name, [int]$duration) {
2323
$messageAttributes = @{name=$name; duration=$duration}
24-
24+
2525
if ($duration -gt 0) {
2626
$messageAttributes.duration=$duration
2727
}
@@ -47,7 +47,7 @@ function TeamCity-TestFailed([string]$name, [string]$message, [string]$details='
4747
if (![string]::IsNullOrEmpty($type)) {
4848
$messageAttributes.type = $type
4949
}
50-
50+
5151
if (![string]::IsNullOrEmpty($expected)) {
5252
$messageAttributes.expected=$expected
5353
}
@@ -110,66 +110,66 @@ function TeamCity-SetBuildStatistic([string]$key, [string]$value) {
110110

111111
function TeamCity-Block([string]$name, [scriptblock]$cmd) {
112112
TeamCity-WriteServiceMessage 'blockOpened' @{ name=$name }
113-
& $cmd
113+
& $cmd
114114
TeamCity-WriteServiceMessage 'blockClosed' @{ name=$name }
115115
}
116116

117117
function TeamCity-CreateInfoDocument([string]$buildNumber='', [boolean]$status=$true, [string[]]$statusText=$null, [System.Collections.IDictionary]$statistics=$null) {
118118
$doc=New-Object xml;
119119
$buildEl=$doc.CreateElement('build');
120-
120+
121121
if (![string]::IsNullOrEmpty($buildNumber)) {
122122
$buildEl.SetAttribute('number', $buildNumber);
123123
}
124-
124+
125125
$buildEl=$doc.AppendChild($buildEl);
126-
126+
127127
$statusEl=$doc.CreateElement('statusInfo');
128128
if ($status) {
129129
$statusEl.SetAttribute('status', 'SUCCESS');
130130
} else {
131131
$statusEl.SetAttribute('status', 'FAILURE');
132132
}
133-
133+
134134
if ($statusText -ne $null) {
135135
foreach ($text in $statusText) {
136136
$textEl=$doc.CreateElement('text');
137137
$textEl.SetAttribute('action', 'append');
138138
$textEl.set_InnerText($text);
139139
$textEl=$statusEl.AppendChild($textEl);
140140
}
141-
}
142-
141+
}
142+
143143
$statusEl=$buildEl.AppendChild($statusEl);
144-
144+
145145
if ($statistics -ne $null) {
146146
foreach ($key in $statistics.Keys) {
147147
$val=$statistics.$key
148148
if ($val -eq $null) {
149149
$val=''
150150
}
151-
151+
152152
$statEl=$doc.CreateElement('statisticsValue');
153153
$statEl.SetAttribute('key', $key);
154154
$statEl.SetAttribute('value', $val.ToString());
155155
$statEl=$buildEl.AppendChild($statEl);
156156
}
157157
}
158-
158+
159159
return $doc;
160160
}
161161

162162
function TeamCity-WriteInfoDocument([xml]$doc) {
163163
$dir=(Split-Path $buildFile)
164164
$path=(Join-Path $dir 'teamcity-info.xml')
165-
165+
166166
$doc.Save($path);
167167
}
168168

169169
function TeamCity-WriteServiceMessage([string]$messageName, $messageAttributesHashOrSingleValue) {
170170
function escape([string]$value) {
171-
([char[]] $value |
172-
%{ switch ($_)
171+
([char[]] $value |
172+
%{ switch ($_)
173173
{
174174
"|" { "||" }
175175
"'" { "|'" }
@@ -186,7 +186,7 @@ function TeamCity-WriteServiceMessage([string]$messageName, $messageAttributesHa
186186
}
187187

188188
if ($messageAttributesHashOrSingleValue -is [hashtable]) {
189-
$messageAttributesString = ($messageAttributesHashOrSingleValue.GetEnumerator() |
189+
$messageAttributesString = ($messageAttributesHashOrSingleValue.GetEnumerator() |
190190
%{ "{0}='{1}'" -f $_.Key, (escape $_.Value) }) -join ' '
191191
} else {
192192
$messageAttributesString = ("'{0}'" -f (escape $messageAttributesHashOrSingleValue))

Build/default.ps1

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
properties {
2-
$BaseDirectory = Resolve-Path ..
3-
$ArtifactsDirectory = "$BaseDirectory\Artifacts\"
1+
properties {
2+
$BaseDirectory = Resolve-Path ..
3+
$ArtifactsDirectory = "$BaseDirectory\Artifacts\"
44
$LibDir = "$BaseDirectory\Lib"
55
$defaultRulePrefix = "AV"
66
}
77

88
task default -depends Clean, ExtractVersionsFromGit, Compile, CompileCheatsheet, BuildHtml
99

10-
task Clean {
10+
task Clean {
1111
if (Test-Path $ArtifactsDirectory) {
1212
Get-ChildItem $ArtifactsDirectory | ForEach { Remove-Item $_.FullName -Recurse -Force }
1313
}
1414
}
1515

1616
task ExtractVersionsFromGit {
17-
18-
$json = . "$LibDir\GitVersion.exe"
19-
17+
18+
$json = . "$LibDir\GitVersion.exe"
19+
2020
if ($LASTEXITCODE -eq 0) {
2121
$version = (ConvertFrom-Json ($json -join "`n"));
22-
22+
2323
$script:SemVer = $version.SemVer;
2424
$script:CommitDate = ([datetime]$version.CommitDate).ToString("MMMM d, yyyy");
2525
}
@@ -51,11 +51,11 @@ task Compile {
5151
$outfile = "$ArtifactsDirectory\Guidelines\CSharpCodingGuidelines.md"
5252

5353
foreach ($file in $files) {
54-
$rawContent = Get-Content $file | Out-String
54+
$rawContent = Get-Content $file | Out-String
5555

5656
$rawContent = $rawContent.replace('%semver%', $script:Semver)
57-
$rawContent = $rawContent.replace('%commitdate%', $script:CommitDate)
58-
$rawContent = $rawContent.replace('![](/assets', '![](assets')
57+
$rawContent = $rawContent.replace('%commitdate%', $script:CommitDate)
58+
$rawContent = $rawContent.replace('![](/assets', '![](assets')
5959

6060
# Extract the title of the section from the Frontmatter block
6161
$title = ""
@@ -86,19 +86,19 @@ task Compile {
8686
if ($rule -match "---(.|\n)*title\: (.+)") {
8787
$ruleTitle = $Matches[2].Trim()
8888
}
89-
89+
9090
# Extract the severity of the rule from the Frontmatter block
9191
$ruleSeverity = ""
9292
if ($rule -match "---(.|\n)*severity\: (.+)") {
9393
$ruleSeverity = $Matches[2].Trim()
9494
}
95-
95+
9696
# Extract the id of the rule from the Frontmatter block
9797
$ruleId = ""
9898
if ($rule -match "---(.|\n)*rule_id\: (.+)") {
9999
$ruleId = $Matches[2].Trim()
100100
}
101-
101+
102102
# Extract the id prefix of the rule from the Frontmatter block
103103
$ruleIdPrefix = "{{ site.default_rule_prefix }}"
104104
if ($rule -match "---(.|\n)*custom_prefix\: (.+)") {
@@ -126,7 +126,7 @@ task Compile {
126126

127127
Add-Content -Path $outfile $content
128128
}
129-
129+
130130
Copy-Item -Path "$BaseDirectory\Assets\css\guidelines.css" -Destination "$ArtifactsDirectory\Guidelines\style.css" -recurse -Force
131131
Copy-Item -Path "$BaseDirectory\Assets\Images\" -Destination "$ArtifactsDirectory\Guidelines\Assets\Images" -recurse -Force
132132
}
@@ -137,13 +137,13 @@ task CompileCheatsheet {
137137
}
138138

139139
$outfile = "$ArtifactsDirectory\Cheatsheet\Cheatsheet.md"
140-
140+
141141
$content = Get-Content "$BaseDirectory\_pages\Cheatsheet.md"
142142
$content = ($content -replace '%semver%', $script:Semver)
143-
$content = ($content -replace '%commitdate%', $script:CommitDate)
143+
$content = ($content -replace '%commitdate%', $script:CommitDate)
144144
$content = ($content -replace '{{ site.default_rule_prefix }}', $defaultRulePrefix)
145145
Add-Content $outfile $content
146-
146+
147147
Copy-Item -Path "$BaseDirectory\assets\css\CheatSheet.css" -Destination "$ArtifactsDirectory\Cheatsheet\style.css" -recurse -Force
148148
Copy-Item -Path "$BaseDirectory\assets\Images" -Destination "$ArtifactsDirectory\Cheatsheet\Assets\Images" -recurse -Force
149149
}
@@ -157,26 +157,25 @@ task BuildHtml {
157157
Set-Location "$ArtifactsDirectory\Guidelines"
158158

159159
$outfile = "$ArtifactsDirectory\CSharpCodingGuidelines.htm"
160-
161-
if (Test-Path $outfile) {
160+
161+
if (Test-Path $outfile) {
162162
Remove-Item $outfile
163163
}
164-
165-
& "$LibDir\Pandoc\pandoc.exe" CSharpCodingGuidelines.md -f markdown_phpextra -s -o $outfile --self-contained
164+
165+
& "$LibDir\Pandoc\pandoc.exe" CSharpCodingGuidelines.md -f markdown_phpextra -s -o $outfile --self-contained
166166

167167
Set-Location "$ArtifactsDirectory\Cheatsheet\"
168168

169169
$outfile = "$ArtifactsDirectory\CSharpCodingGuidelinesCheatsheet.htm"
170-
170+
171171
if (Test-Path $outfile) {
172172
Remove-Item $outfile
173173
}
174-
175-
& "$LibDir\Pandoc\pandoc.exe" Cheatsheet.md -f markdown+markdown_in_html_blocks -s -o $outfile --self-contained
174+
175+
& "$LibDir\Pandoc\pandoc.exe" Cheatsheet.md -f markdown+markdown_in_html_blocks -s -o $outfile --self-contained
176176
}
177177
finally
178178
{
179179
Set-Location $PreviousPwd
180180
}
181-
182181
}

Build/psake.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@echo off
22
rem Helper script for those who want to run psake from cmd.exe
33
rem Example run from cmd.exe:
4-
rem psake "default.ps1" "BuildHelloWord" "4.0"
4+
rem psake "default.ps1" "BuildHelloWord" "4.0"
55

66
if '%1'=='/?' goto help
77
if '%1'=='-help' goto help

Build/psake.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Helper script for those who want to run psake without importing the module.
22
# Example run from PowerShell:
3-
# .\psake.ps1 "default.ps1" "BuildHelloWord" "4.0"
3+
# .\psake.ps1 "default.ps1" "BuildHelloWord" "4.0"
44

5-
# Must match parameter definitions for psake.psm1/invoke-psake
5+
# Must match parameter definitions for psake.psm1/invoke-psake
66
# otherwise named parameter binding fails
77
param(
88
[Parameter(Position=0,Mandatory=0)]
@@ -48,6 +48,6 @@ if ($buildFile -and (-not(test-path $buildFile))) {
4848
if (test-path $absoluteBuildFile) {
4949
$buildFile = $absoluteBuildFile
5050
}
51-
}
51+
}
5252

5353
Invoke-psake $buildFile $taskList $framework $docs $parameters $properties $initialization $nologo $detailedDocs

Build/psake.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Description = 'psake is a build automation tool written in PowerShell.'
99
FunctionsToExport = @('Invoke-psake',
1010
'Invoke-Task',
11-
'Get-PSakeScriptTasks',
11+
'Get-PSakeScriptTasks',
1212
'Task',
1313
'Properties',
1414
'Include',

0 commit comments

Comments
 (0)