Skip to content

Commit 5d73fe3

Browse files
authored
Releasing 0.29.0 (#1320)
1 parent f2fa42d commit 5d73fe3

File tree

5 files changed

+234
-4
lines changed

5 files changed

+234
-4
lines changed

CHANGELOG.md

Lines changed: 202 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,204 @@
1-
# 0.28.2
1+
# 0.29.0
2+
## Breaking Changes
3+
### The formatting command will now exit with an error code of 1 if one of the target files cannot be compiled [#1131](https://github.com/belav/csharpier/issues/1131)
4+
Prior to 0.29.0 if csharpier encountered a file that could not be compiled it would treat it as a warning and exit with a code of 0.
5+
As of 0.2.9.0 a file that cannot be compiled is now treated as an error and csharpier will exit with code 1
6+
7+
## What's Changed
8+
### Enforce trailing commas in object and collection initializer [#668](https://github.com/belav/csharpier/issues/668)
9+
CSharpier will now add trailing commas automatically where appropriate. It will collapse to a single line and remove the trailing comma in cases where everything fits on one line.
10+
```c#
11+
// input
12+
public enum SomeEnum
13+
{
14+
Value1,
15+
Value2
16+
}
17+
18+
string[] someArray = new string[]
19+
{
20+
someLongValue_____________________________________________,
21+
someLongValue_____________________________________________
22+
};
23+
24+
string[] someArray = new string[]
25+
{
26+
someValue,
27+
someValue,
28+
};
29+
30+
// 0.29.0
31+
public enum SomeEnum
32+
{
33+
Value1,
34+
Value2,
35+
}
36+
37+
string[] someArray = new string[]
38+
{
39+
someLongValue_____________________________________________,
40+
someLongValue_____________________________________________,
41+
}
42+
43+
string[] someArray = new string[] { someValue, someValue };
44+
```
45+
Many thanks go to @dawust for the contribution.
46+
47+
### Support for formatting custom file extensions [#1220](https://github.com/belav/csharpier/issues/1220)
48+
Prior to 0.29.0 csharpier would only format files with an extension of .cs or .csx. It is now possible to configure csharpier to format other files extensions, and to specify configuration options per file extension.
49+
See https://csharpier.com/docs/Configuration#configuration-overrides for more details.
50+
51+
### Invalid blank line being added with lambda returning collection expression [#1306](https://github.com/belav/csharpier/issues/1306)
52+
```c#
53+
// input & expected output
54+
CallMethod(_ =>
55+
[
56+
LongValue________________________________________________,
57+
LongValue________________________________________________,
58+
]
59+
);
60+
61+
// 0.28.2
62+
CallMethod(_ =>
63+
64+
[
65+
LongValue________________________________________________,
66+
LongValue________________________________________________,
67+
]
68+
);
69+
70+
```
71+
### Switch expressions do not break consistently with other lambdas [#1282](https://github.com/belav/csharpier/issues/1282)
72+
Prior to 0.29.0 csharpier would break before the `=>` in switch expression arms. It now breaks after them to be consistent with other lambda expressions.
73+
```c#
74+
// 0.28.2
75+
return someEnum switch
76+
{
77+
Value1 => someOtherValue,
78+
Value2
79+
or Value3
80+
=> someValue________________________________________________________________________,
81+
Value4
82+
=> someValue_____________________________________________________________________________,
83+
};
84+
85+
// 0.29.0
86+
return someEnum switch
87+
{
88+
Value1 => someOtherValue,
89+
Value2 or Value3 =>
90+
someValue________________________________________________________________________,
91+
Value4 =>
92+
someValue_____________________________________________________________________________,
93+
};
94+
95+
```
96+
### Formatting of empty collection initializer for huge type [#1268](https://github.com/belav/csharpier/issues/1268)
97+
Empty collection expression initializers formatting was including a break plus indentation resulting in poor formatting.
98+
```c#
99+
// 0.28.2
100+
var someObject = new List<(
101+
int Field1__________________________________,
102+
int Field2__________________________________
103+
)>
104+
{
105+
};
106+
107+
// 0.29.0
108+
var someObject = new List<(
109+
int Field1__________________________________,
110+
int Field2__________________________________
111+
)>
112+
{ };
113+
114+
```
115+
116+
Thanks go to @Rudomitori for the contribution
117+
118+
### Switch expression single line broken when preceded by comment [#1262](https://github.com/belav/csharpier/issues/1262)
119+
Improved formatting for short expression arms that have a leading comment.
120+
```c#
121+
// 0.28.2
122+
return someValue switch
123+
{
124+
// comment
125+
Some.One
126+
=> 1,
127+
Some.Two => 2,
128+
};
129+
130+
return someValue switch
131+
{
132+
Some.One => 1,
133+
// comment
134+
Some.Two
135+
=> 2,
136+
};
137+
138+
// 0.29.0
139+
return someValue switch
140+
{
141+
// comment
142+
Some.One => 1,
143+
Some.Two => 2,
144+
};
145+
146+
return someValue switch
147+
{
148+
Some.One => 1,
149+
// comment
150+
Some.Two => 2,
151+
};
152+
153+
```
154+
### Incorrect formatting of ternary expression with a comment after an interpolated string [#1258](https://github.com/belav/csharpier/issues/1258)
155+
Fixed bug with comments on a ternary expression that resulted in invalid code.
156+
```c#
157+
// input & expected output
158+
public string TrailingComment = someCondition
159+
? $"empty" // trailing comment
160+
: someString;
161+
162+
// 0.28.2
163+
public string TrailingComment = someCondition ? $"empty" // trailing comment : someString;
164+
165+
```
166+
### Formatting for indexer parameters should mostly be the same as for method parameters. [#1255](https://github.com/belav/csharpier/issues/1255)
167+
Improved formatting of indexed properties that contained attributes.
168+
```c#
169+
// input & expected output
170+
public class ClassName
171+
{
172+
public string this[
173+
[SomeAttribute] int a________________________________,
174+
[SomeAttribute] int b________________________________
175+
] => someValue;
176+
}
177+
178+
// 0.28.2
179+
public class ClassName
180+
{
181+
public string this[[SomeAttribute] int a________________________________, [SomeAttribute]
182+
int b________________________________] => someValue;
183+
}
184+
185+
```
186+
187+
### Do not overwrite `CSharpier_Check` when already set. [#1314](https://github.com/belav/csharpier/pull/1314)
188+
Fixed a bug with csharpier.msbuild where it would overwrite the `CSharpier_Check` value in some cases.
189+
190+
Thanks go to @PetSerAl for the contribution
191+
192+
### The CLI has contradictory message about directoryOrFile being required [#1296](https://github.com/belav/csharpier/issues/1296)
193+
The help text for the cli has been improved to better indicate when `directoryOrFile` is required.
194+
195+
Thanks go to @marcinjahn for the contribution
196+
197+
### Fullwidth unicode characters should be accounted for in print width [#260](https://github.com/belav/csharpier/issues/260)
198+
CSharpier now considers full width unicode characters such as `가` to be 2 spaces wide when determining how to format code.
199+
200+
**Full Changelog**: https://github.com/belav/csharpier/compare/0.28.2...0.29.0
201+
# 0.28.2
2202
## What's Changed
3203
### Pipe to `dotnet csharpier` fails when subdirectory is inaccessible [#1240](https://github.com/belav/csharpier/pull/1240)
4204
When running the following CSharpier would look for config files in subdirectories of the `pwd`. This could lead to exceptions if some of those directories were inaccessible.
@@ -2360,3 +2560,4 @@ Thanks go to @pingzing
23602560
23612561
23622562
2563+

Nuget/Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>0.28.2</Version>
3+
<Version>0.29.0</Version>
44
<PackageLicenseExpression>MIT</PackageLicenseExpression>
55
<RepositoryUrl>https://github.com/belav/csharpier</RepositoryUrl>
66
<RepositoryType>git</RepositoryType>

Src/Website/docs/About.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ hide_table_of_contents: true
55
---
66

77
CSharpier is an opinionated code formatter for c#. It uses Roslyn to parse your code and re-prints it using its own rules.
8-
The printing process was ported from [prettier](https://github.com/prettier/prettier) but has evolved over time.
8+
The printing process was ported from [prettier](https://github.com/prettier/prettier) but has evolved over time.
99

1010
CSharpier provides a few basic options that affect formatting and follows the [Option Philosophy](https://prettier.io/docs/en/option-philosophy.html) of prettier. Option requests are out of scope for CSharpier, they will be closed without discussion.
1111

Src/Website/docs/Configuration.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,35 @@ When supplying symbol sets, they will be used for all files being formatted. Thi
7979

8080
The long term plan is to improve Csharpier's ability to determine the symbol sets itself and to allow specifying them for individual files.
8181

82+
### Configuration Overrides ###
83+
_First available in 0.29.0_
84+
Overrides allows you to specify different configuration options based on glob patterns. This can be used to format non-standard extensions, or to change options based on file path. Top level options will apply to `**/*.{cs,csx}`
85+
86+
```json
87+
{
88+
"overrides": [
89+
{
90+
"files": ["*.cst"],
91+
"formatter": "csharp",
92+
"tabWidth": 2,
93+
"useTabs": true,
94+
"printWidth": 10,
95+
"endOfLine": "LF"
96+
}
97+
]
98+
}
99+
```
100+
101+
```yaml
102+
overrides:
103+
- files: "*.cst"
104+
formatter: "csharp"
105+
tabWidth: 2
106+
useTabs: true
107+
printWidth: 10
108+
endOfLine: "LF"
109+
```
110+
82111
### EditorConfig
83112
_First available in 0.26.0_
84113

Src/Website/docs/Installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dotnet new tool-manifest
1111
dotnet tool install csharpier
1212
```
1313

14-
This will as a local dotnet tool for the directory these commands are run from. This ensures the project gets the correct version of CSharpier.
14+
This will act as a local dotnet tool for the directory these commands are run from. This ensures the project gets the correct version of CSharpier.
1515

1616
Dotnet tools can also be installed globally with the following command.
1717

0 commit comments

Comments
 (0)