Skip to content

Commit 05c3e40

Browse files
authored
Linux CI enabled (OpenXmlDev#3)
* Enabled building & testing with ubuntu * Cleaned up code
1 parent 1fde25d commit 05c3e40

File tree

139 files changed

+12356
-8940
lines changed

Some content is hidden

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

139 files changed

+12356
-8940
lines changed

.vscode/launch.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
// Use IntelliSense to find out which attributes exist for C# debugging
3+
// Use hover for the description of the existing attributes
4+
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": ".NET Core Launch (console)",
9+
"type": "coreclr",
10+
"request": "launch",
11+
"preLaunchTask": "build",
12+
// If you have changed target frameworks, make sure to update the program path.
13+
"program": "${workspaceFolder}/OpenXmlPowerToolsExamples/DocumentAssembler/bin/Debug/netcoreapp3.1/DocumentAssembler.dll",
14+
"args": [],
15+
"cwd": "${workspaceFolder}/OpenXmlPowerToolsExamples/DocumentAssembler",
16+
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
17+
"console": "internalConsole",
18+
"stopAtEntry": false
19+
},
20+
{
21+
"name": ".NET Core Attach",
22+
"type": "coreclr",
23+
"request": "attach",
24+
"processId": "${command:pickProcess}"
25+
}
26+
]
27+
}

