Skip to content

Commit

Permalink
releasing 0.26.0
Browse files Browse the repository at this point in the history
  • Loading branch information
belav committed Nov 6, 2023
1 parent 76dfb66 commit 62c94e5
Show file tree
Hide file tree
Showing 4 changed files with 254 additions and 12 deletions.
213 changes: 212 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,214 @@
# 0.25.0
# 0.26.0
## What's Changed
#### Net8 Support
CSharpier now supports the .net8 sdk. It still supports net6 and net7.

#### Sorting of using directives [#661](https://github.com/belav/csharpier/issues/661)
CSharpier now sorts using statements. It follows the following rules
```c#
global using System.Linq; // sort global first
using System; // sort anything in System
using NonSystem; // sort anything non-system
using static Static; // sort static
using Alias = Z; // sort alias
using SomeAlias = A;
#if DEBUG // finally any usings in #if's
using Z; // contents are not sorted as of now
using A;
#endif
```
#### Remove line before the content of a bracketless if/else statement [#979](https://github.com/belav/csharpier/issues/979)
```c#
// input
if (true)

CallMethod();
else if (false)

CallMethod();
else

CallMethod();

for (; ; )

CallMethod();

while (true)

CallMethod();

// 0.26.0
if (true)
CallMethod();
else if (false)
CallMethod();
else
CallMethod();

for (; ; )
CallMethod();

while (true)
CallMethod();
```

Thanks go to @Infinite-3D for reporting
#### Support C# 12 primary constructors on structs [#969](https://github.com/belav/csharpier/issues/969)
CSharpier now supports primary constructors on structs
```c#
public struct NamedItem2(
string name1,
string name2
)
{
public string Name1 => name1;
public string Name2 => name1;
}
```
#### Support C# 12 collection expressions [#964](https://github.com/belav/csharpier/issues/964
CSharpier now supports collection expressions
```c#
int[] a = [ 1, 2, 3, 4, 5, 6, 7, 8 ];

Span<int> b = [ 'a', 'b', 'c', 'd', 'e', 'f', 'h', 'i' ];

string[] c =
[
"________________________",
"________________________",
"________________________",
"________________________"
];

int[][] d =
[
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
];
```

Thanks go to @meenzen for reporting
#### MSBuild - when a file fails to compile csharpier interferes with getting you clickable links to the compilation errors. [#957](https://github.com/belav/csharpier/issues/957)
Build errors will now display properly when using CSharpier.MSBuild
#### Format element access properly in long invocation chains [#956](https://github.com/belav/csharpier/issues/956)
```c#
// 0.25.0
var x = someLongNameField.CallMethod____________________________________().AccessArray[
1
].Property_______________;

// 0.26.0
var x = someLongNameField
.CallMethod____________________________________()
.AccessArray[1]
.Property_______________;
```
#### Improvements to visible whitespace in console output. [#953](https://github.com/belav/csharpier/issues/953)
When using `cshapier --check` whitespace is now only visible in the following situations

When an otherwise empty line contains whitespace
```
----------------------------- Expected: Around Line 4 -----------------------------
private string field1;
private string field2;
----------------------------- Actual: Around Line 4 -----------------------------
private string field1;
····
private string field2;
```

When a line has extra trailing whitespace
```
----------------------------- Expected: Around Line 3 -----------------------------
{
private string field1;
}
----------------------------- Actual: Around Line 3 -----------------------------
{
private string field1;····
}
```
#### MSBuild is not encoding using UTF8 [#947](https://github.com/belav/csharpier/issues/947)
When CSharpier.MSBuild ran into a failed csharpier check, it was not encoding the std-error output with UTF8. This resulted in messages such as
```
----------------------------- Expected: Around Line 3 -----------------------------
{
┬╖┬╖┬╖┬╖private┬╖string┬╖field1;
}
----------------------------- Actual: Around Line 3 -----------------------------
{
┬╖┬╖┬╖┬╖private┬╖string┬╖field1;┬╖┬╖┬╖┬╖
}
```
Thanks go to @Tyrrrz for reporting
#### Comment inside raw string literal is lost when file is formatted. [#937](https://github.com/belav/csharpier/issues/937)
```c#
// input
var rawLiteralWithExpressionThatWeDontFormat = new StringContent(
// this comment shouldn't go away
$$"""
{
"params": "{{searchFilter switch
{
SearchFilter.Video => "EgIQAQ%3D%3D",
_ => null
}}}"
}
"""
);

// 0.25.0
var rawLiteralWithExpressionThatWeDontFormat = new StringContent(
$$"""
{
"params": "{{searchFilter switch
{
SearchFilter.Video => "EgIQAQ%3D%3D",
_ => null
}}}"
}
"""
);
```

