Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: format code with csharpier #80

Merged
merged 4 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
"dotnet-csharpier"
],
"rollForward": false
},
"husky": {
"version": "0.7.1",
"commands": [
"husky"
],
"rollForward": false
}
}
}
15 changes: 12 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,19 @@
# top-most EditorConfig file
root = true

# Don't use tabs for indentation.
[*]
# Non-configurable behaviors
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = false

# Configurable behaviors
# end_of_line = lf - there is no 'auto' with a .editorconfig
indent_style = space
# (Please don't specify an indent_size here; that has too many unintended consequences.)
indent_size = 4
max_line_length = 120

# Code files
[*.{cs,csx,vb,vbx}]
Expand Down Expand Up @@ -204,4 +213,4 @@ csharp_space_between_square_brackets = false
# Blocks are allowed
csharp_prefer_braces = true:silent
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = true
csharp_preserve_single_line_statements = true
22 changes: 22 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

## husky task runner examples -------------------
## Note : for local installation use 'dotnet' prefix. e.g. 'dotnet husky'

## run all tasks
#husky run

### run all tasks with group: 'group-name'
#husky run --group group-name

## run task with name: 'task-name'
#husky run --name task-name

## pass hook arguments to task
#husky run --args "$1" "$2"

## or put your custom commands -------------------
#echo 'Husky.Net is awesome!'

dotnet husky run
11 changes: 11 additions & 0 deletions .husky/task-runner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://alirezanet.github.io/Husky.Net/schema.json",
"tasks": [
{
"name": "Run csharpier",
"command": "dotnet",
"args": ["csharpier", "${staged}"],
"include": ["**/*.cs"]
}
]
}
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## 2.2.0 - September 8, 2024
## [2.2.0] - September 8, 2024