.vscode/tasks.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "build",
6+
"command": "dotnet",
7+
"type": "process",
8+
"args": [
9+
"build",
10+
"${workspaceFolder}/OpenXmlPowerToolsExamples/DocumentAssembler/DocumentAssembler.csproj",
11+
"/property:GenerateFullPaths=true",
12+
"/consoleloggerparameters:NoSummary"
13+
],
14+
"problemMatcher": "$msCompile"
15+
},
16+
{
17+
"label": "publish",
18+
"command": "dotnet",
19+
"type": "process",
20+
"args": [
21+
"publish",
22+
"${workspaceFolder}/OpenXmlPowerToolsExamples/DocumentAssembler/DocumentAssembler.csproj",
23+
"/property:GenerateFullPaths=true",
24+
"/consoleloggerparameters:NoSummary"
25+
],
26+
"problemMatcher": "$msCompile"
27+
},
28+
{
29+
"label": "watch",
30+
"command": "dotnet",
31+
"type": "process",
32+
"args": [
33+
"watch",
34+
"run",
35+
"${workspaceFolder}/OpenXmlPowerToolsExamples/DocumentAssembler/DocumentAssembler.csproj",
36+
"/property:GenerateFullPaths=true",
37+
"/consoleloggerparameters:NoSummary"
38+
],
39+
"problemMatcher": "$msCompile"
40+
}
41+
]
42+
}
Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,24 @@
11
[environment]::CurrentDirectory = $(Get-Location)
2-
if (-not $(Test-Path .\GenerateNewDocxCmdlet.ps1))
3-
{
2+
if (-not $(Test-Path .\GenerateNewDocxCmdlet.ps1)) {
43
Throw "You must run this script from within the NewDocxDocuments directory"
54
}
65

76
$dx = "..\Cmdlets\DocxLib.ps1"
8-
if (Test-Path $dx) { del $dx }
7+
if (Test-Path $dx) { Remove-Item $dx }
98

109
$lineBreak = [System.Environment]::NewLine
1110

1211
[System.Text.StringBuilder]$sbDxl = New-Object -TypeName System.Text.StringBuilder
1312

1413
$copyrightString = @"
15-
<#***************************************************************************
16-
17-
Copyright (c) Microsoft Corporation 2015.
18-
19-
This code is licensed using the Microsoft Public License (Ms-PL). The text of the license can be found here:
20-
21-
http://www.microsoft.com/resources/sharedsource/licensingbasics/publiclicense.mspx
22-
23-
Published at http://OpenXmlDeveloper.org
24-
Resource Center and Documentation: http://openxmldeveloper.org/wiki/w/wiki/powertools-for-open-xml.aspx
25-
26-
***************************************************************************#>
14+
<# Copyright (c) Microsoft. All rights reserved.
15+
Licensed under the MIT license. See LICENSE file in the project root for full license information.#>
2716
2817
"@
2918

3019
[void]$sbDxl.Append($copyrightString + $lineBreak)
3120

32-
dir *.docx | % {
21+
Get-ChildItem *.docx | ForEach-Object {
3322
$fi = New-Object System.IO.FileInfo $_
3423
[void]$sbDxl.Append("`$SampleDocx$($_.BaseName) =" + $lineBreak)
3524
$b64 = $(ConvertTo-Base64 $_ -PowerShellLiteral)
@@ -42,66 +31,60 @@ $template = [System.IO.File]::ReadAllLines("..\Cmdlets\New-Docx-Template.ps1")
4231
$paramDocs = -1;
4332
$paramDecl = -1;
4433
$paramUse = -1;
45-
for ($i = 0; $i -lt $template.Length; $i++)
46-
{
34+
for ($i = 0; $i -lt $template.Length; $i++) {
4735
$t = $template[$i]
4836
if ($t.Contains("ParameterDocumentation")) { $paramDocs = $i }
4937
if ($t.Contains("ParameterDeclaration")) { $paramDecl = $i }
5038
if ($t.Contains("ParameterUse")) { $paramUse = $i }
5139
}
5240

5341
$ndx = "..\Cmdlets\New-Docx.ps1"
54-
if (Test-Path $ndx)
55-
{
42+
if (Test-Path $ndx) {
5643
Remove-Item $ndx
5744
}
5845

5946
$sbGenNewDocx = New-Object System.Text.StringBuilder;
6047

6148
$template[0..($paramDocs - 1)] | % { [void]$sbGenNewDocx.Append($_ + $lineBreak) }
62-
dir *.docx | % {
49+
Get-ChildItem *.docx | ForEach-Object {
6350
$fi = New-Object System.IO.FileInfo $_
6451
[void]$sbGenNewDocx.Append(" .PARAMETER $($fi.BaseName)" + $lineBreak)
6552
$fiDesc = New-Object System.IO.FileInfo $($_.BaseName + ".txt")
66-
if ($fiDesc.Exists)
67-
{
68-
Get-Content $($fiDesc.FullName) | % { [void]$sbGenNewDocx.Append(' ' + $_ + $lineBreak) }
53+
if ($fiDesc.Exists) {
54+
Get-Content $($fiDesc.FullName) | ForEach-Object { [void]$sbGenNewDocx.Append(' ' + $_ + $lineBreak) }
6955
}
70-
else
71-
{
56+
else {
7257
$errMessage = "Error: $($fi.BaseName).docx does not have a corresponding $($fi.BaseName).txt"
73-
Write-Host -ForegroundColor Red $errMessage
58+
Write-Error $errMessage
7459
[void]$sbGenNewDocx.Append(' ' + $errMessage + $lineBreak)
7560
}
7661
}
7762
$start = $paramDocs + 1
7863
$end = $paramDecl - 1
79-
$template[$start..$end] | % { [void]$sbGenNewDocx.Append($_ + $lineBreak) }
80-
$last = (($(dir *.docx) | measure).Count) - 1
64+
$template[$start..$end] | ForEach-Object { [void]$sbGenNewDocx.Append($_ + $lineBreak) }
65+
$last = (($(Get-ChildItem *.docx) | Measure-Object).Count) - 1
8166
$count = 0
82-
dir *.docx | % {
67+
Get-ChildItem *.docx | ForEach-Object {
8368
$fi = New-Object System.IO.FileInfo $_
8469
[void]$sbGenNewDocx.Append(' [Parameter(Mandatory=$False)]' + $lineBreak)
8570
[void]$sbGenNewDocx.Append(' [Switch]' + $lineBreak)
86-
if ($count -ne $last)
87-
{
71+
if ($count -ne $last) {
8872
[void]$sbGenNewDocx.Append(" [bool]`$$($_.BaseName)," + $lineBreak)
8973
}
90-
else
91-
{
74+
else {
9275
[void]$sbGenNewDocx.Append(" [bool]`$$($_.BaseName)" + $lineBreak)
9376
}
9477
[void]$sbGenNewDocx.Append($lineBreak)
9578
$count++
9679
}
9780
$start = $paramDecl + 1
9881
$end = $paramUse - 1
99-
$template[$start..$end] | % { [void]$sbGenNewDocx.Append($_ + $lineBreak) }
100-
dir *.docx | % {
82+
$template[$start..$end] | ForEach-Object { [void]$sbGenNewDocx.Append($_ + $lineBreak) }
83+
Get-ChildItem *.docx | ForEach-Object {
10184
$fi = New-Object System.IO.FileInfo $_
10285
[void]$sbGenNewDocx.Append(" if (`$All -or `$$($fi.BaseName)) { AppendDoc `$srcList `$SampleDocx$($fi.BaseName) `"$($fi.BaseName)`" }" + $lineBreak)
10386
}
10487
$start = $paramUse + 1
105-
$template[$start..99999] | % { [void]$sbGenNewDocx.Append($_ + $lineBreak) }
88+
$template[$start..99999] | ForEach-Object { [void]$sbGenNewDocx.Append($_ + $lineBreak) }
10689

10790
Set-Content -Value $sbGenNewDocx.ToString() -Path $ndx -Encoding UTF8
Lines changed: 21 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,24 @@
11
[environment]::CurrentDirectory = $(Get-Location)
2-
if (-not $(Test-Path .\GenerateNewPptxCmdlet.ps1))
3-
{
2+
if (-not $(Test-Path .\GenerateNewPptxCmdlet.ps1)) {
43
Throw "You must run this script from within the NewPptxPresentations directory"
54
}
65

76
$dx = "..\Cmdlets\PptxLib.ps1"
8-
if (Test-Path $dx) { del $dx}
7+
if (Test-Path $dx) { Remove-Item $dx }
98

109
$lineBreak = [System.Environment]::NewLine
1110

1211
[System.Text.StringBuilder]$sbDxl = New-Object -TypeName System.Text.StringBuilder
1312

1413
$copyrightString = @"
15-
<#***************************************************************************
16-
17-
Copyright (c) Microsoft Corporation 2015.
18-
19-
This code is licensed using the Microsoft Public License (Ms-PL). The text of the license can be found here:
20-
21-
http://www.microsoft.com/resources/sharedsource/licensingbasics/publiclicense.mspx
22-
23-
Published at http://OpenXmlDeveloper.org
24-
Resource Center and Documentation: http://openxmldeveloper.org/wiki/w/wiki/powertools-for-open-xml.aspx
25-
26-
***************************************************************************#>
14+
<#Copyright (c) Microsoft. All rights reserved.
15+
Licensed under the MIT license. See LICENSE file in the project root for full license information.#>
2716
2817
"@
2918

3019
[void]$sbDxl.Append($copyrightString + $lineBreak)
3120

32-
dir *.pptx | % {
21+
Get-ChildItem *.pptx | ForEach-Object {
3322
$fi = New-Object System.IO.FileInfo $_
3423
[void]$sbDxl.Append("`$SamplePptx$($_.BaseName) =" + $lineBreak)
3524
$b64 = $(ConvertTo-Base64 $_ -PowerShellLiteral)
@@ -42,66 +31,60 @@ $template = [System.IO.File]::ReadAllLines("..\Cmdlets\New-Pptx-Template.ps1")
4231
$paramDocs = -1;
4332
$paramDecl = -1;
4433
$paramUse = -1;
45-
for ($i = 0; $i -lt $template.Length; $i++)
46-
{
34+
for ($i = 0; $i -lt $template.Length; $i++) {
4735
$t = $template[$i]
4836
if ($t.Contains("ParameterDocumentation")) { $paramDocs = $i }
4937
if ($t.Contains("ParameterDeclaration")) { $paramDecl = $i }
5038
if ($t.Contains("ParameterUse")) { $paramUse = $i }
5139
}
5240

5341
$npx = "..\Cmdlets\New-Pptx.ps1"
54-
if (Test-Path $npx)
55-
{
42+
if (Test-Path $npx) {
5643
Remove-Item $npx
5744
}
5845

5946
$sbGenNewPptx = New-Object System.Text.StringBuilder;
6047

61-
$template[0..($paramDocs - 1)] | % { [void]$sbGenNewPptx.Append($_ + $lineBreak) }
62-
dir *.pptx | % {
48+
$template[0..($paramDocs - 1)] | ForEach-Object { [void]$sbGenNewPptx.Append($_ + $lineBreak) }
49+
Get-ChildItem *.pptx | ForEach-Object {
6350
$fi = New-Object System.IO.FileInfo $_
6451
[void]$sbGenNewPptx.Append(" .PARAMETER $($fi.BaseName)" + $lineBreak)
6552
$fiDesc = New-Object System.IO.FileInfo $($_.BaseName + ".txt")
66-
if ($fiDesc.Exists)
67-
{
68-
Get-Content $($fiDesc.FullName) | % { [void]$sbGenNewPptx.Append(' ' + $_ + $lineBreak) }
53+
if ($fiDesc.Exists) {
54+
Get-Content $($fiDesc.FullName) | ForEach-Object { [void]$sbGenNewPptx.Append(' ' + $_ + $lineBreak) }
6955
}
70-
else
71-
{
56+
else {
7257
$errMessage = "Error: $($fi.BaseName).pptx does not have a corresponding $($fi.BaseName).txt"
73-
Write-Host -ForegroundColor Red $errMessage
58+
Write-Error $errMessage
7459
[void]$sbGenNewPptx.Append(' ' + $errMessage + $lineBreak)
7560
}
7661
}
7762
$start = $paramDocs + 1
7863
$end = $paramDecl - 1
79-
$template[$start..$end] | % { [void]$sbGenNewPptx.Append($_ + $lineBreak) }
80-
$last = (($(dir *.pptx) | measure).Count) - 1
64+
$template[$start..$end] | ForEach-Object { [void]$sbGenNewPptx.Append($_ + $lineBreak) }
65+
$last = (($(Get-ChildItem *.pptx) | Measure-Object).Count) - 1
8166
$count = 0
82-
dir *.pptx | % {
67+
Get-ChildItem *.pptx | ForEach-Object {
8368
$fi = New-Object System.IO.FileInfo $_
8469
[void]$sbGenNewPptx.Append(' [Parameter(Mandatory=$False)]' + $lineBreak)
8570
[void]$sbGenNewPptx.Append(' [Switch]' + $lineBreak)
86-
if ($count -ne $last)
87-
{
71+
if ($count -ne $last) {
8872
[void]$sbGenNewPptx.Append(" [bool]`$$($_.BaseName)," + $lineBreak)
8973
}
90-
else
91-
{
74+
else {
9275
[void]$sbGenNewPptx.Append(" [bool]`$$($_.BaseName)" + $lineBreak)
9376
}
9477
[void]$sbGenNewPptx.Append($lineBreak)
9578
$count++
9679
}
9780
$start = $paramDecl + 1
9881
$end = $paramUse - 1
99-
$template[$start..$end] | % { [void]$sbGenNewPptx.Append($_ + $lineBreak) }
100-
dir *.pptx | % {
82+
$template[$start..$end] | ForEach-Object { [void]$sbGenNewPptx.Append($_ + $lineBreak) }
83+
Get-ChildItem *.pptx | ForEach-Object {
10184
$fi = New-Object System.IO.FileInfo $_
10285
[void]$sbGenNewPptx.Append(" if (`$All -or `$$($fi.BaseName)) { AppendPresentation `$srcList `$SamplePptx$($fi.BaseName) `"$($fi.BaseName)`" }" + $lineBreak)
10386
}
10487
$start = $paramUse + 1
105-
$template[$start..99999] | % { [void]$sbGenNewPptx.Append($_ + $lineBreak) }
88+
$template[$start..99999] | ForEach-Object { [void]$sbGenNewPptx.Append($_ + $lineBreak) }
10689

10790
Set-Content -Value $sbGenNewPptx.ToString() -Path $npx -Encoding UTF8

OpenXmlPowerTools.Tests/DocumentBuilderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ private void Validate(FileInfo fi)
876876
return !found;
877877
});
878878

879-
if (errors.Count() != 0)
879+
if (errors.Any())
880880
{
881881
var sb = new StringBuilder();
882882
foreach (var item in errors)

0 commit comments

Comments
 (0)