Thanks go to @Tyrrrz for reporting
#### Allow line endings to be configurable [#935](https://github.com/belav/csharpier/issues/935)
CSharpier now supports the following options for line endings. The default is `auto`
- "auto" - Maintain existing line endings (mixed values within one file are normalised by looking at what's used after the first line)
- "lf" – Line Feed only (\n), common on Linux and macOS as well as inside git repos
- "crlf" - Carriage Return + Line Feed characters (\r\n), common on Windows

Thanks go to @phuhl for the feature request
#### Avoid breaking only around binary expression but not binary expression itself [#924](https://github.com/belav/csharpier/issues/924)
```c#
// 0.25.0
if (
someLongStatement == true || someOtherStatement________________________________ == false
)

// 0.26.0
if (someLongStatement == true || someOtherStatement________________________________ == false)
```

Thanks go to @Nixxen for reporting
#### Nested loops without brackets should not be indented [#867](https://github.com/belav/csharpier/issues/867)
```c#
// 0.25.0
foreach (var subsequence in sequence)
foreach (var item in subsequence)
item.DoSomething();

// 0.26.0
foreach (var subsequence in sequence)
foreach (var item in subsequence)
item.DoSomething();
```
Thanks go to @Rudomitori for the contribution
**Full Changelog**: https://github.com/belav/csharpier/compare/0.25.0...0.26.0
# 0.25.0
## Breaking Changes
#### Improve if directive formatting [#404](https://github.com/belav/csharpier/issues/404)
The `preprocessorSymbolSets` configuration option is no longer supported.
Expand Down Expand Up @@ -1225,3 +1435,4 @@ Thanks go to @pingzing
**Full Changelog**: https://github.com/belav/csharpier/compare/0.9.0...0.9.1
2 changes: 1 addition & 1 deletion Nuget/Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>0.25.0</Version>
<Version>0.26.0</Version>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryUrl>https://github.com/belav/csharpier</RepositoryUrl>
<RepositoryType>git</RepositoryType>
Expand Down
47 changes: 39 additions & 8 deletions Src/Website/docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ hide_table_of_contents: true
CSharpier has support for a configuration file. You can use any of the following files
- A ```.csharpierrc``` file in JSON or YAML.
- A ```.csharpierrc.json``` or ```.csharpierrc.yaml``` file.
- A ```.editorconfig``` file. See EditorConfig section below.

The configuration file will be resolved starting from the location of the file being formatted, and searching up the file tree until a config file is (or isn’t) found.

Expand All @@ -15,38 +16,49 @@ JSON
"printWidth": 100,
"useTabs": false,
"tabWidth": 4,
"preprocessorSymbolSets": ["", "DEBUG", "DEBUG,CODE_STYLE"]
"endOfLine": "auto"
}
```
YAML
```yaml
printWidth: 100
useTabs: false
tabWidth: 4
preprocessorSymbolSets:
- ""
- "DEBUG"
- "DEBUG,CODE_STYLE"
endOfLine: auto
```
#### Print Width
Specify at what point the printer will wrap content. This is not a hard limit. Some lines will be shorter or longer.
Default 100
Default `100`
#### Use Tabs
_First available in 0.17.0_

Indent lines with tabs instead of spaces.

Default false
Default `false`
#### Tab Width
_First available in 0.17.0_

Specify the number of spaces used per indentation level.

Default 4
Default `4`

#### End of Line
_First available in 0.26.0_

Valid options:

- "auto" - Maintain existing line endings (mixed values within one file are normalised by looking at what's used after the first line)
- "lf" – Line Feed only (\n), common on Linux and macOS as well as inside git repos
- "crlf" - Carriage Return + Line Feed characters (\r\n), common on Windows

Default `auto`


#### Preprocessor Symbol Sets
_Removed in 0.25.0_

Currently CSharpier only has basic support for understanding how to format code inside of `#if` directives.
It will attempt to determine which sets of preprocessor symbols are needed for roslyn to parse all the code in each file.

Expand All @@ -65,3 +77,22 @@ For example in the following code block, the following symbol sets would be need
When supplying symbol sets, they will be used for all files being formatted. This will slow down formatting, and determining all symbol sets needed across all files won't be straight forward.

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

### EditorConfig

CSharpier supports configuration via an `.editorconfig` file. A `.csahrpierrc*` file in the same directory will take priority.

```ini
[*]
# Non-configurable behaviors
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
# Configurable behaviors
# end_of_line = lf - there is no 'auto' with a .editorconfig
indent_style = space
indent_size = 4
max_line_length = 100
```
4 changes: 2 additions & 2 deletions Src/Website/docs/ContinuousIntegration.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ Normally when using a code formatter like CSharpier, you'll want to ensure that
steps:
- uses: actions/checkout@v2
- run: |
dotnet tool restore
dotnet csharpier --check .
dotnet tool restore
dotnet csharpier --check .
```

0 comments on commit 62c94e5

Please sign in to comment.