- DocumentFormat.OpenXml 3.0.2 -> 3.1.0
- DocumentFormat.OpenXml.Framework 3.0.2 -> 3.1.0
Expand Down
147 changes: 38 additions & 109 deletions Clippit.Tests/Common/ChartUpdaterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ namespace Clippit.Tests.Common
{
public class ChartUpdaterTests : TestsBase
{
public ChartUpdaterTests(ITestOutputHelper log) : base(log)
{
}

public ChartUpdaterTests(ITestOutputHelper log)
: base(log) { }

[Theory]
[InlineData("CU001-Chart-Cached-Data-01.docx")]
[InlineData("CU002-Chart-Cached-Data-02.docx")]
Expand All @@ -29,7 +28,6 @@ public ChartUpdaterTests(ITestOutputHelper log) : base(log)
[InlineData("CU006-Chart-Cached-Data-06.docx")]
[InlineData("CU007-Chart-Cached-Data-07.docx")]
[InlineData("CU008-Chart-Cached-Data-08.docx")]

[InlineData("CU009-Chart-Embedded-Xlsx-01.docx")]
[InlineData("CU010-Chart-Embedded-Xlsx-02.docx")]
[InlineData("CU011-Chart-Embedded-Xlsx-03.docx")]
Expand All @@ -39,10 +37,8 @@ public ChartUpdaterTests(ITestOutputHelper log) : base(log)
[InlineData("CU015-Chart-Embedded-Xlsx-07.docx")]
[InlineData("CU016-Chart-Embedded-Xlsx-08.docx")]
[InlineData("CU017-Chart-Embedded-Xlsx-10.docx")]

[InlineData("CU018-Chart-Cached-Data-41.pptx")]
[InlineData("CU019-Chart-Embedded-Xlsx-41.pptx")]

public void CU001(string name)
{
var sourceDir = new DirectoryInfo("../../../../TestFiles/");
Expand All @@ -52,109 +48,61 @@ public void CU001(string name)
{
var wmlTemplate = new WmlDocument(templateFile.FullName);

var afterUpdatingDocx = new FileInfo(Path.Combine(TempDir, templateFile.Name.Replace(".docx", "-processed-by-ChartUpdater.docx")));
var afterUpdatingDocx = new FileInfo(
Path.Combine(TempDir, templateFile.Name.Replace(".docx", "-processed-by-ChartUpdater.docx"))
);
wmlTemplate.SaveAs(afterUpdatingDocx.FullName);

using var wDoc = WordprocessingDocument.Open(afterUpdatingDocx.FullName, true);
var chart1Data = new ChartData
{
SeriesNames = new[] {
"Car",
"Truck",
"Van",
"Bike",
"Boat",
},
SeriesNames = new[] { "Car", "Truck", "Van", "Bike", "Boat" },
CategoryDataType = ChartDataType.String,
CategoryNames = new[] {
"Q1",
"Q2",
"Q3",
"Q4",
},
CategoryNames = new[] { "Q1", "Q2", "Q3", "Q4" },
Values = new[]
{
new double[] {
100, 310, 220, 450,
},
new double[] {
200, 300, 350, 411,
},
new double[] {
80, 120, 140, 600,
},
new double[] {
120, 100, 140, 400,
},
new double[] {
200, 210, 210, 480,
},
new double[] { 100, 310, 220, 450 },
new double[] { 200, 300, 350, 411 },
new double[] { 80, 120, 140, 600 },
new double[] { 120, 100, 140, 400 },
new double[] { 200, 210, 210, 480 },
},
};
ChartUpdater.UpdateChart(wDoc, "Chart1", chart1Data);

var chart2Data = new ChartData
{
SeriesNames = new[] {
"Series"
},
SeriesNames = new[] { "Series" },
CategoryDataType = ChartDataType.String,
CategoryNames = new[] {
"Cars",
"Trucks",
"Vans",
"Boats",
},
Values = new[]
{
new double[] {
320, 112, 64, 80,
},
},
CategoryNames = new[] { "Cars", "Trucks", "Vans", "Boats" },
Values = new[] { new double[] { 320, 112, 64, 80 } },
};
ChartUpdater.UpdateChart(wDoc, "Chart2", chart2Data);

var chart3Data = new ChartData
{
SeriesNames = new[] {
"X1",
"X2",
"X3",
"X4",
"X5",
"X6",
},
SeriesNames = new[] { "X1", "X2", "X3", "X4", "X5", "X6" },
CategoryDataType = ChartDataType.String,
CategoryNames = new[] {
"Y1",
"Y2",
"Y3",
"Y4",
"Y5",
"Y6",
},
CategoryNames = new[] { "Y1", "Y2", "Y3", "Y4", "Y5", "Y6" },
Values = new[]
{
new[] { 3.0, 2.1, .7, .7, 2.1, 3.0, },
new[] { 3.0, 2.1, .8, .8, 2.1, 3.0, },
new[] { 3.0, 2.4, 1.2, 1.2, 2.4, 3.0, },
new[] { 3.0, 2.7, 1.7, 1.7, 2.7, 3.0, },
new[] { 3.0, 2.9, 2.5, 2.5, 2.9, 3.0, },
new[] { 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, },
new[] { 3.0, 2.1, .7, .7, 2.1, 3.0 },
new[] { 3.0, 2.1, .8, .8, 2.1, 3.0 },
new[] { 3.0, 2.4, 1.2, 1.2, 2.4, 3.0 },
new[] { 3.0, 2.7, 1.7, 1.7, 2.7, 3.0 },
new[] { 3.0, 2.9, 2.5, 2.5, 2.9, 3.0 },
new[] { 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 },
},
};
ChartUpdater.UpdateChart(wDoc, "Chart3", chart3Data);

var chart4Data = new ChartData
{
SeriesNames = new[] {
"Car",
"Truck",
"Van",
},
SeriesNames = new[] { "Car", "Truck", "Van" },
CategoryDataType = ChartDataType.DateTime,
CategoryFormatCode = 14,
CategoryNames = new[] {
CategoryNames = new[]
{
ToExcelInteger(new DateTime(2013, 9, 1)),
ToExcelInteger(new DateTime(2013, 9, 2)),
ToExcelInteger(new DateTime(2013, 9, 3)),
Expand All @@ -178,15 +126,9 @@ public void CU001(string name)
},
Values = new[]
{
new double[] {
1, 2, 3, 2, 3, 4, 5, 4, 5, 6, 5, 4, 5, 6, 7, 8, 7, 8, 8, 9,
},
new double[] {
2, 3, 3, 4, 4, 5, 6, 7, 8, 7, 8, 9, 9, 9, 7, 8, 9, 9, 10, 11,
},
new double[] {
2, 3, 3, 3, 3, 2, 2, 2, 3, 2, 3, 3, 4, 4, 4, 3, 4, 5, 5, 4,
},
new double[] { 1, 2, 3, 2, 3, 4, 5, 4, 5, 6, 5, 4, 5, 6, 7, 8, 7, 8, 8, 9 },
new double[] { 2, 3, 3, 4, 4, 5, 6, 7, 8, 7, 8, 9, 9, 9, 7, 8, 9, 9, 10, 11 },
new double[] { 2, 3, 3, 3, 3, 2, 2, 2, 3, 2, 3, 3, 4, 4, 4, 3, 4, 5, 5, 4 },
},
};
ChartUpdater.UpdateChart(wDoc, "Chart4", chart4Data);
Expand All @@ -195,35 +137,22 @@ public void CU001(string name)
{
var pmlTemplate = new PmlDocument(templateFile.FullName);

var afterUpdatingPptx = new FileInfo(Path.Combine(TempDir, templateFile.Name.Replace(".pptx", "-processed-by-ChartUpdater.pptx")));
var afterUpdatingPptx = new FileInfo(
Path.Combine(TempDir, templateFile.Name.Replace(".pptx", "-processed-by-ChartUpdater.pptx"))
);
pmlTemplate.SaveAs(afterUpdatingPptx.FullName);

using var pDoc = PresentationDocument.Open(afterUpdatingPptx.FullName, true);
var chart1Data = new ChartData
{
SeriesNames = new[] {
"Car",
"Truck",
"Van",
},
SeriesNames = new[] { "Car", "Truck", "Van" },
CategoryDataType = ChartDataType.String,
CategoryNames = new[] {
"Q1",
"Q2",
"Q3",
"Q4",
},
CategoryNames = new[] { "Q1", "Q2", "Q3", "Q4" },
Values = new[]
{
new double[] {
320, 310, 320, 330,
},
new double[] {
201, 224, 230, 221,
},
new double[] {
180, 200, 220, 230,
},
new double[] { 320, 310, 320, 330 },
new double[] { 201, 224, 230, 221 },
new double[] { 180, 200, 220, 230 },
},
};
ChartUpdater.UpdateChart(pDoc, 1, chart1Data);
Expand Down
8 changes: 3 additions & 5 deletions Clippit.Tests/Common/MetricsGetterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ namespace Clippit.Tests.Common
{
public class MetricsGetterTests : TestsBase
{
public MetricsGetterTests(ITestOutputHelper log) : base(log)
{
}

public MetricsGetterTests(ITestOutputHelper log)
: base(log) { }

[Theory]
[InlineData("Presentation.pptx")]
[InlineData("Spreadsheet.xlsx")]
Expand Down Expand Up @@ -61,7 +60,6 @@ public void MG001(string name)

Assert.NotNull(metrics);
}

}
}

Expand Down
Loading
Loading