Skip to content

Commit 5a3446d

Browse files
authored
Merge pull request #210 from belav/prep-0.9.3
bumping version, updating change log, updating readme
2 parents 3d19de6 + d5a6d65 commit 5a3446d

File tree

8 files changed

+156
-141
lines changed

8 files changed

+156
-141
lines changed

CHANGELOG.md

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,32 @@
1+
# 0.9.3
2+
3+
[diff](https://github.com/belav/csharpier/compare/0.9.2...0.9.3)
4+
5+
- RecordDeclaration with Generics produces invalid code [#201](https://github.com/belav/csharpier/issues/201)
6+
- Formatting of auto implemented properties with access modifiers [#188](https://github.com/belav/csharpier/issues/188)
7+
- Verbatim string literals take into account EndOfLine configuration [#183](https://github.com/belav/csharpier/issues/183)
8+
- CSharpierIgnore & CSharpierRC from parent directories should be respected. [#181](https://github.com/belav/csharpier/issues/181)
9+
- Break apart readme [#172](https://github.com/belav/csharpier/issues/172)
10+
- PatternMatching includes extra spaces [#167](https://github.com/belav/csharpier/issues/167)
11+
- Re-add async file reads [#127](https://github.com/belav/csharpier/issues/127)
12+
- Dictionary Initializer inserts extra new line [#103](https://github.com/belav/csharpier/issues/103)
13+
114
#0.9.2
215
[diff](https://github.com/belav/csharpier/compare/0.9.1...0.9.2)
316

4-
- Support "auto" for endOfLine [#147](https://api.github.com/repos/belav/csharpier/issues/147)
5-
- Long Parameter Attribute should break after ending brace [#174](https://api.github.com/repos/belav/csharpier/issues/174)
6-
- Attribute on parameter should have space [#104](https://api.github.com/repos/belav/csharpier/issues/104)
7-
17+
- Support "auto" for endOfLine [#147](https://github.com/belav/csharpier/issues/147)
18+
- Long Parameter Attribute should break after ending brace [#174](https://github.com/belav/csharpier/issues/174)
19+
- Attribute on parameter should have space [#104](https://github.com/belav/csharpier/issues/104)
820

921
# 0.9.1
1022

1123
[diff](https://github.com/belav/csharpier/compare/0.9.0...0.9.1)
1224

13-
- Add support for .csharpierignore [#159](https://api.github.com/repos/belav/csharpier/issues/159)
14-
- Break before BinaryOperator [#152](https://api.github.com/repos/belav/csharpier/issues/152)
15-
- LeadingComments affect breaking [#149](https://api.github.com/repos/belav/csharpier/issues/149)
16-
- Ignore generated files by default [#140](https://api.github.com/repos/belav/csharpier/issues/140)
17-
- Return with BinaryExpression [#137](https://api.github.com/repos/belav/csharpier/issues/137)
18-
- IsPattern breaking inside of IfStatement [#130](https://api.github.com/repos/belav/csharpier/issues/130)
19-
- SpaceBrace causing breaking when it shouldn't [#100](https://api.github.com/repos/belav/csharpier/issues/100)
20-
- Implement Formatting Options with Configuration File [#10](https://api.github.com/repos/belav/csharpier/issues/10)
25+
- Add support for .csharpierignore [#159](https://github.com/belav/csharpier/issues/159)
26+
- Break before BinaryOperator [#152](https://github.com/belav/csharpier/issues/152)
27+
- LeadingComments affect breaking [#149](https://github.com/belav/csharpier/issues/149)
28+
- Ignore generated files by default [#140](https://github.com/belav/csharpier/issues/140)
29+
- Return with BinaryExpression [#137](https://github.com/belav/csharpier/issues/137)
30+
- IsPattern breaking inside of IfStatement [#130](https://github.com/belav/csharpier/issues/130)
31+
- SpaceBrace causing breaking when it shouldn't [#100](https://github.com/belav/csharpier/issues/100)
32+
- Implement Formatting Options with Configuration File [#10](https://github.com/belav/csharpier/issues/10)

CSharpier.sln

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ EndProject
3838
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docs", "Docs", "{7C99AEA7-E608-40B5-9B2E-353B6E4C9DBE}"
3939
ProjectSection(SolutionItems) = preProject
4040
Docs/EditorsAndCICD.md = Docs/EditorsAndCICD.md
41+
Docs/Configuration.md = Docs/Configuration.md
42+
Docs/CLI.md = Docs/CLI.md
43+
Docs/Ignore.md = Docs/Ignore.md
4144
EndProjectSection
4245
EndProject
4346
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpier.Benchmarks", "Src\CSharpier.Benchmarks\CSharpier.Benchmarks.csproj", "{A338903F-69AD-4950-B827-8EE75F98B620}"

Docs/CLI.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
2+
### Command Line Options
3+
```console
4+
Usage:
5+
dotnet-csharpier [options] [<directoryOrFile>]
6+
7+
Arguments:
8+
<directoryOrFile> A path to a directory containing files to format or a file to format. If a path is not specified the current directory is used
9+
10+
Options:
11+
--check Check that files are formatted. Will not write any changes.
12+
--fast Skip comparing syntax tree of formatted file to original file to validate changes.
13+
--skip-write Skip writing changes. Generally used for testing to ensure csharpier doesn't throw any errors or cause syntax tree validation failures.
14+
--version Show version information
15+
-?, -h, --help Show help and usage information
16+
17+
18+
```
19+
20+
### \<directoryOrFile\>
21+
Currently CSharpier only supports being passed a directory to recursively scan for .cs files or a single file to format.
22+
If a directory is not supplied, it will use the current directory.
23+
24+
### --check
25+
Used to check if your files are already formatted. Outputs any files that have not already been formatted.
26+
This will return exit code 1 if there are unformatted files which is useful for CI pipelines.
27+
28+
### --fast
29+
CSharpier validates the changes it makes to a file.
30+
It does this by comparing the syntax tree before and after formatting, but ignoring any whitespace trivia in the syntax tree.
31+
If a file fails validation, CSharpier will output the lines that differ. If this happens it indicates a bug in CSharpier's code.
32+
This validation may be skipped by passing the --fast argument. Validation appears to increase the formatting time by ~50%.
33+
34+
An example of CSharpier finding a file that failed validation.
35+
```
36+
\src\[Snip]\AbstractReferenceFinder_GlobalSuppressions.cs - failed syntax tree validation
37+
Original: Around Line 280
38+
}
39+
40+
if (prefix.Span[^2] is < 'A' or > 'Z')
41+
{
42+
return false;
43+
}
44+
45+
if (prefix.Span[^1] is not ':')
46+
Formatted: Around Line 330
47+
}
48+
49+
if (prefix.Span[^2] is )
50+
{
51+
return false;
52+
}
53+
54+
if (prefix.Span[^1] is not ':')
55+
```

Docs/Configuration.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
CSharpier has support for a configuration file. You can use any of the following files
2+
- A ```.csharpierrc``` file in JSON or YAML.
3+
- A ```.csharpierrc.json``` or ```.csharpierrc.yaml``` file.
4+
5+
### Configuration Options
6+
JSON
7+
```json
8+
{
9+
"printWidth": 100,
10+
"useTabs": false,
11+
"tabWidth": 4,
12+
"endOfLine": "auto"
13+
}
14+
```
15+
YAML
16+
```json
17+
printWidth: 100
18+
useTabs: false
19+
tabWidth: 4
20+
endOfLine: auto
21+
```
22+
23+
#### Print Width
24+
Specify at what point the printer will wrap content. This is not a hard limit. Some lines will be shorter or longer.
25+
26+
Default 100
27+
#### Use Tabs
28+
Indent lines with tabs instead of spaces.
29+
30+
Default false
31+
#### Tab Width
32+
Specify the number of spaces used per indentation level.
33+
34+
Default 4
35+
#### End of Line
36+
Specify what type of line endings will be printed in files.
37+
Options
38+
- "auto" - Detects which type of line ending to used based on the first one it encounters in the file **Default**
39+
- "lf" - Line feed only (\n)
40+
- "crlf" Carriage return and line feed (\r\n)

Docs/Ignore.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
### Ignoring Files
2+
Csharpier will ignore the following files
3+
- Any file that begins with ```TemporaryGeneratedFile_```
4+
- Any file that ends with ```.designer.cs```
5+
- Any file that ends with ```.generated.cs```
6+
- Any file that ends with ```.g.cs```
7+
- Any file that ends with ```.g.i.cs```
8+
- Any file that begins with a comment that contains ```<autogenerated``` or ```<auto-generated```
9+
10+
Add a ```.csharpierignore``` file to ignore additional files and folders. The file uses [gitignore syntax](https://git-scm.com/docs/gitignore#_pattern_format)
11+
12+
Example
13+
```
14+
Uploads/
15+
**/App_Data/*.cs
16+
```

README.md

Lines changed: 13 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## CSharpier
2-
CSharpier is an opinionated code formatter for c#. It uses Roslyn to parse your code and re-prints it using its own rules. The printing process was ported from [prettier](https://github.com/prettier/prettier) but has evolved over time.
2+
CSharpier is an opinionated code formatter for c#. It uses Roslyn to parse your code and re-prints it using its own rules.
3+
The printing process was ported from [prettier](https://github.com/prettier/prettier) but has evolved over time.
4+
CSharpier provides a few basic options that affect formatting and has no plans to add more. It follows the [Option Philosophy](https://prettier.io/docs/en/option-philosophy.html) of prettier
35

46
### Work In Progress
57
CSharpier is still in active development.
@@ -41,12 +43,13 @@ public class ClassName
4143
public void LongUglyMethod(
4244
string longParameter1,
4345
string longParameter2,
44-
string longParameter3)
45-
{
46+
string longParameter3
47+
) {
4648
this.LongUglyMethod(
4749
"1234567890",
4850
"abcdefghijklmnopqrstuvwxyz",
49-
"ABCDEFGHIJKLMNOPQRSTUVWXYZ");
51+
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
52+
);
5053
}
5154
}
5255
```
@@ -57,134 +60,19 @@ dotnet tool install -g csharpier
5760
```
5861

5962
## Basic Usage
60-
By default csharpier will validate any files it formats by comparing the resulting syntax tree to the original.
61-
Formatting will take longer, but csharpier will validate the formatted syntax tree against the original and warn if it believes it introduced breaking changes.
62-
6363
Run csharpier from the directory you wish to format.
6464
```console
6565
dotnet csharpier
6666
```
6767

68-
## Configuration
69-
CSharpier has support for a configuration file. You can use any of the following files
70-
- A ```.csharpierrc``` file in JSON or YAML.
71-
- A ```.csharpierrc.json``` or ```.csharpierrc.yaml``` file.
72-
73-
### Configuration Options
74-
JSON
75-
```json
76-
{
77-
"printWidth": 100,
78-
"useTabs": false,
79-
"tabWidth": 4,
80-
"endOfLine": "auto"
81-
}
82-
```
83-
YAML
84-
```json
85-
printWidth: 100
86-
useTabs: false
87-
tabWidth: 4
88-
endOfLine: auto
89-
```
90-
91-
#### Print Width
92-
Specify at what point the printer will wrap content. This is not a hard limit. Some lines will be shorter or longer.
93-
94-
Default 100
95-
#### Use Tabs
96-
Indent lines with tabs instead of spaces.
97-
98-
Default false
99-
#### Tab Width
100-
Specify the number of spaces used per indentation level.
101-
102-
Default 4
103-
#### End of Line
104-
Specify what type of line endings will be printed in files.
105-
Options
106-
- "auto" - Detects which type of line ending to used based on the first one it encounters in the file **Default**
107-
- "lf" - Line feed only (\n)
108-
- "crlf" Carriage return and line feed (\r\n)
109-
110-
### Ignoring Files
111-
Csharpier will ignore the following files
112-
- Any file that begins with ```TemporaryGeneratedFile_```
113-
- Any file that ends with ```.designer.cs```
114-
- Any file that ends with ```.generated.cs```
115-
- Any file that ends with ```.g.cs```
116-
- Any file that ends with ```.g.i.cs```
117-
- Any file that begins with a comment that contains ```<autogenerated``` or ```<auto-generated```
118-
119-
Add a ```.csharpierignore``` file to ignore additional files and folders. The file uses [gitignore syntax](https://git-scm.com/docs/gitignore#_pattern_format)
120-
121-
Example
122-
```
123-
Uploads/
124-
**/App_Data/*.cs
125-
```
126-
127-
### Command Line Options
128-
```console
129-
Usage:
130-
dotnet-csharpier [options] [<directoryOrFile>]
131-
132-
Arguments:
133-
<directoryOrFile> A path to a directory containing files to format or a file to format. If a path is not specified the current directory is used
134-
135-
Options:
136-
--check Check that files are formatted. Will not write any changes.
137-
--fast Skip comparing syntax tree of formatted file to original file to validate changes.
138-
--skip-write Skip writing changes. Generally used for testing to ensure csharpier doesn't throw any errors or cause syntax tree validation failures.
139-
--version Show version information
140-
-?, -h, --help Show help and usage information
141-
142-
143-
```
144-
145-
### \<directoryOrFile\>
146-
Currently CSharpier only supports being passed a directory to recursively scan for .cs files or a single file to format.
147-
If a directory is not supplied, it will use the current directory.
148-
149-
### --check
150-
Used to check if your files are already formatted. Outputs any files that have not already been formatted.
151-
This will return exit code 1 if there are unformatted files which is useful for CI pipelines.
152-
153-
### --fast
154-
CSharpier validates the changes it makes to a file.
155-
It does this by comparing the syntax tree before and after formatting, but ignoring any whitespace trivia in the syntax tree.
156-
If a file fails validation, CSharpier will output the lines that differ. If this happens it indicates a bug in CSharpier's code.
157-
This validation may be skipped by passing the --fast argument. Validation appears to increase the formatting time by ~50%.
158-
159-
An example of CSharpier finding a file that failed validation.
160-
```
161-
\src\[Snip]\AbstractReferenceFinder_GlobalSuppressions.cs - failed syntax tree validation
162-
Original: Around Line 280
163-
}
164-
165-
if (prefix.Span[^2] is < 'A' or > 'Z')
166-
{
167-
return false;
168-
}
169-
170-
if (prefix.Span[^1] is not ':')
171-
Formatted: Around Line 330
172-
}
173-
174-
if (prefix.Span[^2] is )
175-
{
176-
return false;
177-
}
178-
179-
if (prefix.Span[^1] is not ':')
180-
```
181-
182-
## More Documentation
183-
[Editors and CI/CD](Docs/EditorsAndCICD.md)
68+
## Documentation
69+
[Command Line Interface](Docs/CLI.md)
70+
[Configuration File](Docs/Configure.md)
71+
[Editors and CI/CD](Docs/EditorsAndCICD.md)
72+
[Ignoring Files](Docs/Ignore.md)
73+
[ChangeLog](CHANGELOG.md)
18474

18575
## Contributing
18676
See [Development Readme](CONTRIBUTING.md)
18777

18878
Join Us [![Discord](https://img.shields.io/badge/Discord-chat?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/HfAKGEZQcX)
189-
190-
[ChangeLog](CHANGELOG.md)

Scripts/ChangeLog.ps1

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# this uses https://github.com/microsoft/PowerShellForGitHub
22
# you'll need to Set-GitHubAuthentication first
33

4-
$versionNumber = "0.9.1"
5-
$previousVersionNumber = "0.9.0"
4+
$versionNumber = "0.9.3"
5+
$previousVersionNumber = "0.9.2"
66

77
$repository = "https://github.com/belav/csharpier"
88

@@ -25,7 +25,8 @@ foreach ($issue in $issues) {
2525
if ($issue.title.ToLower().Contains("checklist")) {
2626
continue
2727
}
28-
$content.AppendLine("- " + $issue.title + " [#" + $issue.number +"](" + $issue.url + ")")
28+
29+
$content.AppendLine("- " + $issue.title + " [#" + $issue.number +"](" + $issue.html_url + ")")
2930
}
3031

3132
Write-Output $content.ToString()

Src/CSharpier/CSharpier.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<TargetFramework>net5.0</TargetFramework>
88
<RootNamespace>CSharpier</RootNamespace>
99
<PackAsTool>true</PackAsTool>
10-
<Version>0.9.2</Version>
10+
<Version>0.9.3</Version>
1111
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1212
<RepositoryUrl>https://github.com/belav/csharpier</RepositoryUrl>
1313
<RepositoryType>git</RepositoryType>

0 commit comments

Comments
 (0)