Skip to content

Commit adf7026

Browse files
authored
Releasing 1.2.0 (#1746)
1 parent f0cf0ab commit adf7026

File tree

4 files changed

+195
-3
lines changed

4 files changed

+195
-3
lines changed

CHANGELOG.md

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,182 @@
1+
# 1.2.0
2+
## What's Changed
3+
### Custom XML Parser [#1679](https://github.com/belav/csharpier/pull/1679)
4+
CSharpier now has a custom xml parser. `XmlDocument` and `XDocument` do not provide the original white space or the original attribute values from the file that was parsed which blocked the ability to implement supporting keeping empty new lines and not automatically encoding attributes.
5+
### Support for keeping empty lines in xml files [#1599](https://github.com/belav/csharpier/issues/1599)
6+
CSharpier now supports keeping a single empty line between elements in xml files. It will remove any initial or trailing empty lines.
7+
```xml
8+
<!-- input -->
9+
<Root>
10+
11+
<Element />
12+
13+
14+
<Element />
15+
16+
</Root>
17+
18+
<!-- expected output -->
19+
<Root>
20+
<Element />
21+
22+
<Element />
23+
</Root>
24+
25+
<!-- 1.1.2 -->
26+
<Root>
27+
<Element />
28+
<Element />
29+
</Root>
30+
```
31+
### Xml - don't automatically encode attribute values [#1610](https://github.com/belav/csharpier/issues/1610)
32+
CSharpier will no longer encode attribute values. It will leave them encoded if they are supplied that way.
33+
```xml
34+
<!-- input & expected output -->
35+
<Target Name="Transform" BeforeTargets="Build">
36+
<Message Importance="high" Text="@(MyItems->'MyItems has %(Identity)', ', ')" />
37+
</Target>
38+
39+
<!-- 1.1.2 -->
40+
<Target Name="Transform" BeforeTargets="Build">
41+
<Message Importance="high" Text="@(MyItems-&gt;'MyItems has %(Identity)', ', ')" />
42+
</Target>
43+
```
44+
### Add option to all integrations to report incorrect formatting as a warning instead of error [#1687](https://github.com/belav/csharpier/issues/1687)
45+
46+
### Formatting "using" import split on multiple lines requires formatting it twice to get the expected result [#1698](https://github.com/belav/csharpier/issues/1698)
47+
When a using contained a newline before the namespace it was not being sorted properly.
48+
```c#
49+
// input
50+
using System.Net;
51+
using
52+
SomeProject.Bar;
53+
using Microsoft.Extensions.Logging;
54+
55+
// expected output
56+
using System.Net;
57+
using Microsoft.Extensions.Logging;
58+
using SomeProject.Bar;
59+
60+
// 1.1.2
61+
using System.Net;
62+
using SomeProject.Bar;
63+
using Microsoft.Extensions.Logging;
64+
```
65+
66+
### An empty line is inserted in lambda [#1694](https://github.com/belav/csharpier/issues/1694)
67+
CSharpier was inserting an extra blank line in some situations with a lambda and a collection expression
68+
```c#
69+
// input & expected output
70+
CallMethod(
71+
(parameter1, parameter2) =>
72+
[
73+
LongValue________________________________________________,
74+
LongValue________________________________________________,
75+
]
76+
);
77+
78+
// 1.1.2
79+
CallMethod(
80+
(parameter1, parameter2) =>
81+
82+
[
83+
LongValue________________________________________________,
84+
LongValue________________________________________________,
85+
]
86+
);
87+
```
88+
89+
### Indent .ThenInclude() for clearer navigation hierarchy in EF Core queries [#1602](https://github.com/belav/csharpier/issues/1602)
90+
CSharpier now treats `.ThenInclude` as a special case to improve formatting of EF queries
91+
```c#
92+
// input & expected output
93+
websiteQueryable = websiteQueryable
94+
.Include(o => o.Categories)
95+
.Include(o => o.Categories)
96+
.ThenInclude(c => c.Products)
97+
.Include(o => o.Categories)
98+
.ThenInclude(c => c.RuleManager)
99+
.ThenInclude(rm => rm.RuleClauses)
100+
.Include(o => o.Categories)
101+
.ThenInclude(c => c.RuleManager)
102+
.ThenInclude(rm => rm.RuleClauses)
103+
.ThenInclude(rc => rc.RuleTypeOption);
104+
105+
// 1.1.2
106+
websiteQueryable = websiteQueryable
107+
.Include(o => o.Categories)
108+
.Include(o => o.Categories)
109+
.ThenInclude(c => c.Products)
110+
.Include(o => o.Categories)
111+
.ThenInclude(c => c.RuleManager)
112+
.ThenInclude(rm => rm.RuleClauses)
113+
.Include(o => o.Categories)
114+
.ThenInclude(c => c.RuleManager)
115+
.ThenInclude(rm => rm.RuleClauses)
116+
.ThenInclude(rc => rc.RuleTypeOption);
117+
118+
```
119+
### Inconsistent indentation between `is` and other operators [#1601](https://github.com/belav/csharpier/issues/1601)
120+
Pattern operators were being indented inconsistently with other operators. The formatting is now more consistent
121+
```c#
122+
// input & expected output
123+
var b2 = (
124+
System.Environment.SpecialFolder.AdminTools
125+
is System.Environment.SpecialFolder.AdminTools
126+
or System.Environment.SpecialFolder.AdminTools
127+
or System.Environment.SpecialFolder.AdminTools
128+
);
129+
130+
var b2 =
131+
System.Environment.SpecialFolder.AdminTools
132+
is System.Environment.SpecialFolder.AdminTools
133+
or System.Environment.SpecialFolder.AdminTools
134+
or System.Environment.SpecialFolder.AdminTools;
135+
136+
var b2 =
137+
someLongValue____________________________________________
138+
== someOtherLongValue______________________________
139+
+ someOtherLongValue______________________________;
140+
141+
var b2 = (
142+
someLongValue____________________________________________
143+
== someOtherLongValue______________________________
144+
+ someOtherLongValue______________________________
145+
);
146+
147+
// 1.1.2
148+
var b2 = (
149+
System.Environment.SpecialFolder.AdminTools
150+
is System.Environment.SpecialFolder.AdminTools
151+
or System.Environment.SpecialFolder.AdminTools
152+
or System.Environment.SpecialFolder.AdminTools
153+
);
154+
155+
var b2 =
156+
System.Environment.SpecialFolder.AdminTools
157+
is System.Environment.SpecialFolder.AdminTools
158+
or System.Environment.SpecialFolder.AdminTools
159+
or System.Environment.SpecialFolder.AdminTools;
160+
161+
var b2 =
162+
someLongValue____________________________________________
163+
== someOtherLongValue______________________________
164+
+ someOtherLongValue______________________________;
165+
166+
var b2 = (
167+
someLongValue____________________________________________
168+
== someOtherLongValue______________________________
169+
+ someOtherLongValue______________________________
170+
);
171+
172+
```
173+
### Error when formatting with an indent size <= 0 [#1741](https://github.com/belav/csharpier/pull/1741)
174+
Previously csharpier would attempt to format code when indent size was set to 0. This was not intentional and had a number of bugs. CSharpier now error out when encountering an indent size of 0
175+
176+
### Fix condition causing FirstTargetFramework build property erasure [#1696](https://github.com/belav/csharpier/pull/1696)
177+
In some situations CSharpier.Msbuild was running into a build failure.
178+
179+
**Full Changelog**: https://github.com/belav/csharpier/compare/1.1.2...1.2.0
1180
# 1.1.2
2181
## What's Changed
3182
### Inconsistencies with null-coalescing wrapping on method chains [#1573](https://github.com/belav/csharpier/issues/1573)
@@ -3473,5 +3652,6 @@ Thanks go to @pingzing
34733652
34743653
34753654
3655+
34763656
34773657

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>1.1.2</Version>
3+
<Version>1.2.0</Version>
44
<PackageLicenseExpression>MIT</PackageLicenseExpression>
55
<RepositoryUrl>https://github.com/belav/csharpier</RepositoryUrl>
66
<RepositoryType>git</RepositoryType>

Src/Website/docs/CLI.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,14 @@ If a list of paths is not supplied, then stdin is read as a file, formatted and
159159
`dotnet csharpier check [<directoryOrFile\>]`
160160

161161
Used to check if your files are already formatted. Outputs any files that have not already been formatted.
162-
This will return exit code 1 if there are unformatted files which is useful for CI pipelines.
162+
By default this will return exit code 1 if there are unformatted files which is useful for CI pipelines.
163163

164164
#### Options
165-
See the `format` command for descriptions of these options
165+
`--unformatted-as-warnings`
166+
167+
Treat unformatted files as a warning instead of an error. If there are unformatted files they will be printed to the output as a warning and the process will return an exit code of 0.
168+
169+
See the `format` command for descriptions of these additional options
166170
- `--include-generated`
167171
- `--no-msbuild-check`
168172
- `--compilation-errors-as-warnings`

Src/Website/docs/MsBuild.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ Valid options are:
5050
- Information (default)
5151
- Debug
5252

53+
### Unformatted as Warnings
54+
If you do not want to fail the build when running `check` and encountering unformatted files you may set the following property.
55+
```xml
56+
<PropertyGroup>
57+
<CSharpier_UnformattedAsWarnings>true</CSharpier_UnformattedAsWarnings>
58+
</PropertyGroup>
59+
```
60+
5361
### Target Frameworks
5462
CSharpier.MSBuild will be run with net8.0 or net9.0 if the project targets one of the three frameworks. In cases where the project targets something else (net48, netstandard2.0) `CSharpier_FrameworkVersion` will default to net8.0
5563
This can be controlled with the following property. This property is required if the csproj is targeting < net8.0 (netstandard2.0, net48, etc) and net8.0 is not installed.

0 commit comments

Comments
 (0)