Skip to content

Commit

Permalink
Releasing 0.27.0 (#1128)
Browse files Browse the repository at this point in the history
  • Loading branch information
belav authored Jan 15, 2024
1 parent 99206da commit 7d09173
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 20 deletions.
146 changes: 145 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,147 @@
# 0.26.7
# 0.27.0
## What's Changed
### `readonly ref` is changed to `ref readonly` causing error CS9190 [#1123](https://github.com/belav/csharpier/issues/1123)
CSharpier was sorting modifiers in all places they occurred. Resulting the following change that led to code that would not compile.
```c#
// input
void Method(ref readonly int someParameter) { }

// 0.26.7
void Method(readonly ref int someParameter) { }

// 0.27.0
void Method(ref readonly int someParameter) { }
```
Thanks go to @aurnoi1 for reporting the bug
### #if at the end of collection expression gets eaten [#1119](https://github.com/belav/csharpier/issues/1119)
When a collection expression contained a directive immediately before the closing bracket, that directive was not included in the output.

```c#
// input
int[] someArray =
[
1
#if DEBUG
,
2
#endif
];

// 0.26.7
int[] someArray = [1];

// 0.27.0
int[] someArray =
[
1
#if DEBUG
,
2
#endif
];
```

Thanks go to @Meowtimer for reporting the bug
### CSharpier.MsBuild - Set Fallback for dotnetcore3.1 or net5.0 applications [#1111](https://github.com/belav/csharpier/pull/1111)
CSharpier.MsBuild made an assumption that the project being built would be built using net6-net8 and failed when the project was built with earlier versions of dotnet.

It now falls back to trying to use `net8`

Thanks go to @samtrion for the contribution
### Allow empty/blank lines in object initializers [#1110](https://github.com/belav/csharpier/issues/1110)
Large object initializers now retain single empty lines between initializers.

```c#
vvar someObject = new SomeObject
{
NoLineAllowedAboveHere = 1,

ThisLineIsOkay = 2,

// comment
AndThisLine = 3,
DontAddLines = 4,
};
```

Thanks go to @Qtax for the suggestion
### Add option to allow formatting auto generated files. [#1055](https://github.com/belav/csharpier/issues/1055
By default CSharpier will not format files that were generated by the SDK, or files that begin with `<autogenerated />` comments.

Passing the option `--include-generated` to the CLI will cause those files to be formatted.

### Format raw string literals indentation [#975](https://github.com/belav/csharpier/issues/975)
CSharpier now adjusts the indentation of raw string literals if the end delimiter is indented.

```c#
// input
var someString = """
Indent based on previous line
""";

var doNotIndentIfEndDelimiterIsAtZero = """
Keep This
Where It
Is
""";

// 0.26.7
var someString = """
Indent based on previous line
""";

var doNotIndentIfEndDelimiterIsAtZero = """
Keep This
Where It
Is
""";

// 0.27.0
var someString = """
Indent based on previous line
""";

var doNotIndentIfEndDelimiterIsAtZero = """
Keep This
Where It
Is
""";
```

Thanks go to @jods4 for reporting the issue
### Incorrect indentation on a multi-line statement split by comments [#968](https://github.com/belav/csharpier/issues/968
CSharpier was not properly indenting an invocation chain when it was being split by comments.
```c#
// input
var someValue =
// Some Comment
CallSomeMethod()
// Another Comment
.CallSomeMethod();

// 0.26.7
var someValue =
// Some Comment
CallSomeMethod()
// Another Comment
.CallSomeMethod();

// 0.27.0
var someValue =
// Some Comment
CallSomeMethod()
// Another Comment
.CallSomeMethod();
```

Thanks go to @tyrrrz for reporting the issue
### Adding experimental support for GRPC for the extensions to communicate with CSharpier [#944](https://github.com/belav/csharpier/pull/944)
Currently the extensions for CSharpier send data to a running instance of CSharpier by piping stdin/stdout back and forth. This approach has proved problematic and hard to extend.

As of 0.27.0, CSharpier can run a GRPC server to allow communication with the extensions once they are all updated.

**Full Changelog**: https://github.com/belav/csharpier/compare/0.26.7...0.27.0
# 0.26.7
## What's Changed
### Keep Field.Method() on the same line when breaking long method chain [#1010](https://github.com/belav/csharpier/issues/1010)
0.26.0 introduced changes that broke long invocation chains on fields/properties as well as methods. That change has been reverted after community feedback.
Expand Down Expand Up @@ -1756,3 +1899,4 @@ Thanks go to @pingzing
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.26.7</Version>
<Version>0.27.0</Version>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryUrl>https://github.com/belav/csharpier</RepositoryUrl>
<RepositoryType>git</RepositoryType>
Expand Down
28 changes: 18 additions & 10 deletions Src/Website/docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,19 @@ Arguments:
<directoryOrFile> One or more paths to a directory containing files to format or a file to format. If a path is not specified the current directory is used

Options:
--check Check that files are formatted. Will not write any changes.
--loglevel Specify the log level - Debug, Information (default), Warning, Error, None
--no-cache Bypass the cache to determine if a file needs to be formatted.
--fast Skip comparing syntax tree of formatted file to original file to validate changes.
--skip-write Skip writing changes. Generally used for testing to ensure csharpier doesn't throw any errors or cause syntax tree validation failures.
--write-stdout Write the results of formatting any files to stdout.
--pipe-multiple-files Keep csharpier running so that multiples files can be piped to it via stdin
--config-path Path to the CSharpier configuration file
--version Show version information
-?, -h, --help Show help and usage information
--check Check that files are formatted. Will not write any changes.
--loglevel <loglevel> Specify the log level - Debug, Information (default), Warning, Error, None [default: Information]
--no-cache Bypass the cache to determine if a file needs to be formatted.
--no-msbuild-check Bypass the check to determine if a csproj files references a different version of CSharpier.MsBuild.
--include-generated Include files generated by the SDK and files that begin with <autogenerated /> comments
--fast Skip comparing syntax tree of formatted file to original file to validate changes.
--skip-write Skip writing changes. Generally used for testing to ensure csharpier doesn't throw any errors or cause syntax tree validation failures.
--write-stdout Write the results of formatting any files to stdout.
--pipe-multiple-files Keep csharpier running so that multiples files can be piped to it via stdin
--config-path <config-path> Path to the CSharpier configuration file
--version Show version information
-?, -h, --help Show help and usage information



```
Expand Down Expand Up @@ -66,6 +69,11 @@ By default the following are used as cache keys and a file is only formatted if

The cache is stored at `[LocalApplicationData]/CSharpier/.formattingCache`.

### --include-generated
_First available in 0.27.0_

By default CSharpier ignores any files generated by the SDK or that begin with a comment that contains `<autogenerated` or `<auto-generated`. This option can be used to format those files.

### --fast
CSharpier validates the changes it makes to a file.
It does this by comparing the syntax tree before and after formatting, but ignoring any whitespace trivia in the syntax tree.
Expand Down
33 changes: 25 additions & 8 deletions Src/Website/docs/Ignore.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,40 @@
title: Ignoring Code
hide_table_of_contents: true
---
Use `.csharpierignore` to bypass formatting specific files and folders.

Csharpier will ignore the following files
- Any file that begins with ```TemporaryGeneratedFile_```
- Any file that ends with ```.designer.cs```
- Any file that ends with ```.generated.cs```
- Any file that ends with ```.g.cs```
- Any file that ends with ```.g.i.cs```
- Any file that begins with a comment that contains ```<autogenerated``` or ```<auto-generated```
Use `csharpier-ignore` comments to bypass formatting specific parts of files.

## Ignoring Files `.csharpierignore`

Add a ```.csharpierignore``` file to ignore additional files and folders. The file uses [gitignore syntax](https://git-scm.com/docs/gitignore#_pattern_format)
Add a `.csharpierignore` file to ignore additional files and folders. The file uses [gitignore syntax](https://git-scm.com/docs/gitignore#_pattern_format)

Example
```
Uploads/
**/App_Data/*.cs
```

### Files Ignored by Default

Csharpier will ignore the following files

#### SDK Generated Files
_See [Configuration](CLI.md) for including these files_

- Any file that begins with `TemporaryGeneratedFile_`
- Any file that ends with `.designer.cs`
- Any file that ends with `.generated.cs`
- Any file that ends with `.g.cs`
- Any file that ends with `.g.i.cs`
- Any file that begins with a comment that contains `<autogenerated` or `<auto-generated`

#### Node Module Files

- Any file that matches the gitignore syntax `**/node_modules/**/*.cs`

## Ignoring Code

Add a `// csharpier-ignore` comment to exclude the next node from formatting. This is valid on statements and members.

```c#
Expand Down

0 comments on commit 7d09173

Please sign in to comment.